diff --git a/sdk/compute/azure-mgmt-compute/CHANGELOG.md b/sdk/compute/azure-mgmt-compute/CHANGELOG.md index 4937b8478144..ac1be88fa04e 100644 --- a/sdk/compute/azure-mgmt-compute/CHANGELOG.md +++ b/sdk/compute/azure-mgmt-compute/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 0.0.0 (2025-07-24) + +change log generation was timeout!!! You need to write it manually!!! + ## 35.0.0 (2025-07-21) ### Features Added diff --git a/sdk/compute/azure-mgmt-compute/_metadata.json b/sdk/compute/azure-mgmt-compute/_metadata.json index c7caaa919d89..19f13e95c338 100644 --- a/sdk/compute/azure-mgmt-compute/_metadata.json +++ b/sdk/compute/azure-mgmt-compute/_metadata.json @@ -1,11 +1,11 @@ { - "commit": "81cb525ba1985326c5607fc368abfc64ff9f5aa2", + "commit": "6aaa856cc514dcf53efbc37569f1ec40bd93cd27", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.10.2", "use": [ "@autorest/python@6.35.0", "@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.35.0 --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/azure-sdk-for-python/sdk --tag=package-python-sdk --use=@autorest/python@6.35.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/compute/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/__init__.py index 821506e73af9..ab7c46e8991d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/__init__.py @@ -5,16 +5,28 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._compute_management_client import ComputeManagementClient -__all__ = ['ComputeManagementClient'] +from typing import TYPE_CHECKING -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import +from ._compute_management_client import ComputeManagementClient # type: ignore from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ComputeManagementClient", +] +__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/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_compute_management_client.py index b1f13b46d654..5bf190b5c5e7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_compute_management_client.py @@ -1,133 +1,228 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import Any, Optional, TYPE_CHECKING, cast from typing_extensions import Self from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse from azure.core.settings import settings from azure.mgmt.core import ARMPipelineClient from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from azure.mgmt.core.tools import get_arm_endpoints -from azure.profiles import KnownProfiles, ProfileDefinition -from azure.profiles.multiapiclient import MultiApiClientMixin +from . import models as _models from ._configuration import ComputeManagementClientConfiguration -from ._serialization import Deserializer, Serializer +from ._utils.serialization import Deserializer, Serializer +from .operations import ( + AvailabilitySetsOperations, + CapacityReservationGroupsOperations, + CapacityReservationsOperations, + CloudServiceOperatingSystemsOperations, + CloudServiceRoleInstancesOperations, + CloudServiceRolesOperations, + CloudServicesOperations, + CloudServicesUpdateDomainOperations, + CommunityGalleriesOperations, + CommunityGalleryImageVersionsOperations, + CommunityGalleryImagesOperations, + DedicatedHostGroupsOperations, + DedicatedHostsOperations, + DiskAccessesOperations, + DiskEncryptionSetsOperations, + DiskRestorePointOperations, + DisksOperations, + GalleriesOperations, + GalleryApplicationVersionsOperations, + GalleryApplicationsOperations, + GalleryImageVersionsOperations, + GalleryImagesOperations, + GallerySharingProfileOperations, + ImagesOperations, + LogAnalyticsOperations, + Operations, + ProximityPlacementGroupsOperations, + ResourceSkusOperations, + RestorePointCollectionsOperations, + RestorePointsOperations, + SharedGalleriesOperations, + SharedGalleryImageVersionsOperations, + SharedGalleryImagesOperations, + SnapshotsOperations, + SshPublicKeysOperations, + UsageOperations, + VirtualMachineExtensionImagesOperations, + VirtualMachineExtensionsOperations, + VirtualMachineImagesEdgeZoneOperations, + VirtualMachineImagesOperations, + VirtualMachineRunCommandsOperations, + VirtualMachineScaleSetExtensionsOperations, + VirtualMachineScaleSetRollingUpgradesOperations, + VirtualMachineScaleSetVMExtensionsOperations, + VirtualMachineScaleSetVMRunCommandsOperations, + VirtualMachineScaleSetVMsOperations, + VirtualMachineScaleSetsOperations, + VirtualMachineSizesOperations, + VirtualMachinesOperations, +) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class _SDKClient(object): - def __init__(self, *args, **kwargs): - """This is a fake class to support current implementation of MultiApiClientMixin." - Will be removed in final version of multiapi azure-core based client - """ - pass -class ComputeManagementClient(MultiApiClientMixin, _SDKClient): +class ComputeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Compute Client. - This ready contains multiple API versions, to help you deal with all of the Azure clouds - (Azure Stack, Azure Government, Azure China, etc.). - By default, it uses the latest API version available on public Azure. - For production, you should stick to a particular api-version and/or profile. - The profile sets a mapping between an operation group and its API version. - The api-version parameter sets the default API version if the operation - group is not described in the profile. - + :ivar operations: Operations operations + :vartype operations: azure.mgmt.compute.operations.Operations + :ivar availability_sets: AvailabilitySetsOperations operations + :vartype availability_sets: azure.mgmt.compute.operations.AvailabilitySetsOperations + :ivar capacity_reservation_groups: CapacityReservationGroupsOperations operations + :vartype capacity_reservation_groups: + azure.mgmt.compute.operations.CapacityReservationGroupsOperations + :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations + :vartype dedicated_host_groups: azure.mgmt.compute.operations.DedicatedHostGroupsOperations + :ivar images: ImagesOperations operations + :vartype images: azure.mgmt.compute.operations.ImagesOperations + :ivar virtual_machine_images_edge_zone: VirtualMachineImagesEdgeZoneOperations operations + :vartype virtual_machine_images_edge_zone: + azure.mgmt.compute.operations.VirtualMachineImagesEdgeZoneOperations + :ivar virtual_machine_images: VirtualMachineImagesOperations operations + :vartype virtual_machine_images: azure.mgmt.compute.operations.VirtualMachineImagesOperations + :ivar log_analytics: LogAnalyticsOperations operations + :vartype log_analytics: azure.mgmt.compute.operations.LogAnalyticsOperations + :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations + :vartype virtual_machine_extension_images: + azure.mgmt.compute.operations.VirtualMachineExtensionImagesOperations + :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations + :vartype virtual_machine_run_commands: + azure.mgmt.compute.operations.VirtualMachineRunCommandsOperations + :ivar usage: UsageOperations operations + :vartype usage: azure.mgmt.compute.operations.UsageOperations + :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations + :vartype virtual_machine_scale_sets: + azure.mgmt.compute.operations.VirtualMachineScaleSetsOperations + :ivar virtual_machines: VirtualMachinesOperations operations + :vartype virtual_machines: azure.mgmt.compute.operations.VirtualMachinesOperations + :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations + :vartype virtual_machine_sizes: azure.mgmt.compute.operations.VirtualMachineSizesOperations + :ivar proximity_placement_groups: ProximityPlacementGroupsOperations operations + :vartype proximity_placement_groups: + azure.mgmt.compute.operations.ProximityPlacementGroupsOperations + :ivar restore_point_collections: RestorePointCollectionsOperations operations + :vartype restore_point_collections: + azure.mgmt.compute.operations.RestorePointCollectionsOperations + :ivar ssh_public_keys: SshPublicKeysOperations operations + :vartype ssh_public_keys: azure.mgmt.compute.operations.SshPublicKeysOperations + :ivar capacity_reservations: CapacityReservationsOperations operations + :vartype capacity_reservations: azure.mgmt.compute.operations.CapacityReservationsOperations + :ivar dedicated_hosts: DedicatedHostsOperations operations + :vartype dedicated_hosts: azure.mgmt.compute.operations.DedicatedHostsOperations + :ivar restore_points: RestorePointsOperations operations + :vartype restore_points: azure.mgmt.compute.operations.RestorePointsOperations + :ivar virtual_machine_scale_set_rolling_upgrades: + VirtualMachineScaleSetRollingUpgradesOperations operations + :vartype virtual_machine_scale_set_rolling_upgrades: + azure.mgmt.compute.operations.VirtualMachineScaleSetRollingUpgradesOperations + :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations + operations + :vartype virtual_machine_scale_set_extensions: + azure.mgmt.compute.operations.VirtualMachineScaleSetExtensionsOperations + :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations + :vartype virtual_machine_scale_set_vms: + azure.mgmt.compute.operations.VirtualMachineScaleSetVMsOperations + :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations + operations + :vartype virtual_machine_scale_set_vm_extensions: + azure.mgmt.compute.operations.VirtualMachineScaleSetVMExtensionsOperations + :ivar virtual_machine_scale_set_vm_run_commands: VirtualMachineScaleSetVMRunCommandsOperations + operations + :vartype virtual_machine_scale_set_vm_run_commands: + azure.mgmt.compute.operations.VirtualMachineScaleSetVMRunCommandsOperations + :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations + :vartype virtual_machine_extensions: + azure.mgmt.compute.operations.VirtualMachineExtensionsOperations + :ivar cloud_service_role_instances: CloudServiceRoleInstancesOperations operations + :vartype cloud_service_role_instances: + azure.mgmt.compute.operations.CloudServiceRoleInstancesOperations + :ivar cloud_service_roles: CloudServiceRolesOperations operations + :vartype cloud_service_roles: azure.mgmt.compute.operations.CloudServiceRolesOperations + :ivar cloud_services: CloudServicesOperations operations + :vartype cloud_services: azure.mgmt.compute.operations.CloudServicesOperations + :ivar cloud_services_update_domain: CloudServicesUpdateDomainOperations operations + :vartype cloud_services_update_domain: + azure.mgmt.compute.operations.CloudServicesUpdateDomainOperations + :ivar cloud_service_operating_systems: CloudServiceOperatingSystemsOperations operations + :vartype cloud_service_operating_systems: + azure.mgmt.compute.operations.CloudServiceOperatingSystemsOperations + :ivar disks: DisksOperations operations + :vartype disks: azure.mgmt.compute.operations.DisksOperations + :ivar disk_accesses: DiskAccessesOperations operations + :vartype disk_accesses: azure.mgmt.compute.operations.DiskAccessesOperations + :ivar disk_encryption_sets: DiskEncryptionSetsOperations operations + :vartype disk_encryption_sets: azure.mgmt.compute.operations.DiskEncryptionSetsOperations + :ivar disk_restore_point: DiskRestorePointOperations operations + :vartype disk_restore_point: azure.mgmt.compute.operations.DiskRestorePointOperations + :ivar snapshots: SnapshotsOperations operations + :vartype snapshots: azure.mgmt.compute.operations.SnapshotsOperations + :ivar resource_skus: ResourceSkusOperations operations + :vartype resource_skus: azure.mgmt.compute.operations.ResourceSkusOperations + :ivar galleries: GalleriesOperations operations + :vartype galleries: azure.mgmt.compute.operations.GalleriesOperations + :ivar gallery_images: GalleryImagesOperations operations + :vartype gallery_images: azure.mgmt.compute.operations.GalleryImagesOperations + :ivar gallery_image_versions: GalleryImageVersionsOperations operations + :vartype gallery_image_versions: azure.mgmt.compute.operations.GalleryImageVersionsOperations + :ivar gallery_applications: GalleryApplicationsOperations operations + :vartype gallery_applications: azure.mgmt.compute.operations.GalleryApplicationsOperations + :ivar gallery_application_versions: GalleryApplicationVersionsOperations operations + :vartype gallery_application_versions: + azure.mgmt.compute.operations.GalleryApplicationVersionsOperations + :ivar gallery_sharing_profile: GallerySharingProfileOperations operations + :vartype gallery_sharing_profile: azure.mgmt.compute.operations.GallerySharingProfileOperations + :ivar shared_galleries: SharedGalleriesOperations operations + :vartype shared_galleries: azure.mgmt.compute.operations.SharedGalleriesOperations + :ivar shared_gallery_images: SharedGalleryImagesOperations operations + :vartype shared_gallery_images: azure.mgmt.compute.operations.SharedGalleryImagesOperations + :ivar shared_gallery_image_versions: SharedGalleryImageVersionsOperations operations + :vartype shared_gallery_image_versions: + azure.mgmt.compute.operations.SharedGalleryImageVersionsOperations + :ivar community_galleries: CommunityGalleriesOperations operations + :vartype community_galleries: azure.mgmt.compute.operations.CommunityGalleriesOperations + :ivar community_gallery_images: CommunityGalleryImagesOperations operations + :vartype community_gallery_images: + azure.mgmt.compute.operations.CommunityGalleryImagesOperations + :ivar community_gallery_image_versions: CommunityGalleryImageVersionsOperations operations + :vartype community_gallery_image_versions: + azure.mgmt.compute.operations.CommunityGalleryImageVersionsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param api_version: API version to use if no profile is provided, or if missing in profile. - :type api_version: str - :param base_url: Service URL + :param base_url: Service URL. Default value is None. :type base_url: str - :param profile: A profile definition, from KnownProfiles to dict. - :type profile: azure.profiles.KnownProfiles - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ - DEFAULT_API_VERSION = '2025-01-02' - _PROFILE_TAG = "azure.mgmt.compute.ComputeManagementClient" - LATEST_PROFILE = ProfileDefinition({ - _PROFILE_TAG: { - None: DEFAULT_API_VERSION, - 'availability_sets': '2024-11-01', - 'capacity_reservation_groups': '2024-11-01', - 'capacity_reservations': '2024-11-01', - 'cloud_service_operating_systems': '2024-11-04', - 'cloud_service_role_instances': '2024-11-04', - 'cloud_service_roles': '2024-11-04', - 'cloud_services': '2024-11-04', - 'cloud_services_update_domain': '2024-11-04', - 'community_galleries': '2023-07-03', - 'community_gallery_image_versions': '2023-07-03', - 'community_gallery_images': '2023-07-03', - 'dedicated_host_groups': '2024-11-01', - 'dedicated_hosts': '2024-11-01', - 'galleries': '2023-07-03', - 'gallery_application_versions': '2023-07-03', - 'gallery_applications': '2023-07-03', - 'gallery_image_versions': '2023-07-03', - 'gallery_images': '2023-07-03', - 'gallery_sharing_profile': '2023-07-03', - 'images': '2024-11-01', - 'log_analytics': '2024-11-01', - 'operations': '2024-11-01', - 'proximity_placement_groups': '2024-11-01', - 'resource_skus': '2021-07-01', - 'restore_point_collections': '2024-11-01', - 'restore_points': '2024-11-01', - 'shared_galleries': '2023-07-03', - 'shared_gallery_image_versions': '2023-07-03', - 'shared_gallery_images': '2023-07-03', - 'ssh_public_keys': '2024-11-01', - 'usage': '2024-11-01', - 'virtual_machine_extension_images': '2024-11-01', - 'virtual_machine_extensions': '2024-11-01', - 'virtual_machine_images': '2024-11-01', - 'virtual_machine_images_edge_zone': '2024-11-01', - 'virtual_machine_run_commands': '2024-11-01', - 'virtual_machine_scale_set_extensions': '2024-11-01', - 'virtual_machine_scale_set_rolling_upgrades': '2024-11-01', - 'virtual_machine_scale_set_vm_extensions': '2024-11-01', - 'virtual_machine_scale_set_vm_run_commands': '2024-11-01', - 'virtual_machine_scale_set_vms': '2024-11-01', - 'virtual_machine_scale_sets': '2024-11-01', - 'virtual_machine_sizes': '2024-11-01', - 'virtual_machines': '2024-11-01', - }}, - _PROFILE_TAG + " latest" - ) - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - api_version: Optional[str]=None, - base_url: Optional[str] = None, - profile: KnownProfiles=KnownProfiles.default, - **kwargs: Any - ): - if api_version: - kwargs.setdefault('api_version', api_version) + self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any + ) -> None: _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore _endpoints = get_arm_endpoints(_cloud) if not base_url: base_url = _endpoints["resource_manager"] credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration(credential, subscription_id, credential_scopes=credential_scopes, **kwargs) + self._config = ComputeManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs + ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -147,1377 +242,159 @@ def __init__( self._config.http_logging_policy, ] self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - super(ComputeManagementClient, self).__init__( - api_version=api_version, - profile=profile - ) - - @classmethod - def _models_dict(cls, api_version): - return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} - - @classmethod - def models(cls, api_version=DEFAULT_API_VERSION): - """Module depends on the API version: - - * 2016-03-30: :mod:`v2016_03_30.models` - * 2017-03-30: :mod:`v2017_03_30.models` - * 2017-09-01: :mod:`v2017_09_01.models` - * 2017-12-01: :mod:`v2017_12_01.models` - * 2019-04-01: :mod:`v2019_04_01.models` - * 2019-07-01: :mod:`v2019_07_01.models` - * 2019-12-01: :mod:`v2019_12_01.models` - * 2020-05-01: :mod:`v2020_05_01.models` - * 2020-06-01: :mod:`v2020_06_01.models` - * 2021-07-01: :mod:`v2021_07_01.models` - * 2021-10-01: :mod:`v2021_10_01.models` - * 2022-01-03: :mod:`v2022_01_03.models` - * 2022-03-02: :mod:`v2022_03_02.models` - * 2022-09-04: :mod:`v2022_09_04.models` - * 2023-04-02: :mod:`v2023_04_02.models` - * 2023-07-03: :mod:`v2023_07_03.models` - * 2023-10-02: :mod:`v2023_10_02.models` - * 2024-11-01: :mod:`v2024_11_01.models` - * 2024-11-04: :mod:`v2024_11_04.models` - * 2025-01-02: :mod:`v2025_01_02.models` - """ - if api_version == '2016-03-30': - from .v2016_03_30 import models - return models - elif api_version == '2017-03-30': - from .v2017_03_30 import models - return models - elif api_version == '2017-09-01': - from .v2017_09_01 import models - return models - elif api_version == '2017-12-01': - from .v2017_12_01 import models - return models - elif api_version == '2019-04-01': - from .v2019_04_01 import models - return models - elif api_version == '2019-07-01': - from .v2019_07_01 import models - return models - elif api_version == '2019-12-01': - from .v2019_12_01 import models - return models - elif api_version == '2020-05-01': - from .v2020_05_01 import models - return models - elif api_version == '2020-06-01': - from .v2020_06_01 import models - return models - elif api_version == '2021-07-01': - from .v2021_07_01 import models - return models - elif api_version == '2021-10-01': - from .v2021_10_01 import models - return models - elif api_version == '2022-01-03': - from .v2022_01_03 import models - return models - elif api_version == '2022-03-02': - from .v2022_03_02 import models - return models - elif api_version == '2022-09-04': - from .v2022_09_04 import models - return models - elif api_version == '2023-04-02': - from .v2023_04_02 import models - return models - elif api_version == '2023-07-03': - from .v2023_07_03 import models - return models - elif api_version == '2023-10-02': - from .v2023_10_02 import models - return models - elif api_version == '2024-11-01': - from .v2024_11_01 import models - return models - elif api_version == '2024-11-04': - from .v2024_11_04 import models - return models - elif api_version == '2025-01-02': - from .v2025_01_02 import models - return models - raise ValueError("API version {} is not available".format(api_version)) - - @property - def availability_sets(self): - """Instance depends on the API version: - - * 2016-03-30: :class:`AvailabilitySetsOperations` - * 2017-03-30: :class:`AvailabilitySetsOperations` - * 2017-12-01: :class:`AvailabilitySetsOperations` - * 2019-07-01: :class:`AvailabilitySetsOperations` - * 2019-12-01: :class:`AvailabilitySetsOperations` - * 2020-06-01: :class:`AvailabilitySetsOperations` - * 2021-07-01: :class:`AvailabilitySetsOperations` - * 2024-11-01: :class:`AvailabilitySetsOperations` - """ - api_version = self._get_api_version('availability_sets') - if api_version == '2016-03-30': - from .v2016_03_30.operations import AvailabilitySetsOperations as OperationClass - elif api_version == '2017-03-30': - from .v2017_03_30.operations import AvailabilitySetsOperations as OperationClass - elif api_version == '2017-12-01': - from .v2017_12_01.operations import AvailabilitySetsOperations as OperationClass - elif api_version == '2019-07-01': - from .v2019_07_01.operations import AvailabilitySetsOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import AvailabilitySetsOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import AvailabilitySetsOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import AvailabilitySetsOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import AvailabilitySetsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'availability_sets'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def capacity_reservation_groups(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`CapacityReservationGroupsOperations` - * 2024-11-01: :class:`CapacityReservationGroupsOperations` - """ - api_version = self._get_api_version('capacity_reservation_groups') - if api_version == '2021-07-01': - from .v2021_07_01.operations import CapacityReservationGroupsOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import CapacityReservationGroupsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'capacity_reservation_groups'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def capacity_reservations(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`CapacityReservationsOperations` - * 2024-11-01: :class:`CapacityReservationsOperations` - """ - api_version = self._get_api_version('capacity_reservations') - if api_version == '2021-07-01': - from .v2021_07_01.operations import CapacityReservationsOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import CapacityReservationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'capacity_reservations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def cloud_service_operating_systems(self): - """Instance depends on the API version: - - * 2022-09-04: :class:`CloudServiceOperatingSystemsOperations` - * 2024-11-04: :class:`CloudServiceOperatingSystemsOperations` - """ - api_version = self._get_api_version('cloud_service_operating_systems') - if api_version == '2022-09-04': - from .v2022_09_04.operations import CloudServiceOperatingSystemsOperations as OperationClass - elif api_version == '2024-11-04': - from .v2024_11_04.operations import CloudServiceOperatingSystemsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'cloud_service_operating_systems'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def cloud_service_role_instances(self): - """Instance depends on the API version: - - * 2022-09-04: :class:`CloudServiceRoleInstancesOperations` - * 2024-11-04: :class:`CloudServiceRoleInstancesOperations` - """ - api_version = self._get_api_version('cloud_service_role_instances') - if api_version == '2022-09-04': - from .v2022_09_04.operations import CloudServiceRoleInstancesOperations as OperationClass - elif api_version == '2024-11-04': - from .v2024_11_04.operations import CloudServiceRoleInstancesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'cloud_service_role_instances'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def cloud_service_roles(self): - """Instance depends on the API version: - - * 2022-09-04: :class:`CloudServiceRolesOperations` - * 2024-11-04: :class:`CloudServiceRolesOperations` - """ - api_version = self._get_api_version('cloud_service_roles') - if api_version == '2022-09-04': - from .v2022_09_04.operations import CloudServiceRolesOperations as OperationClass - elif api_version == '2024-11-04': - from .v2024_11_04.operations import CloudServiceRolesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'cloud_service_roles'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def cloud_services(self): - """Instance depends on the API version: - - * 2022-09-04: :class:`CloudServicesOperations` - * 2024-11-04: :class:`CloudServicesOperations` - """ - api_version = self._get_api_version('cloud_services') - if api_version == '2022-09-04': - from .v2022_09_04.operations import CloudServicesOperations as OperationClass - elif api_version == '2024-11-04': - from .v2024_11_04.operations import CloudServicesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'cloud_services'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def cloud_services_update_domain(self): - """Instance depends on the API version: - - * 2022-09-04: :class:`CloudServicesUpdateDomainOperations` - * 2024-11-04: :class:`CloudServicesUpdateDomainOperations` - """ - api_version = self._get_api_version('cloud_services_update_domain') - if api_version == '2022-09-04': - from .v2022_09_04.operations import CloudServicesUpdateDomainOperations as OperationClass - elif api_version == '2024-11-04': - from .v2024_11_04.operations import CloudServicesUpdateDomainOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'cloud_services_update_domain'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def community_galleries(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`CommunityGalleriesOperations` - * 2022-01-03: :class:`CommunityGalleriesOperations` - * 2023-07-03: :class:`CommunityGalleriesOperations` - """ - api_version = self._get_api_version('community_galleries') - if api_version == '2021-07-01': - from .v2021_07_01.operations import CommunityGalleriesOperations as OperationClass - elif api_version == '2022-01-03': - from .v2022_01_03.operations import CommunityGalleriesOperations as OperationClass - elif api_version == '2023-07-03': - from .v2023_07_03.operations import CommunityGalleriesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'community_galleries'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def community_gallery_image_versions(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`CommunityGalleryImageVersionsOperations` - * 2022-01-03: :class:`CommunityGalleryImageVersionsOperations` - * 2023-07-03: :class:`CommunityGalleryImageVersionsOperations` - """ - api_version = self._get_api_version('community_gallery_image_versions') - if api_version == '2021-07-01': - from .v2021_07_01.operations import CommunityGalleryImageVersionsOperations as OperationClass - elif api_version == '2022-01-03': - from .v2022_01_03.operations import CommunityGalleryImageVersionsOperations as OperationClass - elif api_version == '2023-07-03': - from .v2023_07_03.operations import CommunityGalleryImageVersionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'community_gallery_image_versions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def community_gallery_images(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`CommunityGalleryImagesOperations` - * 2022-01-03: :class:`CommunityGalleryImagesOperations` - * 2023-07-03: :class:`CommunityGalleryImagesOperations` - """ - api_version = self._get_api_version('community_gallery_images') - if api_version == '2021-07-01': - from .v2021_07_01.operations import CommunityGalleryImagesOperations as OperationClass - elif api_version == '2022-01-03': - from .v2022_01_03.operations import CommunityGalleryImagesOperations as OperationClass - elif api_version == '2023-07-03': - from .v2023_07_03.operations import CommunityGalleryImagesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'community_gallery_images'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def dedicated_host_groups(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`DedicatedHostGroupsOperations` - * 2019-12-01: :class:`DedicatedHostGroupsOperations` - * 2020-06-01: :class:`DedicatedHostGroupsOperations` - * 2021-07-01: :class:`DedicatedHostGroupsOperations` - * 2024-11-01: :class:`DedicatedHostGroupsOperations` - """ - api_version = self._get_api_version('dedicated_host_groups') - if api_version == '2019-07-01': - from .v2019_07_01.operations import DedicatedHostGroupsOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import DedicatedHostGroupsOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import DedicatedHostGroupsOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import DedicatedHostGroupsOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import DedicatedHostGroupsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'dedicated_host_groups'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def dedicated_hosts(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`DedicatedHostsOperations` - * 2019-12-01: :class:`DedicatedHostsOperations` - * 2020-06-01: :class:`DedicatedHostsOperations` - * 2021-07-01: :class:`DedicatedHostsOperations` - * 2024-11-01: :class:`DedicatedHostsOperations` - """ - api_version = self._get_api_version('dedicated_hosts') - if api_version == '2019-07-01': - from .v2019_07_01.operations import DedicatedHostsOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import DedicatedHostsOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import DedicatedHostsOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import DedicatedHostsOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import DedicatedHostsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'dedicated_hosts'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def disk_accesses(self): - """Instance depends on the API version: - - * 2020-05-01: :class:`DiskAccessesOperations` - * 2022-03-02: :class:`DiskAccessesOperations` - * 2023-04-02: :class:`DiskAccessesOperations` - * 2023-10-02: :class:`DiskAccessesOperations` - * 2025-01-02: :class:`DiskAccessesOperations` - """ - api_version = self._get_api_version('disk_accesses') - if api_version == '2020-05-01': - from .v2020_05_01.operations import DiskAccessesOperations as OperationClass - elif api_version == '2022-03-02': - from .v2022_03_02.operations import DiskAccessesOperations as OperationClass - elif api_version == '2023-04-02': - from .v2023_04_02.operations import DiskAccessesOperations as OperationClass - elif api_version == '2023-10-02': - from .v2023_10_02.operations import DiskAccessesOperations as OperationClass - elif api_version == '2025-01-02': - from .v2025_01_02.operations import DiskAccessesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'disk_accesses'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def disk_encryption_sets(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`DiskEncryptionSetsOperations` - * 2020-05-01: :class:`DiskEncryptionSetsOperations` - * 2022-03-02: :class:`DiskEncryptionSetsOperations` - * 2023-04-02: :class:`DiskEncryptionSetsOperations` - * 2023-10-02: :class:`DiskEncryptionSetsOperations` - * 2025-01-02: :class:`DiskEncryptionSetsOperations` - """ - api_version = self._get_api_version('disk_encryption_sets') - if api_version == '2019-07-01': - from .v2019_07_01.operations import DiskEncryptionSetsOperations as OperationClass - elif api_version == '2020-05-01': - from .v2020_05_01.operations import DiskEncryptionSetsOperations as OperationClass - elif api_version == '2022-03-02': - from .v2022_03_02.operations import DiskEncryptionSetsOperations as OperationClass - elif api_version == '2023-04-02': - from .v2023_04_02.operations import DiskEncryptionSetsOperations as OperationClass - elif api_version == '2023-10-02': - from .v2023_10_02.operations import DiskEncryptionSetsOperations as OperationClass - elif api_version == '2025-01-02': - from .v2025_01_02.operations import DiskEncryptionSetsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'disk_encryption_sets'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def disk_restore_point(self): - """Instance depends on the API version: - - * 2022-03-02: :class:`DiskRestorePointOperations` - * 2023-04-02: :class:`DiskRestorePointOperations` - * 2023-10-02: :class:`DiskRestorePointOperations` - * 2025-01-02: :class:`DiskRestorePointOperations` - """ - api_version = self._get_api_version('disk_restore_point') - if api_version == '2022-03-02': - from .v2022_03_02.operations import DiskRestorePointOperations as OperationClass - elif api_version == '2023-04-02': - from .v2023_04_02.operations import DiskRestorePointOperations as OperationClass - elif api_version == '2023-10-02': - from .v2023_10_02.operations import DiskRestorePointOperations as OperationClass - elif api_version == '2025-01-02': - from .v2025_01_02.operations import DiskRestorePointOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'disk_restore_point'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def disks(self): - """Instance depends on the API version: - - * 2017-03-30: :class:`DisksOperations` - * 2019-07-01: :class:`DisksOperations` - * 2020-05-01: :class:`DisksOperations` - * 2022-03-02: :class:`DisksOperations` - * 2023-04-02: :class:`DisksOperations` - * 2023-10-02: :class:`DisksOperations` - * 2025-01-02: :class:`DisksOperations` - """ - api_version = self._get_api_version('disks') - if api_version == '2017-03-30': - from .v2017_03_30.operations import DisksOperations as OperationClass - elif api_version == '2019-07-01': - from .v2019_07_01.operations import DisksOperations as OperationClass - elif api_version == '2020-05-01': - from .v2020_05_01.operations import DisksOperations as OperationClass - elif api_version == '2022-03-02': - from .v2022_03_02.operations import DisksOperations as OperationClass - elif api_version == '2023-04-02': - from .v2023_04_02.operations import DisksOperations as OperationClass - elif api_version == '2023-10-02': - from .v2023_10_02.operations import DisksOperations as OperationClass - elif api_version == '2025-01-02': - from .v2025_01_02.operations import DisksOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'disks'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def galleries(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`GalleriesOperations` - * 2019-12-01: :class:`GalleriesOperations` - * 2021-07-01: :class:`GalleriesOperations` - * 2021-10-01: :class:`GalleriesOperations` - * 2022-01-03: :class:`GalleriesOperations` - * 2023-07-03: :class:`GalleriesOperations` - """ - api_version = self._get_api_version('galleries') - if api_version == '2019-07-01': - from .v2019_07_01.operations import GalleriesOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import GalleriesOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import GalleriesOperations as OperationClass - elif api_version == '2021-10-01': - from .v2021_10_01.operations import GalleriesOperations as OperationClass - elif api_version == '2022-01-03': - from .v2022_01_03.operations import GalleriesOperations as OperationClass - elif api_version == '2023-07-03': - from .v2023_07_03.operations import GalleriesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'galleries'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def gallery_application_versions(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`GalleryApplicationVersionsOperations` - * 2019-12-01: :class:`GalleryApplicationVersionsOperations` - * 2021-07-01: :class:`GalleryApplicationVersionsOperations` - * 2021-10-01: :class:`GalleryApplicationVersionsOperations` - * 2022-01-03: :class:`GalleryApplicationVersionsOperations` - * 2023-07-03: :class:`GalleryApplicationVersionsOperations` - """ - api_version = self._get_api_version('gallery_application_versions') - if api_version == '2019-07-01': - from .v2019_07_01.operations import GalleryApplicationVersionsOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import GalleryApplicationVersionsOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import GalleryApplicationVersionsOperations as OperationClass - elif api_version == '2021-10-01': - from .v2021_10_01.operations import GalleryApplicationVersionsOperations as OperationClass - elif api_version == '2022-01-03': - from .v2022_01_03.operations import GalleryApplicationVersionsOperations as OperationClass - elif api_version == '2023-07-03': - from .v2023_07_03.operations import GalleryApplicationVersionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'gallery_application_versions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def gallery_applications(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`GalleryApplicationsOperations` - * 2019-12-01: :class:`GalleryApplicationsOperations` - * 2021-07-01: :class:`GalleryApplicationsOperations` - * 2021-10-01: :class:`GalleryApplicationsOperations` - * 2022-01-03: :class:`GalleryApplicationsOperations` - * 2023-07-03: :class:`GalleryApplicationsOperations` - """ - api_version = self._get_api_version('gallery_applications') - if api_version == '2019-07-01': - from .v2019_07_01.operations import GalleryApplicationsOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import GalleryApplicationsOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import GalleryApplicationsOperations as OperationClass - elif api_version == '2021-10-01': - from .v2021_10_01.operations import GalleryApplicationsOperations as OperationClass - elif api_version == '2022-01-03': - from .v2022_01_03.operations import GalleryApplicationsOperations as OperationClass - elif api_version == '2023-07-03': - from .v2023_07_03.operations import GalleryApplicationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'gallery_applications'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def gallery_image_versions(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`GalleryImageVersionsOperations` - * 2019-12-01: :class:`GalleryImageVersionsOperations` - * 2021-07-01: :class:`GalleryImageVersionsOperations` - * 2021-10-01: :class:`GalleryImageVersionsOperations` - * 2022-01-03: :class:`GalleryImageVersionsOperations` - * 2023-07-03: :class:`GalleryImageVersionsOperations` - """ - api_version = self._get_api_version('gallery_image_versions') - if api_version == '2019-07-01': - from .v2019_07_01.operations import GalleryImageVersionsOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import GalleryImageVersionsOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import GalleryImageVersionsOperations as OperationClass - elif api_version == '2021-10-01': - from .v2021_10_01.operations import GalleryImageVersionsOperations as OperationClass - elif api_version == '2022-01-03': - from .v2022_01_03.operations import GalleryImageVersionsOperations as OperationClass - elif api_version == '2023-07-03': - from .v2023_07_03.operations import GalleryImageVersionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'gallery_image_versions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def gallery_images(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`GalleryImagesOperations` - * 2019-12-01: :class:`GalleryImagesOperations` - * 2021-07-01: :class:`GalleryImagesOperations` - * 2021-10-01: :class:`GalleryImagesOperations` - * 2022-01-03: :class:`GalleryImagesOperations` - * 2023-07-03: :class:`GalleryImagesOperations` - """ - api_version = self._get_api_version('gallery_images') - if api_version == '2019-07-01': - from .v2019_07_01.operations import GalleryImagesOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import GalleryImagesOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import GalleryImagesOperations as OperationClass - elif api_version == '2021-10-01': - from .v2021_10_01.operations import GalleryImagesOperations as OperationClass - elif api_version == '2022-01-03': - from .v2022_01_03.operations import GalleryImagesOperations as OperationClass - elif api_version == '2023-07-03': - from .v2023_07_03.operations import GalleryImagesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'gallery_images'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def gallery_sharing_profile(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`GallerySharingProfileOperations` - * 2021-10-01: :class:`GallerySharingProfileOperations` - * 2022-01-03: :class:`GallerySharingProfileOperations` - * 2023-07-03: :class:`GallerySharingProfileOperations` - """ - api_version = self._get_api_version('gallery_sharing_profile') - if api_version == '2021-07-01': - from .v2021_07_01.operations import GallerySharingProfileOperations as OperationClass - elif api_version == '2021-10-01': - from .v2021_10_01.operations import GallerySharingProfileOperations as OperationClass - elif api_version == '2022-01-03': - from .v2022_01_03.operations import GallerySharingProfileOperations as OperationClass - elif api_version == '2023-07-03': - from .v2023_07_03.operations import GallerySharingProfileOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'gallery_sharing_profile'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def images(self): - """Instance depends on the API version: - - * 2017-03-30: :class:`ImagesOperations` - * 2017-12-01: :class:`ImagesOperations` - * 2019-07-01: :class:`ImagesOperations` - * 2019-12-01: :class:`ImagesOperations` - * 2020-06-01: :class:`ImagesOperations` - * 2021-07-01: :class:`ImagesOperations` - * 2024-11-01: :class:`ImagesOperations` - """ - api_version = self._get_api_version('images') - if api_version == '2017-03-30': - from .v2017_03_30.operations import ImagesOperations as OperationClass - elif api_version == '2017-12-01': - from .v2017_12_01.operations import ImagesOperations as OperationClass - elif api_version == '2019-07-01': - from .v2019_07_01.operations import ImagesOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import ImagesOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import ImagesOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import ImagesOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import ImagesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'images'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def log_analytics(self): - """Instance depends on the API version: - - * 2017-12-01: :class:`LogAnalyticsOperations` - * 2019-07-01: :class:`LogAnalyticsOperations` - * 2019-12-01: :class:`LogAnalyticsOperations` - * 2020-06-01: :class:`LogAnalyticsOperations` - * 2021-07-01: :class:`LogAnalyticsOperations` - * 2024-11-01: :class:`LogAnalyticsOperations` - """ - api_version = self._get_api_version('log_analytics') - if api_version == '2017-12-01': - from .v2017_12_01.operations import LogAnalyticsOperations as OperationClass - elif api_version == '2019-07-01': - from .v2019_07_01.operations import LogAnalyticsOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import LogAnalyticsOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import LogAnalyticsOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import LogAnalyticsOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import LogAnalyticsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'log_analytics'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def operations(self): - """Instance depends on the API version: - - * 2017-12-01: :class:`Operations` - * 2019-07-01: :class:`Operations` - * 2019-12-01: :class:`Operations` - * 2020-06-01: :class:`Operations` - * 2021-07-01: :class:`Operations` - * 2024-11-01: :class:`Operations` - """ - api_version = self._get_api_version('operations') - if api_version == '2017-12-01': - from .v2017_12_01.operations import Operations as OperationClass - elif api_version == '2019-07-01': - from .v2019_07_01.operations import Operations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import Operations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import Operations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import Operations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import Operations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def proximity_placement_groups(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`ProximityPlacementGroupsOperations` - * 2019-12-01: :class:`ProximityPlacementGroupsOperations` - * 2020-06-01: :class:`ProximityPlacementGroupsOperations` - * 2021-07-01: :class:`ProximityPlacementGroupsOperations` - * 2024-11-01: :class:`ProximityPlacementGroupsOperations` - """ - api_version = self._get_api_version('proximity_placement_groups') - if api_version == '2019-07-01': - from .v2019_07_01.operations import ProximityPlacementGroupsOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import ProximityPlacementGroupsOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import ProximityPlacementGroupsOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import ProximityPlacementGroupsOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import ProximityPlacementGroupsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'proximity_placement_groups'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def resource_skus(self): - """Instance depends on the API version: - - * 2017-03-30: :class:`ResourceSkusOperations` - * 2017-09-01: :class:`ResourceSkusOperations` - * 2019-04-01: :class:`ResourceSkusOperations` - * 2021-07-01: :class:`ResourceSkusOperations` - """ - api_version = self._get_api_version('resource_skus') - if api_version == '2017-03-30': - from .v2017_03_30.operations import ResourceSkusOperations as OperationClass - elif api_version == '2017-09-01': - from .v2017_09_01.operations import ResourceSkusOperations as OperationClass - elif api_version == '2019-04-01': - from .v2019_04_01.operations import ResourceSkusOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import ResourceSkusOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'resource_skus'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - @property - def restore_point_collections(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`RestorePointCollectionsOperations` - * 2024-11-01: :class:`RestorePointCollectionsOperations` - """ - api_version = self._get_api_version('restore_point_collections') - if api_version == '2021-07-01': - from .v2021_07_01.operations import RestorePointCollectionsOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import RestorePointCollectionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'restore_point_collections'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def restore_points(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`RestorePointsOperations` - * 2024-11-01: :class:`RestorePointsOperations` - """ - api_version = self._get_api_version('restore_points') - if api_version == '2021-07-01': - from .v2021_07_01.operations import RestorePointsOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import RestorePointsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'restore_points'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def shared_galleries(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`SharedGalleriesOperations` - * 2022-01-03: :class:`SharedGalleriesOperations` - * 2023-07-03: :class:`SharedGalleriesOperations` - """ - api_version = self._get_api_version('shared_galleries') - if api_version == '2021-07-01': - from .v2021_07_01.operations import SharedGalleriesOperations as OperationClass - elif api_version == '2022-01-03': - from .v2022_01_03.operations import SharedGalleriesOperations as OperationClass - elif api_version == '2023-07-03': - from .v2023_07_03.operations import SharedGalleriesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'shared_galleries'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def shared_gallery_image_versions(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`SharedGalleryImageVersionsOperations` - * 2022-01-03: :class:`SharedGalleryImageVersionsOperations` - * 2023-07-03: :class:`SharedGalleryImageVersionsOperations` - """ - api_version = self._get_api_version('shared_gallery_image_versions') - if api_version == '2021-07-01': - from .v2021_07_01.operations import SharedGalleryImageVersionsOperations as OperationClass - elif api_version == '2022-01-03': - from .v2022_01_03.operations import SharedGalleryImageVersionsOperations as OperationClass - elif api_version == '2023-07-03': - from .v2023_07_03.operations import SharedGalleryImageVersionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'shared_gallery_image_versions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def shared_gallery_images(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`SharedGalleryImagesOperations` - * 2022-01-03: :class:`SharedGalleryImagesOperations` - * 2023-07-03: :class:`SharedGalleryImagesOperations` - """ - api_version = self._get_api_version('shared_gallery_images') - if api_version == '2021-07-01': - from .v2021_07_01.operations import SharedGalleryImagesOperations as OperationClass - elif api_version == '2022-01-03': - from .v2022_01_03.operations import SharedGalleryImagesOperations as OperationClass - elif api_version == '2023-07-03': - from .v2023_07_03.operations import SharedGalleryImagesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'shared_gallery_images'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def snapshots(self): - """Instance depends on the API version: - - * 2017-03-30: :class:`SnapshotsOperations` - * 2019-07-01: :class:`SnapshotsOperations` - * 2020-05-01: :class:`SnapshotsOperations` - * 2022-03-02: :class:`SnapshotsOperations` - * 2023-04-02: :class:`SnapshotsOperations` - * 2023-10-02: :class:`SnapshotsOperations` - * 2025-01-02: :class:`SnapshotsOperations` - """ - api_version = self._get_api_version('snapshots') - if api_version == '2017-03-30': - from .v2017_03_30.operations import SnapshotsOperations as OperationClass - elif api_version == '2019-07-01': - from .v2019_07_01.operations import SnapshotsOperations as OperationClass - elif api_version == '2020-05-01': - from .v2020_05_01.operations import SnapshotsOperations as OperationClass - elif api_version == '2022-03-02': - from .v2022_03_02.operations import SnapshotsOperations as OperationClass - elif api_version == '2023-04-02': - from .v2023_04_02.operations import SnapshotsOperations as OperationClass - elif api_version == '2023-10-02': - from .v2023_10_02.operations import SnapshotsOperations as OperationClass - elif api_version == '2025-01-02': - from .v2025_01_02.operations import SnapshotsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'snapshots'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def ssh_public_keys(self): - """Instance depends on the API version: - - * 2019-12-01: :class:`SshPublicKeysOperations` - * 2020-06-01: :class:`SshPublicKeysOperations` - * 2021-07-01: :class:`SshPublicKeysOperations` - * 2024-11-01: :class:`SshPublicKeysOperations` - """ - api_version = self._get_api_version('ssh_public_keys') - if api_version == '2019-12-01': - from .v2019_12_01.operations import SshPublicKeysOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import SshPublicKeysOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import SshPublicKeysOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import SshPublicKeysOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'ssh_public_keys'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def usage(self): - """Instance depends on the API version: - - * 2016-03-30: :class:`UsageOperations` - * 2017-03-30: :class:`UsageOperations` - * 2017-12-01: :class:`UsageOperations` - * 2019-07-01: :class:`UsageOperations` - * 2019-12-01: :class:`UsageOperations` - * 2020-06-01: :class:`UsageOperations` - * 2021-07-01: :class:`UsageOperations` - * 2024-11-01: :class:`UsageOperations` - """ - api_version = self._get_api_version('usage') - if api_version == '2016-03-30': - from .v2016_03_30.operations import UsageOperations as OperationClass - elif api_version == '2017-03-30': - from .v2017_03_30.operations import UsageOperations as OperationClass - elif api_version == '2017-12-01': - from .v2017_12_01.operations import UsageOperations as OperationClass - elif api_version == '2019-07-01': - from .v2019_07_01.operations import UsageOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import UsageOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import UsageOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import UsageOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import UsageOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'usage'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_extension_images(self): - """Instance depends on the API version: - - * 2016-03-30: :class:`VirtualMachineExtensionImagesOperations` - * 2017-03-30: :class:`VirtualMachineExtensionImagesOperations` - * 2017-12-01: :class:`VirtualMachineExtensionImagesOperations` - * 2019-07-01: :class:`VirtualMachineExtensionImagesOperations` - * 2019-12-01: :class:`VirtualMachineExtensionImagesOperations` - * 2020-06-01: :class:`VirtualMachineExtensionImagesOperations` - * 2021-07-01: :class:`VirtualMachineExtensionImagesOperations` - * 2024-11-01: :class:`VirtualMachineExtensionImagesOperations` - """ - api_version = self._get_api_version('virtual_machine_extension_images') - if api_version == '2016-03-30': - from .v2016_03_30.operations import VirtualMachineExtensionImagesOperations as OperationClass - elif api_version == '2017-03-30': - from .v2017_03_30.operations import VirtualMachineExtensionImagesOperations as OperationClass - elif api_version == '2017-12-01': - from .v2017_12_01.operations import VirtualMachineExtensionImagesOperations as OperationClass - elif api_version == '2019-07-01': - from .v2019_07_01.operations import VirtualMachineExtensionImagesOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import VirtualMachineExtensionImagesOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import VirtualMachineExtensionImagesOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import VirtualMachineExtensionImagesOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import VirtualMachineExtensionImagesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_extension_images'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_extensions(self): - """Instance depends on the API version: - - * 2016-03-30: :class:`VirtualMachineExtensionsOperations` - * 2017-03-30: :class:`VirtualMachineExtensionsOperations` - * 2017-12-01: :class:`VirtualMachineExtensionsOperations` - * 2019-07-01: :class:`VirtualMachineExtensionsOperations` - * 2019-12-01: :class:`VirtualMachineExtensionsOperations` - * 2020-06-01: :class:`VirtualMachineExtensionsOperations` - * 2021-07-01: :class:`VirtualMachineExtensionsOperations` - * 2024-11-01: :class:`VirtualMachineExtensionsOperations` - """ - api_version = self._get_api_version('virtual_machine_extensions') - if api_version == '2016-03-30': - from .v2016_03_30.operations import VirtualMachineExtensionsOperations as OperationClass - elif api_version == '2017-03-30': - from .v2017_03_30.operations import VirtualMachineExtensionsOperations as OperationClass - elif api_version == '2017-12-01': - from .v2017_12_01.operations import VirtualMachineExtensionsOperations as OperationClass - elif api_version == '2019-07-01': - from .v2019_07_01.operations import VirtualMachineExtensionsOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import VirtualMachineExtensionsOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import VirtualMachineExtensionsOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import VirtualMachineExtensionsOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import VirtualMachineExtensionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_extensions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_images(self): - """Instance depends on the API version: - - * 2016-03-30: :class:`VirtualMachineImagesOperations` - * 2017-03-30: :class:`VirtualMachineImagesOperations` - * 2017-12-01: :class:`VirtualMachineImagesOperations` - * 2019-07-01: :class:`VirtualMachineImagesOperations` - * 2019-12-01: :class:`VirtualMachineImagesOperations` - * 2020-06-01: :class:`VirtualMachineImagesOperations` - * 2021-07-01: :class:`VirtualMachineImagesOperations` - * 2024-11-01: :class:`VirtualMachineImagesOperations` - """ - api_version = self._get_api_version('virtual_machine_images') - if api_version == '2016-03-30': - from .v2016_03_30.operations import VirtualMachineImagesOperations as OperationClass - elif api_version == '2017-03-30': - from .v2017_03_30.operations import VirtualMachineImagesOperations as OperationClass - elif api_version == '2017-12-01': - from .v2017_12_01.operations import VirtualMachineImagesOperations as OperationClass - elif api_version == '2019-07-01': - from .v2019_07_01.operations import VirtualMachineImagesOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import VirtualMachineImagesOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import VirtualMachineImagesOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import VirtualMachineImagesOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import VirtualMachineImagesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_images'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_images_edge_zone(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`VirtualMachineImagesEdgeZoneOperations` - * 2024-11-01: :class:`VirtualMachineImagesEdgeZoneOperations` - """ - api_version = self._get_api_version('virtual_machine_images_edge_zone') - if api_version == '2021-07-01': - from .v2021_07_01.operations import VirtualMachineImagesEdgeZoneOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import VirtualMachineImagesEdgeZoneOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_images_edge_zone'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_run_commands(self): - """Instance depends on the API version: - - * 2017-03-30: :class:`VirtualMachineRunCommandsOperations` - * 2017-12-01: :class:`VirtualMachineRunCommandsOperations` - * 2019-07-01: :class:`VirtualMachineRunCommandsOperations` - * 2019-12-01: :class:`VirtualMachineRunCommandsOperations` - * 2020-06-01: :class:`VirtualMachineRunCommandsOperations` - * 2021-07-01: :class:`VirtualMachineRunCommandsOperations` - * 2024-11-01: :class:`VirtualMachineRunCommandsOperations` - """ - api_version = self._get_api_version('virtual_machine_run_commands') - if api_version == '2017-03-30': - from .v2017_03_30.operations import VirtualMachineRunCommandsOperations as OperationClass - elif api_version == '2017-12-01': - from .v2017_12_01.operations import VirtualMachineRunCommandsOperations as OperationClass - elif api_version == '2019-07-01': - from .v2019_07_01.operations import VirtualMachineRunCommandsOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import VirtualMachineRunCommandsOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import VirtualMachineRunCommandsOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import VirtualMachineRunCommandsOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import VirtualMachineRunCommandsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_run_commands'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_scale_set_extensions(self): - """Instance depends on the API version: - - * 2017-03-30: :class:`VirtualMachineScaleSetExtensionsOperations` - * 2017-12-01: :class:`VirtualMachineScaleSetExtensionsOperations` - * 2019-07-01: :class:`VirtualMachineScaleSetExtensionsOperations` - * 2019-12-01: :class:`VirtualMachineScaleSetExtensionsOperations` - * 2020-06-01: :class:`VirtualMachineScaleSetExtensionsOperations` - * 2021-07-01: :class:`VirtualMachineScaleSetExtensionsOperations` - * 2024-11-01: :class:`VirtualMachineScaleSetExtensionsOperations` - """ - api_version = self._get_api_version('virtual_machine_scale_set_extensions') - if api_version == '2017-03-30': - from .v2017_03_30.operations import VirtualMachineScaleSetExtensionsOperations as OperationClass - elif api_version == '2017-12-01': - from .v2017_12_01.operations import VirtualMachineScaleSetExtensionsOperations as OperationClass - elif api_version == '2019-07-01': - from .v2019_07_01.operations import VirtualMachineScaleSetExtensionsOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import VirtualMachineScaleSetExtensionsOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import VirtualMachineScaleSetExtensionsOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import VirtualMachineScaleSetExtensionsOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import VirtualMachineScaleSetExtensionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_scale_set_extensions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_scale_set_rolling_upgrades(self): - """Instance depends on the API version: - - * 2017-03-30: :class:`VirtualMachineScaleSetRollingUpgradesOperations` - * 2017-12-01: :class:`VirtualMachineScaleSetRollingUpgradesOperations` - * 2019-07-01: :class:`VirtualMachineScaleSetRollingUpgradesOperations` - * 2019-12-01: :class:`VirtualMachineScaleSetRollingUpgradesOperations` - * 2020-06-01: :class:`VirtualMachineScaleSetRollingUpgradesOperations` - * 2021-07-01: :class:`VirtualMachineScaleSetRollingUpgradesOperations` - * 2024-11-01: :class:`VirtualMachineScaleSetRollingUpgradesOperations` - """ - api_version = self._get_api_version('virtual_machine_scale_set_rolling_upgrades') - if api_version == '2017-03-30': - from .v2017_03_30.operations import VirtualMachineScaleSetRollingUpgradesOperations as OperationClass - elif api_version == '2017-12-01': - from .v2017_12_01.operations import VirtualMachineScaleSetRollingUpgradesOperations as OperationClass - elif api_version == '2019-07-01': - from .v2019_07_01.operations import VirtualMachineScaleSetRollingUpgradesOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import VirtualMachineScaleSetRollingUpgradesOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import VirtualMachineScaleSetRollingUpgradesOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import VirtualMachineScaleSetRollingUpgradesOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import VirtualMachineScaleSetRollingUpgradesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_scale_set_rolling_upgrades'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_scale_set_vm_extensions(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`VirtualMachineScaleSetVMExtensionsOperations` - * 2019-12-01: :class:`VirtualMachineScaleSetVMExtensionsOperations` - * 2020-06-01: :class:`VirtualMachineScaleSetVMExtensionsOperations` - * 2021-07-01: :class:`VirtualMachineScaleSetVMExtensionsOperations` - * 2024-11-01: :class:`VirtualMachineScaleSetVMExtensionsOperations` - """ - api_version = self._get_api_version('virtual_machine_scale_set_vm_extensions') - if api_version == '2019-07-01': - from .v2019_07_01.operations import VirtualMachineScaleSetVMExtensionsOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import VirtualMachineScaleSetVMExtensionsOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import VirtualMachineScaleSetVMExtensionsOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import VirtualMachineScaleSetVMExtensionsOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import VirtualMachineScaleSetVMExtensionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_scale_set_vm_extensions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_scale_set_vm_run_commands(self): - """Instance depends on the API version: - - * 2020-06-01: :class:`VirtualMachineScaleSetVMRunCommandsOperations` - * 2021-07-01: :class:`VirtualMachineScaleSetVMRunCommandsOperations` - * 2024-11-01: :class:`VirtualMachineScaleSetVMRunCommandsOperations` - """ - api_version = self._get_api_version('virtual_machine_scale_set_vm_run_commands') - if api_version == '2020-06-01': - from .v2020_06_01.operations import VirtualMachineScaleSetVMRunCommandsOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import VirtualMachineScaleSetVMRunCommandsOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import VirtualMachineScaleSetVMRunCommandsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_scale_set_vm_run_commands'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_scale_set_vms(self): - """Instance depends on the API version: - - * 2016-03-30: :class:`VirtualMachineScaleSetVMsOperations` - * 2017-03-30: :class:`VirtualMachineScaleSetVMsOperations` - * 2017-12-01: :class:`VirtualMachineScaleSetVMsOperations` - * 2019-07-01: :class:`VirtualMachineScaleSetVMsOperations` - * 2019-12-01: :class:`VirtualMachineScaleSetVMsOperations` - * 2020-06-01: :class:`VirtualMachineScaleSetVMsOperations` - * 2021-07-01: :class:`VirtualMachineScaleSetVMsOperations` - * 2024-11-01: :class:`VirtualMachineScaleSetVMsOperations` - """ - api_version = self._get_api_version('virtual_machine_scale_set_vms') - if api_version == '2016-03-30': - from .v2016_03_30.operations import VirtualMachineScaleSetVMsOperations as OperationClass - elif api_version == '2017-03-30': - from .v2017_03_30.operations import VirtualMachineScaleSetVMsOperations as OperationClass - elif api_version == '2017-12-01': - from .v2017_12_01.operations import VirtualMachineScaleSetVMsOperations as OperationClass - elif api_version == '2019-07-01': - from .v2019_07_01.operations import VirtualMachineScaleSetVMsOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import VirtualMachineScaleSetVMsOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import VirtualMachineScaleSetVMsOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import VirtualMachineScaleSetVMsOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import VirtualMachineScaleSetVMsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_scale_set_vms'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.capacity_reservation_groups = CapacityReservationGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_point_collections = RestorePointCollectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ssh_public_keys = SshPublicKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.capacity_reservations = CapacityReservationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) + self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_service_role_instances = CloudServiceRoleInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_service_roles = CloudServiceRolesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_services = CloudServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.cloud_services_update_domain = CloudServicesUpdateDomainOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_service_operating_systems = CloudServiceOperatingSystemsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) + self.disk_accesses = DiskAccessesOperations(self._client, self._config, self._serialize, self._deserialize) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_restore_point = DiskRestorePointOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_skus = ResourceSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.galleries = GalleriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.gallery_image_versions = GalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_applications = GalleryApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_application_versions = GalleryApplicationVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_sharing_profile = GallerySharingProfileOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_galleries = SharedGalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_gallery_images = SharedGalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.community_galleries = CommunityGalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.community_gallery_images = CommunityGalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - @property - def virtual_machine_scale_sets(self): - """Instance depends on the API version: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. - * 2016-03-30: :class:`VirtualMachineScaleSetsOperations` - * 2017-03-30: :class:`VirtualMachineScaleSetsOperations` - * 2017-12-01: :class:`VirtualMachineScaleSetsOperations` - * 2019-07-01: :class:`VirtualMachineScaleSetsOperations` - * 2019-12-01: :class:`VirtualMachineScaleSetsOperations` - * 2020-06-01: :class:`VirtualMachineScaleSetsOperations` - * 2021-07-01: :class:`VirtualMachineScaleSetsOperations` - * 2024-11-01: :class:`VirtualMachineScaleSetsOperations` - """ - api_version = self._get_api_version('virtual_machine_scale_sets') - if api_version == '2016-03-30': - from .v2016_03_30.operations import VirtualMachineScaleSetsOperations as OperationClass - elif api_version == '2017-03-30': - from .v2017_03_30.operations import VirtualMachineScaleSetsOperations as OperationClass - elif api_version == '2017-12-01': - from .v2017_12_01.operations import VirtualMachineScaleSetsOperations as OperationClass - elif api_version == '2019-07-01': - from .v2019_07_01.operations import VirtualMachineScaleSetsOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import VirtualMachineScaleSetsOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import VirtualMachineScaleSetsOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import VirtualMachineScaleSetsOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import VirtualMachineScaleSetsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_scale_sets'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + - @property - def virtual_machine_sizes(self): - """Instance depends on the API version: + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - * 2016-03-30: :class:`VirtualMachineSizesOperations` - * 2017-03-30: :class:`VirtualMachineSizesOperations` - * 2017-12-01: :class:`VirtualMachineSizesOperations` - * 2019-07-01: :class:`VirtualMachineSizesOperations` - * 2019-12-01: :class:`VirtualMachineSizesOperations` - * 2020-06-01: :class:`VirtualMachineSizesOperations` - * 2021-07-01: :class:`VirtualMachineSizesOperations` - * 2024-11-01: :class:`VirtualMachineSizesOperations` + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse """ - api_version = self._get_api_version('virtual_machine_sizes') - if api_version == '2016-03-30': - from .v2016_03_30.operations import VirtualMachineSizesOperations as OperationClass - elif api_version == '2017-03-30': - from .v2017_03_30.operations import VirtualMachineSizesOperations as OperationClass - elif api_version == '2017-12-01': - from .v2017_12_01.operations import VirtualMachineSizesOperations as OperationClass - elif api_version == '2019-07-01': - from .v2019_07_01.operations import VirtualMachineSizesOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import VirtualMachineSizesOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import VirtualMachineSizesOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import VirtualMachineSizesOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import VirtualMachineSizesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_sizes'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machines(self): - """Instance depends on the API version: - * 2016-03-30: :class:`VirtualMachinesOperations` - * 2017-03-30: :class:`VirtualMachinesOperations` - * 2017-12-01: :class:`VirtualMachinesOperations` - * 2019-07-01: :class:`VirtualMachinesOperations` - * 2019-12-01: :class:`VirtualMachinesOperations` - * 2020-06-01: :class:`VirtualMachinesOperations` - * 2021-07-01: :class:`VirtualMachinesOperations` - * 2024-11-01: :class:`VirtualMachinesOperations` - """ - api_version = self._get_api_version('virtual_machines') - if api_version == '2016-03-30': - from .v2016_03_30.operations import VirtualMachinesOperations as OperationClass - elif api_version == '2017-03-30': - from .v2017_03_30.operations import VirtualMachinesOperations as OperationClass - elif api_version == '2017-12-01': - from .v2017_12_01.operations import VirtualMachinesOperations as OperationClass - elif api_version == '2019-07-01': - from .v2019_07_01.operations import VirtualMachinesOperations as OperationClass - elif api_version == '2019-12-01': - from .v2019_12_01.operations import VirtualMachinesOperations as OperationClass - elif api_version == '2020-06-01': - from .v2020_06_01.operations import VirtualMachinesOperations as OperationClass - elif api_version == '2021-07-01': - from .v2021_07_01.operations import VirtualMachinesOperations as OperationClass - elif api_version == '2024-11-01': - from .v2024_11_01.operations import VirtualMachinesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machines'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - def close(self): + def close(self) -> None: self._client.close() - def __enter__(self): + + def __enter__(self) -> Self: self._client.__enter__() return self - def __exit__(self, *exc_details): + + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_configuration.py index 3d0ba8868277..c012d0cabd65 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_configuration.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_configuration.py @@ -1,13 +1,11 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- + from typing import Any, TYPE_CHECKING from azure.core.pipeline import policies @@ -16,10 +14,10 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ComputeManagementClientConfiguration: + +class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for ComputeManagementClient. Note that all parameters used to create this instance are saved as instance @@ -31,12 +29,7 @@ class ComputeManagementClientConfiguration: :type subscription_id: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ): + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -44,23 +37,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'azure-mgmt-compute/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ): - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_patch.py similarity index 100% rename from sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_patch.py rename to sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_patch.py diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_serialization.py deleted file mode 100644 index 05bcd7d403ae..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_serialization.py +++ /dev/null @@ -1,2025 +0,0 @@ -# coding=utf-8 - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_utils/__init__.py similarity index 100% rename from sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_utils/__init__.py rename to sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_utils/__init__.py diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_utils/serialization.py similarity index 100% rename from sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_utils/serialization.py rename to sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_utils/serialization.py diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_version.py index ce330953651e..c89f5e6483e2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_version.py @@ -5,4 +5,4 @@ # license information. # -------------------------------------------------------------------------- -VERSION = "35.0.0" +VERSION = "36.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/__init__.py index 9e9459635989..d3fd1ba93379 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/__init__.py @@ -5,6 +5,25 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._compute_management_client import ComputeManagementClient -__all__ = ['ComputeManagementClient'] +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._compute_management_client import ComputeManagementClient # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ComputeManagementClient", +] +__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/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/_compute_management_client.py index 35016644326d..504a557e01af 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/_compute_management_client.py @@ -1,133 +1,232 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING, cast +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast from typing_extensions import Self from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.settings import settings from azure.mgmt.core import AsyncARMPipelineClient from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from azure.mgmt.core.tools import get_arm_endpoints -from azure.profiles import KnownProfiles, ProfileDefinition -from azure.profiles.multiapiclient import MultiApiClientMixin -from .._serialization import Deserializer, Serializer +from .. import models as _models +from .._utils.serialization import Deserializer, Serializer from ._configuration import ComputeManagementClientConfiguration +from .operations import ( + AvailabilitySetsOperations, + CapacityReservationGroupsOperations, + CapacityReservationsOperations, + CloudServiceOperatingSystemsOperations, + CloudServiceRoleInstancesOperations, + CloudServiceRolesOperations, + CloudServicesOperations, + CloudServicesUpdateDomainOperations, + CommunityGalleriesOperations, + CommunityGalleryImageVersionsOperations, + CommunityGalleryImagesOperations, + DedicatedHostGroupsOperations, + DedicatedHostsOperations, + DiskAccessesOperations, + DiskEncryptionSetsOperations, + DiskRestorePointOperations, + DisksOperations, + GalleriesOperations, + GalleryApplicationVersionsOperations, + GalleryApplicationsOperations, + GalleryImageVersionsOperations, + GalleryImagesOperations, + GallerySharingProfileOperations, + ImagesOperations, + LogAnalyticsOperations, + Operations, + ProximityPlacementGroupsOperations, + ResourceSkusOperations, + RestorePointCollectionsOperations, + RestorePointsOperations, + SharedGalleriesOperations, + SharedGalleryImageVersionsOperations, + SharedGalleryImagesOperations, + SnapshotsOperations, + SshPublicKeysOperations, + UsageOperations, + VirtualMachineExtensionImagesOperations, + VirtualMachineExtensionsOperations, + VirtualMachineImagesEdgeZoneOperations, + VirtualMachineImagesOperations, + VirtualMachineRunCommandsOperations, + VirtualMachineScaleSetExtensionsOperations, + VirtualMachineScaleSetRollingUpgradesOperations, + VirtualMachineScaleSetVMExtensionsOperations, + VirtualMachineScaleSetVMRunCommandsOperations, + VirtualMachineScaleSetVMsOperations, + VirtualMachineScaleSetsOperations, + VirtualMachineSizesOperations, + VirtualMachinesOperations, +) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class _SDKClient(object): - def __init__(self, *args, **kwargs): - """This is a fake class to support current implementation of MultiApiClientMixin." - Will be removed in final version of multiapi azure-core based client - """ - pass -class ComputeManagementClient(MultiApiClientMixin, _SDKClient): +class ComputeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Compute Client. - This ready contains multiple API versions, to help you deal with all of the Azure clouds - (Azure Stack, Azure Government, Azure China, etc.). - By default, it uses the latest API version available on public Azure. - For production, you should stick to a particular api-version and/or profile. - The profile sets a mapping between an operation group and its API version. - The api-version parameter sets the default API version if the operation - group is not described in the profile. - + :ivar operations: Operations operations + :vartype operations: azure.mgmt.compute.aio.operations.Operations + :ivar availability_sets: AvailabilitySetsOperations operations + :vartype availability_sets: azure.mgmt.compute.aio.operations.AvailabilitySetsOperations + :ivar capacity_reservation_groups: CapacityReservationGroupsOperations operations + :vartype capacity_reservation_groups: + azure.mgmt.compute.aio.operations.CapacityReservationGroupsOperations + :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations + :vartype dedicated_host_groups: azure.mgmt.compute.aio.operations.DedicatedHostGroupsOperations + :ivar images: ImagesOperations operations + :vartype images: azure.mgmt.compute.aio.operations.ImagesOperations + :ivar virtual_machine_images_edge_zone: VirtualMachineImagesEdgeZoneOperations operations + :vartype virtual_machine_images_edge_zone: + azure.mgmt.compute.aio.operations.VirtualMachineImagesEdgeZoneOperations + :ivar virtual_machine_images: VirtualMachineImagesOperations operations + :vartype virtual_machine_images: + azure.mgmt.compute.aio.operations.VirtualMachineImagesOperations + :ivar log_analytics: LogAnalyticsOperations operations + :vartype log_analytics: azure.mgmt.compute.aio.operations.LogAnalyticsOperations + :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations + :vartype virtual_machine_extension_images: + azure.mgmt.compute.aio.operations.VirtualMachineExtensionImagesOperations + :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations + :vartype virtual_machine_run_commands: + azure.mgmt.compute.aio.operations.VirtualMachineRunCommandsOperations + :ivar usage: UsageOperations operations + :vartype usage: azure.mgmt.compute.aio.operations.UsageOperations + :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations + :vartype virtual_machine_scale_sets: + azure.mgmt.compute.aio.operations.VirtualMachineScaleSetsOperations + :ivar virtual_machines: VirtualMachinesOperations operations + :vartype virtual_machines: azure.mgmt.compute.aio.operations.VirtualMachinesOperations + :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations + :vartype virtual_machine_sizes: azure.mgmt.compute.aio.operations.VirtualMachineSizesOperations + :ivar proximity_placement_groups: ProximityPlacementGroupsOperations operations + :vartype proximity_placement_groups: + azure.mgmt.compute.aio.operations.ProximityPlacementGroupsOperations + :ivar restore_point_collections: RestorePointCollectionsOperations operations + :vartype restore_point_collections: + azure.mgmt.compute.aio.operations.RestorePointCollectionsOperations + :ivar ssh_public_keys: SshPublicKeysOperations operations + :vartype ssh_public_keys: azure.mgmt.compute.aio.operations.SshPublicKeysOperations + :ivar capacity_reservations: CapacityReservationsOperations operations + :vartype capacity_reservations: + azure.mgmt.compute.aio.operations.CapacityReservationsOperations + :ivar dedicated_hosts: DedicatedHostsOperations operations + :vartype dedicated_hosts: azure.mgmt.compute.aio.operations.DedicatedHostsOperations + :ivar restore_points: RestorePointsOperations operations + :vartype restore_points: azure.mgmt.compute.aio.operations.RestorePointsOperations + :ivar virtual_machine_scale_set_rolling_upgrades: + VirtualMachineScaleSetRollingUpgradesOperations operations + :vartype virtual_machine_scale_set_rolling_upgrades: + azure.mgmt.compute.aio.operations.VirtualMachineScaleSetRollingUpgradesOperations + :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations + operations + :vartype virtual_machine_scale_set_extensions: + azure.mgmt.compute.aio.operations.VirtualMachineScaleSetExtensionsOperations + :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations + :vartype virtual_machine_scale_set_vms: + azure.mgmt.compute.aio.operations.VirtualMachineScaleSetVMsOperations + :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations + operations + :vartype virtual_machine_scale_set_vm_extensions: + azure.mgmt.compute.aio.operations.VirtualMachineScaleSetVMExtensionsOperations + :ivar virtual_machine_scale_set_vm_run_commands: VirtualMachineScaleSetVMRunCommandsOperations + operations + :vartype virtual_machine_scale_set_vm_run_commands: + azure.mgmt.compute.aio.operations.VirtualMachineScaleSetVMRunCommandsOperations + :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations + :vartype virtual_machine_extensions: + azure.mgmt.compute.aio.operations.VirtualMachineExtensionsOperations + :ivar cloud_service_role_instances: CloudServiceRoleInstancesOperations operations + :vartype cloud_service_role_instances: + azure.mgmt.compute.aio.operations.CloudServiceRoleInstancesOperations + :ivar cloud_service_roles: CloudServiceRolesOperations operations + :vartype cloud_service_roles: azure.mgmt.compute.aio.operations.CloudServiceRolesOperations + :ivar cloud_services: CloudServicesOperations operations + :vartype cloud_services: azure.mgmt.compute.aio.operations.CloudServicesOperations + :ivar cloud_services_update_domain: CloudServicesUpdateDomainOperations operations + :vartype cloud_services_update_domain: + azure.mgmt.compute.aio.operations.CloudServicesUpdateDomainOperations + :ivar cloud_service_operating_systems: CloudServiceOperatingSystemsOperations operations + :vartype cloud_service_operating_systems: + azure.mgmt.compute.aio.operations.CloudServiceOperatingSystemsOperations + :ivar disks: DisksOperations operations + :vartype disks: azure.mgmt.compute.aio.operations.DisksOperations + :ivar disk_accesses: DiskAccessesOperations operations + :vartype disk_accesses: azure.mgmt.compute.aio.operations.DiskAccessesOperations + :ivar disk_encryption_sets: DiskEncryptionSetsOperations operations + :vartype disk_encryption_sets: azure.mgmt.compute.aio.operations.DiskEncryptionSetsOperations + :ivar disk_restore_point: DiskRestorePointOperations operations + :vartype disk_restore_point: azure.mgmt.compute.aio.operations.DiskRestorePointOperations + :ivar snapshots: SnapshotsOperations operations + :vartype snapshots: azure.mgmt.compute.aio.operations.SnapshotsOperations + :ivar resource_skus: ResourceSkusOperations operations + :vartype resource_skus: azure.mgmt.compute.aio.operations.ResourceSkusOperations + :ivar galleries: GalleriesOperations operations + :vartype galleries: azure.mgmt.compute.aio.operations.GalleriesOperations + :ivar gallery_images: GalleryImagesOperations operations + :vartype gallery_images: azure.mgmt.compute.aio.operations.GalleryImagesOperations + :ivar gallery_image_versions: GalleryImageVersionsOperations operations + :vartype gallery_image_versions: + azure.mgmt.compute.aio.operations.GalleryImageVersionsOperations + :ivar gallery_applications: GalleryApplicationsOperations operations + :vartype gallery_applications: azure.mgmt.compute.aio.operations.GalleryApplicationsOperations + :ivar gallery_application_versions: GalleryApplicationVersionsOperations operations + :vartype gallery_application_versions: + azure.mgmt.compute.aio.operations.GalleryApplicationVersionsOperations + :ivar gallery_sharing_profile: GallerySharingProfileOperations operations + :vartype gallery_sharing_profile: + azure.mgmt.compute.aio.operations.GallerySharingProfileOperations + :ivar shared_galleries: SharedGalleriesOperations operations + :vartype shared_galleries: azure.mgmt.compute.aio.operations.SharedGalleriesOperations + :ivar shared_gallery_images: SharedGalleryImagesOperations operations + :vartype shared_gallery_images: azure.mgmt.compute.aio.operations.SharedGalleryImagesOperations + :ivar shared_gallery_image_versions: SharedGalleryImageVersionsOperations operations + :vartype shared_gallery_image_versions: + azure.mgmt.compute.aio.operations.SharedGalleryImageVersionsOperations + :ivar community_galleries: CommunityGalleriesOperations operations + :vartype community_galleries: azure.mgmt.compute.aio.operations.CommunityGalleriesOperations + :ivar community_gallery_images: CommunityGalleryImagesOperations operations + :vartype community_gallery_images: + azure.mgmt.compute.aio.operations.CommunityGalleryImagesOperations + :ivar community_gallery_image_versions: CommunityGalleryImageVersionsOperations operations + :vartype community_gallery_image_versions: + azure.mgmt.compute.aio.operations.CommunityGalleryImageVersionsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param api_version: API version to use if no profile is provided, or if missing in profile. - :type api_version: str - :param base_url: Service URL + :param base_url: Service URL. Default value is None. :type base_url: str - :param profile: A profile definition, from KnownProfiles to dict. - :type profile: azure.profiles.KnownProfiles - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ - DEFAULT_API_VERSION = '2025-01-02' - _PROFILE_TAG = "azure.mgmt.compute.ComputeManagementClient" - LATEST_PROFILE = ProfileDefinition({ - _PROFILE_TAG: { - None: DEFAULT_API_VERSION, - 'availability_sets': '2024-11-01', - 'capacity_reservation_groups': '2024-11-01', - 'capacity_reservations': '2024-11-01', - 'cloud_service_operating_systems': '2024-11-04', - 'cloud_service_role_instances': '2024-11-04', - 'cloud_service_roles': '2024-11-04', - 'cloud_services': '2024-11-04', - 'cloud_services_update_domain': '2024-11-04', - 'community_galleries': '2023-07-03', - 'community_gallery_image_versions': '2023-07-03', - 'community_gallery_images': '2023-07-03', - 'dedicated_host_groups': '2024-11-01', - 'dedicated_hosts': '2024-11-01', - 'galleries': '2023-07-03', - 'gallery_application_versions': '2023-07-03', - 'gallery_applications': '2023-07-03', - 'gallery_image_versions': '2023-07-03', - 'gallery_images': '2023-07-03', - 'gallery_sharing_profile': '2023-07-03', - 'images': '2024-11-01', - 'log_analytics': '2024-11-01', - 'operations': '2024-11-01', - 'proximity_placement_groups': '2024-11-01', - 'resource_skus': '2021-07-01', - 'restore_point_collections': '2024-11-01', - 'restore_points': '2024-11-01', - 'shared_galleries': '2023-07-03', - 'shared_gallery_image_versions': '2023-07-03', - 'shared_gallery_images': '2023-07-03', - 'ssh_public_keys': '2024-11-01', - 'usage': '2024-11-01', - 'virtual_machine_extension_images': '2024-11-01', - 'virtual_machine_extensions': '2024-11-01', - 'virtual_machine_images': '2024-11-01', - 'virtual_machine_images_edge_zone': '2024-11-01', - 'virtual_machine_run_commands': '2024-11-01', - 'virtual_machine_scale_set_extensions': '2024-11-01', - 'virtual_machine_scale_set_rolling_upgrades': '2024-11-01', - 'virtual_machine_scale_set_vm_extensions': '2024-11-01', - 'virtual_machine_scale_set_vm_run_commands': '2024-11-01', - 'virtual_machine_scale_set_vms': '2024-11-01', - 'virtual_machine_scale_sets': '2024-11-01', - 'virtual_machine_sizes': '2024-11-01', - 'virtual_machines': '2024-11-01', - }}, - _PROFILE_TAG + " latest" - ) - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - api_version: Optional[str] = None, - base_url: Optional[str] = None, - profile: KnownProfiles = KnownProfiles.default, - **kwargs: Any + self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any ) -> None: - if api_version: - kwargs.setdefault('api_version', api_version) _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore _endpoints = get_arm_endpoints(_cloud) if not base_url: base_url = _endpoints["resource_manager"] credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration(credential, subscription_id, credential_scopes=credential_scopes, **kwargs) + self._config = ComputeManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs + ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -146,1378 +245,164 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - super(ComputeManagementClient, self).__init__( - api_version=api_version, - profile=profile + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, base_url), policies=_policies, **kwargs ) - @classmethod - def _models_dict(cls, api_version): - return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} - - @classmethod - def models(cls, api_version=DEFAULT_API_VERSION): - """Module depends on the API version: - - * 2016-03-30: :mod:`v2016_03_30.models` - * 2017-03-30: :mod:`v2017_03_30.models` - * 2017-09-01: :mod:`v2017_09_01.models` - * 2017-12-01: :mod:`v2017_12_01.models` - * 2019-04-01: :mod:`v2019_04_01.models` - * 2019-07-01: :mod:`v2019_07_01.models` - * 2019-12-01: :mod:`v2019_12_01.models` - * 2020-05-01: :mod:`v2020_05_01.models` - * 2020-06-01: :mod:`v2020_06_01.models` - * 2021-07-01: :mod:`v2021_07_01.models` - * 2021-10-01: :mod:`v2021_10_01.models` - * 2022-01-03: :mod:`v2022_01_03.models` - * 2022-03-02: :mod:`v2022_03_02.models` - * 2022-09-04: :mod:`v2022_09_04.models` - * 2023-04-02: :mod:`v2023_04_02.models` - * 2023-07-03: :mod:`v2023_07_03.models` - * 2023-10-02: :mod:`v2023_10_02.models` - * 2024-11-01: :mod:`v2024_11_01.models` - * 2024-11-04: :mod:`v2024_11_04.models` - * 2025-01-02: :mod:`v2025_01_02.models` - """ - if api_version == '2016-03-30': - from ..v2016_03_30 import models - return models - elif api_version == '2017-03-30': - from ..v2017_03_30 import models - return models - elif api_version == '2017-09-01': - from ..v2017_09_01 import models - return models - elif api_version == '2017-12-01': - from ..v2017_12_01 import models - return models - elif api_version == '2019-04-01': - from ..v2019_04_01 import models - return models - elif api_version == '2019-07-01': - from ..v2019_07_01 import models - return models - elif api_version == '2019-12-01': - from ..v2019_12_01 import models - return models - elif api_version == '2020-05-01': - from ..v2020_05_01 import models - return models - elif api_version == '2020-06-01': - from ..v2020_06_01 import models - return models - elif api_version == '2021-07-01': - from ..v2021_07_01 import models - return models - elif api_version == '2021-10-01': - from ..v2021_10_01 import models - return models - elif api_version == '2022-01-03': - from ..v2022_01_03 import models - return models - elif api_version == '2022-03-02': - from ..v2022_03_02 import models - return models - elif api_version == '2022-09-04': - from ..v2022_09_04 import models - return models - elif api_version == '2023-04-02': - from ..v2023_04_02 import models - return models - elif api_version == '2023-07-03': - from ..v2023_07_03 import models - return models - elif api_version == '2023-10-02': - from ..v2023_10_02 import models - return models - elif api_version == '2024-11-01': - from ..v2024_11_01 import models - return models - elif api_version == '2024-11-04': - from ..v2024_11_04 import models - return models - elif api_version == '2025-01-02': - from ..v2025_01_02 import models - return models - raise ValueError("API version {} is not available".format(api_version)) - - @property - def availability_sets(self): - """Instance depends on the API version: - - * 2016-03-30: :class:`AvailabilitySetsOperations` - * 2017-03-30: :class:`AvailabilitySetsOperations` - * 2017-12-01: :class:`AvailabilitySetsOperations` - * 2019-07-01: :class:`AvailabilitySetsOperations` - * 2019-12-01: :class:`AvailabilitySetsOperations` - * 2020-06-01: :class:`AvailabilitySetsOperations` - * 2021-07-01: :class:`AvailabilitySetsOperations` - * 2024-11-01: :class:`AvailabilitySetsOperations` - """ - api_version = self._get_api_version('availability_sets') - if api_version == '2016-03-30': - from ..v2016_03_30.aio.operations import AvailabilitySetsOperations as OperationClass - elif api_version == '2017-03-30': - from ..v2017_03_30.aio.operations import AvailabilitySetsOperations as OperationClass - elif api_version == '2017-12-01': - from ..v2017_12_01.aio.operations import AvailabilitySetsOperations as OperationClass - elif api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import AvailabilitySetsOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import AvailabilitySetsOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import AvailabilitySetsOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import AvailabilitySetsOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import AvailabilitySetsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'availability_sets'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def capacity_reservation_groups(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`CapacityReservationGroupsOperations` - * 2024-11-01: :class:`CapacityReservationGroupsOperations` - """ - api_version = self._get_api_version('capacity_reservation_groups') - if api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import CapacityReservationGroupsOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import CapacityReservationGroupsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'capacity_reservation_groups'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def capacity_reservations(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`CapacityReservationsOperations` - * 2024-11-01: :class:`CapacityReservationsOperations` - """ - api_version = self._get_api_version('capacity_reservations') - if api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import CapacityReservationsOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import CapacityReservationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'capacity_reservations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def cloud_service_operating_systems(self): - """Instance depends on the API version: - - * 2022-09-04: :class:`CloudServiceOperatingSystemsOperations` - * 2024-11-04: :class:`CloudServiceOperatingSystemsOperations` - """ - api_version = self._get_api_version('cloud_service_operating_systems') - if api_version == '2022-09-04': - from ..v2022_09_04.aio.operations import CloudServiceOperatingSystemsOperations as OperationClass - elif api_version == '2024-11-04': - from ..v2024_11_04.aio.operations import CloudServiceOperatingSystemsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'cloud_service_operating_systems'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def cloud_service_role_instances(self): - """Instance depends on the API version: - - * 2022-09-04: :class:`CloudServiceRoleInstancesOperations` - * 2024-11-04: :class:`CloudServiceRoleInstancesOperations` - """ - api_version = self._get_api_version('cloud_service_role_instances') - if api_version == '2022-09-04': - from ..v2022_09_04.aio.operations import CloudServiceRoleInstancesOperations as OperationClass - elif api_version == '2024-11-04': - from ..v2024_11_04.aio.operations import CloudServiceRoleInstancesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'cloud_service_role_instances'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def cloud_service_roles(self): - """Instance depends on the API version: - - * 2022-09-04: :class:`CloudServiceRolesOperations` - * 2024-11-04: :class:`CloudServiceRolesOperations` - """ - api_version = self._get_api_version('cloud_service_roles') - if api_version == '2022-09-04': - from ..v2022_09_04.aio.operations import CloudServiceRolesOperations as OperationClass - elif api_version == '2024-11-04': - from ..v2024_11_04.aio.operations import CloudServiceRolesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'cloud_service_roles'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def cloud_services(self): - """Instance depends on the API version: - - * 2022-09-04: :class:`CloudServicesOperations` - * 2024-11-04: :class:`CloudServicesOperations` - """ - api_version = self._get_api_version('cloud_services') - if api_version == '2022-09-04': - from ..v2022_09_04.aio.operations import CloudServicesOperations as OperationClass - elif api_version == '2024-11-04': - from ..v2024_11_04.aio.operations import CloudServicesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'cloud_services'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def cloud_services_update_domain(self): - """Instance depends on the API version: - - * 2022-09-04: :class:`CloudServicesUpdateDomainOperations` - * 2024-11-04: :class:`CloudServicesUpdateDomainOperations` - """ - api_version = self._get_api_version('cloud_services_update_domain') - if api_version == '2022-09-04': - from ..v2022_09_04.aio.operations import CloudServicesUpdateDomainOperations as OperationClass - elif api_version == '2024-11-04': - from ..v2024_11_04.aio.operations import CloudServicesUpdateDomainOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'cloud_services_update_domain'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def community_galleries(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`CommunityGalleriesOperations` - * 2022-01-03: :class:`CommunityGalleriesOperations` - * 2023-07-03: :class:`CommunityGalleriesOperations` - """ - api_version = self._get_api_version('community_galleries') - if api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import CommunityGalleriesOperations as OperationClass - elif api_version == '2022-01-03': - from ..v2022_01_03.aio.operations import CommunityGalleriesOperations as OperationClass - elif api_version == '2023-07-03': - from ..v2023_07_03.aio.operations import CommunityGalleriesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'community_galleries'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def community_gallery_image_versions(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`CommunityGalleryImageVersionsOperations` - * 2022-01-03: :class:`CommunityGalleryImageVersionsOperations` - * 2023-07-03: :class:`CommunityGalleryImageVersionsOperations` - """ - api_version = self._get_api_version('community_gallery_image_versions') - if api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import CommunityGalleryImageVersionsOperations as OperationClass - elif api_version == '2022-01-03': - from ..v2022_01_03.aio.operations import CommunityGalleryImageVersionsOperations as OperationClass - elif api_version == '2023-07-03': - from ..v2023_07_03.aio.operations import CommunityGalleryImageVersionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'community_gallery_image_versions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def community_gallery_images(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`CommunityGalleryImagesOperations` - * 2022-01-03: :class:`CommunityGalleryImagesOperations` - * 2023-07-03: :class:`CommunityGalleryImagesOperations` - """ - api_version = self._get_api_version('community_gallery_images') - if api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import CommunityGalleryImagesOperations as OperationClass - elif api_version == '2022-01-03': - from ..v2022_01_03.aio.operations import CommunityGalleryImagesOperations as OperationClass - elif api_version == '2023-07-03': - from ..v2023_07_03.aio.operations import CommunityGalleryImagesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'community_gallery_images'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def dedicated_host_groups(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`DedicatedHostGroupsOperations` - * 2019-12-01: :class:`DedicatedHostGroupsOperations` - * 2020-06-01: :class:`DedicatedHostGroupsOperations` - * 2021-07-01: :class:`DedicatedHostGroupsOperations` - * 2024-11-01: :class:`DedicatedHostGroupsOperations` - """ - api_version = self._get_api_version('dedicated_host_groups') - if api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import DedicatedHostGroupsOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import DedicatedHostGroupsOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import DedicatedHostGroupsOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import DedicatedHostGroupsOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import DedicatedHostGroupsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'dedicated_host_groups'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def dedicated_hosts(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`DedicatedHostsOperations` - * 2019-12-01: :class:`DedicatedHostsOperations` - * 2020-06-01: :class:`DedicatedHostsOperations` - * 2021-07-01: :class:`DedicatedHostsOperations` - * 2024-11-01: :class:`DedicatedHostsOperations` - """ - api_version = self._get_api_version('dedicated_hosts') - if api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import DedicatedHostsOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import DedicatedHostsOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import DedicatedHostsOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import DedicatedHostsOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import DedicatedHostsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'dedicated_hosts'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def disk_accesses(self): - """Instance depends on the API version: - - * 2020-05-01: :class:`DiskAccessesOperations` - * 2022-03-02: :class:`DiskAccessesOperations` - * 2023-04-02: :class:`DiskAccessesOperations` - * 2023-10-02: :class:`DiskAccessesOperations` - * 2025-01-02: :class:`DiskAccessesOperations` - """ - api_version = self._get_api_version('disk_accesses') - if api_version == '2020-05-01': - from ..v2020_05_01.aio.operations import DiskAccessesOperations as OperationClass - elif api_version == '2022-03-02': - from ..v2022_03_02.aio.operations import DiskAccessesOperations as OperationClass - elif api_version == '2023-04-02': - from ..v2023_04_02.aio.operations import DiskAccessesOperations as OperationClass - elif api_version == '2023-10-02': - from ..v2023_10_02.aio.operations import DiskAccessesOperations as OperationClass - elif api_version == '2025-01-02': - from ..v2025_01_02.aio.operations import DiskAccessesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'disk_accesses'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def disk_encryption_sets(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`DiskEncryptionSetsOperations` - * 2020-05-01: :class:`DiskEncryptionSetsOperations` - * 2022-03-02: :class:`DiskEncryptionSetsOperations` - * 2023-04-02: :class:`DiskEncryptionSetsOperations` - * 2023-10-02: :class:`DiskEncryptionSetsOperations` - * 2025-01-02: :class:`DiskEncryptionSetsOperations` - """ - api_version = self._get_api_version('disk_encryption_sets') - if api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import DiskEncryptionSetsOperations as OperationClass - elif api_version == '2020-05-01': - from ..v2020_05_01.aio.operations import DiskEncryptionSetsOperations as OperationClass - elif api_version == '2022-03-02': - from ..v2022_03_02.aio.operations import DiskEncryptionSetsOperations as OperationClass - elif api_version == '2023-04-02': - from ..v2023_04_02.aio.operations import DiskEncryptionSetsOperations as OperationClass - elif api_version == '2023-10-02': - from ..v2023_10_02.aio.operations import DiskEncryptionSetsOperations as OperationClass - elif api_version == '2025-01-02': - from ..v2025_01_02.aio.operations import DiskEncryptionSetsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'disk_encryption_sets'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def disk_restore_point(self): - """Instance depends on the API version: - - * 2022-03-02: :class:`DiskRestorePointOperations` - * 2023-04-02: :class:`DiskRestorePointOperations` - * 2023-10-02: :class:`DiskRestorePointOperations` - * 2025-01-02: :class:`DiskRestorePointOperations` - """ - api_version = self._get_api_version('disk_restore_point') - if api_version == '2022-03-02': - from ..v2022_03_02.aio.operations import DiskRestorePointOperations as OperationClass - elif api_version == '2023-04-02': - from ..v2023_04_02.aio.operations import DiskRestorePointOperations as OperationClass - elif api_version == '2023-10-02': - from ..v2023_10_02.aio.operations import DiskRestorePointOperations as OperationClass - elif api_version == '2025-01-02': - from ..v2025_01_02.aio.operations import DiskRestorePointOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'disk_restore_point'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def disks(self): - """Instance depends on the API version: - - * 2017-03-30: :class:`DisksOperations` - * 2019-07-01: :class:`DisksOperations` - * 2020-05-01: :class:`DisksOperations` - * 2022-03-02: :class:`DisksOperations` - * 2023-04-02: :class:`DisksOperations` - * 2023-10-02: :class:`DisksOperations` - * 2025-01-02: :class:`DisksOperations` - """ - api_version = self._get_api_version('disks') - if api_version == '2017-03-30': - from ..v2017_03_30.aio.operations import DisksOperations as OperationClass - elif api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import DisksOperations as OperationClass - elif api_version == '2020-05-01': - from ..v2020_05_01.aio.operations import DisksOperations as OperationClass - elif api_version == '2022-03-02': - from ..v2022_03_02.aio.operations import DisksOperations as OperationClass - elif api_version == '2023-04-02': - from ..v2023_04_02.aio.operations import DisksOperations as OperationClass - elif api_version == '2023-10-02': - from ..v2023_10_02.aio.operations import DisksOperations as OperationClass - elif api_version == '2025-01-02': - from ..v2025_01_02.aio.operations import DisksOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'disks'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def galleries(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`GalleriesOperations` - * 2019-12-01: :class:`GalleriesOperations` - * 2021-07-01: :class:`GalleriesOperations` - * 2021-10-01: :class:`GalleriesOperations` - * 2022-01-03: :class:`GalleriesOperations` - * 2023-07-03: :class:`GalleriesOperations` - """ - api_version = self._get_api_version('galleries') - if api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import GalleriesOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import GalleriesOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import GalleriesOperations as OperationClass - elif api_version == '2021-10-01': - from ..v2021_10_01.aio.operations import GalleriesOperations as OperationClass - elif api_version == '2022-01-03': - from ..v2022_01_03.aio.operations import GalleriesOperations as OperationClass - elif api_version == '2023-07-03': - from ..v2023_07_03.aio.operations import GalleriesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'galleries'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def gallery_application_versions(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`GalleryApplicationVersionsOperations` - * 2019-12-01: :class:`GalleryApplicationVersionsOperations` - * 2021-07-01: :class:`GalleryApplicationVersionsOperations` - * 2021-10-01: :class:`GalleryApplicationVersionsOperations` - * 2022-01-03: :class:`GalleryApplicationVersionsOperations` - * 2023-07-03: :class:`GalleryApplicationVersionsOperations` - """ - api_version = self._get_api_version('gallery_application_versions') - if api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import GalleryApplicationVersionsOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import GalleryApplicationVersionsOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import GalleryApplicationVersionsOperations as OperationClass - elif api_version == '2021-10-01': - from ..v2021_10_01.aio.operations import GalleryApplicationVersionsOperations as OperationClass - elif api_version == '2022-01-03': - from ..v2022_01_03.aio.operations import GalleryApplicationVersionsOperations as OperationClass - elif api_version == '2023-07-03': - from ..v2023_07_03.aio.operations import GalleryApplicationVersionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'gallery_application_versions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def gallery_applications(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`GalleryApplicationsOperations` - * 2019-12-01: :class:`GalleryApplicationsOperations` - * 2021-07-01: :class:`GalleryApplicationsOperations` - * 2021-10-01: :class:`GalleryApplicationsOperations` - * 2022-01-03: :class:`GalleryApplicationsOperations` - * 2023-07-03: :class:`GalleryApplicationsOperations` - """ - api_version = self._get_api_version('gallery_applications') - if api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import GalleryApplicationsOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import GalleryApplicationsOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import GalleryApplicationsOperations as OperationClass - elif api_version == '2021-10-01': - from ..v2021_10_01.aio.operations import GalleryApplicationsOperations as OperationClass - elif api_version == '2022-01-03': - from ..v2022_01_03.aio.operations import GalleryApplicationsOperations as OperationClass - elif api_version == '2023-07-03': - from ..v2023_07_03.aio.operations import GalleryApplicationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'gallery_applications'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def gallery_image_versions(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`GalleryImageVersionsOperations` - * 2019-12-01: :class:`GalleryImageVersionsOperations` - * 2021-07-01: :class:`GalleryImageVersionsOperations` - * 2021-10-01: :class:`GalleryImageVersionsOperations` - * 2022-01-03: :class:`GalleryImageVersionsOperations` - * 2023-07-03: :class:`GalleryImageVersionsOperations` - """ - api_version = self._get_api_version('gallery_image_versions') - if api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import GalleryImageVersionsOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import GalleryImageVersionsOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import GalleryImageVersionsOperations as OperationClass - elif api_version == '2021-10-01': - from ..v2021_10_01.aio.operations import GalleryImageVersionsOperations as OperationClass - elif api_version == '2022-01-03': - from ..v2022_01_03.aio.operations import GalleryImageVersionsOperations as OperationClass - elif api_version == '2023-07-03': - from ..v2023_07_03.aio.operations import GalleryImageVersionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'gallery_image_versions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def gallery_images(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`GalleryImagesOperations` - * 2019-12-01: :class:`GalleryImagesOperations` - * 2021-07-01: :class:`GalleryImagesOperations` - * 2021-10-01: :class:`GalleryImagesOperations` - * 2022-01-03: :class:`GalleryImagesOperations` - * 2023-07-03: :class:`GalleryImagesOperations` - """ - api_version = self._get_api_version('gallery_images') - if api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import GalleryImagesOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import GalleryImagesOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import GalleryImagesOperations as OperationClass - elif api_version == '2021-10-01': - from ..v2021_10_01.aio.operations import GalleryImagesOperations as OperationClass - elif api_version == '2022-01-03': - from ..v2022_01_03.aio.operations import GalleryImagesOperations as OperationClass - elif api_version == '2023-07-03': - from ..v2023_07_03.aio.operations import GalleryImagesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'gallery_images'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def gallery_sharing_profile(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`GallerySharingProfileOperations` - * 2021-10-01: :class:`GallerySharingProfileOperations` - * 2022-01-03: :class:`GallerySharingProfileOperations` - * 2023-07-03: :class:`GallerySharingProfileOperations` - """ - api_version = self._get_api_version('gallery_sharing_profile') - if api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import GallerySharingProfileOperations as OperationClass - elif api_version == '2021-10-01': - from ..v2021_10_01.aio.operations import GallerySharingProfileOperations as OperationClass - elif api_version == '2022-01-03': - from ..v2022_01_03.aio.operations import GallerySharingProfileOperations as OperationClass - elif api_version == '2023-07-03': - from ..v2023_07_03.aio.operations import GallerySharingProfileOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'gallery_sharing_profile'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def images(self): - """Instance depends on the API version: - - * 2017-03-30: :class:`ImagesOperations` - * 2017-12-01: :class:`ImagesOperations` - * 2019-07-01: :class:`ImagesOperations` - * 2019-12-01: :class:`ImagesOperations` - * 2020-06-01: :class:`ImagesOperations` - * 2021-07-01: :class:`ImagesOperations` - * 2024-11-01: :class:`ImagesOperations` - """ - api_version = self._get_api_version('images') - if api_version == '2017-03-30': - from ..v2017_03_30.aio.operations import ImagesOperations as OperationClass - elif api_version == '2017-12-01': - from ..v2017_12_01.aio.operations import ImagesOperations as OperationClass - elif api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import ImagesOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import ImagesOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import ImagesOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import ImagesOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import ImagesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'images'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def log_analytics(self): - """Instance depends on the API version: - - * 2017-12-01: :class:`LogAnalyticsOperations` - * 2019-07-01: :class:`LogAnalyticsOperations` - * 2019-12-01: :class:`LogAnalyticsOperations` - * 2020-06-01: :class:`LogAnalyticsOperations` - * 2021-07-01: :class:`LogAnalyticsOperations` - * 2024-11-01: :class:`LogAnalyticsOperations` - """ - api_version = self._get_api_version('log_analytics') - if api_version == '2017-12-01': - from ..v2017_12_01.aio.operations import LogAnalyticsOperations as OperationClass - elif api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import LogAnalyticsOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import LogAnalyticsOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import LogAnalyticsOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import LogAnalyticsOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import LogAnalyticsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'log_analytics'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def operations(self): - """Instance depends on the API version: - - * 2017-12-01: :class:`Operations` - * 2019-07-01: :class:`Operations` - * 2019-12-01: :class:`Operations` - * 2020-06-01: :class:`Operations` - * 2021-07-01: :class:`Operations` - * 2024-11-01: :class:`Operations` - """ - api_version = self._get_api_version('operations') - if api_version == '2017-12-01': - from ..v2017_12_01.aio.operations import Operations as OperationClass - elif api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import Operations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import Operations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import Operations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import Operations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import Operations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def proximity_placement_groups(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`ProximityPlacementGroupsOperations` - * 2019-12-01: :class:`ProximityPlacementGroupsOperations` - * 2020-06-01: :class:`ProximityPlacementGroupsOperations` - * 2021-07-01: :class:`ProximityPlacementGroupsOperations` - * 2024-11-01: :class:`ProximityPlacementGroupsOperations` - """ - api_version = self._get_api_version('proximity_placement_groups') - if api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import ProximityPlacementGroupsOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import ProximityPlacementGroupsOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import ProximityPlacementGroupsOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import ProximityPlacementGroupsOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import ProximityPlacementGroupsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'proximity_placement_groups'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def resource_skus(self): - """Instance depends on the API version: - - * 2017-03-30: :class:`ResourceSkusOperations` - * 2017-09-01: :class:`ResourceSkusOperations` - * 2019-04-01: :class:`ResourceSkusOperations` - * 2021-07-01: :class:`ResourceSkusOperations` - """ - api_version = self._get_api_version('resource_skus') - if api_version == '2017-03-30': - from ..v2017_03_30.aio.operations import ResourceSkusOperations as OperationClass - elif api_version == '2017-09-01': - from ..v2017_09_01.aio.operations import ResourceSkusOperations as OperationClass - elif api_version == '2019-04-01': - from ..v2019_04_01.aio.operations import ResourceSkusOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import ResourceSkusOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'resource_skus'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def restore_point_collections(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`RestorePointCollectionsOperations` - * 2024-11-01: :class:`RestorePointCollectionsOperations` - """ - api_version = self._get_api_version('restore_point_collections') - if api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import RestorePointCollectionsOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import RestorePointCollectionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'restore_point_collections'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def restore_points(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`RestorePointsOperations` - * 2024-11-01: :class:`RestorePointsOperations` - """ - api_version = self._get_api_version('restore_points') - if api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import RestorePointsOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import RestorePointsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'restore_points'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def shared_galleries(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`SharedGalleriesOperations` - * 2022-01-03: :class:`SharedGalleriesOperations` - * 2023-07-03: :class:`SharedGalleriesOperations` - """ - api_version = self._get_api_version('shared_galleries') - if api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import SharedGalleriesOperations as OperationClass - elif api_version == '2022-01-03': - from ..v2022_01_03.aio.operations import SharedGalleriesOperations as OperationClass - elif api_version == '2023-07-03': - from ..v2023_07_03.aio.operations import SharedGalleriesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'shared_galleries'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def shared_gallery_image_versions(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`SharedGalleryImageVersionsOperations` - * 2022-01-03: :class:`SharedGalleryImageVersionsOperations` - * 2023-07-03: :class:`SharedGalleryImageVersionsOperations` - """ - api_version = self._get_api_version('shared_gallery_image_versions') - if api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import SharedGalleryImageVersionsOperations as OperationClass - elif api_version == '2022-01-03': - from ..v2022_01_03.aio.operations import SharedGalleryImageVersionsOperations as OperationClass - elif api_version == '2023-07-03': - from ..v2023_07_03.aio.operations import SharedGalleryImageVersionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'shared_gallery_image_versions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def shared_gallery_images(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`SharedGalleryImagesOperations` - * 2022-01-03: :class:`SharedGalleryImagesOperations` - * 2023-07-03: :class:`SharedGalleryImagesOperations` - """ - api_version = self._get_api_version('shared_gallery_images') - if api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import SharedGalleryImagesOperations as OperationClass - elif api_version == '2022-01-03': - from ..v2022_01_03.aio.operations import SharedGalleryImagesOperations as OperationClass - elif api_version == '2023-07-03': - from ..v2023_07_03.aio.operations import SharedGalleryImagesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'shared_gallery_images'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def snapshots(self): - """Instance depends on the API version: - - * 2017-03-30: :class:`SnapshotsOperations` - * 2019-07-01: :class:`SnapshotsOperations` - * 2020-05-01: :class:`SnapshotsOperations` - * 2022-03-02: :class:`SnapshotsOperations` - * 2023-04-02: :class:`SnapshotsOperations` - * 2023-10-02: :class:`SnapshotsOperations` - * 2025-01-02: :class:`SnapshotsOperations` - """ - api_version = self._get_api_version('snapshots') - if api_version == '2017-03-30': - from ..v2017_03_30.aio.operations import SnapshotsOperations as OperationClass - elif api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import SnapshotsOperations as OperationClass - elif api_version == '2020-05-01': - from ..v2020_05_01.aio.operations import SnapshotsOperations as OperationClass - elif api_version == '2022-03-02': - from ..v2022_03_02.aio.operations import SnapshotsOperations as OperationClass - elif api_version == '2023-04-02': - from ..v2023_04_02.aio.operations import SnapshotsOperations as OperationClass - elif api_version == '2023-10-02': - from ..v2023_10_02.aio.operations import SnapshotsOperations as OperationClass - elif api_version == '2025-01-02': - from ..v2025_01_02.aio.operations import SnapshotsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'snapshots'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def ssh_public_keys(self): - """Instance depends on the API version: - - * 2019-12-01: :class:`SshPublicKeysOperations` - * 2020-06-01: :class:`SshPublicKeysOperations` - * 2021-07-01: :class:`SshPublicKeysOperations` - * 2024-11-01: :class:`SshPublicKeysOperations` - """ - api_version = self._get_api_version('ssh_public_keys') - if api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import SshPublicKeysOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import SshPublicKeysOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import SshPublicKeysOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import SshPublicKeysOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'ssh_public_keys'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def usage(self): - """Instance depends on the API version: - - * 2016-03-30: :class:`UsageOperations` - * 2017-03-30: :class:`UsageOperations` - * 2017-12-01: :class:`UsageOperations` - * 2019-07-01: :class:`UsageOperations` - * 2019-12-01: :class:`UsageOperations` - * 2020-06-01: :class:`UsageOperations` - * 2021-07-01: :class:`UsageOperations` - * 2024-11-01: :class:`UsageOperations` - """ - api_version = self._get_api_version('usage') - if api_version == '2016-03-30': - from ..v2016_03_30.aio.operations import UsageOperations as OperationClass - elif api_version == '2017-03-30': - from ..v2017_03_30.aio.operations import UsageOperations as OperationClass - elif api_version == '2017-12-01': - from ..v2017_12_01.aio.operations import UsageOperations as OperationClass - elif api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import UsageOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import UsageOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import UsageOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import UsageOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import UsageOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'usage'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_extension_images(self): - """Instance depends on the API version: - - * 2016-03-30: :class:`VirtualMachineExtensionImagesOperations` - * 2017-03-30: :class:`VirtualMachineExtensionImagesOperations` - * 2017-12-01: :class:`VirtualMachineExtensionImagesOperations` - * 2019-07-01: :class:`VirtualMachineExtensionImagesOperations` - * 2019-12-01: :class:`VirtualMachineExtensionImagesOperations` - * 2020-06-01: :class:`VirtualMachineExtensionImagesOperations` - * 2021-07-01: :class:`VirtualMachineExtensionImagesOperations` - * 2024-11-01: :class:`VirtualMachineExtensionImagesOperations` - """ - api_version = self._get_api_version('virtual_machine_extension_images') - if api_version == '2016-03-30': - from ..v2016_03_30.aio.operations import VirtualMachineExtensionImagesOperations as OperationClass - elif api_version == '2017-03-30': - from ..v2017_03_30.aio.operations import VirtualMachineExtensionImagesOperations as OperationClass - elif api_version == '2017-12-01': - from ..v2017_12_01.aio.operations import VirtualMachineExtensionImagesOperations as OperationClass - elif api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import VirtualMachineExtensionImagesOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import VirtualMachineExtensionImagesOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import VirtualMachineExtensionImagesOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import VirtualMachineExtensionImagesOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import VirtualMachineExtensionImagesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_extension_images'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_extensions(self): - """Instance depends on the API version: - - * 2016-03-30: :class:`VirtualMachineExtensionsOperations` - * 2017-03-30: :class:`VirtualMachineExtensionsOperations` - * 2017-12-01: :class:`VirtualMachineExtensionsOperations` - * 2019-07-01: :class:`VirtualMachineExtensionsOperations` - * 2019-12-01: :class:`VirtualMachineExtensionsOperations` - * 2020-06-01: :class:`VirtualMachineExtensionsOperations` - * 2021-07-01: :class:`VirtualMachineExtensionsOperations` - * 2024-11-01: :class:`VirtualMachineExtensionsOperations` - """ - api_version = self._get_api_version('virtual_machine_extensions') - if api_version == '2016-03-30': - from ..v2016_03_30.aio.operations import VirtualMachineExtensionsOperations as OperationClass - elif api_version == '2017-03-30': - from ..v2017_03_30.aio.operations import VirtualMachineExtensionsOperations as OperationClass - elif api_version == '2017-12-01': - from ..v2017_12_01.aio.operations import VirtualMachineExtensionsOperations as OperationClass - elif api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import VirtualMachineExtensionsOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import VirtualMachineExtensionsOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import VirtualMachineExtensionsOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import VirtualMachineExtensionsOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import VirtualMachineExtensionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_extensions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_images(self): - """Instance depends on the API version: - - * 2016-03-30: :class:`VirtualMachineImagesOperations` - * 2017-03-30: :class:`VirtualMachineImagesOperations` - * 2017-12-01: :class:`VirtualMachineImagesOperations` - * 2019-07-01: :class:`VirtualMachineImagesOperations` - * 2019-12-01: :class:`VirtualMachineImagesOperations` - * 2020-06-01: :class:`VirtualMachineImagesOperations` - * 2021-07-01: :class:`VirtualMachineImagesOperations` - * 2024-11-01: :class:`VirtualMachineImagesOperations` - """ - api_version = self._get_api_version('virtual_machine_images') - if api_version == '2016-03-30': - from ..v2016_03_30.aio.operations import VirtualMachineImagesOperations as OperationClass - elif api_version == '2017-03-30': - from ..v2017_03_30.aio.operations import VirtualMachineImagesOperations as OperationClass - elif api_version == '2017-12-01': - from ..v2017_12_01.aio.operations import VirtualMachineImagesOperations as OperationClass - elif api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import VirtualMachineImagesOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import VirtualMachineImagesOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import VirtualMachineImagesOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import VirtualMachineImagesOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import VirtualMachineImagesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_images'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_images_edge_zone(self): - """Instance depends on the API version: - - * 2021-07-01: :class:`VirtualMachineImagesEdgeZoneOperations` - * 2024-11-01: :class:`VirtualMachineImagesEdgeZoneOperations` - """ - api_version = self._get_api_version('virtual_machine_images_edge_zone') - if api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import VirtualMachineImagesEdgeZoneOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import VirtualMachineImagesEdgeZoneOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_images_edge_zone'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_run_commands(self): - """Instance depends on the API version: - - * 2017-03-30: :class:`VirtualMachineRunCommandsOperations` - * 2017-12-01: :class:`VirtualMachineRunCommandsOperations` - * 2019-07-01: :class:`VirtualMachineRunCommandsOperations` - * 2019-12-01: :class:`VirtualMachineRunCommandsOperations` - * 2020-06-01: :class:`VirtualMachineRunCommandsOperations` - * 2021-07-01: :class:`VirtualMachineRunCommandsOperations` - * 2024-11-01: :class:`VirtualMachineRunCommandsOperations` - """ - api_version = self._get_api_version('virtual_machine_run_commands') - if api_version == '2017-03-30': - from ..v2017_03_30.aio.operations import VirtualMachineRunCommandsOperations as OperationClass - elif api_version == '2017-12-01': - from ..v2017_12_01.aio.operations import VirtualMachineRunCommandsOperations as OperationClass - elif api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import VirtualMachineRunCommandsOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import VirtualMachineRunCommandsOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import VirtualMachineRunCommandsOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import VirtualMachineRunCommandsOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import VirtualMachineRunCommandsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_run_commands'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_scale_set_extensions(self): - """Instance depends on the API version: - - * 2017-03-30: :class:`VirtualMachineScaleSetExtensionsOperations` - * 2017-12-01: :class:`VirtualMachineScaleSetExtensionsOperations` - * 2019-07-01: :class:`VirtualMachineScaleSetExtensionsOperations` - * 2019-12-01: :class:`VirtualMachineScaleSetExtensionsOperations` - * 2020-06-01: :class:`VirtualMachineScaleSetExtensionsOperations` - * 2021-07-01: :class:`VirtualMachineScaleSetExtensionsOperations` - * 2024-11-01: :class:`VirtualMachineScaleSetExtensionsOperations` - """ - api_version = self._get_api_version('virtual_machine_scale_set_extensions') - if api_version == '2017-03-30': - from ..v2017_03_30.aio.operations import VirtualMachineScaleSetExtensionsOperations as OperationClass - elif api_version == '2017-12-01': - from ..v2017_12_01.aio.operations import VirtualMachineScaleSetExtensionsOperations as OperationClass - elif api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import VirtualMachineScaleSetExtensionsOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import VirtualMachineScaleSetExtensionsOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import VirtualMachineScaleSetExtensionsOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import VirtualMachineScaleSetExtensionsOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import VirtualMachineScaleSetExtensionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_scale_set_extensions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_scale_set_rolling_upgrades(self): - """Instance depends on the API version: - - * 2017-03-30: :class:`VirtualMachineScaleSetRollingUpgradesOperations` - * 2017-12-01: :class:`VirtualMachineScaleSetRollingUpgradesOperations` - * 2019-07-01: :class:`VirtualMachineScaleSetRollingUpgradesOperations` - * 2019-12-01: :class:`VirtualMachineScaleSetRollingUpgradesOperations` - * 2020-06-01: :class:`VirtualMachineScaleSetRollingUpgradesOperations` - * 2021-07-01: :class:`VirtualMachineScaleSetRollingUpgradesOperations` - * 2024-11-01: :class:`VirtualMachineScaleSetRollingUpgradesOperations` - """ - api_version = self._get_api_version('virtual_machine_scale_set_rolling_upgrades') - if api_version == '2017-03-30': - from ..v2017_03_30.aio.operations import VirtualMachineScaleSetRollingUpgradesOperations as OperationClass - elif api_version == '2017-12-01': - from ..v2017_12_01.aio.operations import VirtualMachineScaleSetRollingUpgradesOperations as OperationClass - elif api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import VirtualMachineScaleSetRollingUpgradesOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import VirtualMachineScaleSetRollingUpgradesOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import VirtualMachineScaleSetRollingUpgradesOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import VirtualMachineScaleSetRollingUpgradesOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import VirtualMachineScaleSetRollingUpgradesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_scale_set_rolling_upgrades'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_scale_set_vm_extensions(self): - """Instance depends on the API version: - - * 2019-07-01: :class:`VirtualMachineScaleSetVMExtensionsOperations` - * 2019-12-01: :class:`VirtualMachineScaleSetVMExtensionsOperations` - * 2020-06-01: :class:`VirtualMachineScaleSetVMExtensionsOperations` - * 2021-07-01: :class:`VirtualMachineScaleSetVMExtensionsOperations` - * 2024-11-01: :class:`VirtualMachineScaleSetVMExtensionsOperations` - """ - api_version = self._get_api_version('virtual_machine_scale_set_vm_extensions') - if api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import VirtualMachineScaleSetVMExtensionsOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import VirtualMachineScaleSetVMExtensionsOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import VirtualMachineScaleSetVMExtensionsOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import VirtualMachineScaleSetVMExtensionsOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import VirtualMachineScaleSetVMExtensionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_scale_set_vm_extensions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_scale_set_vm_run_commands(self): - """Instance depends on the API version: - - * 2020-06-01: :class:`VirtualMachineScaleSetVMRunCommandsOperations` - * 2021-07-01: :class:`VirtualMachineScaleSetVMRunCommandsOperations` - * 2024-11-01: :class:`VirtualMachineScaleSetVMRunCommandsOperations` - """ - api_version = self._get_api_version('virtual_machine_scale_set_vm_run_commands') - if api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import VirtualMachineScaleSetVMRunCommandsOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import VirtualMachineScaleSetVMRunCommandsOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import VirtualMachineScaleSetVMRunCommandsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_scale_set_vm_run_commands'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machine_scale_set_vms(self): - """Instance depends on the API version: - - * 2016-03-30: :class:`VirtualMachineScaleSetVMsOperations` - * 2017-03-30: :class:`VirtualMachineScaleSetVMsOperations` - * 2017-12-01: :class:`VirtualMachineScaleSetVMsOperations` - * 2019-07-01: :class:`VirtualMachineScaleSetVMsOperations` - * 2019-12-01: :class:`VirtualMachineScaleSetVMsOperations` - * 2020-06-01: :class:`VirtualMachineScaleSetVMsOperations` - * 2021-07-01: :class:`VirtualMachineScaleSetVMsOperations` - * 2024-11-01: :class:`VirtualMachineScaleSetVMsOperations` - """ - api_version = self._get_api_version('virtual_machine_scale_set_vms') - if api_version == '2016-03-30': - from ..v2016_03_30.aio.operations import VirtualMachineScaleSetVMsOperations as OperationClass - elif api_version == '2017-03-30': - from ..v2017_03_30.aio.operations import VirtualMachineScaleSetVMsOperations as OperationClass - elif api_version == '2017-12-01': - from ..v2017_12_01.aio.operations import VirtualMachineScaleSetVMsOperations as OperationClass - elif api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import VirtualMachineScaleSetVMsOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import VirtualMachineScaleSetVMsOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import VirtualMachineScaleSetVMsOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import VirtualMachineScaleSetVMsOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import VirtualMachineScaleSetVMsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_scale_set_vms'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.capacity_reservation_groups = CapacityReservationGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_point_collections = RestorePointCollectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ssh_public_keys = SshPublicKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.capacity_reservations = CapacityReservationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) + self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_service_role_instances = CloudServiceRoleInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_service_roles = CloudServiceRolesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_services = CloudServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.cloud_services_update_domain = CloudServicesUpdateDomainOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_service_operating_systems = CloudServiceOperatingSystemsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) + self.disk_accesses = DiskAccessesOperations(self._client, self._config, self._serialize, self._deserialize) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_restore_point = DiskRestorePointOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_skus = ResourceSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.galleries = GalleriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.gallery_image_versions = GalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_applications = GalleryApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_application_versions = GalleryApplicationVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_sharing_profile = GallerySharingProfileOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_galleries = SharedGalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_gallery_images = SharedGalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.community_galleries = CommunityGalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.community_gallery_images = CommunityGalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - @property - def virtual_machine_scale_sets(self): - """Instance depends on the API version: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. - * 2016-03-30: :class:`VirtualMachineScaleSetsOperations` - * 2017-03-30: :class:`VirtualMachineScaleSetsOperations` - * 2017-12-01: :class:`VirtualMachineScaleSetsOperations` - * 2019-07-01: :class:`VirtualMachineScaleSetsOperations` - * 2019-12-01: :class:`VirtualMachineScaleSetsOperations` - * 2020-06-01: :class:`VirtualMachineScaleSetsOperations` - * 2021-07-01: :class:`VirtualMachineScaleSetsOperations` - * 2024-11-01: :class:`VirtualMachineScaleSetsOperations` - """ - api_version = self._get_api_version('virtual_machine_scale_sets') - if api_version == '2016-03-30': - from ..v2016_03_30.aio.operations import VirtualMachineScaleSetsOperations as OperationClass - elif api_version == '2017-03-30': - from ..v2017_03_30.aio.operations import VirtualMachineScaleSetsOperations as OperationClass - elif api_version == '2017-12-01': - from ..v2017_12_01.aio.operations import VirtualMachineScaleSetsOperations as OperationClass - elif api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import VirtualMachineScaleSetsOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import VirtualMachineScaleSetsOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import VirtualMachineScaleSetsOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import VirtualMachineScaleSetsOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import VirtualMachineScaleSetsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_scale_sets'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + - @property - def virtual_machine_sizes(self): - """Instance depends on the API version: + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - * 2016-03-30: :class:`VirtualMachineSizesOperations` - * 2017-03-30: :class:`VirtualMachineSizesOperations` - * 2017-12-01: :class:`VirtualMachineSizesOperations` - * 2019-07-01: :class:`VirtualMachineSizesOperations` - * 2019-12-01: :class:`VirtualMachineSizesOperations` - * 2020-06-01: :class:`VirtualMachineSizesOperations` - * 2021-07-01: :class:`VirtualMachineSizesOperations` - * 2024-11-01: :class:`VirtualMachineSizesOperations` + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse """ - api_version = self._get_api_version('virtual_machine_sizes') - if api_version == '2016-03-30': - from ..v2016_03_30.aio.operations import VirtualMachineSizesOperations as OperationClass - elif api_version == '2017-03-30': - from ..v2017_03_30.aio.operations import VirtualMachineSizesOperations as OperationClass - elif api_version == '2017-12-01': - from ..v2017_12_01.aio.operations import VirtualMachineSizesOperations as OperationClass - elif api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import VirtualMachineSizesOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import VirtualMachineSizesOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import VirtualMachineSizesOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import VirtualMachineSizesOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import VirtualMachineSizesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machine_sizes'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def virtual_machines(self): - """Instance depends on the API version: - * 2016-03-30: :class:`VirtualMachinesOperations` - * 2017-03-30: :class:`VirtualMachinesOperations` - * 2017-12-01: :class:`VirtualMachinesOperations` - * 2019-07-01: :class:`VirtualMachinesOperations` - * 2019-12-01: :class:`VirtualMachinesOperations` - * 2020-06-01: :class:`VirtualMachinesOperations` - * 2021-07-01: :class:`VirtualMachinesOperations` - * 2024-11-01: :class:`VirtualMachinesOperations` - """ - api_version = self._get_api_version('virtual_machines') - if api_version == '2016-03-30': - from ..v2016_03_30.aio.operations import VirtualMachinesOperations as OperationClass - elif api_version == '2017-03-30': - from ..v2017_03_30.aio.operations import VirtualMachinesOperations as OperationClass - elif api_version == '2017-12-01': - from ..v2017_12_01.aio.operations import VirtualMachinesOperations as OperationClass - elif api_version == '2019-07-01': - from ..v2019_07_01.aio.operations import VirtualMachinesOperations as OperationClass - elif api_version == '2019-12-01': - from ..v2019_12_01.aio.operations import VirtualMachinesOperations as OperationClass - elif api_version == '2020-06-01': - from ..v2020_06_01.aio.operations import VirtualMachinesOperations as OperationClass - elif api_version == '2021-07-01': - from ..v2021_07_01.aio.operations import VirtualMachinesOperations as OperationClass - elif api_version == '2024-11-01': - from ..v2024_11_01.aio.operations import VirtualMachinesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'virtual_machines'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - async def close(self): + async def close(self) -> None: await self._client.close() - async def __aenter__(self): + + async def __aenter__(self) -> Self: await self._client.__aenter__() return self - async def __aexit__(self, *exc_details): + + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/_configuration.py index ed6ec6d03cc9..da664d6f6056 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/_configuration.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/_configuration.py @@ -1,13 +1,11 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- + from typing import Any, TYPE_CHECKING from azure.core.pipeline import policies @@ -16,10 +14,10 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ComputeManagementClientConfiguration: + +class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for ComputeManagementClient. Note that all parameters used to create this instance are saved as instance @@ -31,12 +29,7 @@ class ComputeManagementClientConfiguration: :type subscription_id: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -44,23 +37,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'azure-mgmt-compute/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/_patch.py similarity index 100% rename from sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/aio/_patch.py rename to sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/_patch.py diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/__init__.py new file mode 100644 index 000000000000..6e78d6482cd3 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/__init__.py @@ -0,0 +1,122 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import Operations # type: ignore +from ._availability_sets_operations import AvailabilitySetsOperations # type: ignore +from ._capacity_reservation_groups_operations import CapacityReservationGroupsOperations # type: ignore +from ._dedicated_host_groups_operations import DedicatedHostGroupsOperations # type: ignore +from ._images_operations import ImagesOperations # type: ignore +from ._virtual_machine_images_edge_zone_operations import VirtualMachineImagesEdgeZoneOperations # type: ignore +from ._virtual_machine_images_operations import VirtualMachineImagesOperations # type: ignore +from ._log_analytics_operations import LogAnalyticsOperations # type: ignore +from ._virtual_machine_extension_images_operations import VirtualMachineExtensionImagesOperations # type: ignore +from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations # type: ignore +from ._usage_operations import UsageOperations # type: ignore +from ._virtual_machine_scale_sets_operations import VirtualMachineScaleSetsOperations # type: ignore +from ._virtual_machines_operations import VirtualMachinesOperations # type: ignore +from ._virtual_machine_sizes_operations import VirtualMachineSizesOperations # type: ignore +from ._proximity_placement_groups_operations import ProximityPlacementGroupsOperations # type: ignore +from ._restore_point_collections_operations import RestorePointCollectionsOperations # type: ignore +from ._ssh_public_keys_operations import SshPublicKeysOperations # type: ignore +from ._capacity_reservations_operations import CapacityReservationsOperations # type: ignore +from ._dedicated_hosts_operations import DedicatedHostsOperations # type: ignore +from ._restore_points_operations import RestorePointsOperations # type: ignore +from ._virtual_machine_scale_set_rolling_upgrades_operations import VirtualMachineScaleSetRollingUpgradesOperations # type: ignore +from ._virtual_machine_scale_set_extensions_operations import VirtualMachineScaleSetExtensionsOperations # type: ignore +from ._virtual_machine_scale_set_vms_operations import VirtualMachineScaleSetVMsOperations # type: ignore +from ._virtual_machine_scale_set_vm_extensions_operations import VirtualMachineScaleSetVMExtensionsOperations # type: ignore +from ._virtual_machine_scale_set_vm_run_commands_operations import VirtualMachineScaleSetVMRunCommandsOperations # type: ignore +from ._virtual_machine_extensions_operations import VirtualMachineExtensionsOperations # type: ignore +from ._cloud_service_role_instances_operations import CloudServiceRoleInstancesOperations # type: ignore +from ._cloud_service_roles_operations import CloudServiceRolesOperations # type: ignore +from ._cloud_services_operations import CloudServicesOperations # type: ignore +from ._cloud_services_update_domain_operations import CloudServicesUpdateDomainOperations # type: ignore +from ._cloud_service_operating_systems_operations import CloudServiceOperatingSystemsOperations # type: ignore +from ._disks_operations import DisksOperations # type: ignore +from ._disk_accesses_operations import DiskAccessesOperations # type: ignore +from ._disk_encryption_sets_operations import DiskEncryptionSetsOperations # type: ignore +from ._disk_restore_point_operations import DiskRestorePointOperations # type: ignore +from ._snapshots_operations import SnapshotsOperations # type: ignore +from ._resource_skus_operations import ResourceSkusOperations # type: ignore +from ._galleries_operations import GalleriesOperations # type: ignore +from ._gallery_images_operations import GalleryImagesOperations # type: ignore +from ._gallery_image_versions_operations import GalleryImageVersionsOperations # type: ignore +from ._gallery_applications_operations import GalleryApplicationsOperations # type: ignore +from ._gallery_application_versions_operations import GalleryApplicationVersionsOperations # type: ignore +from ._gallery_sharing_profile_operations import GallerySharingProfileOperations # type: ignore +from ._shared_galleries_operations import SharedGalleriesOperations # type: ignore +from ._shared_gallery_images_operations import SharedGalleryImagesOperations # type: ignore +from ._shared_gallery_image_versions_operations import SharedGalleryImageVersionsOperations # type: ignore +from ._community_galleries_operations import CommunityGalleriesOperations # type: ignore +from ._community_gallery_images_operations import CommunityGalleryImagesOperations # type: ignore +from ._community_gallery_image_versions_operations import CommunityGalleryImageVersionsOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "Operations", + "AvailabilitySetsOperations", + "CapacityReservationGroupsOperations", + "DedicatedHostGroupsOperations", + "ImagesOperations", + "VirtualMachineImagesEdgeZoneOperations", + "VirtualMachineImagesOperations", + "LogAnalyticsOperations", + "VirtualMachineExtensionImagesOperations", + "VirtualMachineRunCommandsOperations", + "UsageOperations", + "VirtualMachineScaleSetsOperations", + "VirtualMachinesOperations", + "VirtualMachineSizesOperations", + "ProximityPlacementGroupsOperations", + "RestorePointCollectionsOperations", + "SshPublicKeysOperations", + "CapacityReservationsOperations", + "DedicatedHostsOperations", + "RestorePointsOperations", + "VirtualMachineScaleSetRollingUpgradesOperations", + "VirtualMachineScaleSetExtensionsOperations", + "VirtualMachineScaleSetVMsOperations", + "VirtualMachineScaleSetVMExtensionsOperations", + "VirtualMachineScaleSetVMRunCommandsOperations", + "VirtualMachineExtensionsOperations", + "CloudServiceRoleInstancesOperations", + "CloudServiceRolesOperations", + "CloudServicesOperations", + "CloudServicesUpdateDomainOperations", + "CloudServiceOperatingSystemsOperations", + "DisksOperations", + "DiskAccessesOperations", + "DiskEncryptionSetsOperations", + "DiskRestorePointOperations", + "SnapshotsOperations", + "ResourceSkusOperations", + "GalleriesOperations", + "GalleryImagesOperations", + "GalleryImageVersionsOperations", + "GalleryApplicationsOperations", + "GalleryApplicationVersionsOperations", + "GallerySharingProfileOperations", + "SharedGalleriesOperations", + "SharedGalleryImagesOperations", + "SharedGalleryImageVersionsOperations", + "CommunityGalleriesOperations", + "CommunityGalleryImagesOperations", + "CommunityGalleryImageVersionsOperations", +] +__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/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_availability_sets_operations.py new file mode 100644 index 000000000000..d683b9c4afe1 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_availability_sets_operations.py @@ -0,0 +1,1164 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._availability_sets_operations import ( + build_cancel_migration_to_virtual_machine_scale_set_request, + build_convert_to_virtual_machine_scale_set_request, + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_available_sizes_request, + build_list_by_subscription_request, + build_list_request, + build_start_migration_to_virtual_machine_scale_set_request, + build_update_request, + build_validate_migration_to_virtual_machine_scale_set_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription( + self, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.AvailabilitySet"]: + """Lists all availability sets in a subscription. + + :param expand: The expand expression to apply to the operation. Allowed values are + 'instanceView'. Default value is None. + :type 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.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", "2024-11-01")) + cls: ClsType[_models.AvailabilitySetListResult] = 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_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, 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(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.AvailabilitySet"]: + """Lists all availability sets 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 AvailabilitySet or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.AvailabilitySetListResult] = 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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, 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, 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.models.AvailabilitySet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) + + _request = build_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) + + _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("AvailabilitySet", 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, + availability_set_name: str, + parameters: _models.AvailabilitySet, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AvailabilitySet: + """Create or update an availability set. + + :param resource_group_name: The name of the resource group. 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.models.AvailabilitySet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.AvailabilitySet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + availability_set_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AvailabilitySet: + """Create or update an availability set. + + :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: IO[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.models.AvailabilitySet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + availability_set_name: str, + parameters: Union[_models.AvailabilitySet, IO[bytes]], + **kwargs: Any + ) -> _models.AvailabilitySet: + """Create or update an availability set. + + :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.models.AvailabilitySet or IO[bytes] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AvailabilitySet") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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("AvailabilitySet", 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, + availability_set_name: str, + parameters: _models.AvailabilitySetUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AvailabilitySet: + """Update 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 + :param parameters: Parameters supplied to the Update Availability Set operation. Required. + :type parameters: ~azure.mgmt.compute.models.AvailabilitySetUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.AvailabilitySet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + availability_set_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AvailabilitySet: + """Update an availability set. + + :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: IO[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.models.AvailabilitySet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + availability_set_name: str, + parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], + **kwargs: Any + ) -> _models.AvailabilitySet: + """Update 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 + :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.models.AvailabilitySetUpdate or IO[bytes] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AvailabilitySetUpdate") + + _request = build_update_request( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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("AvailabilitySet", 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. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :return: None or the result of cls(response) + :rtype: None + :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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def cancel_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, resource_group_name: str, availability_set_name: str, **kwargs: Any + ) -> None: + """Cancel the migration operation on an Availability Set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :return: None or the result of cls(response) + :rtype: None + :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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_cancel_migration_to_virtual_machine_scale_set_request( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 _convert_to_virtual_machine_scale_set_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: Optional[Union[_models.ConvertToVirtualMachineScaleSetInput, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "ConvertToVirtualMachineScaleSetInput") + else: + _json = None + + _request = build_convert_to_virtual_machine_scale_set_request( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: Optional[_models.ConvertToVirtualMachineScaleSetInput] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the + Availability Set. This does not trigger a downtime on the Virtual Machines. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Default value is None. + :type parameters: ~azure.mgmt.compute.models.ConvertToVirtualMachineScaleSetInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the + Availability Set. This does not trigger a downtime on the Virtual Machines. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Default value is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: Optional[Union[_models.ConvertToVirtualMachineScaleSetInput, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the + Availability Set. This does not trigger a downtime on the Virtual Machines. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. Is + either a ConvertToVirtualMachineScaleSetInput type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.models.ConvertToVirtualMachineScaleSetInput or IO[bytes] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._convert_to_virtual_machine_scale_set_initial( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, 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 + + @overload + async def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: _models.MigrateToVirtualMachineScaleSetInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual + Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that + triggers a downtime on the Virtual Machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Required. + :type parameters: ~azure.mgmt.compute.models.MigrateToVirtualMachineScaleSetInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual + Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that + triggers a downtime on the Virtual Machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: Union[_models.MigrateToVirtualMachineScaleSetInput, IO[bytes]], + **kwargs: Any + ) -> None: + """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual + Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that + triggers a downtime on the Virtual Machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. Is + either a MigrateToVirtualMachineScaleSetInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.models.MigrateToVirtualMachineScaleSetInput or IO[bytes] + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrateToVirtualMachineScaleSetInput") + + _request = build_start_migration_to_virtual_machine_scale_set_request( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 + + @overload + async def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: _models.MigrateToVirtualMachineScaleSetInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Validates that the Virtual Machines in the Availability Set can be migrated to the provided + Virtual Machine Scale Set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Required. + :type parameters: ~azure.mgmt.compute.models.MigrateToVirtualMachineScaleSetInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Validates that the Virtual Machines in the Availability Set can be migrated to the provided + Virtual Machine Scale Set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: Union[_models.MigrateToVirtualMachineScaleSetInput, IO[bytes]], + **kwargs: Any + ) -> None: + """Validates that the Virtual Machines in the Availability Set can be migrated to the provided + Virtual Machine Scale Set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. Is + either a MigrateToVirtualMachineScaleSetInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.models.MigrateToVirtualMachineScaleSetInput or IO[bytes] + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrateToVirtualMachineScaleSetInput") + + _request = build_validate_migration_to_virtual_machine_scale_set_request( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 + + @distributed_trace + def list_available_sizes( + self, resource_group_name: str, availability_set_name: str, **kwargs: Any + ) -> AsyncItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_capacity_reservation_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_capacity_reservation_groups_operations.py new file mode 100644 index 000000000000..e1f0105a2244 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_capacity_reservation_groups_operations.py @@ -0,0 +1,623 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._capacity_reservation_groups_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CapacityReservationGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`capacity_reservation_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + ) -> AsyncItemPaged["_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 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. + :type expand: str or ~azure.mgmt.compute.models.ExpandTypesForGetCapacityReservationGroups + :param 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. + :type resource_ids_only: str or + ~azure.mgmt.compute.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.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", "2024-11-01")) + cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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_resource_group( + self, + resource_group_name: str, + expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, + **kwargs: Any + ) -> AsyncItemPaged["_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 + :param 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. + :type expand: str or ~azure.mgmt.compute.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.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", "2024-11-01")) + cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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_async + async def get( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + expand: Optional[Union[str, _models.CapacityReservationGroupInstanceViewTypes]] = None, + **kwargs: Any + ) -> _models.CapacityReservationGroup: + """The operation that retrieves information about a capacity reservation group. + + :param resource_group_name: The name of the resource group. 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 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. + :type expand: str or ~azure.mgmt.compute.models.CapacityReservationGroupInstanceViewTypes + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.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 = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) + + _request = build_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) + + _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 + + @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. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param parameters: Parameters supplied to the Create capacity reservation Group. Required. + :type parameters: ~azure.mgmt.compute.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.models.CapacityReservationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CapacityReservationGroup: + """The operation to create or update a capacity reservation group. When updating a capacity + reservation group, only tags and sharing profile may be modified. Please refer to + https://aka.ms/CapacityReservation for more details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param parameters: Parameters supplied to the Create capacity reservation Group. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.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.models.CapacityReservationGroup or IO[bytes] + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CapacityReservationGroup") + + _request = build_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) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CapacityReservationGroup", 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, + 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. 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: ~azure.mgmt.compute.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.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.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.models.CapacityReservationGroupUpdate or IO[bytes] + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CapacityReservationGroupUpdate") + + _request = build_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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_capacity_reservations_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_capacity_reservations_operations.py new file mode 100644 index 000000000000..e10d5c7663a2 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_capacity_reservations_operations.py @@ -0,0 +1,762 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._capacity_reservations_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_capacity_reservation_group_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CapacityReservationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`capacity_reservations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_capacity_reservation_group( + self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CapacityReservation"]: + """Lists all of the capacity reservations in the specified capacity reservation group. Use the + nextLink property in the response to get the next page of capacity reservations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.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", "2024-11-01")) + cls: ClsType[_models.CapacityReservationListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_capacity_reservation_group_request( + resource_group_name=resource_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + 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) + + 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, + 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. 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 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. + :type expand: str or ~azure.mgmt.compute.models.CapacityReservationInstanceViewTypes + :return: CapacityReservation or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + + _request = build_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, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CapacityReservation") + + _request = build_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) + + _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, + 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. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Create capacity reservation. Required. + :type parameters: ~azure.mgmt.compute.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.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. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Create capacity reservation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.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. + + :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.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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + capacity_reservation_name=capacity_reservation_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.CapacityReservation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CapacityReservation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CapacityReservationUpdate") + + _request = build_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) + + _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_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: _models.CapacityReservationUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CapacityReservation]: + """The operation to update a capacity reservation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Update capacity reservation operation. Required. + :type parameters: ~azure.mgmt.compute.models.CapacityReservationUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.CapacityReservation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CapacityReservation]: + """The operation to update a capacity reservation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Update capacity reservation operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.CapacityReservation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.CapacityReservation]: + """The operation to update a capacity reservation. + + :param resource_group_name: The name of the resource group. 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.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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._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 _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, + 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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_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, + 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, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """The operation to delete a capacity reservation. This operation is allowed only when all the + associated resources are disassociated from the capacity reservation. Please refer to + https://aka.ms/CapacityReservation for more details. + + :param resource_group_name: The name of the resource group. 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 + :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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + 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) + + 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_cloud_service_operating_systems_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_cloud_service_operating_systems_operations.py new file mode 100644 index 000000000000..1047c917b5b4 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_cloud_service_operating_systems_operations.py @@ -0,0 +1,305 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._cloud_service_operating_systems_operations import ( + build_get_os_family_request, + build_get_os_version_request, + build_list_os_families_request, + build_list_os_versions_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CloudServiceOperatingSystemsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`cloud_service_operating_systems` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get_os_version(self, location: str, os_version_name: str, **kwargs: Any) -> _models.OSVersion: + """Gets properties of a guest operating system version that can be specified in the XML service + configuration (.cscfg) for a cloud service. + + :param location: Name of the location that the OS version pertains to. Required. + :type location: str + :param os_version_name: Name of the OS version. Required. + :type os_version_name: str + :return: OSVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.OSVersion + :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", "2024-11-04")) + cls: ClsType[_models.OSVersion] = kwargs.pop("cls", None) + + _request = build_get_os_version_request( + location=location, + os_version_name=os_version_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("OSVersion", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_os_versions(self, location: str, **kwargs: Any) -> AsyncItemPaged["_models.OSVersion"]: + """Gets a list of all guest operating system versions available to be specified in the XML service + configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the + next page of OS versions. Do this till nextLink is null to fetch all the OS versions. + + :param location: Name of the location that the OS versions pertain to. Required. + :type location: str + :return: An iterator like instance of either OSVersion or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.models.OSVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + cls: ClsType[_models.OSVersionListResult] = 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_list_os_versions_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OSVersionListResult", 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_os_family(self, location: str, os_family_name: str, **kwargs: Any) -> _models.OSFamily: + """Gets properties of a guest operating system family that can be specified in the XML service + configuration (.cscfg) for a cloud service. + + :param location: Name of the location that the OS family pertains to. Required. + :type location: str + :param os_family_name: Name of the OS family. Required. + :type os_family_name: str + :return: OSFamily or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.OSFamily + :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", "2024-11-04")) + cls: ClsType[_models.OSFamily] = kwargs.pop("cls", None) + + _request = build_get_os_family_request( + location=location, + os_family_name=os_family_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("OSFamily", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_os_families(self, location: str, **kwargs: Any) -> AsyncItemPaged["_models.OSFamily"]: + """Gets a list of all guest operating system families available to be specified in the XML service + configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the + next page of OS Families. Do this till nextLink is null to fetch all the OS Families. + + :param location: Name of the location that the OS families pertain to. Required. + :type location: str + :return: An iterator like instance of either OSFamily or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.models.OSFamily] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + cls: ClsType[_models.OSFamilyListResult] = 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_list_os_families_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OSFamilyListResult", 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/aio/operations/_cloud_service_role_instances_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_cloud_service_role_instances_operations.py new file mode 100644 index 000000000000..7bbb1f338cd2 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_cloud_service_role_instances_operations.py @@ -0,0 +1,777 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, AsyncIterator, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._cloud_service_role_instances_operations import ( + build_delete_request, + build_get_instance_view_request, + build_get_remote_desktop_file_request, + build_get_request, + build_list_request, + build_rebuild_request, + build_reimage_request, + build_restart_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CloudServiceRoleInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`cloud_service_role_instances` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _delete_initial( + self, role_instance_name: str, resource_group_name: str, cloud_service_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", "2024-11-04")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a role instance from a cloud service. + + :param role_instance_name: Name of the role instance. Required. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_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", "2024-11-04")) + 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( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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, + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any + ) -> _models.RoleInstance: + """Gets a role instance from a cloud service. + + :param role_instance_name: Name of the role instance. Required. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param expand: The expand expression to apply to the operation. 'UserData' is not supported for + cloud services. Known values are: "instanceView", "userData", and "resiliencyView". Default + value is None. + :type expand: str or ~azure.mgmt.compute.models.InstanceViewTypes + :return: RoleInstance or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.RoleInstance + :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", "2024-11-04")) + cls: ClsType[_models.RoleInstance] = kwargs.pop("cls", None) + + _request = build_get_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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("RoleInstance", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_instance_view( + self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> _models.RoleInstanceView: + """Retrieves information about the run-time state of a role instance in a cloud service. + + :param role_instance_name: Name of the role instance. Required. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :return: RoleInstanceView or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.RoleInstanceView + :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", "2024-11-04")) + cls: ClsType[_models.RoleInstanceView] = kwargs.pop("cls", None) + + _request = build_get_instance_view_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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("RoleInstanceView", 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, + cloud_service_name: str, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.RoleInstance"]: + """Gets the list of all role instances in a cloud service. Use nextLink property in the response + to get the next page of role instances. Do this till nextLink is null to fetch all the role + instances. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param expand: The expand expression to apply to the operation. 'UserData' is not supported for + cloud services. Known values are: "instanceView", "userData", and "resiliencyView". Default + value is None. + :type expand: str or ~azure.mgmt.compute.models.InstanceViewTypes + :return: An iterator like instance of either RoleInstance or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.models.RoleInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + cls: ClsType[_models.RoleInstanceListResult] = 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_list_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RoleInstanceListResult", 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 _restart_initial( + self, role_instance_name: str, resource_group_name: str, cloud_service_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", "2024-11-04")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_restart_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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 + + @distributed_trace_async + async def begin_restart( + self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """The Reboot Role Instance asynchronous operation requests a reboot of a role instance in the + cloud service. + + :param role_instance_name: Name of the role instance. Required. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_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", "2024-11-04")) + 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( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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 _reimage_initial( + self, role_instance_name: str, resource_group_name: str, cloud_service_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", "2024-11-04")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_reimage_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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 + + @distributed_trace_async + async def begin_reimage( + self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """The Reimage Role Instance asynchronous operation reinstalls the operating system on instances + of web roles or worker roles. + + :param role_instance_name: Name of the role instance. Required. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_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", "2024-11-04")) + 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( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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 _rebuild_initial( + self, role_instance_name: str, resource_group_name: str, cloud_service_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", "2024-11-04")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_rebuild_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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 + + @distributed_trace_async + async def begin_rebuild( + self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """The Rebuild Role Instance asynchronous operation reinstalls the operating system on instances + of web roles or worker roles and initializes the storage resources that are used by them. If + you do not want to initialize storage resources, you can use Reimage Role Instance. + + :param role_instance_name: Name of the role instance. Required. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_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", "2024-11-04")) + 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._rebuild_initial( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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_remote_desktop_file( + self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + """Gets a remote desktop file for a role instance in a cloud service. + + :param role_instance_name: Name of the role instance. Required. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :return: AsyncIterator[bytes] or the result of cls(response) + :rtype: AsyncIterator[bytes] + :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", "2024-11-04")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_get_remote_desktop_file_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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]: + 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_cloud_service_roles_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_cloud_service_roles_operations.py new file mode 100644 index 000000000000..aa45f6273d2b --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_cloud_service_roles_operations.py @@ -0,0 +1,185 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._cloud_service_roles_operations import build_get_request, build_list_request +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CloudServiceRolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`cloud_service_roles` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, role_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> _models.CloudServiceRole: + """Gets a role from a cloud service. + + :param role_name: Name of the role. Required. + :type role_name: str + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :return: CloudServiceRole or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.CloudServiceRole + :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", "2024-11-04")) + cls: ClsType[_models.CloudServiceRole] = kwargs.pop("cls", None) + + _request = build_get_request( + role_name=role_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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("CloudServiceRole", 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, cloud_service_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CloudServiceRole"]: + """Gets a list of all roles in a cloud service. Use nextLink property in the response to get the + next page of roles. Do this till nextLink is null to fetch all the roles. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :return: An iterator like instance of either CloudServiceRole or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.models.CloudServiceRole] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + cls: ClsType[_models.CloudServiceRoleListResult] = 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_list_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CloudServiceRoleListResult", 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/aio/operations/_cloud_services_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_cloud_services_operations.py new file mode 100644 index 000000000000..e8f36a746b89 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_cloud_services_operations.py @@ -0,0 +1,1766 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._cloud_services_operations import ( + build_create_or_update_request, + build_delete_instances_request, + build_delete_request, + build_get_instance_view_request, + build_get_request, + build_list_all_request, + build_list_request, + build_power_off_request, + build_rebuild_request, + build_reimage_request, + build_restart_request, + build_start_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CloudServicesOperations: # 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.aio.ComputeManagementClient`'s + :attr:`cloud_services` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_or_update_initial( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.CloudService, 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", "2024-11-04")) + 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, "CloudService") + else: + _json = None + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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) + + 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, + cloud_service_name: str, + parameters: Optional[_models.CloudService] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CloudService]: + """Create or update a cloud service. Please note some properties can be set only during cloud + service creation. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: The cloud service object. Default value is None. + :type parameters: ~azure.mgmt.compute.models.CloudService + :keyword content_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 CloudService or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.CloudService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CloudService]: + """Create or update a cloud service. Please note some properties can be set only during cloud + service creation. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: The cloud service object. 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 CloudService or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.CloudService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.CloudService, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.CloudService]: + """Create or update a cloud service. Please note some properties can be set only during cloud + service creation. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: The cloud service object. Is either a CloudService type or a IO[bytes] type. + Default value is None. + :type parameters: ~azure.mgmt.compute.models.CloudService or IO[bytes] + :return: An instance of AsyncLROPoller that returns either CloudService or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.CloudService] + :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", "2024-11-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CloudService] = 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, + cloud_service_name=cloud_service_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("CloudService", 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.CloudService].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CloudService]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.CloudServiceUpdate, 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", "2024-11-04")) + 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, "CloudServiceUpdate") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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, + cloud_service_name: str, + parameters: Optional[_models.CloudServiceUpdate] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CloudService]: + """Update a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: The cloud service object. Default value is None. + :type parameters: ~azure.mgmt.compute.models.CloudServiceUpdate + :keyword content_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 CloudService or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.CloudService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CloudService]: + """Update a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: The cloud service object. 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 CloudService or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.CloudService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.CloudServiceUpdate, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.CloudService]: + """Update a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: The cloud service object. Is either a CloudServiceUpdate type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.compute.models.CloudServiceUpdate or IO[bytes] + :return: An instance of AsyncLROPoller that returns either CloudService or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.CloudService] + :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", "2024-11-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CloudService] = 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, + cloud_service_name=cloud_service_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("CloudService", 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.CloudService].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CloudService]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, cloud_service_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", "2024-11-04")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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, cloud_service_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_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", "2024-11-04")) + 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, + cloud_service_name=cloud_service_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, cloud_service_name: str, **kwargs: Any) -> _models.CloudService: + """Display information about a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :return: CloudService or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.CloudService + :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", "2024-11-04")) + cls: ClsType[_models.CloudService] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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("CloudService", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_instance_view( + self, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> _models.CloudServiceInstanceView: + """Gets the status of a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :return: CloudServiceInstanceView or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.CloudServiceInstanceView + :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", "2024-11-04")) + cls: ClsType[_models.CloudServiceInstanceView] = kwargs.pop("cls", None) + + _request = build_get_instance_view_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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("CloudServiceInstanceView", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_all(self, **kwargs: Any) -> AsyncItemPaged["_models.CloudService"]: + """Gets a list of all cloud services in the subscription, regardless of the associated resource + group. Use nextLink property in the response to get the next page of Cloud Services. Do this + till nextLink is null to fetch all the Cloud Services. + + :return: An iterator like instance of either CloudService or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.models.CloudService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + cls: ClsType[_models.CloudServiceListResult] = 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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CloudServiceListResult", 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(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.CloudService"]: + """Gets a list of all cloud services under a resource group. Use nextLink property in the response + to get the next page of Cloud Services. Do this till nextLink is null to fetch all the Cloud + Services. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :return: An iterator like instance of either CloudService or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.models.CloudService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + cls: ClsType[_models.CloudServiceListResult] = 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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CloudServiceListResult", 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, cloud_service_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", "2024-11-04")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_start_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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 + + @distributed_trace_async + async def begin_start( + self, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Starts the cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_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", "2024-11-04")) + 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, + cloud_service_name=cloud_service_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 _power_off_initial( + self, resource_group_name: str, cloud_service_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", "2024-11-04")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_power_off_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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 + + @distributed_trace_async + async def begin_power_off( + self, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Power off the cloud service. Note that resources are still attached and you are getting charged + for the resources. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_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", "2024-11-04")) + 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, + cloud_service_name=cloud_service_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 _restart_initial( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.RoleInstances, 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", "2024-11-04")) + 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, "RoleInstances") + else: + _json = None + + _request = build_restart_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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_restart( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts one or more role instances in a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: ~azure.mgmt.compute.models.RoleInstances + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restart( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts one or more role instances in a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_restart( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts one or more role instances in a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Is either a RoleInstances type or + a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.models.RoleInstances 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", "2024-11-04")) + 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, + cloud_service_name=cloud_service_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 + + async def _reimage_initial( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.RoleInstances, 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", "2024-11-04")) + 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, "RoleInstances") + else: + _json = None + + _request = build_reimage_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_reimage( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Reimage asynchronous operation reinstalls the operating system on instances of web roles or + worker roles. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: ~azure.mgmt.compute.models.RoleInstances + :keyword content_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, + cloud_service_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Reimage asynchronous operation reinstalls the operating system on instances of web roles or + worker roles. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_reimage( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Reimage asynchronous operation reinstalls the operating system on instances of web roles or + worker roles. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Is either a RoleInstances type or + a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.models.RoleInstances 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", "2024-11-04")) + 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, + cloud_service_name=cloud_service_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 + + async def _rebuild_initial( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.RoleInstances, 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", "2024-11-04")) + 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, "RoleInstances") + else: + _json = None + + _request = build_rebuild_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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_rebuild( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker + roles and initializes the storage resources that are used by them. If you do not want to + initialize storage resources, you can use Reimage Role Instances. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: ~azure.mgmt.compute.models.RoleInstances + :keyword content_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_rebuild( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker + roles and initializes the storage resources that are used by them. If you do not want to + initialize storage resources, you can use Reimage Role Instances. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_rebuild( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker + roles and initializes the storage resources that are used by them. If you do not want to + initialize storage resources, you can use Reimage Role Instances. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Is either a RoleInstances type or + a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.models.RoleInstances 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", "2024-11-04")) + 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._rebuild_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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 + + async def _delete_instances_initial( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.RoleInstances, 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", "2024-11-04")) + 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, "RoleInstances") + else: + _json = None + + _request = build_delete_instances_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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_delete_instances( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes role instances in a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: ~azure.mgmt.compute.models.RoleInstances + :keyword content_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, + cloud_service_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes role instances in a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_delete_instances( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes role instances in a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Is either a RoleInstances type or + a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.models.RoleInstances 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", "2024-11-04")) + 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, + cloud_service_name=cloud_service_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_cloud_services_update_domain_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_cloud_services_update_domain_operations.py new file mode 100644 index 000000000000..009e5db7d473 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_cloud_services_update_domain_operations.py @@ -0,0 +1,400 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._cloud_services_update_domain_operations import ( + build_get_update_domain_request, + build_list_update_domains_request, + build_walk_update_domain_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CloudServicesUpdateDomainOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`cloud_services_update_domain` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _walk_update_domain_initial( + self, + resource_group_name: str, + cloud_service_name: str, + update_domain: int, + parameters: Optional[Union[_models.UpdateDomain, 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", "2024-11-04")) + 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, "UpdateDomain") + else: + _json = None + + _request = build_walk_update_domain_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + update_domain=update_domain, + 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_walk_update_domain( + self, + resource_group_name: str, + cloud_service_name: str, + update_domain: int, + parameters: Optional[_models.UpdateDomain] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the role instances in the specified update domain. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param update_domain: Specifies an integer value that identifies the update domain. Update + domains are identified with a zero-based index: the first update domain has an ID of 0, the + second has an ID of 1, and so on. Required. + :type update_domain: int + :param parameters: The update domain object. Default value is None. + :type parameters: ~azure.mgmt.compute.models.UpdateDomain + :keyword content_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_walk_update_domain( + self, + resource_group_name: str, + cloud_service_name: str, + update_domain: int, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the role instances in the specified update domain. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param update_domain: Specifies an integer value that identifies the update domain. Update + domains are identified with a zero-based index: the first update domain has an ID of 0, the + second has an ID of 1, and so on. Required. + :type update_domain: int + :param parameters: The update domain object. Default value is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_walk_update_domain( + self, + resource_group_name: str, + cloud_service_name: str, + update_domain: int, + parameters: Optional[Union[_models.UpdateDomain, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the role instances in the specified update domain. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param update_domain: Specifies an integer value that identifies the update domain. Update + domains are identified with a zero-based index: the first update domain has an ID of 0, the + second has an ID of 1, and so on. Required. + :type update_domain: int + :param parameters: The update domain object. Is either a UpdateDomain type or a IO[bytes] type. + Default value is None. + :type parameters: ~azure.mgmt.compute.models.UpdateDomain 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", "2024-11-04")) + 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._walk_update_domain_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + update_domain=update_domain, + 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 + + @distributed_trace_async + async def get_update_domain( + self, resource_group_name: str, cloud_service_name: str, update_domain: int, **kwargs: Any + ) -> _models.UpdateDomain: + """Gets the specified update domain of a cloud service. Use nextLink property in the response to + get the next page of update domains. Do this till nextLink is null to fetch all the update + domains. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param update_domain: Specifies an integer value that identifies the update domain. Update + domains are identified with a zero-based index: the first update domain has an ID of 0, the + second has an ID of 1, and so on. Required. + :type update_domain: int + :return: UpdateDomain or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.UpdateDomain + :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", "2024-11-04")) + cls: ClsType[_models.UpdateDomain] = kwargs.pop("cls", None) + + _request = build_get_update_domain_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + update_domain=update_domain, + 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("UpdateDomain", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_update_domains( + self, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.UpdateDomain"]: + """Gets a list of all update domains in a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :return: An iterator like instance of either UpdateDomain or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.models.UpdateDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + cls: ClsType[_models.UpdateDomainListResult] = 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_list_update_domains_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("UpdateDomainListResult", 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/aio/operations/_community_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_community_galleries_operations.py new file mode 100644 index 000000000000..1b02d787103d --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_community_galleries_operations.py @@ -0,0 +1,106 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._community_galleries_operations import build_get_request +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CommunityGalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`community_galleries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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: 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.models.CommunityGallery + :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", "2023-07-03")) + cls: ClsType[_models.CommunityGallery] = kwargs.pop("cls", None) + + _request = build_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) + + _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("CommunityGallery", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_community_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_community_gallery_image_versions_operations.py new file mode 100644 index 000000000000..139df1926cd3 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_community_gallery_image_versions_operations.py @@ -0,0 +1,200 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._community_gallery_image_versions_operations import build_get_request, build_list_request +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CommunityGalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`community_gallery_image_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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: 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.models.CommunityGalleryImageVersion + :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", "2023-07-03")) + cls: ClsType[_models.CommunityGalleryImageVersion] = kwargs.pop("cls", None) + + _request = build_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, + 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("CommunityGalleryImageVersion", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, location: str, public_gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CommunityGalleryImageVersion"]: + """List community gallery image versions inside an 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: An iterator like instance of either CommunityGalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.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", "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_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: + _request = HttpRequest("GET", next_link) + _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) + 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/aio/operations/_community_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_community_gallery_images_operations.py new file mode 100644 index 000000000000..b2573777ba0b --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_community_gallery_images_operations.py @@ -0,0 +1,186 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._community_gallery_images_operations import build_get_request, build_list_request +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CommunityGalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`community_gallery_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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.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", "2023-07-03")) + cls: ClsType[_models.CommunityGalleryImage] = kwargs.pop("cls", None) + + _request = build_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 = 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("CommunityGalleryImage", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, location: str, public_gallery_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CommunityGalleryImage"]: + """List community gallery images inside 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 + :return: An iterator like instance of either CommunityGalleryImage or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.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", "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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CommunityGalleryImageList", 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/aio/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_dedicated_host_groups_operations.py new file mode 100644 index 000000000000..1d5feec37ba8 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_dedicated_host_groups_operations.py @@ -0,0 +1,580 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._dedicated_host_groups_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DedicatedHostGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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 + + if response.status_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 + ) -> AsyncItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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 + + if response.status_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 + :param expand: The expand expression to apply on the operation. 'InstanceView' will retrieve + the list of instance views of the dedicated hosts under the dedicated host group. 'UserData' is + not supported for dedicated host group. Known values are: "instanceView", "userData", and + "resiliencyView". Default value is None. + :type expand: str or ~azure.mgmt.compute.models.InstanceViewTypes + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) + + _request = build_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) + + _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("DedicatedHostGroup", 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, + host_group_name: str, + parameters: _models.DedicatedHostGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DedicatedHostGroup: + """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host + Groups please see [Dedicated Host Documentation] + (https://go.microsoft.com/fwlink/?linkid=2082596). + + :param resource_group_name: The name of the resource group. 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.models.DedicatedHostGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.DedicatedHostGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + host_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DedicatedHostGroup: + """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host + Groups please see [Dedicated Host Documentation] + (https://go.microsoft.com/fwlink/?linkid=2082596). + + :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: IO[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.models.DedicatedHostGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + host_group_name: str, + parameters: Union[_models.DedicatedHostGroup, IO[bytes]], + **kwargs: Any + ) -> _models.DedicatedHostGroup: + """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host + Groups please see [Dedicated Host Documentation] + (https://go.microsoft.com/fwlink/?linkid=2082596). + + :param resource_group_name: The name of the resource group. 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.models.DedicatedHostGroup or IO[bytes] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DedicatedHostGroup") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DedicatedHostGroup", 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, + host_group_name: str, + parameters: _models.DedicatedHostGroupUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DedicatedHostGroup: + """Update an dedicated host group. + + :param resource_group_name: The name of the resource group. 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.models.DedicatedHostGroupUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.DedicatedHostGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + host_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DedicatedHostGroup: + """Update an dedicated host group. + + :param resource_group_name: The name of the resource group. 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: IO[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.models.DedicatedHostGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + host_group_name: str, + parameters: Union[_models.DedicatedHostGroupUpdate, IO[bytes]], + **kwargs: Any + ) -> _models.DedicatedHostGroup: + """Update an 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 + :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.models.DedicatedHostGroupUpdate or IO[bytes] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DedicatedHostGroupUpdate") + + _request = build_update_request( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = 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("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. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :return: None or the result of cls(response) + :rtype: None + :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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_dedicated_hosts_operations.py new file mode 100644 index 000000000000..7c1209c0bf90 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_dedicated_hosts_operations.py @@ -0,0 +1,1069 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._dedicated_hosts_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_available_sizes_request, + build_list_by_host_group_request, + build_redeploy_request, + build_restart_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DedicatedHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_host_group( + self, resource_group_name: str, host_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_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. 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.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", "2024-11-01")) + cls: ClsType[_models.DedicatedHostListResult] = 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_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, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DedicatedHostListResult", 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, + 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. 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 + :param expand: The expand expression to apply on the operation. 'InstanceView' will retrieve + the list of instance views of the dedicated host. 'UserData' is not supported for dedicated + host. Known values are: "instanceView", "userData", and "resiliencyView". Default value is + None. + :type expand: str or ~azure.mgmt.compute.models.InstanceViewTypes + :return: DedicatedHost or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.DedicatedHost] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + host_name=host_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DedicatedHost", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + host_group_name: str, + host_name: str, + parameters: Union[_models.DedicatedHost, 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DedicatedHost") + + _request = build_create_or_update_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, + 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, + host_group_name: str, + host_name: str, + parameters: _models.DedicatedHost, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DedicatedHost]: + """Create or update a dedicated host . + + :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 + :param parameters: Parameters supplied to the Create Dedicated Host. Required. + :type parameters: ~azure.mgmt.compute.models.DedicatedHost + :keyword content_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 DedicatedHost or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.DedicatedHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + host_group_name: str, + host_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DedicatedHost]: + """Create or update a dedicated host . + + :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 + :param parameters: Parameters supplied to the Create Dedicated Host. 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 DedicatedHost or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.DedicatedHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + host_group_name: str, + host_name: str, + parameters: Union[_models.DedicatedHost, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.DedicatedHost]: + """Create or update a dedicated host . + + :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 + :param parameters: Parameters supplied to the Create Dedicated Host. Is either a DedicatedHost + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.models.DedicatedHost or IO[bytes] + :return: An instance of AsyncLROPoller that returns either DedicatedHost or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.DedicatedHost] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DedicatedHost] = 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, + host_group_name=host_group_name, + host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DedicatedHost]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + host_group_name: str, + host_name: str, + parameters: Union[_models.DedicatedHostUpdate, 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DedicatedHostUpdate") + + _request = build_update_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, + 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, + host_group_name: str, + host_name: str, + parameters: _models.DedicatedHostUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DedicatedHost]: + """Update a dedicated host . + + :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 + :param parameters: Parameters supplied to the Update Dedicated Host operation. Required. + :type parameters: ~azure.mgmt.compute.models.DedicatedHostUpdate + :keyword content_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 DedicatedHost or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.DedicatedHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + host_group_name: str, + host_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DedicatedHost]: + """Update a dedicated host . + + :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 + :param parameters: Parameters supplied to the Update Dedicated Host 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 DedicatedHost or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.DedicatedHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + host_group_name: str, + host_name: str, + parameters: Union[_models.DedicatedHostUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.DedicatedHost]: + """Update a dedicated host . + + :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 + :param parameters: Parameters supplied to the Update Dedicated Host operation. Is either a + DedicatedHostUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.models.DedicatedHostUpdate or IO[bytes] + :return: An instance of AsyncLROPoller that returns either DedicatedHost or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.DedicatedHost] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DedicatedHost] = 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, + host_group_name=host_group_name, + host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DedicatedHost]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_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 [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, host_group_name: str, host_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a dedicated host. + + :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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + 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 + + @distributed_trace + def list_available_sizes( + self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any + ) -> AsyncItemPaged[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. 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + 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_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: + _request = HttpRequest("GET", next_link) + _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 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 _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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_redeploy_request( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + host_name=host_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_redeploy( + self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Redeploy the dedicated host. The operation will complete successfully once the dedicated host + has migrated to a new node and is running. To determine the health of VMs deployed on the + dedicated host after the redeploy check the Resource Health Center in the Azure Portal. Please + refer to https://docs.microsoft.com/azure/service-health/resource-health-overview for more + details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param host_name: The name of the dedicated host. Required. + :type host_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._redeploy_initial( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + host_name=host_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _restart_initial( + self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + 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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_restart_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 [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 + + @distributed_trace_async + async def begin_restart( + self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any + ) -> AsyncLROPoller[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. + + :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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._restart_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_disk_accesses_operations.py new file mode 100644 index 000000000000..755f19254fba --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_disk_accesses_operations.py @@ -0,0 +1,1278 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._disk_accesses_operations import ( + build_create_or_update_request, + build_delete_a_private_endpoint_connection_request, + build_delete_request, + build_get_a_private_endpoint_connection_request, + build_get_private_link_resources_request, + build_get_request, + build_list_by_resource_group_request, + build_list_private_endpoint_connections_request, + build_list_request, + build_update_a_private_endpoint_connection_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DiskAccessesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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]: + 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", "2023-10-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk_access, (IOBase, bytes)): + _content = disk_access + else: + _json = self._serialize.body(disk_access, "DiskAccess") + + _request = build_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) + + _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_create_or_update( + self, + resource_group_name: str, + disk_access_name: str, + disk_access: _models.DiskAccess, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DiskAccess]: + """Creates or updates a disk access resource. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the Put disk access operation. + Required. + :type disk_access: ~azure.mgmt.compute.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.models.DiskAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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.models.DiskAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the Put disk access operation. + Is either a DiskAccess type or a IO[bytes] type. Required. + :type disk_access: ~azure.mgmt.compute.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.models.DiskAccess] + :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", "2023-10-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) + + 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 + + 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 + ) + + async def _update_initial( + 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, + 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", "2023-10-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk_access, (IOBase, bytes)): + _content = disk_access + else: + _json = self._serialize.body(disk_access, "DiskAccessUpdate") + + _request = build_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) + + _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( + self, + resource_group_name: str, + disk_access_name: str, + disk_access: _models.DiskAccessUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DiskAccess]: + """Updates (patches) a disk access resource. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the Patch disk access operation. + Required. + :type disk_access: ~azure.mgmt.compute.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 DiskAccess or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.DiskAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + disk_access_name: str, + disk_access: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DiskAccess]: + """Updates (patches) a disk access resource. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the 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 DiskAccess or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.DiskAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + 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. + :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.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.models.DiskAccess] + :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", "2023-10-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._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) + + 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 + + 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 + ) + + @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.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", "2023-10-02")) + cls: ClsType[_models.DiskAccess] = kwargs.pop("cls", None) + + _request = build_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 + ) -> 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", "2023-10-02")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_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) + + _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_access_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes 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 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", "2023-10-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: + 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) -> AsyncItemPaged["_models.DiskAccess"]: + """Lists all the disk access resources 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 DiskAccess or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.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", "2023-10-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_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: + _request = HttpRequest("GET", next_link) + _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(self, **kwargs: Any) -> AsyncItemPaged["_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.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", "2023-10-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_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: + _request = HttpRequest("GET", next_link) + _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_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. + :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.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", "2023-10-02")) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + _request = build_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 + + 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, + 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", "2023-10-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_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.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.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long + self, + resource_group_name: str, + disk_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection under disk access resource, this can't be used + to create a new private endpoint connection. + + :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.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.models.PrivateEndpointConnection] + :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", "2023-10-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 + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + 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 polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def get_a_private_endpoint_connection( + self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets information about a private endpoint connection under a disk access resource. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_get_a_private_endpoint_connection_request( + resource_group_name=resource_group_name, + disk_access_name=disk_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # 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 + ) -> 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", "2023-10-02")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_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) + + _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_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. + + :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: 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", "2023-10-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_a_private_endpoint_connection_initial( + resource_group_name=resource_group_name, + disk_access_name=disk_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_private_endpoint_connections( + self, resource_group_name: str, disk_access_name: str, **kwargs: Any + ) -> AsyncItemPaged["_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.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", "2023-10-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_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: + _request = HttpRequest("GET", next_link) + _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) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_disk_encryption_sets_operations.py new file mode 100644 index 000000000000..54e0979c45b8 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_disk_encryption_sets_operations.py @@ -0,0 +1,830 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._disk_encryption_sets_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_associated_resources_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DiskEncryptionSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_or_update_initial( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk_encryption_set, (IOBase, bytes)): + _content = disk_encryption_set + else: + _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + disk_encryption_set_name=disk_encryption_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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, + disk_encryption_set_name: str, + disk_encryption_set: _models.DiskEncryptionSet, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: + """Creates or updates a disk encryption set. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk + encryption set operation. Required. + :type disk_encryption_set: ~azure.mgmt.compute.models.DiskEncryptionSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.DiskEncryptionSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: + """Creates or updates a disk encryption set. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk + encryption set operation. Required. + :type disk_encryption_set: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.DiskEncryptionSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: + """Creates or updates a disk encryption set. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk + encryption set operation. Is either a DiskEncryptionSet type or a IO[bytes] type. Required. + :type disk_encryption_set: ~azure.mgmt.compute.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.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", "2023-10-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._create_or_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, **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 _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, + 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", "2023-10-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk_encryption_set, (IOBase, bytes)): + _content = disk_encryption_set + else: + _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSetUpdate") + + _request = build_update_request( + resource_group_name=resource_group_name, + disk_encryption_set_name=disk_encryption_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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, + 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. + :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.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.models.DiskEncryptionSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. 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.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. 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.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.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", "2023-10-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, **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 + ) + + @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.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", "2023-10-02")) + cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) + + _request = build_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 + ) -> 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", "2023-10-02")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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) + + 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_encryption_set_name: str, **kwargs: Any + ) -> AsyncLROPoller[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 + :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", "2023-10-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 + ) -> AsyncItemPaged["_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.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", "2023-10-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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_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.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", "2023-10-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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_associated_resources( + self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any + ) -> AsyncItemPaged[str]: + """Lists all resources that are encrypted with this 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: 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", "2023-10-02")) + cls: ClsType[_models.ResourceUriList] = 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_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, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ResourceUriList", 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/aio/operations/_disk_restore_point_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_disk_restore_point_operations.py new file mode 100644 index 000000000000..9eb482fd9c20 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_disk_restore_point_operations.py @@ -0,0 +1,558 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._disk_restore_point_operations import ( + build_get_request, + build_grant_access_request, + build_list_by_restore_point_request, + build_revoke_access_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DiskRestorePointOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`disk_restore_point` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. + + :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 + :return: DiskRestorePoint or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.DiskRestorePoint + :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", "2023-10-02")) + cls: ClsType[_models.DiskRestorePoint] = kwargs.pop("cls", None) + + _request = build_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 = 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 + ) -> AsyncItemPaged["_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.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", "2023-10-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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DiskRestorePointList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _grant_access_initial( + self, + resource_group_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, + grant_access_data: Union[_models.GrantAccessData, IO[bytes]], + **kwargs: Any + ) -> 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", "2023-10-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(grant_access_data, (IOBase, bytes)): + _content = grant_access_data + else: + _json = self._serialize.body(grant_access_data, "GrantAccessData") + + _request = build_grant_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, + 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_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: _models.GrantAccessData, + *, + 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: ~azure.mgmt.compute.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 AccessUri or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.AccessUri] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + 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: 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.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. + + :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.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.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", "2023-10-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", "2023-10-02")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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 + + @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. + + :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 + :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", "2023-10-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, + 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, + 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_disks_operations.py new file mode 100644 index 000000000000..2778e960e319 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_disks_operations.py @@ -0,0 +1,1031 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._disks_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_grant_access_request, + build_list_by_resource_group_request, + build_list_request, + build_revoke_access_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`disks` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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, + 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", "2023-10-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk, (IOBase, bytes)): + _content = disk + else: + _json = self._serialize.body(disk, "Disk") + + _request = build_create_or_update_request( + resource_group_name=resource_group_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) + + _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_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. 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.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.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. 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.models.Disk] + :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. + + :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 + :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.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.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", "2023-10-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, 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, + 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("Disk", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Disk].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Disk]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _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, + 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", "2023-10-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk, (IOBase, bytes)): + _content = disk + else: + _json = self._serialize.body(disk, "DiskUpdate") + + _request = build_update_request( + resource_group_name=resource_group_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) + + _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( + self, + resource_group_name: str, + disk_name: str, + disk: _models.DiskUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Disk]: + """Updates (patches) a disk. + + :param resource_group_name: The name of the resource group. 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.models.DiskUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.Disk] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + disk_name: str, + disk: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Disk]: + """Updates (patches) a disk. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param disk: Disk object supplied in the body of the Patch disk operation. Required. + :type disk: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.Disk] + :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. + + :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 + :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.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.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", "2023-10-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, 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, + 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("Disk", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Disk].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Disk]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @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.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", "2023-10-02")) + cls: ClsType[_models.Disk] = kwargs.pop("cls", None) + + _request = build_get_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) + + _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("Disk", 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_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", "2023-10-02")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-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, **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) -> AsyncItemPaged["_models.Disk"]: + """Lists all the disks 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 Disk or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.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", "2023-10-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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DiskList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_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.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", "2023-10-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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DiskList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _grant_access_initial( + self, + resource_group_name: str, + disk_name: str, + grant_access_data: Union[_models.GrantAccessData, 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", "2023-10-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(grant_access_data, (IOBase, bytes)): + _content = grant_access_data + else: + _json = self._serialize.body(grant_access_data, "GrantAccessData") + + _request = build_grant_access_request( + resource_group_name=resource_group_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) + + _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_grant_access( + self, + resource_group_name: str, + disk_name: str, + grant_access_data: _models.GrantAccessData, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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_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.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 AccessUri or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.AccessUri] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_grant_access( + self, + resource_group_name: str, + disk_name: str, + grant_access_data: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param grant_access_data: Access data object supplied in the body of the get disk access + operation. Required. + :type grant_access_data: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either AccessUri or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.AccessUri] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_grant_access( + self, + resource_group_name: str, + disk_name: str, + grant_access_data: Union[_models.GrantAccessData, IO[bytes]], + **kwargs: Any + ) -> 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_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.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.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", "2023-10-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, + disk_name=disk_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, 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", "2023-10-02")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_revoke_access_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]: + 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_revoke_access( + self, resource_group_name: str, disk_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Revokes access to 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-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) + + 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_galleries_operations.py new file mode 100644 index 000000000000..203ee296a454 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_galleries_operations.py @@ -0,0 +1,748 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._galleries_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`galleries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_or_update_initial( + self, resource_group_name: str, gallery_name: str, gallery: Union[_models.Gallery, 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", "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, (IOBase, bytes)): + _content = gallery + else: + _json = self._serialize.body(gallery, "Gallery") + + _request = build_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 = 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: _models.Gallery, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. + Required. + :type gallery_name: str + :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. + Required. + :type gallery: ~azure.mgmt.compute.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 AsyncLROPoller that returns either Gallery or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.Gallery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + gallery_name: str, + gallery: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. + 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 AsyncLROPoller that returns either Gallery or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.Gallery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, gallery_name: str, gallery: Union[_models.Gallery, IO[bytes]], **kwargs: Any + ) -> 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. + 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.models.Gallery or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Gallery or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.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", "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, 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=gallery, + 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("Gallery", 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.Gallery].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Gallery]( + 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: Union[_models.GalleryUpdate, 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", "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, (IOBase, bytes)): + _content = gallery + else: + _json = self._serialize.body(gallery, "GalleryUpdate") + + _request = build_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 = 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: _models.GalleryUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. + Required. + :type gallery_name: str + :param gallery: Parameters supplied to the update Shared Image Gallery operation. Required. + :type gallery: ~azure.mgmt.compute.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 AsyncLROPoller that returns either Gallery or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.Gallery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + gallery_name: str, + gallery: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. + 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 AsyncLROPoller that returns either Gallery or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.Gallery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + gallery_name: str, + gallery: Union[_models.GalleryUpdate, IO[bytes]], + **kwargs: Any + ) -> 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. + 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.models.GalleryUpdate or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Gallery or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.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", "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, 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=gallery, + 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("Gallery", 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.Gallery].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Gallery]( + 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 + :param select: The select expression to apply on the operation. "Permissions" Default value is + None. + :type select: str or ~azure.mgmt.compute.models.SelectPermissions + :param expand: The expand query option to apply on the operation. "SharingProfile/Groups" + Default value is None. + :type expand: str or ~azure.mgmt.compute.models.GalleryExpandParams + :return: Gallery or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2023-07-03")) + cls: ClsType[_models.Gallery] = kwargs.pop("cls", None) + + _request = build_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, + 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", "2023-07-03")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_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) + + _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, gallery_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Delete 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 to be deleted. 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = 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")) + 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, + 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) -> AsyncItemPaged["_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.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", "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_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: + _request = HttpRequest("GET", next_link) + _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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_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.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", "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_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: + _request = HttpRequest("GET", next_link) + _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) + 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/aio/operations/_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_gallery_application_versions_operations.py new file mode 100644 index 000000000000..dae1eb7e123b --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_gallery_application_versions_operations.py @@ -0,0 +1,813 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._gallery_application_versions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_gallery_application_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GalleryApplicationVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`gallery_application_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async 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]], + **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", "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_application_version, (IOBase, bytes)): + _content = gallery_application_version + else: + _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersion") + + _request = build_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, + 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_application_name: str, + gallery_application_version_name: str, + gallery_application_version: _models.GalleryApplicationVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: + """Create or update 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 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.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 AsyncLROPoller that returns either GalleryApplicationVersion or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.GalleryApplicationVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async 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], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: + """Create or update 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 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] + :keyword content_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 GalleryApplicationVersion or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.GalleryApplicationVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async 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]], + **kwargs: Any + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: + """Create or update 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 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.models.GalleryApplicationVersion 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.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", "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._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, + 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 + ) + + async 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]], + **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", "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_application_version, (IOBase, bytes)): + _content = gallery_application_version + else: + _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersionUpdate") + + _request = build_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, + 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_application_name: str, + gallery_application_version_name: str, + gallery_application_version: _models.GalleryApplicationVersionUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: + """Update 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 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.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 AsyncLROPoller that returns either GalleryApplicationVersion or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.GalleryApplicationVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async 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], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: + """Update 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 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] + :keyword content_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 GalleryApplicationVersion or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.GalleryApplicationVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async 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]], + **kwargs: Any + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: + """Update 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 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.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.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", "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 + :param expand: The expand expression to apply on the operation. Known values are: + "ReplicationStatus" and "UefiSettings". Default value is None. + :type expand: str or ~azure.mgmt.compute.models.ReplicationStatusTypes + :return: GalleryApplicationVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2023-07-03")) + cls: ClsType[_models.GalleryApplicationVersion] = kwargs.pop("cls", None) + + _request = build_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) + + deserialized = self._deserialize("GalleryApplicationVersion", 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, + gallery_application_version_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", "2023-07-03")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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, + 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, + gallery_name: str, + gallery_application_name: str, + gallery_application_version_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete 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 + deleted. 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = 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")) + 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_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, + 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_gallery_application( + self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any + ) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.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", "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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async 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, 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/aio/operations/_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_gallery_applications_operations.py new file mode 100644 index 000000000000..43f37ca82be3 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_gallery_applications_operations.py @@ -0,0 +1,732 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._gallery_applications_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_gallery_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GalleryApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_or_update_initial( + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application: Union[_models.GalleryApplication, 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", "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_application, (IOBase, bytes)): + _content = gallery_application + else: + _json = self._serialize.body(gallery_application, "GalleryApplication") + + _request = build_create_or_update_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, + 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_application_name: str, + gallery_application: _models.GalleryApplication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GalleryApplication]: + """Create or update 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 is to be created. 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. + :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.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 AsyncLROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.GalleryApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GalleryApplication]: + """Create or update 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 is to be created. 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. + :type gallery_application_name: str + :param gallery_application: Parameters supplied to the create or 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 AsyncLROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.GalleryApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application: Union[_models.GalleryApplication, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.GalleryApplication]: + """Create or update 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 is to be created. 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. + :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.models.GalleryApplication or IO[bytes] + :return: An instance of AsyncLROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.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", "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, 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_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 + ) + await 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: 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.GalleryApplication].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.GalleryApplication]( + 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_application_name: str, + gallery_application: Union[_models.GalleryApplicationUpdate, 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", "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_application, (IOBase, bytes)): + _content = gallery_application + else: + _json = self._serialize.body(gallery_application, "GalleryApplicationUpdate") + + _request = build_update_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, + 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_application_name: str, + gallery_application: _models.GalleryApplicationUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GalleryApplication]: + """Update 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 is to be updated. 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. + :type gallery_application_name: str + :param gallery_application: Parameters supplied to the update gallery Application operation. + Required. + :type gallery_application: ~azure.mgmt.compute.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 AsyncLROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.GalleryApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async 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 + ) -> AsyncLROPoller[_models.GalleryApplication]: + """Update 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 is to be updated. 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. + :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 AsyncLROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.GalleryApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application: Union[_models.GalleryApplicationUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.GalleryApplication]: + """Update 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 is to be updated. 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. + :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.models.GalleryApplicationUpdate or IO[bytes] + :return: An instance of AsyncLROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.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", "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, 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=gallery_application, + 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("GalleryApplication", 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.GalleryApplication].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.GalleryApplication]( + 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.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", "2023-07-03")) + cls: ClsType[_models.GalleryApplication] = kwargs.pop("cls", None) + + _request = build_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]: + 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", "2023-07-03")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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 = 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, gallery_name: str, gallery_application_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a gallery Application. + + :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 is to be deleted. Required. + :type gallery_name: str + :param gallery_application_name: The name of the gallery Application Definition to be deleted. + 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = 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")) + 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_application_name=gallery_application_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_gallery( + self, resource_group_name: str, gallery_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.GalleryApplication"]: + """List gallery Application 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 Application Gallery from which Application + Definitions are to be listed. Required. + :type gallery_name: str + :return: An iterator like instance of either GalleryApplication or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.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", "2023-07-03")) + cls: ClsType[_models.GalleryApplicationList] = 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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GalleryApplicationList", 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/aio/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_gallery_image_versions_operations.py new file mode 100644 index 000000000000..70c293511888 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_gallery_image_versions_operations.py @@ -0,0 +1,801 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._gallery_image_versions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_gallery_image_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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", "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_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.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.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.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.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.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", "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]: + 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", "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") + + _request = build_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]: + 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_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.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.models.GalleryImageVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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 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.models.GalleryImageVersion] + :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_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. 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.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.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", "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) + + 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 + ) + + @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. + + :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 + :param expand: The expand expression to apply on the operation. Known values are: + "ReplicationStatus" and "UefiSettings". Default value is None. + :type expand: str or ~azure.mgmt.compute.models.ReplicationStatusTypes + :return: GalleryImageVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2023-07-03")) + cls: ClsType[_models.GalleryImageVersion] = kwargs.pop("cls", None) + + _request = build_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) + 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 + + 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, + 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", "2023-07-03")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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, + 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, + 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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "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) + + 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_gallery_image( + self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.GalleryImageVersion"]: + """List gallery image versions in 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 + resides. 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) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.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", "2023-07-03")) + cls: ClsType[_models.GalleryImageVersionList] = 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_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, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GalleryImageVersionList", 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/aio/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_gallery_images_operations.py new file mode 100644 index 000000000000..5886ef12bed6 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_gallery_images_operations.py @@ -0,0 +1,728 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._gallery_images_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_gallery_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`gallery_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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", "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_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.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.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.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.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.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", "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", "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_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.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.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.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.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.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", "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.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", "2023-07-03")) + cls: ClsType[_models.GalleryImage] = kwargs.pop("cls", None) + + _request = build_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 = 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("GalleryImage", 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]: + 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", "2023-07-03")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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) + + _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, 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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "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, **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_gallery( + self, resource_group_name: str, gallery_name: str, **kwargs: Any + ) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.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", "2023-07-03")) + cls: ClsType[_models.GalleryImageList] = 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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GalleryImageList", 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/aio/operations/_gallery_sharing_profile_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_gallery_sharing_profile_operations.py new file mode 100644 index 000000000000..f2f0f9adfbea --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_gallery_sharing_profile_operations.py @@ -0,0 +1,246 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._gallery_sharing_profile_operations import build_update_request +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GallerySharingProfileOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`gallery_sharing_profile` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _update_initial( + self, + resource_group_name: str, + gallery_name: str, + sharing_update: Union[_models.SharingUpdate, 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", "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(sharing_update, (IOBase, bytes)): + _content = sharing_update + else: + _json = self._serialize.body(sharing_update, "SharingUpdate") + + _request = build_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 = 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( + 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 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.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.polling.AsyncLROPoller[~azure.mgmt.compute.models.SharingUpdate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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 AsyncLROPoller that returns either SharingUpdate or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.SharingUpdate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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.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.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", "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) + + 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: 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.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/aio/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_images_operations.py new file mode 100644 index 000000000000..cda87a28a7ad --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_images_operations.py @@ -0,0 +1,750 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._images_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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) + + @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 + :param expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :return: Image or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.Image] = kwargs.pop("cls", None) + + _request = build_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 = 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("Image", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Image") + + _request = build_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[_models.Image]: + """Create or 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 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.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 Image or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.Image] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + image_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Image]: + """Create or 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 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 Image or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.Image] + :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. + + :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.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.models.Image] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._create_or_update_initial( + resource_group_name=resource_group_name, + image_name=image_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Image", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Image].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Image]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + image_name: str, + parameters: Union[_models.ImageUpdate, 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImageUpdate") + + _request = build_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_update( + self, + resource_group_name: str, + image_name: str, + parameters: _models.ImageUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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 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.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 Image or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.Image] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + image_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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 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 Image or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.Image] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + image_name: str, + parameters: Union[_models.ImageUpdate, IO[bytes]], + **kwargs: Any + ) -> 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 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.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.models.Image] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_initial( + resource_group_name=resource_group_name, + image_name=image_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Image", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Image].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Image]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial(self, resource_group_name: str, image_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + image_name=image_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, image_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes an Image. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param image_name: The name of the image. Required. + :type image_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + image_name=image_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_log_analytics_operations.py new file mode 100644 index 000000000000..d7b58b72854c --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_log_analytics_operations.py @@ -0,0 +1,426 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._log_analytics_operations import ( + build_export_request_rate_by_interval_request, + build_export_throttled_requests_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`log_analytics` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RequestRateByIntervalInput") + + _request = build_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, + ) + _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["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, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 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.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.models.LogAnalyticsOperationResult] + :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. + + :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.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.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.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", "2024-11-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._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, + **kwargs + ) + 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) + 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": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LogAnalyticsOperationResult]( + 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 + ) -> 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ThrottledRequestsInput") + + _request = build_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, + ) + _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["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, 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 name of Azure region. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.compute.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.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 name of Azure region. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either LogAnalyticsOperationResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.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. + + :param location: The name of Azure region. Required. + :type location: str + :param parameters: The request body. Is either a ThrottledRequestsInput type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.compute.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.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", "2024-11-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._export_throttled_requests_initial( + location=location, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + 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) + 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": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LogAnalyticsOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_operations.py new file mode 100644 index 000000000000..a24f471f52ae --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_operations.py @@ -0,0 +1,115 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._operations import build_list_request +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: + """List the operations for the provider. + + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.OperationListResult] = 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_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(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 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/v2025_01_02/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_patch.py similarity index 100% rename from sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/aio/operations/_patch.py rename to sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_patch.py diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_proximity_placement_groups_operations.py new file mode 100644 index 000000000000..99be605f85a3 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_proximity_placement_groups_operations.py @@ -0,0 +1,578 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._proximity_placement_groups_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ProximityPlacementGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.ProximityPlacementGroup"]: + """Lists all proximity placement groups in a subscription. + + :return: An iterator like instance of either ProximityPlacementGroup or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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 + ) -> AsyncItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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_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 + :param include_colocation_status: includeColocationStatus=true enables fetching the colocation + status of all the resources in the proximity placement group. Default value is None. + :type include_colocation_status: str + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + proximity_placement_group_name=proximity_placement_group_name, + subscription_id=self._config.subscription_id, + include_colocation_status=include_colocation_status, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @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.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.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.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + 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 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.models.ProximityPlacementGroup or IO[bytes] + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProximityPlacementGroup") + + _request = build_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, + ) + _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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @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.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.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.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + 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 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.models.ProximityPlacementGroupUpdate or IO[bytes] + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProximityPlacementGroupUpdate") + + _request = build_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, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any) -> None: + """Delete a proximity placement group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param proximity_placement_group_name: The name of the proximity placement group. Required. + :type proximity_placement_group_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_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, + 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_resource_skus_operations.py similarity index 77% rename from sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/_operations.py rename to sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_resource_skus_operations.py index 470f3aa1b05e..6cc5ee742188 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_resource_skus_operations.py @@ -7,7 +7,6 @@ # -------------------------------------------------------------------------- from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar -import urllib.parse from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -27,7 +26,7 @@ from ... import models as _models from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import build_resource_skus_list_request +from ...operations._resource_skus_operations import build_list_request from .._configuration import ComputeManagementClientConfiguration T = TypeVar("T") @@ -40,7 +39,7 @@ class ResourceSkusOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_09_01.aio.ComputeManagementClient`'s + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s :attr:`resource_skus` attribute. """ @@ -52,21 +51,27 @@ def __init__(self, *args, **kwargs) -> None: self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.ResourceSku"]: + def list( + self, filter: Optional[str] = None, include_extended_locations: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.ResourceSku"]: """Gets the list of Microsoft.Compute SKUs available for your Subscription. + :param filter: The filter to apply on the operation. Only **location** filter is supported + currently. Default value is None. + :type filter: str + :param include_extended_locations: To Include Extended Locations information or not in the + response. Default value is None. + :type include_extended_locations: str :return: An iterator like instance of either ResourceSku or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_09_01.models.ResourceSku] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.models.ResourceSku] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) cls: ClsType[_models.ResourceSkusResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -80,8 +85,10 @@ def list(self, **kwargs: Any) -> AsyncItemPaged["_models.ResourceSku"]: def prepare_request(next_link=None): if not next_link: - _request = build_resource_skus_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, + filter=filter, + include_extended_locations=include_extended_locations, api_version=api_version, headers=_headers, params=_params, @@ -89,18 +96,7 @@ def prepare_request(next_link=None): _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 = HttpRequest("GET", next_link) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -123,7 +119,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/aio/operations/_restore_point_collections_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_restore_point_collections_operations.py new file mode 100644 index 000000000000..79ca812dae72 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_restore_point_collections_operations.py @@ -0,0 +1,651 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._restore_point_collections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_all_request, + build_list_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class RestorePointCollectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`restore_point_collections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_all(self, **kwargs: Any) -> AsyncItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.RestorePointCollection"]: + """Gets the list of restore point collections 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 RestorePointCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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_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. 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 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. + :type expand: str or ~azure.mgmt.compute.models.RestorePointCollectionExpandOptions + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + restore_point_collection_name: str, + parameters: _models.RestorePointCollection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to create or update the restore point collection. Please refer to + https://aka.ms/RestorePoints for more details. When updating a restore point collection, only + tags may be modified. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Create or Update restore point collection + operation. Required. + :type parameters: ~azure.mgmt.compute.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.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + restore_point_collection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to create or update the restore point collection. Please refer to + https://aka.ms/RestorePoints for more details. When updating a restore point collection, only + tags may be modified. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Create or Update restore point collection + operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + restore_point_collection_name: str, + parameters: Union[_models.RestorePointCollection, IO[bytes]], + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to create or update the restore point collection. Please refer to + https://aka.ms/RestorePoints for more details. When updating a restore point collection, only + tags may be modified. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Create or Update restore point collection + operation. Is either a RestorePointCollection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.models.RestorePointCollection or IO[bytes] + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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, "RestorePointCollection") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RestorePointCollection", 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, + restore_point_collection_name: str, + parameters: _models.RestorePointCollectionUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to update the restore point collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Update restore point collection operation. + Required. + :type parameters: ~azure.mgmt.compute.models.RestorePointCollectionUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + restore_point_collection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to update the restore point collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Update restore point collection operation. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + restore_point_collection_name: str, + parameters: Union[_models.RestorePointCollectionUpdate, IO[bytes]], + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to update the restore point collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Update restore point collection operation. Is + either a RestorePointCollectionUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.models.RestorePointCollectionUpdate or IO[bytes] + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RestorePointCollectionUpdate") + + _request = build_update_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = 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 + + async def _delete_initial( + self, resource_group_name: str, restore_point_collection_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, restore_point_collection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """The operation to delete the restore point collection. This operation will also delete all the + contained restore points. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_restore_points_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_restore_points_operations.py new file mode 100644 index 000000000000..5803c49df084 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_restore_points_operations.py @@ -0,0 +1,460 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._restore_points_operations import build_create_request, build_delete_request, build_get_request +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class RestorePointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`restore_points` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + :param 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. + :type expand: str or ~azure.mgmt.compute.models.RestorePointExpandOptions + :return: RestorePoint or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) + + _request = build_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, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RestorePoint") + + _request = build_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) + + _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 [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 = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = 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( + 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. 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.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.models.RestorePoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. 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: IO[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.models.RestorePoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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.models.RestorePoint or IO[bytes] + :return: An instance of AsyncLROPoller that returns either RestorePoint or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.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", "2024-11-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, 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, + 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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, restore_point_collection_name: str, 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. 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 + :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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + 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) + + 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_shared_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_shared_galleries_operations.py new file mode 100644 index 000000000000..778ac9e110b1 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_shared_galleries_operations.py @@ -0,0 +1,180 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._shared_galleries_operations import build_get_request, build_list_request +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SharedGalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`shared_galleries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, location: str, shared_to: Optional[Union[str, _models.SharedToValues]] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.SharedGallery"]: + """List shared galleries by subscription id or tenant id. + + :param location: Resource location. Required. + :type location: str + :param shared_to: The query parameter to decide what shared galleries to fetch when doing + listing operations. "tenant" Default value is None. + :type shared_to: str or ~azure.mgmt.compute.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.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", "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_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: + _request = HttpRequest("GET", next_link) + _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.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", "2023-07-03")) + cls: ClsType[_models.SharedGallery] = kwargs.pop("cls", None) + + _request = build_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 = 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("SharedGallery", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_shared_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_shared_gallery_image_versions_operations.py new file mode 100644 index 000000000000..9ccd82f25155 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_shared_gallery_image_versions_operations.py @@ -0,0 +1,211 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._shared_gallery_image_versions_operations import build_get_request, build_list_request +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SharedGalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`shared_gallery_image_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + ) -> AsyncItemPaged["_models.SharedGalleryImageVersion"]: + """List shared gallery image versions 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 + :param shared_to: The query parameter to decide what shared galleries to fetch when doing + listing operations. "tenant" Default value is None. + :type shared_to: str or ~azure.mgmt.compute.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.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", "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_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: + _request = HttpRequest("GET", next_link) + _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) + 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, + gallery_image_version_name: str, + **kwargs: Any + ) -> _models.SharedGalleryImageVersion: + """Get a shared gallery image version 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 + :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.models.SharedGalleryImageVersion + :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", "2023-07-03")) + cls: ClsType[_models.SharedGalleryImageVersion] = kwargs.pop("cls", None) + + _request = build_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, + 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("SharedGalleryImageVersion", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_shared_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_shared_gallery_images_operations.py new file mode 100644 index 000000000000..0c00f6e94065 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_shared_gallery_images_operations.py @@ -0,0 +1,193 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._shared_gallery_images_operations import build_get_request, build_list_request +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SharedGalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`shared_gallery_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + location: str, + gallery_unique_name: str, + shared_to: Optional[Union[str, _models.SharedToValues]] = None, + **kwargs: Any + ) -> AsyncItemPaged["_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 + :param shared_to: The query parameter to decide what shared galleries to fetch when doing + listing operations. "tenant" Default value is None. + :type shared_to: str or ~azure.mgmt.compute.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.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", "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_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: + _request = HttpRequest("GET", next_link) + _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: + 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, 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.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", "2023-07-03")) + cls: ClsType[_models.SharedGalleryImage] = kwargs.pop("cls", None) + + _request = build_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 = 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("SharedGalleryImage", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_snapshots_operations.py new file mode 100644 index 000000000000..d807f9e9f18b --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_snapshots_operations.py @@ -0,0 +1,1049 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._snapshots_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_grant_access_request, + build_list_by_resource_group_request, + build_list_request, + build_revoke_access_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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, + 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", "2023-10-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(snapshot, (IOBase, bytes)): + _content = snapshot + else: + _json = self._serialize.body(snapshot, "Snapshot") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + snapshot_name=snapshot_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _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_create_or_update( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: _models.Snapshot, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Snapshot]: + """Creates or updates a snapshot. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. + :type snapshot: ~azure.mgmt.compute.models.Snapshot + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Snapshot]: + """Creates or updates a snapshot. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. + :type snapshot: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any + ) -> AsyncLROPoller[_models.Snapshot]: + """Creates or updates a snapshot. + + :param resource_group_name: The name of the resource group. Required. + :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.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.models.Snapshot] + :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", "2023-10-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, 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, + 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, **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 _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, + 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", "2023-10-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(snapshot, (IOBase, bytes)): + _content = snapshot + else: + _json = self._serialize.body(snapshot, "SnapshotUpdate") + + _request = build_update_request( + resource_group_name=resource_group_name, + snapshot_name=snapshot_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _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( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: _models.SnapshotUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Snapshot]: + """Updates (patches) a snapshot. + + :param resource_group_name: The name of the resource group. 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.models.SnapshotUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Snapshot]: + """Updates (patches) a snapshot. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. + Required. + :type snapshot: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: Union[_models.SnapshotUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Snapshot]: + """Updates (patches) a snapshot. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. Is + either a SnapshotUpdate type or a IO[bytes] type. Required. + :type snapshot: ~azure.mgmt.compute.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.models.Snapshot] + :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", "2023-10-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, 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, **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 + ) + + @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.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", "2023-10-02")) + cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) + + _request = build_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( + 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", "2023-10-02")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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) + + 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, snapshot_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes 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: 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", "2023-10-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, + snapshot_name=snapshot_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) -> AsyncItemPaged["_models.Snapshot"]: + """Lists snapshots 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 Snapshot or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.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", "2023-10-02")) + cls: ClsType[_models.SnapshotList] = 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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + 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) + + 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(self, **kwargs: Any) -> AsyncItemPaged["_models.Snapshot"]: + """Lists snapshots under a subscription. + + :return: An iterator like instance of either Snapshot or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.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", "2023-10-02")) + cls: ClsType[_models.SnapshotList] = 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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + 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) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _grant_access_initial( + self, + resource_group_name: str, + snapshot_name: str, + grant_access_data: Union[_models.GrantAccessData, 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", "2023-10-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(grant_access_data, (IOBase, bytes)): + _content = grant_access_data + else: + _json = self._serialize.body(grant_access_data, "GrantAccessData") + + _request = build_grant_access_request( + resource_group_name=resource_group_name, + snapshot_name=snapshot_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _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_grant_access( + self, + resource_group_name: str, + snapshot_name: str, + grant_access_data: _models.GrantAccessData, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AccessUri]: + """Grants access to a snapshot. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param grant_access_data: Access data object supplied in the body of the get snapshot access + operation. Required. + :type grant_access_data: ~azure.mgmt.compute.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 AccessUri or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.AccessUri] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_grant_access( + self, + resource_group_name: str, + snapshot_name: str, + grant_access_data: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AccessUri]: + """Grants access to a snapshot. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param 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 AccessUri or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.AccessUri] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_grant_access( + self, + resource_group_name: str, + snapshot_name: str, + grant_access_data: Union[_models.GrantAccessData, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AccessUri]: + """Grants access to a snapshot. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param 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.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.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", "2023-10-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, + snapshot_name=snapshot_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, 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", "2023-10-02")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_revoke_access_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]: + 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_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. + :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", "2023-10-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, + snapshot_name=snapshot_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_ssh_public_keys_operations.py new file mode 100644 index 000000000000..b24bf920efc7 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_ssh_public_keys_operations.py @@ -0,0 +1,708 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._ssh_public_keys_operations import ( + build_create_request, + build_delete_request, + build_generate_key_pair_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SshPublicKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + 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) + + 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 + ) -> AsyncItemPaged["_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. 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.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", "2024-11-01")) + cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + 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) + + 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, 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. 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.models.SshPublicKeyResource + :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", "2024-11-01")) + cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) + + _request = build_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) + + _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("SshPublicKeyResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # 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. 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.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.models.SshPublicKeyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to create the SSH public key. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.SshPublicKeyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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.models.SshPublicKeyResource or IO[bytes] + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.SshPublicKeyResource + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SshPublicKeyResource") + + _request = build_create_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, + 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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # 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. + + :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.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.models.SshPublicKeyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.SshPublicKeyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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. Is either a + SshPublicKeyUpdateResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.models.SshPublicKeyUpdateResource or IO[bytes] + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.SshPublicKeyResource + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SshPublicKeyUpdateResource") + + _request = build_update_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, + 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("SshPublicKeyResource", 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, ssh_public_key_name: str, **kwargs: Any) -> None: + """Delete an SSH public key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_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) + + _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 + + @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. + + :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.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.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.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.models.SshGenerateKeyPairInputParameters or IO[bytes] + :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.SshPublicKeyGenerateKeyPairResult + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SshPublicKeyGenerateKeyPairResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "SshGenerateKeyPairInputParameters") + else: + _json = None + + _request = build_generate_key_pair_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, + 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("SshPublicKeyGenerateKeyPairResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_usage_operations.py similarity index 68% rename from sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/_operations.py rename to sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_usage_operations.py index d07a2d813e6a..1da411d7cdb7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_usage_operations.py @@ -7,7 +7,6 @@ # -------------------------------------------------------------------------- from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar -import urllib.parse from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -27,21 +26,21 @@ from ... import models as _models from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import build_resource_skus_list_request +from ...operations._usage_operations import build_list_request from .._configuration import ComputeManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ResourceSkusOperations: +class UsageOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_04_01.aio.ComputeManagementClient`'s - :attr:`resource_skus` attribute. + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`usage` attribute. """ models = _models @@ -52,25 +51,23 @@ def __init__(self, *args, **kwargs) -> None: self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = 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, *, filter: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.ResourceSku"]: - """Gets the list of Microsoft.Compute SKUs available for your Subscription. - - :keyword filter: The filter to apply on the operation. Only **location** filter is supported - currently. Default value is None. - :paramtype filter: str - :return: An iterator like instance of either ResourceSku or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_04_01.models.ResourceSku] + def list(self, location: str, **kwargs: Any) -> AsyncItemPaged["_models.Usage"]: + """Gets, for the specified location, the current compute resource usage information as well as the + limits for compute resources under the subscription. + + :param location: The name of Azure region. Required. + :type location: str + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.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 "2019-04-01")) - cls: ClsType[_models.ResourceSkusResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.ListUsagesResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -83,9 +80,9 @@ def list(self, *, filter: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged def prepare_request(next_link=None): if not next_link: - _request = build_resource_skus_list_request( + _request = build_list_request( + location=location, subscription_id=self._config.subscription_id, - filter=filter, api_version=api_version, headers=_headers, params=_params, @@ -93,24 +90,13 @@ def prepare_request(next_link=None): _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 = HttpRequest("GET", next_link) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("ResourceSkusResult", pipeline_response) + deserialized = self._deserialize("ListUsagesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_extension_images_operations.py new file mode 100644 index 000000000000..c9b7b86533a6 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_extension_images_operations.py @@ -0,0 +1,249 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, List, Optional, TypeVar + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._virtual_machine_extension_images_operations import ( + build_get_request, + build_list_types_request, + build_list_versions_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) + + _request = build_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) + + _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 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 + :param filter: The filter to apply on the operation. Default value is None. + :type filter: str + :param top: Default value is None. + :type top: int + :param orderby: Default value is None. + :type orderby: str + :return: list of VirtualMachineExtensionImage or the result of cls(response) + :rtype: list[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) + + _request = build_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 = 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( + 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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineExtensionImage] = kwargs.pop("cls", None) + + _request = build_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 = 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_extensions_operations.py new file mode 100644 index 000000000000..465f77f78650 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_extensions_operations.py @@ -0,0 +1,738 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._virtual_machine_extensions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. 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 expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :return: VirtualMachineExtensionsListResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.VirtualMachineExtensionsListResult + :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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) + + _request = build_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 + + @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. 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 vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :return: VirtualMachineExtension or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + vm_name=vm_name, + vm_extension_name=vm_extension_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + vm_name: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineExtension, 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters + else: + _json = self._serialize.body(extension_parameters, "VirtualMachineExtension") + + _request = build_create_or_update_request( + resource_group_name=resource_group_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, + 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, + vm_extension_name: str, + extension_parameters: _models.VirtualMachineExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: + """The operation to create or update 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_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.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 VirtualMachineExtension or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.VirtualMachineExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_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 create or update 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_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. + 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.models.VirtualMachineExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: + """The operation to create or update 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_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.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.models.VirtualMachineExtension] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, + 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("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, 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( + 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 + ) + + 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 + ) -> 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters + else: + _json = self._serialize.body(extension_parameters, "VirtualMachineExtensionUpdate") + + _request = build_update_request( + resource_group_name=resource_group_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, + 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, + vm_extension_name: str, + extension_parameters: _models.VirtualMachineExtensionUpdate, + *, + 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. 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 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.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.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. 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 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.models.VirtualMachineExtension] + :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. 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 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.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.models.VirtualMachineExtension] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, + 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("VirtualMachineExtension", 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.VirtualMachineExtension].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 + ) + + async def _delete_initial( + self, resource_group_name: str, vm_name: str, vm_extension_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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + vm_name=vm_name, + 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) + + _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, vm_extension_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """The operation to delete 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_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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + 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, + vm_extension_name=vm_extension_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_images_edge_zone_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_images_edge_zone_operations.py new file mode 100644 index 000000000000..7191972dfb9b --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_images_edge_zone_operations.py @@ -0,0 +1,391 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, List, Optional, TypeVar + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._virtual_machine_images_edge_zone_operations import ( + build_get_request, + build_list_offers_request, + build_list_publishers_request, + build_list_request, + build_list_skus_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class VirtualMachineImagesEdgeZoneOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images_edge_zone` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _request = build_list_publishers_request( + location=location, + edge_zone=edge_zone, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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, edge_zone: str, publisher_name: str, **kwargs: Any + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of virtual machine image offers for the specified location, edge zone and + publisher. + + :param location: The name of Azure region. Required. + :type location: str + :param edge_zone: The name of the edge zone. Required. + :type edge_zone: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _request = build_list_offers_request( + location=location, + edge_zone=edge_zone, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def 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.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _request = build_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) + + _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( + 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. + + :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 expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :param top: An integer value specifying the number of images to return that matches supplied + values. Default value is None. + :type top: int + :param orderby: Specifies the order of the results returned. Formatted as an OData query. + Default value is None. + :type orderby: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _request = build_list_request( + location=location, + edge_zone=edge_zone, + publisher_name=publisher_name, + offer=offer, + skus=skus, + subscription_id=self._config.subscription_id, + expand=expand, + top=top, + orderby=orderby, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 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 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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) + + _request = build_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 = 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_images_operations.py new file mode 100644 index 000000000000..30f32d679143 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_images_operations.py @@ -0,0 +1,506 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, List, Optional, TypeVar + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._virtual_machine_images_operations import ( + build_get_request, + build_list_by_edge_zone_request, + build_list_offers_request, + build_list_publishers_request, + build_list_request, + build_list_skus_request, + build_list_with_properties_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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.models.VmImagesInEdgeZoneListResult + :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", "2024-11-01")) + cls: ClsType[_models.VmImagesInEdgeZoneListResult] = kwargs.pop("cls", None) + + _request = build_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) + + _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("VmImagesInEdgeZoneListResult", 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. + + :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.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _request = build_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) + 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 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.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _request = build_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_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.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _request = build_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) + + _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( + self, + location: str, + publisher_name: str, + offer: str, + skus: str, + expand: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of all virtual machine image versions for the specified location, publisher, offer, + and SKU. + + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :param skus: A valid image SKU. Required. + :type skus: str + :param expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :param top: Default value is None. + :type top: int + :param orderby: Default value is None. + :type orderby: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _request = build_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 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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) + + _request = build_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_with_properties( + self, + location: str, + publisher_name: str, + offer: str, + skus: str, + expand: str, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> List[_models.VirtualMachineImage]: + """list_with_properties. + + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :param skus: A valid image SKU. Required. + :type skus: str + :param expand: The expand expression to apply on the operation. Required. + :type expand: str + :param top: Default value is None. + :type top: int + :param orderby: Default value is None. + :type orderby: str + :return: list of VirtualMachineImage or the result of cls(response) + :rtype: list[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImage]] = kwargs.pop("cls", None) + + _request = build_list_with_properties_request( + location=location, + publisher_name=publisher_name, + offer=offer, + skus=skus, + subscription_id=self._config.subscription_id, + expand=expand, + top=top, + orderby=orderby, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_run_commands_operations.py new file mode 100644 index 000000000000..a334120affdc --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_run_commands_operations.py @@ -0,0 +1,875 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._virtual_machine_run_commands_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_by_virtual_machine_request, + build_get_request, + build_list_by_virtual_machine_request, + build_list_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class VirtualMachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, location: str, **kwargs: Any) -> AsyncItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RunCommandListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, location: str, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: + """Gets specific run command for a subscription in a location. + + :param location: The name of Azure region. Required. + :type location: str + :param command_id: The command id. Required. + :type command_id: str + :return: RunCommandDocument or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.RunCommandDocument + :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", "2024-11-01")) + cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) + + _request = build_get_request( + location=location, + command_id=command_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("RunCommandDocument", 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 + ) -> AsyncItemPaged["_models.VirtualMachineRunCommand"]: + """The operation to get all run commands 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 VirtualMachine. Required. + :type vm_name: str + :param expand: The expand expression to apply on the operation. Default value is None. + :type 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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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 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 + :param expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :return: VirtualMachineRunCommand or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + + _request = build_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) + + _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 + + 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, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_command, (IOBase, bytes)): + _content = run_command + else: + _json = self._serialize.body(run_command, "VirtualMachineRunCommand") + + _request = build_create_or_update_request( + resource_group_name=resource_group_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, + ) + _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, + 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. 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: ~azure.mgmt.compute.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.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.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.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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + polling: Union[bool, 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, + 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) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineRunCommand", 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.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 _update_initial( + self, + resource_group_name: str, + vm_name: str, + run_command_name: str, + run_command: Union[_models.VirtualMachineRunCommandUpdate, 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_command, (IOBase, bytes)): + _content = run_command + else: + _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") + + _request = build_update_request( + resource_group_name=resource_group_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, + ) + _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, + 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. + + :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: ~azure.mgmt.compute.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.models.VirtualMachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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.models.VirtualMachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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.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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + polling: Union[bool, 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) + + 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, 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.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 _delete_initial( + self, resource_group_name: str, vm_name: str, run_command_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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + vm_name=vm_name, + run_command_name=run_command_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, vm_name: str, run_command_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """The operation to delete 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 + :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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + run_command_name=run_command_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_scale_set_extensions_operations.py new file mode 100644 index 000000000000..e911714224c1 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_scale_set_extensions_operations.py @@ -0,0 +1,758 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._virtual_machine_scale_set_extensions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +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.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> AsyncItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetExtensionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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) + + @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. The name is case insensitive. + Required. + :type 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 + :param expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :return: VirtualMachineScaleSetExtension or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) + + _request = build_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 + + 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]: + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters + else: + _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtension") + + _request = build_create_or_update_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, + 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_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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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 + :param extension_parameters: Parameters supplied to the Create VM scale set Extension + operation. Required. + :type extension_parameters: ~azure.mgmt.compute.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.models.VirtualMachineScaleSetExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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 + :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.models.VirtualMachineScaleSetExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetExtension, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: + """The operation to create or update an extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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 + :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.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.models.VirtualMachineScaleSetExtension] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, + extension_parameters=extension_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, 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.VirtualMachineScaleSetExtension].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.VirtualMachineScaleSetExtension]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _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]: + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters + else: + _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtensionUpdate") + + _request = build_update_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, + 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_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. The name is case insensitive. + Required. + :type 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 + :param extension_parameters: Parameters supplied to the Update VM scale set Extension + operation. Required. + :type extension_parameters: ~azure.mgmt.compute.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.models.VirtualMachineScaleSetExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: + """The operation to update an extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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 + :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.models.VirtualMachineScaleSetExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: + """The operation to update an extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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 + :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.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.models.VirtualMachineScaleSetExtension] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, + extension_parameters=extension_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, 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.VirtualMachineScaleSetExtension].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.VirtualMachineScaleSetExtension]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_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, + 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_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. The name is case insensitive. + Required. + :type 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 + :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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py new file mode 100644 index 000000000000..a6be124171f5 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -0,0 +1,458 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, AsyncIterator, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._virtual_machine_scale_set_rolling_upgrades_operations import ( + build_cancel_request, + build_get_latest_request, + build_start_extension_upgrade_request, + build_start_os_upgrade_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +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.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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, + 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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_start_extension_upgrade_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) + + _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_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. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._start_extension_upgrade_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, 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 _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, + 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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_start_os_upgrade_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) + + _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_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. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._start_os_upgrade_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _cancel_initial( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_cancel_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) + + _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_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. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._cancel_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get_latest( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> _models.RollingUpgradeStatusInfo: + """Gets the status of the latest virtual machine scale set rolling upgrade. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: RollingUpgradeStatusInfo or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.RollingUpgradeStatusInfo] = kwargs.pop("cls", None) + + _request = build_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 = 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("RollingUpgradeStatusInfo", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py new file mode 100644 index 000000000000..bb3152a4a0d5 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -0,0 +1,788 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._virtual_machine_scale_set_vm_extensions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +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.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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + :param expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :return: VirtualMachineScaleSetVMExtensionsListResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_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, + 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. The name is case insensitive. + Required. + :type 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 expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :return: VirtualMachineScaleSetVMExtension or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) + + _request = build_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 = 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("VirtualMachineScaleSetVMExtension", 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, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters + else: + _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetVMExtension") + + _request = build_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) + + _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_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.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.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.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. The name is case insensitive. + Required. + :type 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.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.models.VirtualMachineScaleSetVMExtension] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_extension_name=vm_extension_name, + extension_parameters=extension_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + 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, 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 _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, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters + else: + _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetVMExtensionUpdate") + + _request = build_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) + + _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_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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.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) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.VirtualMachineScaleSetVMExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: + """The operation to update the VMSS VM extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.models.VirtualMachineScaleSetVMExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetVMExtensionUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: + """The operation to update the VMSS VM extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.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.models.VirtualMachineScaleSetVMExtension] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._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): + 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, 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.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 _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, + 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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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) + + _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_scale_set_name: str, instance_id: str, vm_extension_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """The operation to delete the VMSS VM extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_extension_name=vm_extension_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py new file mode 100644 index 000000000000..3799af7dc989 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py @@ -0,0 +1,794 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._virtual_machine_scale_set_vm_run_commands_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +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.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_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. 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 expand: The expand expression to apply on the operation. Default value is None. + :type 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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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 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. 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 + :param expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :return: VirtualMachineRunCommand or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + + _request = build_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 + + 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]], + **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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_command, (IOBase, bytes)): + _content = run_command + else: + _json = self._serialize.body(run_command, "VirtualMachineRunCommand") + + _request = build_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, + 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, + 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 VMSS VM 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_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: ~azure.mgmt.compute.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.models.VirtualMachineRunCommand] + :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, + 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 VMSS VM 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_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. + 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.models.VirtualMachineRunCommand] + :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, + run_command_name: str, + run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: + """The operation to create or update the VMSS VM 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_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. + :type run_command: ~azure.mgmt.compute.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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + polling: Union[bool, 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, + 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("VirtualMachineRunCommand", 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.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 _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]], + **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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_command, (IOBase, bytes)): + _content = run_command + else: + _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") + + _request = build_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, + 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) + + 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_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 VMSS VM 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_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: Resource create parameters. Required. + :type run_command: ~azure.mgmt.compute.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.models.VirtualMachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + 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], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: + """The operation to update the VMSS VM 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_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: Resource create parameters. 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.models.VirtualMachineRunCommand] + :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]], + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: + """The operation to update the VMSS VM 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_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: Resource create parameters. Is either a VirtualMachineRunCommandUpdate type + or a IO[bytes] type. Required. + :type run_command: ~azure.mgmt.compute.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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + polling: Union[bool, 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, + 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("VirtualMachineRunCommand", 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.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 _delete_initial( + 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, + 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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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, + 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, vm_scale_set_name: str, instance_id: str, run_command_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """The operation to delete the VMSS VM 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_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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + run_command_name=run_command_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_scale_set_vms_operations.py new file mode 100644 index 000000000000..ede106a4609c --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -0,0 +1,2400 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._virtual_machine_scale_set_vms_operations import ( + build_approve_rolling_upgrade_request, + build_attach_detach_data_disks_request, + build_deallocate_request, + build_delete_request, + build_get_instance_view_request, + build_get_request, + build_list_request, + build_perform_maintenance_request, + build_power_off_request, + build_redeploy_request, + build_reimage_all_request, + build_reimage_request, + build_restart_request, + build_retrieve_boot_diagnostics_data_request, + build_run_command_request, + build_simulate_eviction_request, + build_start_request, + build_update_request, +) +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class VirtualMachineScaleSetVMsOperations: # 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.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + ) -> AsyncItemPaged["_models.VirtualMachineScaleSetVM"]: + """Gets a list of all virtual machines in a VM scale sets. + + :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 VirtualMachineScaleSet. Required. + :type virtual_machine_scale_set_name: str + :param 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. + :type filter: str + :param select: The list parameters. Allowed values are 'instanceView', 'instanceView/statuses'. + Default value is None. + :type select: str + :param expand: The expand expression to apply to the operation. Allowed values are + 'instanceView'. Default value is None. + :type 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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetVMListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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) + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any + ) -> _models.VirtualMachineScaleSetVM: + """Gets a virtual machine from a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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 expand: The expand expression to apply on the operation. 'InstanceView' will retrieve + the instance view of the virtual machine. 'UserData' will retrieve the UserData of the virtual + machine. Known values are: "instanceView", "userData", and "resiliencyView". Default value is + None. + :type expand: str or ~azure.mgmt.compute.models.InstanceViewTypes + :return: VirtualMachineScaleSetVM or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetVM] = kwargs.pop("cls", None) + + _request = build_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 = 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("VirtualMachineScaleSetVM", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualMachineScaleSetVM") + + _request = build_update_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _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_update( + self, + resource_group_name: str, + 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 + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: + """Updates a virtual machine of 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 Update Virtual Machine Scale Sets VM operation. + Required. + :type parameters: ~azure.mgmt.compute.models.VirtualMachineScaleSetVM + :param 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. + :type if_match: str + :param 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. + :type 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 VirtualMachineScaleSetVM or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.VirtualMachineScaleSetVM] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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 Update Virtual Machine Scale Sets VM operation. + Required. + :type parameters: IO[bytes] + :param 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. + :type if_match: str + :param 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. + :type 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 VirtualMachineScaleSetVM or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.VirtualMachineScaleSetVM] + :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, + parameters: Union[_models.VirtualMachineScaleSetVM, 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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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 Update Virtual Machine Scale Sets VM operation. + Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.models.VirtualMachineScaleSetVM or IO[bytes] + :param 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. + :type if_match: str + :param 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. + :type 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.models.VirtualMachineScaleSetVM] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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) + + 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 + + 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 + ) + + async def _delete_initial( + 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, + 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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + force_deletion=force_deletion, + api_version=api_version, + headers=_headers, + params=_params, + ) + _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_scale_set_name: str, + instance_id: str, + force_deletion: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes 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 + :param force_deletion: Optional parameter to force delete a virtual machine from a VM scale + set. (Feature in Preview). Default value is None. + :type 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + 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 + + 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, + 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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._approve_rolling_upgrade_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _attach_detach_data_disks_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AttachDetachDataDisksRequest") + + _request = build_attach_detach_data_disks_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 + 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_scale_set_name: str, + instance_id: str, + parameters: _models.AttachDetachDataDisksRequest, + *, + 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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.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.models.StorageProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_attach_detach_data_disks( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + parameters: 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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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 AsyncLROPoller that returns either StorageProfile or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.StorageProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async 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 + ) -> 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. The name is case insensitive. + Required. + :type 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.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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageProfile] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._attach_detach_data_disks_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + 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 _deallocate_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_deallocate_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = 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_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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._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, 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_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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetVMInstanceView] = kwargs.pop("cls", None) + + _request = build_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 + + 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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = 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_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 vm_scale_set_name: The name of the VM 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._perform_maintenance_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + 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, + vm_scale_set_name: str, + instance_id: str, + skip_shutdown: 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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = 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_power_off( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + skip_shutdown: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached + and you are getting charged for the resources. Instead, use deallocate to release resources and + avoid charges. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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 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. + :type skip_shutdown: bool + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._power_off_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + skip_shutdown=skip_shutdown, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _redeploy_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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, + 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 + + @distributed_trace_async + async def begin_redeploy( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Shuts down the virtual machine in the virtual machine scale set, moves it to a new node, and + powers it back on. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._redeploy_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _reimage_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_scale_set_vm_reimage_input: Optional[ + Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] + ] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(vm_scale_set_vm_reimage_input, (IOBase, bytes)): + _content = vm_scale_set_vm_reimage_input + else: + if vm_scale_set_vm_reimage_input is not None: + _json = self._serialize.body(vm_scale_set_vm_reimage_input, "VirtualMachineScaleSetVMReimageParameters") + else: + _json = None + + _request = build_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, + 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_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. The name is case insensitive. + Required. + :type 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.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. The name is case insensitive. + Required. + :type 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.models.VirtualMachineScaleSetVMReimageParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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, + 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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = 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_reimage_all( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. + This operation is only supported for managed disks. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._reimage_all_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, 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, + 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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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 = 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_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. The name is case insensitive. + Required. + :type 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._restart_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def 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 + :param 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. + :type sas_uri_expiration_time_in_minutes: int + :return: RetrieveBootDiagnosticsDataResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) + + _request = build_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 = 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, + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.RunCommandInput, 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RunCommandInput") + + _request = build_run_command_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 + 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_run_command( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + parameters: _models.RunCommandInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RunCommandResult]: + """Run command on a virtual machine in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the Run command operation. Required. + :type parameters: ~azure.mgmt.compute.models.RunCommandInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.RunCommandResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_run_command( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RunCommandResult]: + """Run command on a virtual machine in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the Run command operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.RunCommandResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_run_command( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.RunCommandInput, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.RunCommandResult]: + """Run command on a virtual machine in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the Run command operation. Is either a + RunCommandInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.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.models.RunCommandResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._run_command_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.RunCommandResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.RunCommandResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def simulate_eviction( + self, resource_group_name: str, vm_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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_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, + 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", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_start_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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = 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_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. The name is case insensitive. + Required. + :type 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._start_initial( + resource_group_name=resource_group_name, + vm_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_scale_sets_operations.py similarity index 52% rename from sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_operations.py rename to sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_scale_sets_operations.py index 3c568097544e..5fb667b6dfe5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_scale_sets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -9,7 +9,6 @@ from collections.abc import MutableMapping from io import IOBase from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -34,36 +33,32 @@ from ... import models as _models from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import ( - build_disk_accesses_create_or_update_request, - build_disk_accesses_delete_request, - build_disk_accesses_get_private_link_resources_request, - build_disk_accesses_get_request, - build_disk_accesses_list_by_resource_group_request, - build_disk_accesses_list_request, - build_disk_accesses_update_request, - build_disk_encryption_sets_create_or_update_request, - build_disk_encryption_sets_delete_request, - build_disk_encryption_sets_get_request, - build_disk_encryption_sets_list_by_resource_group_request, - build_disk_encryption_sets_list_request, - build_disk_encryption_sets_update_request, - build_disks_create_or_update_request, - build_disks_delete_request, - build_disks_get_request, - build_disks_grant_access_request, - build_disks_list_by_resource_group_request, - build_disks_list_request, - build_disks_revoke_access_request, - build_disks_update_request, - build_snapshots_create_or_update_request, - build_snapshots_delete_request, - build_snapshots_get_request, - build_snapshots_grant_access_request, - build_snapshots_list_by_resource_group_request, - build_snapshots_list_request, - build_snapshots_revoke_access_request, - build_snapshots_update_request, +from ...operations._virtual_machine_scale_sets_operations import ( + build_approve_rolling_upgrade_request, + build_convert_to_single_placement_group_request, + build_create_or_update_request, + build_deallocate_request, + build_delete_instances_request, + build_delete_request, + build_force_recovery_service_fabric_platform_update_domain_walk_request, + build_get_instance_view_request, + build_get_os_upgrade_history_request, + build_get_request, + build_list_all_request, + build_list_by_location_request, + build_list_request, + build_list_skus_request, + build_perform_maintenance_request, + build_power_off_request, + build_reapply_request, + build_redeploy_request, + build_reimage_all_request, + build_reimage_request, + build_restart_request, + build_set_orchestration_service_state_request, + build_start_request, + build_update_instances_request, + build_update_request, ) from .._configuration import ComputeManagementClientConfiguration @@ -71,14 +66,14 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DisksOperations: +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.v2020_05_01.aio.ComputeManagementClient`'s - :attr:`disks` attribute. + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models @@ -89,10 +84,285 @@ def __init__(self, *args, **kwargs) -> None: self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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 + def list_all(self, **kwargs: Any) -> AsyncItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = 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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + 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) + + 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(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.VirtualMachineScaleSet"]: + """Gets a list of all VM scale sets under a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either VirtualMachineScaleSet or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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 + :param 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. + :type expand: str or ~azure.mgmt.compute.models.ExpandTypesForGetVMScaleSets + :return: VirtualMachineScaleSet or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) + + _request = build_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, disk_name: str, disk: Union[_models.Disk, IO[bytes]], **kwargs: Any + 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, @@ -105,22 +375,24 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(disk, (IOBase, bytes)): - _content = disk + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - _json = self._serialize.body(disk, "Disk") + _json = self._serialize.body(parameters, "VirtualMachineScaleSet") - _request = build_disks_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, - disk_name=disk_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, @@ -138,7 +410,7 @@ async def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 201]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -146,10 +418,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 @@ -157,27 +434,37 @@ async def _create_or_update_initial( async def begin_create_or_update( self, resource_group_name: str, - disk_name: str, - disk: _models.Disk, + vm_scale_set_name: str, + parameters: _models.VirtualMachineScaleSet, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Creates or updates a disk. + ) -> 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 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.v2020_05_01.models.Disk + :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.models.VirtualMachineScaleSet + :param 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. + :type if_match: str + :param 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. + :type 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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.Disk] + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -185,63 +472,89 @@ async def begin_create_or_update( async def begin_create_or_update( self, resource_group_name: str, - disk_name: str, - disk: IO[bytes], + 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.Disk]: - """Creates or updates a disk. + ) -> 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 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 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] + :param 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. + :type if_match: str + :param 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. + :type 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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.Disk] + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.VirtualMachineScaleSet] :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, + vm_scale_set_name: str, + parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> 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 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.v2020_05_01.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.v2020_05_01.models.Disk] + :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.models.VirtualMachineScaleSet or IO[bytes] + :param 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. + :type if_match: str + :param 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. + :type 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.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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Disk] = 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._create_or_update_initial( resource_group_name=resource_group_name, - disk_name=disk_name, - disk=disk, + 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, @@ -253,30 +566,38 @@ 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("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.Disk].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.Disk]( + 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, disk_name: str, disk: Union[_models.DiskUpdate, IO[bytes]], **kwargs: Any + 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, @@ -289,22 +610,24 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(disk, (IOBase, bytes)): - _content = disk + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - _json = self._serialize.body(disk, "DiskUpdate") + _json = self._serialize.body(parameters, "VirtualMachineScaleSetUpdate") - _request = build_disks_update_request( + _request = build_update_request( resource_group_name=resource_group_name, - disk_name=disk_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, @@ -322,7 +645,7 @@ async def _update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -330,10 +653,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 @@ -341,27 +668,37 @@ async def _update_initial( async def begin_update( self, resource_group_name: str, - disk_name: str, - disk: _models.DiskUpdate, + 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.Disk]: - """Updates (patches) a disk. + ) -> 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 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.v2020_05_01.models.DiskUpdate + :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.models.VirtualMachineScaleSetUpdate + :param 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. + :type if_match: str + :param 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. + :type 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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.Disk] + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -369,63 +706,89 @@ async def begin_update( async def begin_update( self, resource_group_name: str, - disk_name: str, - disk: IO[bytes], + 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.Disk]: - """Updates (patches) a disk. + ) -> 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 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 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] + :param 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. + :type if_match: str + :param 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. + :type 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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.Disk] + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.VirtualMachineScaleSet] :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, + vm_scale_set_name: str, + parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: + """Update a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param 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.v2020_05_01.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.v2020_05_01.models.Disk] + :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.models.VirtualMachineScaleSetUpdate or IO[bytes] + :param 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. + :type if_match: str + :param 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. + :type 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.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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Disk] = 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( resource_group_name=resource_group_name, - disk_name=disk_name, - disk=disk, + 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, @@ -437,85 +800,38 @@ async def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Disk", 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("VirtualMachineScaleSet", 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.Disk].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.Disk]( + return AsyncLROPoller[_models.VirtualMachineScaleSet]( 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.v2020_05_01.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 "2020-05-01")) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) - - _request = build_disks_get_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) - - _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("Disk", 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_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + 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, @@ -527,13 +843,14 @@ async def _delete_initial(self, resource_group_name: str, disk_name: str, **kwar _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_disks_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, - disk_name=disk_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, @@ -556,23 +873,32 @@ async def _delete_initial(self, resource_group_name: str, disk_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_delete(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes a disk. + 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 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 vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param force_deletion: Optional parameter to force delete a VM scale set. (Feature in Preview). + Default value is None. + :type 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: @@ -580,7 +906,7 @@ async def begin_delete(self, resource_group_name: str, disk_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -588,7 +914,8 @@ 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, + vm_scale_set_name=vm_scale_set_name, + force_deletion=force_deletion, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -603,7 +930,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: @@ -617,162 +946,11 @@ 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) -> AsyncItemPaged["_models.Disk"]: - """Lists all the disks 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 Disk or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_05_01.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 "2020-05-01")) - 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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2020_05_01.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 "2020-05-01")) - cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disks_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _grant_access_initial( + async def _approve_rolling_upgrade_initial( self, resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, 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 = { @@ -786,21 +964,24 @@ async def _grant_access_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(grant_access_data, (IOBase, bytes)): - _content = grant_access_data + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_disks_grant_access_request( + _request = build_approve_rolling_upgrade_request( resource_group_name=resource_group_name, - disk_name=disk_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -819,7 +1000,7 @@ async def _grant_access_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): @@ -827,111 +1008,113 @@ 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 = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, 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_approve_rolling_upgrade( self, resource_group_name: str, - disk_name: str, - grant_access_data: _models.GrantAccessData, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a disk. + ) -> 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. + :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.v2020_05_01.models.GrantAccessData + :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.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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.AccessUri] + :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_grant_access( + async def begin_approve_rolling_upgrade( self, resource_group_name: str, - disk_name: str, - grant_access_data: IO[bytes], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a disk. + ) -> 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. + :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 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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.AccessUri] + :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_grant_access( + async def begin_approve_rolling_upgrade( self, resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a disk. + ) -> 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. + :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.v2020_05_01.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.v2020_05_01.models.AccessUri] + :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.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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessUri] = 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._grant_access_initial( + raw_result = await self._approve_rolling_upgrade_initial( resource_group_name=resource_group_name, - disk_name=disk_name, - grant_access_data=grant_access_data, + 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, @@ -942,11 +1125,9 @@ async def begin_grant_access( 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) + 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( @@ -957,19 +1138,91 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.AccessUri].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.AccessUri]( - 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 _revoke_access_initial( - self, resource_group_name: str, disk_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: + @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.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.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, @@ -978,126 +1231,55 @@ async def _revoke_access_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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_disks_revoke_access_request( + _request = build_convert_to_single_placement_group_request( resource_group_name=resource_group_name, - disk_name=disk_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 + _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) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_revoke_access( - self, resource_group_name: str, disk_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Revokes access to 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-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._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) - - 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 SnapshotsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_05_01.aio.ComputeManagementClient`'s - :attr:`snapshots` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 cls(pipeline_response, None, {}) # 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 _deallocate_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + hibernate: Optional[bool] = None, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1110,22 +1292,26 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(snapshot, "Snapshot") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_snapshots_create_or_update_request( + _request = build_deallocate_request( resource_group_name=resource_group_name, - snapshot_name=snapshot_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, @@ -1151,105 +1337,133 @@ 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_deallocate( self, resource_group_name: str, - snapshot_name: str, - snapshot: _models.Snapshot, + vm_scale_set_name: str, + hibernate: Optional[bool] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. + ) -> AsyncLROPoller[None]: + """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and + releases the compute resources. You are not billed for the compute resources that this virtual + machine scale set deallocates. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param 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.v2020_05_01.models.Snapshot + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param 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. + :type hibernate: 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.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 Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.Snapshot] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_or_update( + async def begin_deallocate( self, resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], + vm_scale_set_name: str, + hibernate: Optional[bool] = None, + vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. + ) -> AsyncLROPoller[None]: + """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and + releases the compute resources. You are not billed for the compute resources that this virtual + machine scale set deallocates. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param 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] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param 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. + :type hibernate: 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: IO[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.v2020_05_01.models.Snapshot] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. + async def begin_deallocate( + self, + resource_group_name: str, + vm_scale_set_name: str, + hibernate: Optional[bool] = None, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and + releases the compute resources. You are not billed for the compute resources that this virtual + machine scale set deallocates. - :param resource_group_name: The name of the resource 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.v2020_05_01.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.v2020_05_01.models.Snapshot] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param 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. + :type hibernate: bool + :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.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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._deallocate_initial( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - snapshot=snapshot, + vm_scale_set_name=vm_scale_set_name, + hibernate=hibernate, + vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1260,34 +1474,33 @@ 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 _delete_instances_initial( self, resource_group_name: str, - snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], + 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 = { @@ -1301,22 +1514,23 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(snapshot, "SnapshotUpdate") + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceRequiredIDs") - _request = build_snapshots_update_request( + _request = build_delete_instances_request( resource_group_name=resource_group_name, - snapshot_name=snapshot_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, @@ -1342,111 +1556,124 @@ 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_delete_instances( self, resource_group_name: str, - snapshot_name: str, - snapshot: _models.SnapshotUpdate, + vm_scale_set_name: str, + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, + force_deletion: Optional[bool] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. + ) -> AsyncLROPoller[None]: + """Deletes virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param 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. + :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 snapshot: ~azure.mgmt.compute.v2020_05_01.models.SnapshotUpdate + :type vm_instance_i_ds: ~azure.mgmt.compute.models.VirtualMachineScaleSetVMInstanceRequiredIDs + :param force_deletion: Optional parameter to force delete virtual machines from the VM scale + set. (Feature in Preview). Default value is None. + :type 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 Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.Snapshot] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update( + async def begin_delete_instances( self, resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], + vm_scale_set_name: str, + vm_instance_i_ds: IO[bytes], + force_deletion: Optional[bool] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. + ) -> AsyncLROPoller[None]: + """Deletes virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param 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. + :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 snapshot: IO[bytes] + :type vm_instance_i_ds: IO[bytes] + :param force_deletion: Optional parameter to force delete virtual machines from the VM scale + set. (Feature in Preview). Default value is None. + :type 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 Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.Snapshot] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update( + async def begin_delete_instances( self, resource_group_name: str, - snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], + force_deletion: Optional[bool] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. + ) -> AsyncLROPoller[None]: + """Deletes virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param 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.v2020_05_01.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.v2020_05_01.models.Snapshot] + :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.models.VirtualMachineScaleSetVMInstanceRequiredIDs + or IO[bytes] + :param force_deletion: Optional parameter to force delete virtual machines from the VM scale + set. (Feature in Preview). Default value is None. + :type 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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._delete_instances_initial( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - snapshot=snapshot, + 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, @@ -1457,41 +1684,116 @@ 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("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 + + @distributed_trace_async + async def force_recovery_service_fabric_platform_update_domain_walk( # pylint: disable=name-too-long + self, + resource_group_name: str, + vm_scale_set_name: str, + platform_update_domain: int, + zone: Optional[str] = None, + placement_group_id: Optional[str] = None, + **kwargs: Any + ) -> _models.RecoveryWalkResponse: + """Manual platform update domain walk to update virtual machines in a service fabric virtual + machine scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param platform_update_domain: The platform update domain for which a manual recovery walk is + requested. Required. + :type platform_update_domain: int + :param zone: The zone in which the manual recovery walk is requested for cross zone virtual + machine scale set. Default value is None. + :type zone: str + :param placement_group_id: The placement group id for which the manual recovery walk is + requested. Default value is None. + :type placement_group_id: str + :return: RecoveryWalkResponse or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.RecoveryWalkResponse] = kwargs.pop("cls", None) + + _request = build_force_recovery_service_fabric_platform_update_domain_walk_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + subscription_id=self._config.subscription_id, + platform_update_domain=platform_update_domain, + zone=zone, + placement_group_id=placement_group_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RecoveryWalkResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @distributed_trace_async - async def get(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> _models.Snapshot: - """Gets information about a snapshot. + 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 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.v2020_05_01.models.Snapshot + :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.models.VirtualMachineScaleSetInstanceView :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1505,12 +1807,12 @@ async def get(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) - cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetInstanceView] = kwargs.pop("cls", None) - _request = build_snapshots_get_request( + _request = build_get_instance_view_request( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1529,15 +1831,19 @@ async def get(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Snapshot", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineScaleSetInstanceView", 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, snapshot_name: str, **kwargs: Any + async def _update_instances_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1547,17 +1853,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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_snapshots_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_update_instances_request( resource_group_name=resource_group_name, - snapshot_name=snapshot_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, ) @@ -1571,7 +1889,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): @@ -1579,40 +1897,113 @@ 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_update_instances( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.models.VirtualMachineScaleSetVMInstanceRequiredIDs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_instances( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. + Required. + :type vm_instance_i_ds: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_delete(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes a snapshot. + async def begin_update_instances( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - :param resource_group_name: The name of the resource group. Required. + :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 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.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 = 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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) 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._update_instances_initial( resource_group_name=resource_group_name, - snapshot_name=snapshot_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, @@ -1626,7 +2017,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: @@ -1641,21 +2034,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) -> AsyncItemPaged["_models.Snapshot"]: - """Lists snapshots under a resource group. + def get_os_upgrade_history( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either Snapshot 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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_05_01.models.Snapshot] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.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 "2020-05-01")) - cls: ClsType[_models.SnapshotList] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1668,8 +2067,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_snapshots_list_by_resource_group_request( + _request = build_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, @@ -1678,24 +2078,13 @@ def prepare_request(next_link=None): _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 = HttpRequest("GET", next_link) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("SnapshotList", pipeline_response) + deserialized = self._deserialize("VirtualMachineScaleSetListOSUpgradeHistory", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -1718,21 +2107,13 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Snapshot"]: - """Lists snapshots under a subscription. - - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_05_01.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 "2020-05-01")) - cls: ClsType[_models.SnapshotList] = kwargs.pop("cls", None) - + async def _perform_maintenance_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1741,63 +2122,204 @@ def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Snapshot"]: } 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_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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds + else: + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") else: - # 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 + _json = None - 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) + _request = build_perform_maintenance_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 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, 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) - return pipeline_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")) - 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_perform_maintenance( + 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]: + """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. The name is case insensitive. + Required. + :type 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.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_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 + ) -> 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. The name is case insensitive. + Required. + :type 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_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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._perform_maintenance_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + vm_instance_i_ds=vm_instance_i_ds, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - async def _grant_access_initial( + 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, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], + vm_scale_set_name: str, + skip_shutdown: Optional[bool] = None, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -1811,22 +2333,26 @@ async def _grant_access_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(grant_access_data, (IOBase, bytes)): - _content = grant_access_data + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_snapshots_grant_access_request( + _request = build_power_off_request( resource_group_name=resource_group_name, - snapshot_name=snapshot_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, @@ -1852,111 +2378,133 @@ 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_power_off( self, resource_group_name: str, - snapshot_name: str, - grant_access_data: _models.GrantAccessData, + vm_scale_set_name: str, + skip_shutdown: Optional[bool] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. + ) -> 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 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 - operation. Required. - :type grant_access_data: ~azure.mgmt.compute.v2020_05_01.models.GrantAccessData + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param 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. + :type 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.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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.AccessUri] + :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_grant_access( + async def begin_power_off( self, resource_group_name: str, - snapshot_name: str, - grant_access_data: IO[bytes], + vm_scale_set_name: str, + skip_shutdown: Optional[bool] = None, + vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. + ) -> 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 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 - operation. Required. - :type grant_access_data: IO[bytes] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param 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. + :type 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: IO[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.v2020_05_01.models.AccessUri] + :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_grant_access( + async def begin_power_off( self, resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], + vm_scale_set_name: str, + skip_shutdown: Optional[bool] = None, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. + ) -> 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 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 - operation. Is either a GrantAccessData type or a IO[bytes] type. Required. - :type grant_access_data: ~azure.mgmt.compute.v2020_05_01.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.v2020_05_01.models.AccessUri] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param 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. + :type skip_shutdown: bool + :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.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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessUri] = 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._grant_access_initial( + raw_result = await self._power_off_initial( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - grant_access_data=grant_access_data, + vm_scale_set_name=vm_scale_set_name, + skip_shutdown=skip_shutdown, + vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1967,11 +2515,9 @@ async def begin_grant_access( 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) + 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( @@ -1982,18 +2528,16 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.AccessUri].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.AccessUri]( - 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 _revoke_access_initial( - self, resource_group_name: str, snapshot_name: str, **kwargs: Any + async def _reapply_initial( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2006,12 +2550,12 @@ async def _revoke_access_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_snapshots_revoke_access_request( + _request = build_reapply_request( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2035,25 +2579,30 @@ 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 + async def begin_reapply( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Revokes access to a snapshot. + """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 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 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: @@ -2061,15 +2610,15 @@ async def begin_revoke_access( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._revoke_access_initial( + raw_result = await self._reapply_initial( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, + vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -2100,32 +2649,11 @@ 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 DiskEncryptionSetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_05_01.aio.ComputeManagementClient`'s - :attr:`disk_encryption_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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( + async def _redeploy_initial( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, 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 = { @@ -2139,21 +2667,24 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_disk_encryption_sets_create_or_update_request( + _request = build_redeploy_request( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2180,115 +2711,114 @@ 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_redeploy( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSet, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. + ) -> 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 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.v2020_05_01.models.DiskEncryptionSet + :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.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 DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSet] + :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_redeploy( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. + ) -> 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 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 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 DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSet] + :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_redeploy( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. + ) -> 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 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.v2020_05_01.models.DiskEncryptionSet 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.models.VirtualMachineScaleSetVMInstanceIDs 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.v2020_05_01.models.DiskEncryptionSet] + :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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._redeploy_initial( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - disk_encryption_set=disk_encryption_set, + 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, @@ -2299,34 +2829,32 @@ async def begin_create_or_update( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSet", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.DiskEncryptionSet].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.DiskEncryptionSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _update_initial( + async def _reimage_initial( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSetUpdate, IO[bytes]], + vm_scale_set_name: str, + vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -2340,21 +2868,24 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set + if isinstance(vm_scale_set_reimage_input, (IOBase, bytes)): + _content = vm_scale_set_reimage_input else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSetUpdate") + if vm_scale_set_reimage_input is not None: + _json = self._serialize.body(vm_scale_set_reimage_input, "VirtualMachineScaleSetReimageParameters") + else: + _json = None - _request = build_disk_encryption_sets_update_request( + _request = build_reimage_request( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2381,116 +2912,116 @@ 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_reimage( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSetUpdate, + vm_scale_set_name: str, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Updates (patches) a disk encryption set. + ) -> AsyncLROPoller[None]: + """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which + don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual + machine is reset to initial state. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param 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.v2020_05_01.models.DiskEncryptionSetUpdate + :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.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 DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSet] + :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_reimage( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], + vm_scale_set_name: str, + vm_scale_set_reimage_input: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Updates (patches) a disk encryption set. + ) -> AsyncLROPoller[None]: + """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which + don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual + machine is reset to initial state. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param 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 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 DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSet] + :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_reimage( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSetUpdate, IO[bytes]], + vm_scale_set_name: str, + vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Updates (patches) a disk encryption set. + ) -> 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 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.v2020_05_01.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.v2020_05_01.models.DiskEncryptionSet] + :type 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.models.VirtualMachineScaleSetReimageParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._reimage_initial( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - disk_encryption_set=disk_encryption_set, + 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, @@ -2501,45 +3032,34 @@ 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("DiskEncryptionSet", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.DiskEncryptionSet].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.DiskEncryptionSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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. + 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 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.v2020_05_01.models.DiskEncryptionSet - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _reimage_all_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2548,42 +3068,198 @@ 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 "2020-05-01")) - cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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_disk_encryption_sets_get_request( + _request = build_reimage_all_request( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_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("DiskEncryptionSet", 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_encryption_set_name: str, **kwargs: Any + @overload + async def begin_reimage_all( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This + operation is only supported for managed disks. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.models.VirtualMachineScaleSetVMInstanceIDs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_reimage_all( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This + operation is only supported for managed disks. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_reimage_all( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This + operation is only supported for managed disks. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._reimage_all_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + vm_instance_i_ds=vm_instance_i_ds, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, 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, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2593,17 +3269,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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_disk_encryption_sets_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_restart_request( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_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, ) @@ -2617,7 +3308,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): @@ -2625,42 +3316,113 @@ 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_restart( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts one or more virtual machines in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.models.VirtualMachineScaleSetVMInstanceIDs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restart( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts one or more virtual machines in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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, disk_encryption_set_name: str, **kwargs: Any + async def begin_restart( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes a disk encryption set. + """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 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 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.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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) 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._restart_initial( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_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, @@ -2674,7 +3436,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: @@ -2688,187 +3452,11 @@ 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 - ) -> AsyncItemPaged["_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.v2020_05_01.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 "2020-05-01")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2020_05_01.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 "2020-05-01")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class DiskAccessesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_05_01.aio.ComputeManagementClient`'s - :attr:`disk_accesses` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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( + async def _set_orchestration_service_state_initial( self, resource_group_name: str, - disk_access_name: str, - disk_access: Union[_models.DiskAccess, IO[bytes]], + vm_scale_set_name: str, + parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -2882,21 +3470,21 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - _json = self._serialize.body(disk_access, "DiskAccess") + _json = self._serialize.body(parameters, "OrchestrationServiceStateInput") - _request = build_disk_accesses_create_or_update_request( + _request = build_set_orchestration_service_state_request( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2923,111 +3511,108 @@ 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_set_orchestration_service_state( self, resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccess, + vm_scale_set_name: str, + parameters: _models.OrchestrationServiceStateInput, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. + ) -> 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 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.v2020_05_01.models.DiskAccess + :type 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.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 DiskAccess or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskAccess] + :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_set_orchestration_service_state( self, resource_group_name: str, - disk_access_name: str, - disk_access: IO[bytes], + vm_scale_set_name: str, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. + ) -> 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 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: 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 AsyncLROPoller that returns either DiskAccess or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskAccess] + :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_set_orchestration_service_state( self, resource_group_name: str, - disk_access_name: str, - disk_access: Union[_models.DiskAccess, IO[bytes]], + vm_scale_set_name: str, + parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. + ) -> 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 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.v2020_05_01.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.v2020_05_01.models.DiskAccess] + :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.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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiskAccess] = 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._set_orchestration_service_state_initial( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - disk_access=disk_access, + vm_scale_set_name=vm_scale_set_name, + parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -3038,34 +3623,107 @@ 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("DiskAccess", 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.DiskAccess].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.DiskAccess]( - 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( + @distributed_trace + def list_skus( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> AsyncItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetListSkusResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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, - disk_access_name: str, - disk_access: Union[_models.DiskAccessUpdate, 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 = { @@ -3079,21 +3737,24 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(disk_access, "DiskAccessUpdate") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_disk_accesses_update_request( + _request = build_start_request( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3120,111 +3781,111 @@ 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_start( self, resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccessUpdate, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. + ) -> 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 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.v2020_05_01.models.DiskAccessUpdate + :type 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.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 DiskAccess or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskAccess] + :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_start( self, resource_group_name: str, - disk_access_name: str, - disk_access: IO[bytes], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. + ) -> 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 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 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 DiskAccess or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskAccess] + :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_start( self, resource_group_name: str, - disk_access_name: str, - disk_access: Union[_models.DiskAccessUpdate, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. + ) -> AsyncLROPoller[None]: + """Starts one or more virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param 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.v2020_05_01.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.v2020_05_01.models.DiskAccess] + :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.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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiskAccess] = 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._start_initial( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - disk_access=disk_access, + 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, @@ -3235,398 +3896,23 @@ 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("DiskAccess", 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.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 - ) - - @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.v2020_05_01.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 "2020-05-01")) - 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 - ) -> 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 "2020-05-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disk_accesses_delete_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) - - _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_access_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes 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 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 "2020-05-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, - 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: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].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[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) -> AsyncItemPaged["_models.DiskAccess"]: - """Lists all the disk access resources 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 DiskAccess or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_05_01.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 "2020-05-01")) - 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 - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2020_05_01.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 "2020-05-01")) - 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_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. 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.v2020_05_01.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 "2020-05-01")) - 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_sizes_operations.py new file mode 100644 index 000000000000..5b783e991900 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machine_sizes_operations.py @@ -0,0 +1,120 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._virtual_machine_sizes_operations import build_list_request +from .._configuration import ComputeManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, location: str, **kwargs: Any) -> AsyncItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machines_operations.py similarity index 56% rename from sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/operations/_operations.py rename to sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machines_operations.py index 00db2b7d04a6..2c8cc0d75a29 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/operations/_virtual_machines_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -9,7 +9,6 @@ from collections.abc import MutableMapping from io import IOBase from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -34,37 +33,34 @@ from ... import models as _models from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import ( - build_cloud_service_operating_systems_get_os_family_request, - build_cloud_service_operating_systems_get_os_version_request, - build_cloud_service_operating_systems_list_os_families_request, - build_cloud_service_operating_systems_list_os_versions_request, - build_cloud_service_role_instances_delete_request, - build_cloud_service_role_instances_get_instance_view_request, - build_cloud_service_role_instances_get_remote_desktop_file_request, - build_cloud_service_role_instances_get_request, - build_cloud_service_role_instances_list_request, - build_cloud_service_role_instances_rebuild_request, - build_cloud_service_role_instances_reimage_request, - build_cloud_service_role_instances_restart_request, - build_cloud_service_roles_get_request, - build_cloud_service_roles_list_request, - build_cloud_services_create_or_update_request, - build_cloud_services_delete_instances_request, - build_cloud_services_delete_request, - build_cloud_services_get_instance_view_request, - build_cloud_services_get_request, - build_cloud_services_list_all_request, - build_cloud_services_list_request, - build_cloud_services_power_off_request, - build_cloud_services_rebuild_request, - build_cloud_services_reimage_request, - build_cloud_services_restart_request, - build_cloud_services_start_request, - build_cloud_services_update_domain_get_update_domain_request, - build_cloud_services_update_domain_list_update_domains_request, - build_cloud_services_update_domain_walk_update_domain_request, - build_cloud_services_update_request, +from ...operations._virtual_machines_operations import ( + build_assess_patches_request, + build_attach_detach_data_disks_request, + build_capture_request, + build_convert_to_managed_disks_request, + build_create_or_update_request, + build_deallocate_request, + build_delete_request, + build_generalize_request, + build_get_request, + build_install_patches_request, + build_instance_view_request, + build_list_all_request, + build_list_available_sizes_request, + build_list_by_location_request, + build_list_request, + build_migrate_to_vm_scale_set_request, + build_perform_maintenance_request, + build_power_off_request, + build_reapply_request, + build_redeploy_request, + build_reimage_request, + build_restart_request, + build_retrieve_boot_diagnostics_data_request, + build_run_command_request, + build_simulate_eviction_request, + build_start_request, + build_update_request, ) from .._configuration import ComputeManagementClientConfiguration @@ -72,14 +68,14 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CloudServiceRoleInstancesOperations: +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.v2022_09_04.aio.ComputeManagementClient`'s - :attr:`cloud_service_role_instances` attribute. + :class:`~azure.mgmt.compute.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models @@ -90,141 +86,23 @@ def __init__(self, *args, **kwargs) -> None: self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = 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 _delete_initial( - self, role_instance_name: str, resource_group_name: str, cloud_service_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 "2022-09-04")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cloud_service_role_instances_delete_request( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a role instance from a cloud service. + @distributed_trace + def list_by_location(self, location: str, **kwargs: Any) -> AsyncItemPaged["_models.VirtualMachine"]: + """Gets all the virtual machines under the specified subscription for the specified location. - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_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 + :return: An iterator like instance of either VirtualMachine or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.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 "2022-09-04")) - 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( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, - role_instance_name: str, - resource_group_name: str, - cloud_service_name: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any - ) -> _models.RoleInstance: - """Gets a role instance from a cloud service. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :keyword expand: The expand expression to apply to the operation. 'UserData' is not supported - for cloud services. Known values are: "instanceView" and "userData". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2022_09_04.models.InstanceViewTypes - :return: RoleInstance or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_09_04.models.RoleInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -233,58 +111,81 @@ 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 "2022-09-04")) - cls: ClsType[_models.RoleInstance] = kwargs.pop("cls", None) + _request = build_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) - _request = build_cloud_service_role_instances_get_request( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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: + _request = HttpRequest("GET", next_link) + _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("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]: - 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("RoleInstance", pipeline_response.http_response) + if response.status_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 get_instance_view( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> _models.RoleInstanceView: - """Retrieves information about the run-time state of a role instance in a cloud service. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: RoleInstanceView or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_09_04.models.RoleInstanceView + @distributed_trace + def list_all( + self, + status_only: Optional[str] = None, + filter: Optional[str] = None, + expand: Optional[Union[str, _models.ExpandTypesForListVMs]] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.VirtualMachine"]: + """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 status_only: statusOnly=true enables fetching run time status of all Virtual Machines in + the subscription. Default value is None. + :type status_only: str + :param 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. + :type filter: str + :param 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. + :type expand: str or ~azure.mgmt.compute.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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -293,71 +194,82 @@ async def get_instance_view( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) - cls: ClsType[_models.RoleInstanceView] = kwargs.pop("cls", None) + _request = build_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_cloud_service_role_instances_get_instance_view_request( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + else: + _request = HttpRequest("GET", next_link) + _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("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]: - 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("RoleInstanceView", pipeline_response.http_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return AsyncItemPaged(get_next, extract_data) @distributed_trace def list( self, resource_group_name: str, - cloud_service_name: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + filter: Optional[str] = None, + expand: Optional[Union[str, _models.ExpandTypeForListVMs]] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.RoleInstance"]: - """Gets the list of all role instances in a cloud service. Use nextLink property in the response - to get the next page of role instances. Do this till nextLink is null to fetch all the role - instances. + ) -> AsyncItemPaged["_models.VirtualMachine"]: + """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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :keyword expand: The expand expression to apply to the operation. 'UserData' is not supported - for cloud services. Known values are: "instanceView" and "userData". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2022_09_04.models.InstanceViewTypes - :return: An iterator like instance of either RoleInstance or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_09_04.models.RoleInstance] + :param 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. + :type filter: str + :param 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. + :type expand: str or ~azure.mgmt.compute.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.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 "2022-09-04")) - cls: ClsType[_models.RoleInstanceListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -370,10 +282,10 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_cloud_service_role_instances_list_request( + _request = build_list_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, subscription_id=self._config.subscription_id, + filter=filter, expand=expand, api_version=api_version, headers=_headers, @@ -382,24 +294,13 @@ def prepare_request(next_link=None): _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 = HttpRequest("GET", next_link) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleInstanceListResult", pipeline_response) + deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -422,9 +323,31 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - async def _restart_initial( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: + @distributed_trace_async + async def get( + self, + resource_group_name: str, + vm_name: str, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any + ) -> _models.VirtualMachine: + """Retrieves information about the model view or the instance view of a virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param expand: The expand expression to apply on the operation. 'InstanceView' retrieves a + snapshot of the runtime properties of the virtual machine that is managed by the platform and + can change outside of control plane operations. 'UserData' retrieves the UserData property as + part of the VM model view that was provided by the user during the VM Create/Update operation. + Known values are: "instanceView", "userData", and "resiliencyView". Default value is None. + :type expand: str or ~azure.mgmt.compute.models.InstanceViewTypes + :return: VirtualMachine or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.VirtualMachine + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -436,74 +359,243 @@ async def _restart_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) - _request = build_cloud_service_role_instances_restart_request( - role_instance_name=role_instance_name, + _request = build_get_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def begin_restart( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The Reboot Role Instance asynchronous operation requests a reboot of a role instance in the - cloud service. + 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 {}) - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_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 {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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_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.models.VirtualMachine + :param 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. + :type if_match: str + :param 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. + :type 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.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + + @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] + :param 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. + :type if_match: str + :param 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. + :type 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.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.models.VirtualMachine or IO[bytes] + :param 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. + :type if_match: str + :param 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. + :type 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.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 "2022-09-04")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._restart_initial( - role_instance_name=role_instance_name, + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, @@ -512,27 +604,39 @@ async def begin_restart( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[None].from_continuation_token( + return AsyncLROPoller[_models.VirtualMachine].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[_models.VirtualMachine]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _reimage_initial( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + 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, @@ -542,18 +646,31 @@ async def _reimage_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 "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_cloud_service_role_instances_reimage_request( - role_instance_name=role_instance_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, "VirtualMachineUpdate") + + _request = build_update_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, ) @@ -567,7 +684,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]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -575,44 +692,144 @@ 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 = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + vm_name: str, + parameters: _models.VirtualMachineUpdate, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachine]: + """The operation to update a virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Update Virtual Machine operation. Required. + :type parameters: ~azure.mgmt.compute.models.VirtualMachineUpdate + :param 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. + :type if_match: str + :param 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. + :type 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.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] + :param 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. + :type if_match: str + :param 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. + :type 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.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_reimage( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The Reimage Role Instance asynchronous operation reinstalls the operating system on instances - of web roles or worker roles. + 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 role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param vm_name: The name of the 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.models.VirtualMachineUpdate or IO[bytes] + :param 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. + :type if_match: str + :param 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. + :type 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.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 "2022-09-04")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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._reimage_initial( - role_instance_name=role_instance_name, + raw_result = await self._update_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, @@ -621,27 +838,38 @@ async def begin_reimage( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[None].from_continuation_token( + return AsyncLROPoller[_models.VirtualMachine].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[_models.VirtualMachine]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _rebuild_initial( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + 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, @@ -654,14 +882,14 @@ async def _rebuild_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_cloud_service_role_instances_rebuild_request( - role_instance_name=role_instance_name, + _request = build_delete_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, + force_deletion=force_deletion, api_version=api_version, headers=_headers, params=_params, @@ -676,7 +904,7 @@ async def _rebuild_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): @@ -684,27 +912,32 @@ async def _rebuild_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_rebuild( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + async def begin_delete( + self, resource_group_name: str, vm_name: str, force_deletion: Optional[bool] = None, **kwargs: Any ) -> AsyncLROPoller[None]: - """The Rebuild Role Instance asynchronous operation reinstalls the operating system on instances - of web roles or worker roles and initializes the storage resources that are used by them. If - you do not want to initialize storage resources, you can use Reimage Role Instance. + """The operation to delete a virtual machine. - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param force_deletion: Optional parameter to force delete virtual machines. Default value is + None. + :type 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: @@ -712,16 +945,16 @@ async def begin_rebuild( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._rebuild_initial( - role_instance_name=role_instance_name, + raw_result = await self._delete_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, + force_deletion=force_deletion, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -736,7 +969,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: @@ -750,22 +985,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_remote_desktop_file( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + async def _assess_patches_initial( + self, resource_group_name: str, vm_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - """Gets a remote desktop file for a role instance in a cloud service. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: AsyncIterator[bytes] or the result of cls(response) - :rtype: AsyncIterator[bytes] - :raises ~azure.core.exceptions.HttpResponseError: - """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -777,13 +999,12 @@ async def get_remote_desktop_file( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_cloud_service_role_instances_get_remote_desktop_file_request( - role_instance_name=role_instance_name, + _request = build_assess_patches_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -799,7 +1020,7 @@ async def get_remote_desktop_file( 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): @@ -807,115 +1028,289 @@ async def get_remote_desktop_file( map_error(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 - -class CloudServiceRolesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_09_04.aio.ComputeManagementClient`'s - :attr:`cloud_service_roles` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, role_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> _models.CloudServiceRole: - """Gets a role from a cloud service. + async def begin_assess_patches( + self, resource_group_name: str, vm_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineAssessPatchesResult]: + """Assess patches on the VM. - :param role_name: Name of the role. Required. - :type role_name: str - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: CloudServiceRole or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceRole + :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.models.VirtualMachineAssessPatchesResult] :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 "2022-09-04")) - cls: ClsType[_models.CloudServiceRole] = kwargs.pop("cls", None) - - _request = build_cloud_service_roles_get_request( - role_name=role_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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", "2024-11-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 + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - _stream = False + 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 + + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AttachDetachDataDisksRequest") + + _request = build_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]: + 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("CloudServiceRole", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def list( - self, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.CloudServiceRole"]: - """Gets a list of all roles in a cloud service. Use nextLink property in the response to get the - next page of roles. Do this till nextLink is null to fetch all the roles. + @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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An iterator like instance of either CloudServiceRole or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_09_04.models.CloudServiceRole] + :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.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.models.StorageProfile] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + + @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. 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.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. + + :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.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.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 "2022-09-04")) - cls: ClsType[_models.CloudServiceRoleListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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, @@ -924,87 +1319,198 @@ def list( } 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_cloud_service_roles_list_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualMachineCaptureParameters") - async def extract_data(pipeline_response): - deserialized = self._deserialize("CloudServiceRoleListResult", 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_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 + ) - _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, 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) - return pipeline_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")) - 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 -class CloudServicesOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. + return deserialized # type: ignore - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_09_04.aio.ComputeManagementClient`'s - :attr:`cloud_services` attribute. - """ + @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. - 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_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.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.models.VirtualMachineCaptureResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_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. - async def _create_or_update_initial( + :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.models.VirtualMachineCaptureResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_capture( self, resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.CloudService, IO[bytes]]] = None, + 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.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.models.VirtualMachineCaptureResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineCaptureResult] = kwargs.pop("cls", None) + polling: Union[bool, 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 + ) + 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) + 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.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 _convert_to_managed_disks_initial( + self, resource_group_name: str, vm_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1014,32 +1520,17 @@ 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 "2022-09-04")) - 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, "CloudService") - else: - _json = None + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_cloud_services_create_or_update_request( + _request = build_convert_to_managed_disks_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, ) @@ -1053,7 +1544,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): @@ -1061,108 +1552,47 @@ 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, - cloud_service_name: str, - parameters: Optional[_models.CloudService] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CloudService]: - """Create or update a cloud service. Please note some properties can be set only during cloud - service creation. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.CloudService - :keyword content_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 CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_09_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CloudService]: - """Create or update a cloud service. Please note some properties can be set only during cloud - service creation. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. 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 CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_09_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.CloudService, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.CloudService]: - """Create or update a cloud service. Please note some properties can be set only during cloud - service creation. + 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. - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. Is either a CloudService type or a IO[bytes] type. - Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.CloudService or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_09_04.models.CloudService] + :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 = 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 "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CloudService] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._convert_to_managed_disks_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - parameters=parameters, + vm_name=vm_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -1171,35 +1601,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("CloudService", 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.CloudService].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.CloudService]( - 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, - cloud_service_name: str, - parameters: Optional[Union[_models.CloudServiceUpdate, IO[bytes]]] = None, - **kwargs: Any + 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, @@ -1209,32 +1633,18 @@ 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 "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) 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, "CloudServiceUpdate") - else: - _json = None - - _request = build_cloud_services_update_request( + _request = build_deallocate_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, + hibernate=hibernate, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -1248,7 +1658,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): @@ -1256,105 +1666,50 @@ 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, - cloud_service_name: str, - parameters: Optional[_models.CloudServiceUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CloudService]: - """Update a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceUpdate - :keyword content_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 CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_09_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CloudService]: - """Update a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. 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 CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_09_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.CloudServiceUpdate, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.CloudService]: - """Update a cloud service. + 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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. Is either a CloudServiceUpdate type or a IO[bytes] - type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_09_04.models.CloudService] + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param hibernate: Optional parameter to hibernate a virtual machine. Default value is None. + :type hibernate: bool + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CloudService] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._deallocate_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - parameters=parameters, + vm_name=vm_name, + hibernate=hibernate, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -1363,31 +1718,89 @@ 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("CloudService", 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.CloudService].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.CloudService]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def generalize(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> None: + """Sets the OS state of the virtual machine to generalized. It is recommended to sysprep the + virtual machine before performing this operation. For Windows, please refer to `Create a + managed image of a generalized VM in Azure + `_. For + Linux, please refer to `How to create an image of a virtual machine or VHD + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_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 ) - async def _delete_initial( - self, resource_group_name: str, cloud_service_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) + + 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, @@ -1397,17 +1810,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 "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_cloud_services_delete_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_install_patches_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, ) @@ -1421,7 +1846,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): @@ -1429,40 +1854,119 @@ 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_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.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.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.models.VirtualMachineInstallPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a cloud service. + 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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param vm_name: The name of the 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.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.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 "2022-09-04")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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._delete_initial( + raw_result = await self._install_patches_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, @@ -1471,35 +1975,44 @@ 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("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 + ) @distributed_trace_async - async def get(self, resource_group_name: str, cloud_service_name: str, **kwargs: Any) -> _models.CloudService: - """Display information about a cloud service. + 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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: CloudService or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_09_04.models.CloudService + :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.models.VirtualMachineInstanceView :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1513,12 +2026,12 @@ async def get(self, resource_group_name: str, cloud_service_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) - cls: ClsType[_models.CloudService] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) - _request = build_cloud_services_get_request( + _request = build_instance_view_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1537,27 +2050,20 @@ async def get(self, resource_group_name: str, cloud_service_name: str, **kwargs: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("CloudService", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineInstanceView", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def get_instance_view( - self, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> _models.CloudServiceInstanceView: - """Gets the status of a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: CloudServiceInstanceView or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceInstanceView - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _migrate_to_vm_scale_set_initial( + self, + resource_group_name: str, + vm_name: str, + parameters: Optional[Union[_models.MigrateVMToVirtualMachineScaleSetInput, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1566,199 +2072,190 @@ async def get_instance_view( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) - cls: ClsType[_models.CloudServiceInstanceView] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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, "MigrateVMToVirtualMachineScaleSetInput") + else: + _json = None - _request = build_cloud_services_get_instance_view_request( + _request = build_migrate_to_vm_scale_set_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [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("CloudServiceInstanceView", 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_all(self, **kwargs: Any) -> AsyncItemPaged["_models.CloudService"]: - """Gets a list of all cloud services in the subscription, regardless of the associated resource - group. Use nextLink property in the response to get the next page of Cloud Services. Do this - till nextLink is null to fetch all the Cloud Services. + @overload + async def begin_migrate_to_vm_scale_set( + self, + resource_group_name: str, + vm_name: str, + parameters: Optional[_models.MigrateVMToVirtualMachineScaleSetInput] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. - :return: An iterator like instance of either CloudService or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_09_04.models.CloudService] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Migrate Virtual Machine operation. Default value + is None. + :type parameters: ~azure.mgmt.compute.models.MigrateVMToVirtualMachineScaleSetInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of 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 "2022-09-04")) - cls: ClsType[_models.CloudServiceListResult] = 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_cloud_services_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("CloudServiceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return pipeline_response + @overload + async def begin_migrate_to_vm_scale_set( + self, + resource_group_name: str, + vm_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. - return AsyncItemPaged(get_next, extract_data) + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Migrate Virtual Machine operation. Default value + is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of 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(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.CloudService"]: - """Gets a list of all cloud services under a resource group. Use nextLink property in the response - to get the next page of Cloud Services. Do this till nextLink is null to fetch all the Cloud - Services. + @distributed_trace_async + async def begin_migrate_to_vm_scale_set( + self, + resource_group_name: str, + vm_name: str, + parameters: Optional[Union[_models.MigrateVMToVirtualMachineScaleSetInput, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. - :param resource_group_name: Name of the 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 CloudService or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_09_04.models.CloudService] + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Migrate Virtual Machine operation. Is either a + MigrateVMToVirtualMachineScaleSetInput type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.models.MigrateVMToVirtualMachineScaleSetInput 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 "2022-09-04")) - cls: ClsType[_models.CloudServiceListResult] = 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_cloud_services_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 + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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._migrate_to_vm_scale_set_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - async def extract_data(pipeline_response): - deserialized = self._deserialize("CloudServiceListResult", 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 _start_initial( - self, resource_group_name: str, cloud_service_name: str, **kwargs: Any + async def _perform_maintenance_initial( + self, resource_group_name: str, vm_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1771,12 +2268,12 @@ async def _start_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_cloud_services_start_request( + _request = build_perform_maintenance_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1800,23 +2297,29 @@ 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, cloud_service_name: str, **kwargs: Any + async def begin_perform_maintenance( + self, resource_group_name: str, vm_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Starts the cloud service. + """The operation to perform maintenance on a virtual machine. - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_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: @@ -1824,15 +2327,15 @@ async def begin_start( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._perform_maintenance_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -1847,7 +2350,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: @@ -1862,7 +2367,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 async def _power_off_initial( - self, resource_group_name: str, cloud_service_name: str, **kwargs: Any + self, resource_group_name: str, vm_name: str, skip_shutdown: Optional[bool] = None, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1875,13 +2380,14 @@ async def _power_off_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_cloud_services_power_off_request( + _request = build_power_off_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, + skip_shutdown=skip_shutdown, api_version=api_version, headers=_headers, params=_params, @@ -1904,24 +2410,34 @@ 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, cloud_service_name: str, **kwargs: Any + self, resource_group_name: str, vm_name: str, skip_shutdown: Optional[bool] = None, **kwargs: Any ) -> AsyncLROPoller[None]: - """Power off the cloud service. Note that resources are still attached and you are getting charged - for the resources. + """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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param 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. + :type 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: @@ -1929,7 +2445,7 @@ async def begin_power_off( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1937,7 +2453,8 @@ async def begin_power_off( if cont_token is None: raw_result = await self._power_off_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, + skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -1952,7 +2469,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: @@ -1966,13 +2485,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 - async def _restart_initial( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **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, @@ -1981,32 +2494,17 @@ async def _restart_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 "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) 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, "RoleInstances") - else: - _json = None - - _request = build_cloud_services_restart_request( + _request = build_reapply_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, ) @@ -2025,105 +2523,47 @@ async def _restart_initial( 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_restart( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[_models.RoleInstances] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more role instances in a cloud service. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.RoleInstances - :keyword content_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: - """ + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - @overload - async def begin_restart( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more role instances in a cloud service. + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. 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: - """ + if cls: + 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, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more role instances in a cloud service. + 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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Is either a RoleInstances type or - a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.RoleInstances or IO[bytes] + :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 = 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 "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._restart_initial( + raw_result = await self._reapply_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - parameters=parameters, + vm_name=vm_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -2137,7 +2577,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: @@ -2151,13 +2593,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 - async def _reimage_initial( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **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, @@ -2166,32 +2602,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 "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) 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, "RoleInstances") - else: - _json = None - - _request = build_cloud_services_reimage_request( + _request = build_redeploy_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, ) @@ -2213,105 +2634,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, - cloud_service_name: str, - parameters: Optional[_models.RoleInstances] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimage asynchronous operation reinstalls the operating system on instances of web roles or - worker roles. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.RoleInstances - :keyword content_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, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimage asynchronous operation reinstalls the operating system on instances of web roles or - worker roles. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def begin_reimage( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimage asynchronous operation reinstalls the operating system on instances of web roles or - worker roles. + 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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Is either a RoleInstances type or - a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.RoleInstances or IO[bytes] + :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 = 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 "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._reimage_initial( + raw_result = await self._redeploy_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - parameters=parameters, + vm_name=vm_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -2325,7 +2685,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: @@ -2339,11 +2701,11 @@ 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 _rebuild_initial( + async def _reimage_initial( self, resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, + vm_name: str, + parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -2357,7 +2719,7 @@ async def _rebuild_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) @@ -2368,13 +2730,13 @@ async def _rebuild_initial( _content = parameters else: if parameters is not None: - _json = self._serialize.body(parameters, "RoleInstances") + _json = self._serialize.body(parameters, "VirtualMachineReimageParameters") else: _json = None - _request = build_cloud_services_rebuild_request( + _request = build_reimage_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2401,33 +2763,43 @@ async def _rebuild_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_rebuild( + async def begin_reimage( self, resource_group_name: str, - cloud_service_name: str, - parameters: Optional[_models.RoleInstances] = None, + vm_name: str, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: - """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker - roles and initializes the storage resources that are used by them. If you do not want to - initialize storage resources, you can use Reimage Role Instances. - - :param resource_group_name: Name of the resource group. Required. + """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, + for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial + state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If + deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is + delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should + be updated accordingly before performing the reimage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.RoleInstances + :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.models.VirtualMachineReimageParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2437,24 +2809,29 @@ async def begin_rebuild( """ @overload - async def begin_rebuild( + async def begin_reimage( self, resource_group_name: str, - cloud_service_name: str, + vm_name: str, parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: - """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker - roles and initializes the storage resources that are used by them. If you do not want to - initialize storage resources, you can use Reimage Role Instances. - - :param resource_group_name: Name of the resource group. Required. + """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, + for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial + state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If + deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is + delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should + be updated accordingly before performing the reimage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. + :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". @@ -2465,24 +2842,28 @@ async def begin_rebuild( """ @distributed_trace_async - async def begin_rebuild( + async def begin_reimage( self, resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, + vm_name: str, + parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, **kwargs: Any ) -> AsyncLROPoller[None]: - """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker - roles and initializes the storage resources that are used by them. If you do not want to - initialize storage resources, you can use Reimage Role Instances. - - :param resource_group_name: Name of the resource group. Required. + """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, + for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial + state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If + deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is + delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should + be updated accordingly before performing the reimage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Is either a RoleInstances type or - a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.RoleInstances or IO[bytes] + :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.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: @@ -2490,16 +2871,16 @@ async def begin_rebuild( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) 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._rebuild_initial( + raw_result = await self._reimage_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, parameters=parameters, api_version=api_version, content_type=content_type, @@ -2516,7 +2897,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: @@ -2530,13 +2913,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 - async def _delete_instances_initial( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **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, @@ -2545,32 +2922,17 @@ async 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 "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) 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, "RoleInstances") - else: - _json = None - - _request = build_cloud_services_delete_instances_request( + _request = build_restart_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, ) @@ -2592,102 +2954,44 @@ async def _delete_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 == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, 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, - cloud_service_name: str, - parameters: Optional[_models.RoleInstances] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes role instances in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.RoleInstances - :keyword content_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, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes role instances in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def begin_delete_instances( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes role instances in a cloud service. + 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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Is either a RoleInstances type or - a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.RoleInstances or IO[bytes] + :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 = 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 "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._restart_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - parameters=parameters, + vm_name=vm_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -2701,7 +3005,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: @@ -2715,33 +3021,77 @@ 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. -class CloudServicesUpdateDomainOperations: - """ - .. 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_name: The name of the virtual machine. Required. + :type vm_name: str + :param 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. + :type sas_uri_expiration_time_in_minutes: int + :return: RetrieveBootDiagnosticsDataResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.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 {}) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_09_04.aio.ComputeManagementClient`'s - :attr:`cloud_services_update_domain` 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", "2024-11-01")) + cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_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 _walk_update_domain_initial( + async def _run_command_initial( self, resource_group_name: str, - cloud_service_name: str, - update_domain: int, - parameters: Optional[Union[_models.UpdateDomain, IO[bytes]]] = None, + vm_name: str, + parameters: Union[_models.RunCommandInput, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -2755,7 +3105,7 @@ async def _walk_update_domain_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) @@ -2765,15 +3115,11 @@ async def _walk_update_domain_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - if parameters is not None: - _json = self._serialize.body(parameters, "UpdateDomain") - else: - _json = None + _json = self._serialize.body(parameters, "RunCommandInput") - _request = build_cloud_services_update_domain_walk_update_domain_request( + _request = build_run_command_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - update_domain=update_domain, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2800,115 +3146,110 @@ async def _walk_update_domain_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_walk_update_domain( + async def begin_run_command( self, resource_group_name: str, - cloud_service_name: str, - update_domain: int, - parameters: Optional[_models.UpdateDomain] = None, + vm_name: str, + parameters: _models.RunCommandInput, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Updates the role instances in the specified update domain. + ) -> AsyncLROPoller[_models.RunCommandResult]: + """Run command on the VM. - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param update_domain: Specifies an integer value that identifies the update domain. Update - domains are identified with a zero-based index: the first update domain has an ID of 0, the - second has an ID of 1, and so on. Required. - :type update_domain: int - :param parameters: The update domain object. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.UpdateDomain + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Run command operation. Required. + :type parameters: ~azure.mgmt.compute.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 None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :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.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_walk_update_domain( + async def begin_run_command( self, resource_group_name: str, - cloud_service_name: str, - update_domain: int, - parameters: Optional[IO[bytes]] = None, + vm_name: str, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Updates the role instances in the specified update domain. + ) -> AsyncLROPoller[_models.RunCommandResult]: + """Run command on the VM. - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param update_domain: Specifies an integer value that identifies the update domain. Update - domains are identified with a zero-based index: the first update domain has an ID of 0, the - second has an ID of 1, and so on. Required. - :type update_domain: int - :param parameters: The update domain object. Default value is None. + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Run command operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_walk_update_domain( + async def begin_run_command( self, resource_group_name: str, - cloud_service_name: str, - update_domain: int, - parameters: Optional[Union[_models.UpdateDomain, IO[bytes]]] = None, + vm_name: str, + parameters: Union[_models.RunCommandInput, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[None]: - """Updates the role instances in the specified update domain. + ) -> AsyncLROPoller[_models.RunCommandResult]: + """Run command on the VM. - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param update_domain: Specifies an integer value that identifies the update domain. Update - domains are identified with a zero-based index: the first update domain has an ID of 0, the - second has an ID of 1, and so on. Required. - :type update_domain: int - :param parameters: The update domain object. Is either a UpdateDomain type or a IO[bytes] type. - Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.UpdateDomain 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 vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Run command operation. Is either a + RunCommandInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.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.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = 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._walk_update_domain_initial( + raw_result = await self._run_command_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - update_domain=update_domain, + vm_name=vm_name, parameters=parameters, api_version=api_version, content_type=content_type, @@ -2920,43 +3261,42 @@ async def begin_walk_update_domain( 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("RunCommandResult", 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.RunCommandResult].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.RunCommandResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async - async def get_update_domain( - self, resource_group_name: str, cloud_service_name: str, update_domain: int, **kwargs: Any - ) -> _models.UpdateDomain: - """Gets the specified update domain of a cloud service. Use nextLink property in the response to - get the next page of update domains. Do this till nextLink is null to fetch all the update - domains. - - :param resource_group_name: Name of the resource group. Required. + async def simulate_eviction(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> None: + """The operation to simulate the eviction of spot virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param update_domain: Specifies an integer value that identifies the update domain. Update - domains are identified with a zero-based index: the first update domain has an ID of 0, the - second has an ID of 1, and so on. Required. - :type update_domain: int - :return: UpdateDomain or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_09_04.models.UpdateDomain + :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 = { @@ -2970,13 +3310,12 @@ async def get_update_domain( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) - cls: ClsType[_models.UpdateDomain] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_cloud_services_update_domain_get_update_domain_request( + _request = build_simulate_eviction_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - update_domain=update_domain, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2991,134 +3330,14 @@ async def get_update_domain( 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("UpdateDomain", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_update_domains( - self, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.UpdateDomain"]: - """Gets a list of all update domains in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An iterator like instance of either UpdateDomain or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_09_04.models.UpdateDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) - cls: ClsType[_models.UpdateDomainListResult] = 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_cloud_services_update_domain_list_update_domains_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("UpdateDomainListResult", 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 CloudServiceOperatingSystemsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_09_04.aio.ComputeManagementClient`'s - :attr:`cloud_service_operating_systems` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_os_version(self, location: str, os_version_name: str, **kwargs: Any) -> _models.OSVersion: - """Gets properties of a guest operating system version that can be specified in the XML service - configuration (.cscfg) for a cloud service. + return cls(pipeline_response, None, {}) # type: ignore - :param location: Name of the location that the OS version pertains to. Required. - :type location: str - :param os_version_name: Name of the OS version. Required. - :type os_version_name: str - :return: OSVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_09_04.models.OSVersion - :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, @@ -3130,12 +3349,12 @@ async def get_os_version(self, location: str, os_version_name: str, **kwargs: An _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) - cls: ClsType[_models.OSVersion] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_cloud_service_operating_systems_get_os_version_request( - location=location, - os_version_name=os_version_name, + _request = build_start_request( + resource_group_name=resource_group_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3143,177 +3362,110 @@ async def get_os_version(self, location: str, os_version_name: str, **kwargs: An ) _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("OSVersion", 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_os_versions(self, location: str, **kwargs: Any) -> AsyncItemPaged["_models.OSVersion"]: - """Gets a list of all guest operating system versions available to be specified in the XML service - configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the - next page of OS versions. Do this till nextLink is null to fetch all the OS versions. + @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 location: Name of the location that the OS versions pertain to. Required. - :type location: str - :return: An iterator like instance of either OSVersion or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_09_04.models.OSVersion] + :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 "2022-09-04")) - cls: ClsType[_models.OSVersionListResult] = 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_cloud_service_operating_systems_list_os_versions_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 + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._start_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - async def extract_data(pipeline_response): - deserialized = self._deserialize("OSVersionListResult", 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) - - @distributed_trace_async - async def get_os_family(self, location: str, os_family_name: str, **kwargs: Any) -> _models.OSFamily: - """Gets properties of a guest operating system family that can be specified in the XML service - configuration (.cscfg) for a cloud service. - - :param location: Name of the location that the OS family pertains to. Required. - :type location: str - :param os_family_name: Name of the OS family. Required. - :type os_family_name: str - :return: OSFamily or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_09_04.models.OSFamily - :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 "2022-09-04")) - cls: ClsType[_models.OSFamily] = kwargs.pop("cls", None) - - _request = build_cloud_service_operating_systems_get_os_family_request( - location=location, - os_family_name=os_family_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("OSFamily", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + 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_os_families(self, location: str, **kwargs: Any) -> AsyncItemPaged["_models.OSFamily"]: - """Gets a list of all guest operating system families available to be specified in the XML service - configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the - next page of OS Families. Do this till nextLink is null to fetch all the OS Families. - - :param location: Name of the location that the OS families pertain to. Required. - :type location: str - :return: An iterator like instance of either OSFamily or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_09_04.models.OSFamily] + def list_available_sizes( + self, resource_group_name: str, vm_name: str, **kwargs: Any + ) -> AsyncItemPaged["_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.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 "2022-09-04")) - cls: ClsType[_models.OSFamilyListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3326,8 +3478,9 @@ def list_os_families(self, location: str, **kwargs: Any) -> AsyncItemPaged["_mod def prepare_request(next_link=None): if not next_link: - _request = build_cloud_service_operating_systems_list_os_families_request( - location=location, + _request = build_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, @@ -3336,24 +3489,13 @@ def prepare_request(next_link=None): _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 = HttpRequest("GET", next_link) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("OSFamilyListResult", pipeline_response) + deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models.py deleted file mode 100644 index b5e63a4775f1..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models.py +++ /dev/null @@ -1,11 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- -from .v2021_07_01.models import * -from .v2023_07_03.models import * -from .v2024_11_01.models import * -from .v2024_11_04.models import * -from .v2025_01_02.models import * diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models/__init__.py similarity index 66% rename from sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/__init__.py rename to sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models/__init__.py index de3bf5381f0b..c933e4bd5ed2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -14,6 +15,7 @@ from ._models_py3 import ( # type: ignore + AccessUri, AdditionalCapabilities, AdditionalUnattendContent, AlternativeOption, @@ -44,9 +46,38 @@ CapacityReservationProfile, CapacityReservationUpdate, CapacityReservationUtilization, + CloudService, + CloudServiceExtensionProfile, + CloudServiceExtensionProperties, + CloudServiceInstanceView, + CloudServiceListResult, + CloudServiceNetworkProfile, + CloudServiceOsProfile, + CloudServiceProperties, + CloudServiceRole, + CloudServiceRoleListResult, + CloudServiceRoleProfile, + CloudServiceRoleProfileProperties, + CloudServiceRoleProperties, + CloudServiceRoleSku, + CloudServiceUpdate, + CloudServiceVaultAndSecretReference, + CloudServiceVaultCertificate, + CloudServiceVaultSecretGroup, + CommunityGallery, + CommunityGalleryImage, + CommunityGalleryImageIdentifier, + CommunityGalleryImageList, + CommunityGalleryImageVersion, + CommunityGalleryImageVersionList, + CommunityGalleryInfo, + CommunityGalleryMetadata, ConvertToVirtualMachineScaleSetInput, + CopyCompletionError, + CreationData, DataDisk, DataDiskImage, + DataDiskImageEncryption, DataDisksToAttach, DataDisksToDetach, DedicatedHost, @@ -65,41 +96,117 @@ DefaultVirtualMachineScaleSetInfo, DiagnosticsProfile, DiffDiskSettings, + Disallowed, DisallowedConfiguration, + Disk, + DiskAccess, + DiskAccessList, + DiskAccessUpdate, + DiskEncryptionSet, + DiskEncryptionSetList, DiskEncryptionSetParameters, + DiskEncryptionSetUpdate, DiskEncryptionSettings, + DiskImageEncryption, DiskInstanceView, + DiskList, + DiskRestorePoint, DiskRestorePointAttributes, DiskRestorePointInstanceView, + DiskRestorePointList, DiskRestorePointReplicationStatus, + DiskSecurityProfile, + DiskSku, + DiskUpdate, + Encryption, EncryptionIdentity, + EncryptionImages, + EncryptionSetIdentity, + EncryptionSettingsCollection, + EncryptionSettingsElement, + ErrorAdditionalInfo, + ErrorDetail, + ErrorResponse, EventGridAndResourceGraph, ExtendedLocation, + Extension, + Gallery, + GalleryApplication, + GalleryApplicationCustomAction, + GalleryApplicationCustomActionParameter, + GalleryApplicationList, + GalleryApplicationUpdate, + GalleryApplicationVersion, + GalleryApplicationVersionList, + GalleryApplicationVersionPublishingProfile, + GalleryApplicationVersionSafetyProfile, + GalleryApplicationVersionUpdate, + GalleryArtifactPublishingProfileBase, + GalleryArtifactSafetyProfileBase, + GalleryArtifactSource, + GalleryArtifactVersionFullSource, + GalleryArtifactVersionSource, + GalleryDataDiskImage, + GalleryDiskImage, + GalleryDiskImageSource, + GalleryExtendedLocation, + GalleryIdentifier, + GalleryImage, + GalleryImageFeature, + GalleryImageIdentifier, + GalleryImageList, + GalleryImageUpdate, + GalleryImageVersion, + GalleryImageVersionList, + GalleryImageVersionPublishingProfile, + GalleryImageVersionSafetyProfile, + GalleryImageVersionStorageProfile, + GalleryImageVersionUefiSettings, + GalleryImageVersionUpdate, + GalleryList, + GalleryOSDiskImage, + GalleryTargetExtendedLocation, + GalleryUpdate, + GrantAccessData, HardwareProfile, HostEndpointSettings, Image, ImageDataDisk, ImageDeprecationStatus, ImageDisk, + ImageDiskReference, ImageListResult, ImageOSDisk, + ImagePurchasePlan, ImageReference, ImageStorageProfile, ImageUpdate, + ImageVersionSecurityProfile, InnerError, + InstanceSku, InstanceViewStatus, + InstanceViewStatusesSummary, + KeyForDiskEncryptionSet, + KeyVaultAndKeyReference, + KeyVaultAndSecretReference, KeyVaultKeyReference, KeyVaultSecretReference, LastPatchInstallationSummary, + LatestGalleryImageVersion, LinuxConfiguration, LinuxParameters, LinuxPatchSettings, LinuxVMGuestPatchAutomaticByPlatformSettings, ListUsagesResult, + LoadBalancerConfiguration, + LoadBalancerConfigurationProperties, + LoadBalancerFrontendIpConfiguration, + LoadBalancerFrontendIpConfigurationProperties, LogAnalyticsInputBase, LogAnalyticsOperationResult, LogAnalyticsOutput, MaintenanceRedeployStatus, + ManagedArtifact, ManagedDiskParameters, MigrateToVirtualMachineScaleSetInput, MigrateVMToVirtualMachineScaleSetInput, @@ -107,9 +214,18 @@ NetworkProfile, OSDisk, OSDiskImage, + OSDiskImageEncryption, + OSDiskImageSecurityProfile, + OSFamily, + OSFamilyListResult, + OSFamilyProperties, OSImageNotificationProfile, OSProfile, OSProfileProvisioningData, + OSVersion, + OSVersionListResult, + OSVersionProperties, + OSVersionPropertiesBase, Operation, OperationDisplay, OperationListResult, @@ -117,25 +233,54 @@ OrchestrationServiceSummary, PatchInstallationDetail, PatchSettings, + PirCommunityGalleryResource, + PirResource, + PirSharedGalleryResource, Placement, Plan, + PolicyViolation, PriorityMixPolicy, + PrivateEndpoint, + PrivateEndpointConnection, + PrivateEndpointConnectionListResult, + PrivateLinkResource, + PrivateLinkResourceListResult, + PrivateLinkServiceConnectionState, + PropertyUpdatesInProgress, ProximityPlacementGroup, ProximityPlacementGroupListResult, ProximityPlacementGroupPropertiesIntent, ProximityPlacementGroupUpdate, ProxyAgentSettings, + ProxyOnlyResource, ProxyResource, PublicIPAddressSku, PurchasePlan, + PurchasePlanAutoGenerated, + RecommendedMachineConfiguration, RecoveryWalkResponse, + RegionalReplicationStatus, + RegionalSharingStatus, + ReplicationStatus, RequestRateByIntervalInput, ResiliencyPolicy, ResilientVMCreationPolicy, ResilientVMDeletionPolicy, Resource, ResourceAutoGenerated, + ResourceInstanceViewStatus, + ResourceRange, ResourceSharingProfile, + ResourceSku, + ResourceSkuCapabilities, + ResourceSkuCapacity, + ResourceSkuCosts, + ResourceSkuLocationInfo, + ResourceSkuRestrictionInfo, + ResourceSkuRestrictions, + ResourceSkuZoneDetails, + ResourceSkusResult, + ResourceUriList, ResourceWithOptionalLocation, ResourceWithOptionalLocationAutoGenerated, RestorePoint, @@ -150,6 +295,12 @@ RestorePointSourceVMOSDisk, RestorePointSourceVMStorageProfile, RetrieveBootDiagnosticsDataResult, + RoleInstance, + RoleInstanceListResult, + RoleInstanceNetworkProfile, + RoleInstanceProperties, + RoleInstanceView, + RoleInstances, RollbackStatusInfo, RollingUpgradePolicy, RollingUpgradeProgressInfo, @@ -171,9 +322,30 @@ SecurityPostureReferenceUpdate, SecurityProfile, ServiceArtifactReference, + ShareInfoElement, + SharedGallery, + SharedGalleryDataDiskImage, + SharedGalleryDiskImage, + SharedGalleryImage, + SharedGalleryImageList, + SharedGalleryImageVersion, + SharedGalleryImageVersionList, + SharedGalleryImageVersionStorageProfile, + SharedGalleryList, + SharedGalleryOSDiskImage, + SharingProfile, + SharingProfileGroup, + SharingStatus, + SharingUpdate, Sku, SkuProfile, SkuProfileVMSize, + Snapshot, + SnapshotList, + SnapshotSku, + SnapshotUpdate, + SoftDeletePolicy, + SourceVault, SpotRestorePolicy, SshConfiguration, SshGenerateKeyPairInputParameters, @@ -182,23 +354,34 @@ SshPublicKeyResource, SshPublicKeyUpdateResource, SshPublicKeysGroupListResult, + StatusCodeCount, StorageProfile, SubResource, SubResourceReadOnly, SubResourceWithColocationStatus, + SupportedCapabilities, SystemData, SystemDataAutoGenerated, + TargetRegion, TerminateNotificationProfile, ThrottledRequestsInput, TrackedResource, + UefiKey, + UefiKeySignatures, UefiSettings, + UpdateDomain, + UpdateDomainListResult, UpdateResource, + UpdateResourceDefinition, UpgradeOperationHistoricalStatusInfo, UpgradeOperationHistoricalStatusInfoProperties, UpgradeOperationHistoryStatus, UpgradePolicy, Usage, UsageName, + UserArtifactManage, + UserArtifactSettings, + UserArtifactSource, UserAssignedIdentitiesValue, UserAssignedIdentitiesValueAutoGenerated, UserInitiatedReboot, @@ -308,31 +491,55 @@ ) from ._compute_management_client_enums import ( # type: ignore + AccessLevel, ActionType, + AggregatedReplicationState, AllocationStrategy, AlternativeType, + Architecture, ArchitectureTypes, AvailabilitySetSkuTypes, CachingTypes, CapacityReservationGroupInstanceViewTypes, CapacityReservationInstanceViewTypes, + CloudServiceSlotType, + CloudServiceUpgradeMode, + ConfidentialVMEncryptionType, ConsistencyModeTypes, + CopyCompletionErrorReason, CreatedByType, + DataAccessAuthMode, DedicatedHostLicenseTypes, DeleteOptions, DiffDiskOptions, DiffDiskPlacement, DiskControllerTypes, + DiskCreateOption, DiskCreateOptionTypes, DiskDeleteOptionTypes, DiskDetachOptionTypes, + DiskEncryptionSetIdentityType, + DiskEncryptionSetType, + DiskSecurityTypes, + DiskState, + DiskStorageAccountTypes, DomainNameLabelScopeTypes, + EdgeZoneStorageAccountType, + EncryptionType, ExecutionState, ExpandTypeForListVMs, ExpandTypesForGetCapacityReservationGroups, ExpandTypesForGetVMScaleSets, ExpandTypesForListVMs, + ExtendedLocationType, ExtendedLocationTypes, + FileFormat, + GalleryApplicationCustomActionParameterType, + GalleryExpandParams, + GalleryExtendedLocationType, + GalleryProvisioningState, + GallerySharingPermissionTypes, + HostCaching, HyperVGeneration, HyperVGenerationType, HyperVGenerationTypes, @@ -347,6 +554,7 @@ MaintenanceOperationResultCodeTypes, Mode, Modes, + NetworkAccessPolicy, NetworkApiVersion, NetworkInterfaceAuxiliaryMode, NetworkInterfaceAuxiliarySku, @@ -361,17 +569,28 @@ PatchAssessmentState, PatchInstallationState, PatchOperationStatus, + PolicyViolationCategory, + PrivateEndpointConnectionProvisioningState, + PrivateEndpointServiceConnectionStatus, ProtocolTypes, + ProvisionedBandwidthCopyOption, ProximityPlacementGroupType, PublicIPAddressSkuName, PublicIPAddressSkuTier, PublicIPAllocationMethod, + PublicNetworkAccess, RebalanceBehavior, RebalanceStrategy, RepairAction, + ReplicationMode, + ReplicationState, + ReplicationStatusTypes, ResilientVMDeletionStatus, ResourceIdOptionsForGetCapacityReservationGroups, ResourceIdentityType, + ResourceSkuCapacityScaleType, + ResourceSkuRestrictionsReasonCode, + ResourceSkuRestrictionsType, RestorePointCollectionExpandOptions, RestorePointEncryptionType, RestorePointExpandOptions, @@ -379,10 +598,20 @@ RollingUpgradeStatusCode, SecurityEncryptionTypes, SecurityTypes, + SelectPermissions, SettingNames, + SharedGalleryHostCaching, + SharedToValues, + SharingProfileGroupTypes, + SharingState, + SharingUpdateOperationTypes, + SnapshotStorageAccountTypes, SshEncryptionTypes, StatusLevelTypes, + StorageAccountType, StorageAccountTypes, + UefiKeyType, + UefiSignatureTemplateName, UpgradeMode, UpgradeOperationInvoker, UpgradeState, @@ -408,6 +637,7 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ + "AccessUri", "AdditionalCapabilities", "AdditionalUnattendContent", "AlternativeOption", @@ -438,9 +668,38 @@ "CapacityReservationProfile", "CapacityReservationUpdate", "CapacityReservationUtilization", + "CloudService", + "CloudServiceExtensionProfile", + "CloudServiceExtensionProperties", + "CloudServiceInstanceView", + "CloudServiceListResult", + "CloudServiceNetworkProfile", + "CloudServiceOsProfile", + "CloudServiceProperties", + "CloudServiceRole", + "CloudServiceRoleListResult", + "CloudServiceRoleProfile", + "CloudServiceRoleProfileProperties", + "CloudServiceRoleProperties", + "CloudServiceRoleSku", + "CloudServiceUpdate", + "CloudServiceVaultAndSecretReference", + "CloudServiceVaultCertificate", + "CloudServiceVaultSecretGroup", + "CommunityGallery", + "CommunityGalleryImage", + "CommunityGalleryImageIdentifier", + "CommunityGalleryImageList", + "CommunityGalleryImageVersion", + "CommunityGalleryImageVersionList", + "CommunityGalleryInfo", + "CommunityGalleryMetadata", "ConvertToVirtualMachineScaleSetInput", + "CopyCompletionError", + "CreationData", "DataDisk", "DataDiskImage", + "DataDiskImageEncryption", "DataDisksToAttach", "DataDisksToDetach", "DedicatedHost", @@ -459,41 +718,117 @@ "DefaultVirtualMachineScaleSetInfo", "DiagnosticsProfile", "DiffDiskSettings", + "Disallowed", "DisallowedConfiguration", + "Disk", + "DiskAccess", + "DiskAccessList", + "DiskAccessUpdate", + "DiskEncryptionSet", + "DiskEncryptionSetList", "DiskEncryptionSetParameters", + "DiskEncryptionSetUpdate", "DiskEncryptionSettings", + "DiskImageEncryption", "DiskInstanceView", + "DiskList", + "DiskRestorePoint", "DiskRestorePointAttributes", "DiskRestorePointInstanceView", + "DiskRestorePointList", "DiskRestorePointReplicationStatus", + "DiskSecurityProfile", + "DiskSku", + "DiskUpdate", + "Encryption", "EncryptionIdentity", + "EncryptionImages", + "EncryptionSetIdentity", + "EncryptionSettingsCollection", + "EncryptionSettingsElement", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", "EventGridAndResourceGraph", "ExtendedLocation", + "Extension", + "Gallery", + "GalleryApplication", + "GalleryApplicationCustomAction", + "GalleryApplicationCustomActionParameter", + "GalleryApplicationList", + "GalleryApplicationUpdate", + "GalleryApplicationVersion", + "GalleryApplicationVersionList", + "GalleryApplicationVersionPublishingProfile", + "GalleryApplicationVersionSafetyProfile", + "GalleryApplicationVersionUpdate", + "GalleryArtifactPublishingProfileBase", + "GalleryArtifactSafetyProfileBase", + "GalleryArtifactSource", + "GalleryArtifactVersionFullSource", + "GalleryArtifactVersionSource", + "GalleryDataDiskImage", + "GalleryDiskImage", + "GalleryDiskImageSource", + "GalleryExtendedLocation", + "GalleryIdentifier", + "GalleryImage", + "GalleryImageFeature", + "GalleryImageIdentifier", + "GalleryImageList", + "GalleryImageUpdate", + "GalleryImageVersion", + "GalleryImageVersionList", + "GalleryImageVersionPublishingProfile", + "GalleryImageVersionSafetyProfile", + "GalleryImageVersionStorageProfile", + "GalleryImageVersionUefiSettings", + "GalleryImageVersionUpdate", + "GalleryList", + "GalleryOSDiskImage", + "GalleryTargetExtendedLocation", + "GalleryUpdate", + "GrantAccessData", "HardwareProfile", "HostEndpointSettings", "Image", "ImageDataDisk", "ImageDeprecationStatus", "ImageDisk", + "ImageDiskReference", "ImageListResult", "ImageOSDisk", + "ImagePurchasePlan", "ImageReference", "ImageStorageProfile", "ImageUpdate", + "ImageVersionSecurityProfile", "InnerError", + "InstanceSku", "InstanceViewStatus", + "InstanceViewStatusesSummary", + "KeyForDiskEncryptionSet", + "KeyVaultAndKeyReference", + "KeyVaultAndSecretReference", "KeyVaultKeyReference", "KeyVaultSecretReference", "LastPatchInstallationSummary", + "LatestGalleryImageVersion", "LinuxConfiguration", "LinuxParameters", "LinuxPatchSettings", "LinuxVMGuestPatchAutomaticByPlatformSettings", "ListUsagesResult", + "LoadBalancerConfiguration", + "LoadBalancerConfigurationProperties", + "LoadBalancerFrontendIpConfiguration", + "LoadBalancerFrontendIpConfigurationProperties", "LogAnalyticsInputBase", "LogAnalyticsOperationResult", "LogAnalyticsOutput", "MaintenanceRedeployStatus", + "ManagedArtifact", "ManagedDiskParameters", "MigrateToVirtualMachineScaleSetInput", "MigrateVMToVirtualMachineScaleSetInput", @@ -501,9 +836,18 @@ "NetworkProfile", "OSDisk", "OSDiskImage", + "OSDiskImageEncryption", + "OSDiskImageSecurityProfile", + "OSFamily", + "OSFamilyListResult", + "OSFamilyProperties", "OSImageNotificationProfile", "OSProfile", "OSProfileProvisioningData", + "OSVersion", + "OSVersionListResult", + "OSVersionProperties", + "OSVersionPropertiesBase", "Operation", "OperationDisplay", "OperationListResult", @@ -511,25 +855,54 @@ "OrchestrationServiceSummary", "PatchInstallationDetail", "PatchSettings", + "PirCommunityGalleryResource", + "PirResource", + "PirSharedGalleryResource", "Placement", "Plan", + "PolicyViolation", "PriorityMixPolicy", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "PropertyUpdatesInProgress", "ProximityPlacementGroup", "ProximityPlacementGroupListResult", "ProximityPlacementGroupPropertiesIntent", "ProximityPlacementGroupUpdate", "ProxyAgentSettings", + "ProxyOnlyResource", "ProxyResource", "PublicIPAddressSku", "PurchasePlan", + "PurchasePlanAutoGenerated", + "RecommendedMachineConfiguration", "RecoveryWalkResponse", + "RegionalReplicationStatus", + "RegionalSharingStatus", + "ReplicationStatus", "RequestRateByIntervalInput", "ResiliencyPolicy", "ResilientVMCreationPolicy", "ResilientVMDeletionPolicy", "Resource", "ResourceAutoGenerated", + "ResourceInstanceViewStatus", + "ResourceRange", "ResourceSharingProfile", + "ResourceSku", + "ResourceSkuCapabilities", + "ResourceSkuCapacity", + "ResourceSkuCosts", + "ResourceSkuLocationInfo", + "ResourceSkuRestrictionInfo", + "ResourceSkuRestrictions", + "ResourceSkuZoneDetails", + "ResourceSkusResult", + "ResourceUriList", "ResourceWithOptionalLocation", "ResourceWithOptionalLocationAutoGenerated", "RestorePoint", @@ -544,6 +917,12 @@ "RestorePointSourceVMOSDisk", "RestorePointSourceVMStorageProfile", "RetrieveBootDiagnosticsDataResult", + "RoleInstance", + "RoleInstanceListResult", + "RoleInstanceNetworkProfile", + "RoleInstanceProperties", + "RoleInstanceView", + "RoleInstances", "RollbackStatusInfo", "RollingUpgradePolicy", "RollingUpgradeProgressInfo", @@ -565,9 +944,30 @@ "SecurityPostureReferenceUpdate", "SecurityProfile", "ServiceArtifactReference", + "ShareInfoElement", + "SharedGallery", + "SharedGalleryDataDiskImage", + "SharedGalleryDiskImage", + "SharedGalleryImage", + "SharedGalleryImageList", + "SharedGalleryImageVersion", + "SharedGalleryImageVersionList", + "SharedGalleryImageVersionStorageProfile", + "SharedGalleryList", + "SharedGalleryOSDiskImage", + "SharingProfile", + "SharingProfileGroup", + "SharingStatus", + "SharingUpdate", "Sku", "SkuProfile", "SkuProfileVMSize", + "Snapshot", + "SnapshotList", + "SnapshotSku", + "SnapshotUpdate", + "SoftDeletePolicy", + "SourceVault", "SpotRestorePolicy", "SshConfiguration", "SshGenerateKeyPairInputParameters", @@ -576,23 +976,34 @@ "SshPublicKeyResource", "SshPublicKeyUpdateResource", "SshPublicKeysGroupListResult", + "StatusCodeCount", "StorageProfile", "SubResource", "SubResourceReadOnly", "SubResourceWithColocationStatus", + "SupportedCapabilities", "SystemData", "SystemDataAutoGenerated", + "TargetRegion", "TerminateNotificationProfile", "ThrottledRequestsInput", "TrackedResource", + "UefiKey", + "UefiKeySignatures", "UefiSettings", + "UpdateDomain", + "UpdateDomainListResult", "UpdateResource", + "UpdateResourceDefinition", "UpgradeOperationHistoricalStatusInfo", "UpgradeOperationHistoricalStatusInfoProperties", "UpgradeOperationHistoryStatus", "UpgradePolicy", "Usage", "UsageName", + "UserArtifactManage", + "UserArtifactSettings", + "UserArtifactSource", "UserAssignedIdentitiesValue", "UserAssignedIdentitiesValueAutoGenerated", "UserInitiatedReboot", @@ -699,31 +1110,55 @@ "WindowsConfiguration", "WindowsParameters", "WindowsVMGuestPatchAutomaticByPlatformSettings", + "AccessLevel", "ActionType", + "AggregatedReplicationState", "AllocationStrategy", "AlternativeType", + "Architecture", "ArchitectureTypes", "AvailabilitySetSkuTypes", "CachingTypes", "CapacityReservationGroupInstanceViewTypes", "CapacityReservationInstanceViewTypes", + "CloudServiceSlotType", + "CloudServiceUpgradeMode", + "ConfidentialVMEncryptionType", "ConsistencyModeTypes", + "CopyCompletionErrorReason", "CreatedByType", + "DataAccessAuthMode", "DedicatedHostLicenseTypes", "DeleteOptions", "DiffDiskOptions", "DiffDiskPlacement", "DiskControllerTypes", + "DiskCreateOption", "DiskCreateOptionTypes", "DiskDeleteOptionTypes", "DiskDetachOptionTypes", + "DiskEncryptionSetIdentityType", + "DiskEncryptionSetType", + "DiskSecurityTypes", + "DiskState", + "DiskStorageAccountTypes", "DomainNameLabelScopeTypes", + "EdgeZoneStorageAccountType", + "EncryptionType", "ExecutionState", "ExpandTypeForListVMs", "ExpandTypesForGetCapacityReservationGroups", "ExpandTypesForGetVMScaleSets", "ExpandTypesForListVMs", + "ExtendedLocationType", "ExtendedLocationTypes", + "FileFormat", + "GalleryApplicationCustomActionParameterType", + "GalleryExpandParams", + "GalleryExtendedLocationType", + "GalleryProvisioningState", + "GallerySharingPermissionTypes", + "HostCaching", "HyperVGeneration", "HyperVGenerationType", "HyperVGenerationTypes", @@ -738,6 +1173,7 @@ "MaintenanceOperationResultCodeTypes", "Mode", "Modes", + "NetworkAccessPolicy", "NetworkApiVersion", "NetworkInterfaceAuxiliaryMode", "NetworkInterfaceAuxiliarySku", @@ -752,17 +1188,28 @@ "PatchAssessmentState", "PatchInstallationState", "PatchOperationStatus", + "PolicyViolationCategory", + "PrivateEndpointConnectionProvisioningState", + "PrivateEndpointServiceConnectionStatus", "ProtocolTypes", + "ProvisionedBandwidthCopyOption", "ProximityPlacementGroupType", "PublicIPAddressSkuName", "PublicIPAddressSkuTier", "PublicIPAllocationMethod", + "PublicNetworkAccess", "RebalanceBehavior", "RebalanceStrategy", "RepairAction", + "ReplicationMode", + "ReplicationState", + "ReplicationStatusTypes", "ResilientVMDeletionStatus", "ResourceIdOptionsForGetCapacityReservationGroups", "ResourceIdentityType", + "ResourceSkuCapacityScaleType", + "ResourceSkuRestrictionsReasonCode", + "ResourceSkuRestrictionsType", "RestorePointCollectionExpandOptions", "RestorePointEncryptionType", "RestorePointExpandOptions", @@ -770,10 +1217,20 @@ "RollingUpgradeStatusCode", "SecurityEncryptionTypes", "SecurityTypes", + "SelectPermissions", "SettingNames", + "SharedGalleryHostCaching", + "SharedToValues", + "SharingProfileGroupTypes", + "SharingState", + "SharingUpdateOperationTypes", + "SnapshotStorageAccountTypes", "SshEncryptionTypes", "StatusLevelTypes", + "StorageAccountType", "StorageAccountTypes", + "UefiKeyType", + "UefiSignatureTemplateName", "UpgradeMode", "UpgradeOperationInvoker", "UpgradeState", diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models/_compute_management_client_enums.py similarity index 66% rename from sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/_compute_management_client_enums.py rename to sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models/_compute_management_client_enums.py index 35b0ff755594..b42f7b0addda 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models/_compute_management_client_enums.py @@ -11,12 +11,29 @@ from azure.core import CaseInsensitiveEnumMeta +class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AccessLevel.""" + + NONE = "None" + READ = "Read" + WRITE = "Write" + + class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" INTERNAL = "Internal" +class AggregatedReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This is the aggregated replication status based on all the regional replication status flags.""" + + UNKNOWN = "Unknown" + IN_PROGRESS = "InProgress" + COMPLETED = "Completed" + FAILED = "Failed" + + class AllocationStrategy(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the allocation strategy for the virtual machine scale set based on which the VMs will be allocated. @@ -35,6 +52,13 @@ class AlternativeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): PLAN = "Plan" +class Architecture(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The architecture of the image. Applicable to OS disks only.""" + + X64 = "x64" + ARM64 = "Arm64" + + class ArchitectureTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the Architecture Type.""" @@ -73,6 +97,43 @@ class CapacityReservationInstanceViewTypes(str, Enum, metaclass=CaseInsensitiveE INSTANCE_VIEW = "instanceView" +class CloudServiceSlotType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Slot type for the cloud service. + Possible values are :code:`
`\\ :code:`
`\\ **Production**\\ :code:`
`\\ + :code:`
`\\ **Staging**\\ :code:`
`\\ :code:`
` + If not specified, the default value is Production. + """ + + PRODUCTION = "Production" + STAGING = "Staging" + + +class CloudServiceUpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Update mode for the cloud service. Role instances are allocated to update domains when the + service is deployed. Updates can be initiated manually in each update domain or initiated + automatically in all update domains. + Possible Values are :code:`
`\\ :code:`
`\\ **Auto**\\ :code:`
`\\ :code:`
`\\ **Manual** :code:`
`\\ :code:`
`\\ **Simultaneous**\\ :code:`
`\\ + :code:`
` + If not specified, the default value is Auto. If set to Manual, PUT UpdateDomain must be called + to apply the update. If set to Auto, the update is automatically applied to each update domain + in sequence. + """ + + AUTO = "Auto" + MANUAL = "Manual" + SIMULTANEOUS = "Simultaneous" + + +class ConfidentialVMEncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """confidential VM encryption types.""" + + ENCRYPTED_VM_GUEST_STATE_ONLY_WITH_PMK = "EncryptedVMGuestStateOnlyWithPmk" + ENCRYPTED_WITH_PMK = "EncryptedWithPmk" + ENCRYPTED_WITH_CMK = "EncryptedWithCmk" + NON_PERSISTED_TPM = "NonPersistedTPM" + + class ConsistencyModeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ConsistencyMode of the RestorePoint. Can be specified in the input while creating a restore point. For now, only CrashConsistent is accepted as a valid input. Please refer to @@ -84,6 +145,16 @@ class ConsistencyModeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): APPLICATION_CONSISTENT = "ApplicationConsistent" +class CopyCompletionErrorReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates the error code if the background copy of a resource created via the CopyStart + operation fails. + """ + + COPY_SOURCE_NOT_FOUND = "CopySourceNotFound" + """Indicates that the source snapshot was deleted while the background copy of the resource + created via CopyStart operation was in progress.""" + + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource.""" @@ -93,6 +164,17 @@ class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): KEY = "Key" +class DataAccessAuthMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Additional authentication requirements when exporting or uploading to a disk or snapshot.""" + + AZURE_ACTIVE_DIRECTORY = "AzureActiveDirectory" + """When export/upload URL is used, the system checks if the user has an identity in Azure Active + Directory and has necessary permissions to export/upload the data. Please refer to + aka.ms/DisksAzureADAuth.""" + NONE = "None" + """No additional authentication would be performed when accessing export/upload URL.""" + + 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.** @@ -147,6 +229,44 @@ class DiskControllerTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): NV_ME = "NVMe" +class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This enumerates the possible sources of a disk's creation.""" + + EMPTY = "Empty" + """Create an empty data disk of a size given by diskSizeGB.""" + ATTACH = "Attach" + """Disk will be attached to a VM.""" + FROM_IMAGE = "FromImage" + """Create a new disk from a platform image specified by the given imageReference or + galleryImageReference.""" + IMPORT = "Import" + """Create a disk by importing from a blob specified by a sourceUri in a storage account specified + by storageAccountId.""" + COPY = "Copy" + """Create a new disk or snapshot by copying from a disk or snapshot specified by the given + sourceResourceId.""" + RESTORE = "Restore" + """Create a new disk by copying from a backup recovery point.""" + UPLOAD = "Upload" + """Create a new disk by obtaining a write token and using it to directly upload the contents of + the disk.""" + COPY_START = "CopyStart" + """Create a new disk by using a deep copy process, where the resource creation is considered + complete only after all data has been copied from the source.""" + IMPORT_SECURE = "ImportSecure" + """Similar to Import create option. Create a new Trusted Launch VM or Confidential VM supported + disk by importing additional blob for VM guest state specified by securityDataUri in storage + account specified by storageAccountId""" + UPLOAD_PREPARED_SECURE = "UploadPreparedSecure" + """Similar to Upload create option. Create a new Trusted Launch VM or Confidential VM supported + disk and upload using write token in both disk and VM guest state""" + COPY_FROM_SAN_SNAPSHOT = "CopyFromSanSnapshot" + """Create a new disk by exporting from elastic san volume snapshot""" + IMPORT_ENUM = "Import" + """Create a disk by importing from a blob specified by a sourceUri in a storage account specified + by storageAccountId.""" + + class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine disk should be created. Possible values are **Attach:** This value is used when you are using a specialized disk to create the virtual machine. @@ -190,6 +310,98 @@ class DiskDetachOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): FORCE_DETACH = "ForceDetach" +class DiskEncryptionSetIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported + for new creations. Disk Encryption Sets can be updated with Identity type None during migration + of subscription to a new Azure Active Directory tenant; it will cause the encrypted resources + to lose access to the keys. + """ + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" + + +class DiskEncryptionSetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of key used to encrypt the data of the disk.""" + + ENCRYPTION_AT_REST_WITH_CUSTOMER_KEY = "EncryptionAtRestWithCustomerKey" + """Resource using diskEncryptionSet would be encrypted at rest with Customer managed key that can + be changed and revoked by a customer.""" + ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" + """Resource using diskEncryptionSet would be encrypted at rest with two layers of encryption. One + of the keys is Customer managed and the other key is Platform managed.""" + CONFIDENTIAL_VM_ENCRYPTED_WITH_CUSTOMER_KEY = "ConfidentialVmEncryptedWithCustomerKey" + """Confidential VM supported disk and VM guest state would be encrypted with customer managed key.""" + + +class DiskSecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the SecurityType of the VM. Applicable for OS disks only.""" + + TRUSTED_LAUNCH = "TrustedLaunch" + """Trusted Launch provides security features such as secure boot and virtual Trusted Platform + Module (vTPM)""" + CONFIDENTIAL_VM_VMGUEST_STATE_ONLY_ENCRYPTED_WITH_PLATFORM_KEY = ( + "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey" + ) + """Indicates Confidential VM disk with only VM guest state encrypted""" + CONFIDENTIAL_VM_DISK_ENCRYPTED_WITH_PLATFORM_KEY = "ConfidentialVM_DiskEncryptedWithPlatformKey" + """Indicates Confidential VM disk with both OS disk and VM guest state encrypted with a platform + managed key""" + CONFIDENTIAL_VM_DISK_ENCRYPTED_WITH_CUSTOMER_KEY = "ConfidentialVM_DiskEncryptedWithCustomerKey" + """Indicates Confidential VM disk with both OS disk and VM guest state encrypted with a customer + managed key""" + CONFIDENTIAL_VM_NON_PERSISTED_TPM = "ConfidentialVM_NonPersistedTPM" + """Indicates Confidential VM disk with a ephemeral vTPM. vTPM state is not persisted across VM + reboots.""" + + +class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This enumerates the possible state of the disk.""" + + UNATTACHED = "Unattached" + """The disk is not being used and can be attached to a VM.""" + ATTACHED = "Attached" + """The disk is currently attached to a running VM.""" + RESERVED = "Reserved" + """The disk is attached to a stopped-deallocated VM.""" + FROZEN = "Frozen" + """The disk is attached to a VM which is in hibernated state.""" + ACTIVE_SAS = "ActiveSAS" + """The disk currently has an Active SAS Uri associated with it.""" + ACTIVE_SAS_FROZEN = "ActiveSASFrozen" + """The disk is attached to a VM in hibernated state and has an active SAS URI associated with it.""" + READY_TO_UPLOAD = "ReadyToUpload" + """A disk is ready to be created by upload by requesting a write token.""" + ACTIVE_UPLOAD = "ActiveUpload" + """A disk is created for upload and a write token has been issued for uploading to it.""" + + +class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The sku name.""" + + STANDARD_LRS = "Standard_LRS" + """Standard HDD locally redundant storage. Best for backup, non-critical, and infrequent access.""" + PREMIUM_LRS = "Premium_LRS" + """Premium SSD locally redundant storage. Best for production and performance sensitive workloads.""" + STANDARD_SSD_LRS = "StandardSSD_LRS" + """Standard SSD locally redundant storage. Best for web servers, lightly used enterprise + applications and dev/test.""" + ULTRA_SSD_LRS = "UltraSSD_LRS" + """Ultra SSD locally redundant storage. Best for IO-intensive workloads such as SAP HANA, top tier + databases (for example, SQL, Oracle), and other transaction-heavy workloads.""" + PREMIUM_ZRS = "Premium_ZRS" + """Premium SSD zone redundant storage. Best for the production workloads that need storage + resiliency against zone failures.""" + STANDARD_SSD_ZRS = "StandardSSD_ZRS" + """Standard SSD zone redundant storage. Best for web servers, lightly used enterprise applications + and dev/test that need storage resiliency against zone failures.""" + PREMIUM_V2_LRS = "PremiumV2_LRS" + """Premium SSD v2 locally redundant storage. Best for production and performance-sensitive + workloads that consistently require low latency and high IOPS and throughput.""" + + class DomainNameLabelScopeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Domain name label scope.The concatenation of the hashed domain name label that generated according to the policy from domain name label scope and vm index will be the domain name @@ -202,6 +414,31 @@ class DomainNameLabelScopeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): NO_REUSE = "NoReuse" +class EdgeZoneStorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the storage account type to be used to store the image. This property is not + updatable. + """ + + STANDARD_LRS = "Standard_LRS" + STANDARD_ZRS = "Standard_ZRS" + STANDARD_SSD_LRS = "StandardSSD_LRS" + PREMIUM_LRS = "Premium_LRS" + + +class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of key used to encrypt the data of the disk.""" + + ENCRYPTION_AT_REST_WITH_PLATFORM_KEY = "EncryptionAtRestWithPlatformKey" + """Disk is encrypted at rest with Platform managed key. It is the default encryption type. This is + not a valid encryption type for disk encryption sets.""" + ENCRYPTION_AT_REST_WITH_CUSTOMER_KEY = "EncryptionAtRestWithCustomerKey" + """Disk is encrypted at rest with Customer managed key that can be changed and revoked by a + customer.""" + ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" + """Disk is encrypted at rest with 2 layers of encryption. One of the keys is Customer managed and + the other key is Platform managed.""" + + class ExecutionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Script execution status.""" @@ -239,14 +476,81 @@ class ExpandTypesForListVMs(str, Enum, metaclass=CaseInsensitiveEnumMeta): INSTANCE_VIEW = "instanceView" +class ExtendedLocationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the extended location.""" + + EDGE_ZONE = "EdgeZone" + + class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation.""" EDGE_ZONE = "EdgeZone" +class FileFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Used to specify the file format when making request for SAS on a VHDX file format snapshot.""" + + VHD = "VHD" + """A VHD file is a disk image file in the Virtual Hard Disk file format.""" + VHDX = "VHDX" + """A VHDX file is a disk image file in the Virtual Hard Disk v2 file format.""" + + +class GalleryApplicationCustomActionParameterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the type of the custom action parameter. Possible values are: String, + ConfigurationDataBlob or LogOutputBlob. + """ + + STRING = "String" + CONFIGURATION_DATA_BLOB = "ConfigurationDataBlob" + LOG_OUTPUT_BLOB = "LogOutputBlob" + + +class GalleryExpandParams(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """GalleryExpandParams.""" + + SHARING_PROFILE_GROUPS = "SharingProfile/Groups" + + +class GalleryExtendedLocationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """It is type of the extended location.""" + + EDGE_ZONE = "EdgeZone" + UNKNOWN = "Unknown" + + +class GalleryProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state, which only appears in the response.""" + + CREATING = "Creating" + UPDATING = "Updating" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + DELETING = "Deleting" + MIGRATING = "Migrating" + + +class GallerySharingPermissionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This property allows you to specify the permission of sharing gallery. Possible values are: + **Private,** **Groups,** **Community.**. + """ + + PRIVATE = "Private" + GROUPS = "Groups" + COMMUNITY = "Community" + + +class HostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'.""" + + NONE = "None" + READ_ONLY = "ReadOnly" + READ_WRITE = "ReadWrite" + + class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The hypervisor generation of the Virtual Machine [V1, V2].""" + """The hypervisor generation of the Virtual Machine. Applicable to OS disks only.""" V1 = "V1" V2 = "V2" @@ -377,6 +681,17 @@ class Modes(str, Enum, metaclass=CaseInsensitiveEnumMeta): DISABLED = "Disabled" +class NetworkAccessPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Policy for accessing the disk via network.""" + + ALLOW_ALL = "AllowAll" + """The disk can be exported or uploaded to from any network.""" + ALLOW_PRIVATE = "AllowPrivate" + """The disk can be exported or uploaded to using a DiskAccess resource's private endpoints.""" + DENY_ALL = "DenyAll" + """The disk cannot be exported.""" + + class NetworkApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations. @@ -405,12 +720,12 @@ class NetworkInterfaceAuxiliarySku(str, Enum, metaclass=CaseInsensitiveEnumMeta) class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The OS State. For managed images, use Generalized.""" + """This property allows the user to specify whether the virtual machines created under this image + are 'Generalized' or 'Specialized'. + """ GENERALIZED = "Generalized" - """Generalized image. Needs to be provisioned during deployment time.""" SPECIALIZED = "Specialized" - """Specialized image. Contains already provisioned OS Disk.""" class OperatingSystemType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -421,8 +736,8 @@ class OperatingSystemType(str, Enum, metaclass=CaseInsensitiveEnumMeta): class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows you to specify the type of the OS that is included in the disk if creating - a VM from user-image or a specialized VHD. Possible values are: **Windows,** **Linux.**. + """This property allows you to specify the supported type of the OS that application is built for. + Possible values are: **Windows,** **Linux.**. """ WINDOWS = "Windows" @@ -498,6 +813,32 @@ class PatchOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): COMPLETED_WITH_WARNINGS = "CompletedWithWarnings" +class PolicyViolationCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Describes the nature of the policy violation.""" + + OTHER = "Other" + IMAGE_FLAGGED_UNSAFE = "ImageFlaggedUnsafe" + COPYRIGHT_VALIDATION = "CopyrightValidation" + IP_THEFT = "IpTheft" + + +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current provisioning state.""" + + SUCCEEDED = "Succeeded" + CREATING = "Creating" + DELETING = "Deleting" + FAILED = "Failed" + + +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private endpoint connection status.""" + + PENDING = "Pending" + APPROVED = "Approved" + REJECTED = "Rejected" + + class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of WinRM listener. Possible values are: **http,** **https.**.""" @@ -505,6 +846,15 @@ class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): HTTPS = "Https" +class ProvisionedBandwidthCopyOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """If this field is set on a snapshot and createOption is CopyStart, the snapshot will be copied + at a quicker speed. + """ + + NONE = "None" + ENHANCED = "Enhanced" + + class ProximityPlacementGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the type of the proximity placement group. Possible values are: **Standard** : Co-locate resources within an Azure region or Availability Zone. **Ultra** : For future use. @@ -536,6 +886,19 @@ class PublicIPAllocationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): STATIC = "Static" +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Policy for controlling export on the disk.""" + + ENABLED = "Enabled" + """You can generate a SAS URI to access the underlying data of the disk publicly on the internet + when NetworkAccessPolicy is set to AllowAll. You can access the data via the SAS URI only from + your trusted Azure VNET when NetworkAccessPolicy is set to AllowPrivate.""" + DISABLED = "Disabled" + """You cannot access the underlying data of the disk publicly on the internet even when + NetworkAccessPolicy is set to AllowAll. You can access the data via the SAS URI only from your + trusted Azure VNET when NetworkAccessPolicy is set to AllowPrivate.""" + + class RebalanceBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of rebalance behavior that will be used for recreating virtual machines in the scale set across availability zones. Default and only supported value for now is CreateBeforeDelete. @@ -562,6 +925,31 @@ class RepairAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): REIMAGE = "Reimage" +class ReplicationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Optional parameter which specifies the mode to be used for replication. This property is not + updatable. + """ + + FULL = "Full" + SHALLOW = "Shallow" + + +class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This is the regional replication state.""" + + UNKNOWN = "Unknown" + REPLICATING = "Replicating" + COMPLETED = "Completed" + FAILED = "Failed" + + +class ReplicationStatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ReplicationStatusTypes.""" + + REPLICATION_STATUS = "ReplicationStatus" + UEFI_SETTINGS = "UefiSettings" + + class ResilientVMDeletionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the resilient VM deletion status for the virtual machine.""" @@ -591,6 +979,28 @@ class ResourceIdOptionsForGetCapacityReservationGroups(str, Enum, metaclass=Case ALL = "All" +class ResourceSkuCapacityScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The scale type applicable to the sku.""" + + AUTOMATIC = "Automatic" + MANUAL = "Manual" + NONE = "None" + + +class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for restriction.""" + + QUOTA_ID = "QuotaId" + NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + + +class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of restrictions.""" + + LOCATION = "Location" + ZONE = "Zone" + + class RestorePointCollectionExpandOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """RestorePointCollectionExpandOptions.""" @@ -654,6 +1064,12 @@ class SecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): CONFIDENTIAL_VM = "ConfidentialVM" +class SelectPermissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SelectPermissions.""" + + PERMISSIONS = "Permissions" + + class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. @@ -663,6 +1079,60 @@ class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): FIRST_LOGON_COMMANDS = "FirstLogonCommands" +class SharedGalleryHostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'.""" + + NONE = "None" + READ_ONLY = "ReadOnly" + READ_WRITE = "ReadWrite" + + +class SharedToValues(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SharedToValues.""" + + TENANT = "tenant" + + +class SharingProfileGroupTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This property allows you to specify the type of sharing group. Possible values are: + **Subscriptions,** **AADTenants.**. + """ + + SUBSCRIPTIONS = "Subscriptions" + AAD_TENANTS = "AADTenants" + + +class SharingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The sharing state of the gallery, which only appears in the response.""" + + SUCCEEDED = "Succeeded" + IN_PROGRESS = "InProgress" + FAILED = "Failed" + UNKNOWN = "Unknown" + + +class SharingUpdateOperationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This property allows you to specify the operation type of gallery sharing update. Possible + values are: **Add,** **Remove,** **Reset.**. + """ + + ADD = "Add" + REMOVE = "Remove" + RESET = "Reset" + ENABLE_COMMUNITY = "EnableCommunity" + + +class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The sku name.""" + + STANDARD_LRS = "Standard_LRS" + """Standard HDD locally redundant storage""" + PREMIUM_LRS = "Premium_LRS" + """Premium SSD locally redundant storage""" + STANDARD_ZRS = "Standard_ZRS" + """Standard zone redundant storage""" + + class SshEncryptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption type of the SSH keys to be generated. See SshEncryptionTypes for possible set of values. If not provided, will default to RSA. @@ -680,6 +1150,16 @@ class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): ERROR = "Error" +class StorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the storage account type to be used to store the image. This property is not + updatable. + """ + + STANDARD_LRS = "Standard_LRS" + STANDARD_ZRS = "Standard_ZRS" + PREMIUM_LRS = "Premium_LRS" + + class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS can only be used with data @@ -700,6 +1180,21 @@ class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): PREMIUM_V2_LRS = "PremiumV2_LRS" +class UefiKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of key signature.""" + + SHA256 = "sha256" + X509 = "x509" + + +class UefiSignatureTemplateName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the signature template that contains default UEFI keys.""" + + NO_SIGNATURE_TEMPLATE = "NoSignatureTemplate" + MICROSOFT_UEFI_CERTIFICATE_AUTHORITY_TEMPLATE = "MicrosoftUefiCertificateAuthorityTemplate" + MICROSOFT_WINDOWS_TEMPLATE = "MicrosoftWindowsTemplate" + + class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.\\ :code:`
`\\ :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` **Manual** - You control diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models/_models_py3.py similarity index 61% rename from sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/_models_py3.py rename to sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models/_models_py3.py index 70eb43899c83..10c7b28d01ba 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models/_models_py3.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping import datetime from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union @@ -14,6 +15,35 @@ if TYPE_CHECKING: from .. import models as _models +JSON = MutableMapping[str, Any] + + +class AccessUri(_serialization.Model): + """A disk access SAS uri. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar access_sas: A SAS uri for accessing a disk. + :vartype access_sas: str + :ivar security_data_access_sas: A SAS uri for accessing a VM guest state. + :vartype security_data_access_sas: str + """ + + _validation = { + "access_sas": {"readonly": True}, + "security_data_access_sas": {"readonly": True}, + } + + _attribute_map = { + "access_sas": {"key": "accessSAS", "type": "str"}, + "security_data_access_sas": {"key": "securityDataAccessSAS", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.access_sas: Optional[str] = None + self.security_data_access_sas: Optional[str] = None class AdditionalCapabilities(_serialization.Model): @@ -65,7 +95,7 @@ class AdditionalUnattendContent(_serialization.Model): :ivar setting_name: Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon" and "FirstLogonCommands". - :vartype setting_name: str or ~azure.mgmt.compute.v2024_11_01.models.SettingNames + :vartype setting_name: str or ~azure.mgmt.compute.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for the specified path and component. The XML must be less than 4KB and must include the root element for the setting or feature that is being inserted. @@ -98,7 +128,7 @@ def __init__( :keyword setting_name: Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon" and "FirstLogonCommands". - :paramtype setting_name: str or ~azure.mgmt.compute.v2024_11_01.models.SettingNames + :paramtype setting_name: str or ~azure.mgmt.compute.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file for the specified path and component. The XML must be less than 4KB and must include the root element for the setting or feature that is being inserted. @@ -117,7 +147,7 @@ class AlternativeOption(_serialization.Model): :ivar type: Describes the type of the alternative option. Known values are: "None", "Offer", and "Plan". - :vartype type: str or ~azure.mgmt.compute.v2024_11_01.models.AlternativeType + :vartype type: str or ~azure.mgmt.compute.models.AlternativeType :ivar value: Indicates the alternative option value specified by the Publisher. This is the Offer name when the type is Offer or the Plan name when the type is Plan. :vartype value: str @@ -138,7 +168,7 @@ def __init__( """ :keyword type: Describes the type of the alternative option. Known values are: "None", "Offer", and "Plan". - :paramtype type: str or ~azure.mgmt.compute.v2024_11_01.models.AlternativeType + :paramtype type: str or ~azure.mgmt.compute.models.AlternativeType :keyword value: Indicates the alternative option value specified by the Publisher. This is the Offer name when the type is Offer or the Plan name when the type is Plan. :paramtype value: str @@ -174,9 +204,9 @@ class ApiError(_serialization.Model): """Api error. :ivar details: The Api error details. - :vartype details: list[~azure.mgmt.compute.v2024_11_01.models.ApiErrorBase] + :vartype details: list[~azure.mgmt.compute.models.ApiErrorBase] :ivar innererror: The Api inner error. - :vartype innererror: ~azure.mgmt.compute.v2024_11_01.models.InnerError + :vartype innererror: ~azure.mgmt.compute.models.InnerError :ivar code: The error code. :vartype code: str :ivar target: The target of the particular error. @@ -205,9 +235,9 @@ def __init__( ) -> None: """ :keyword details: The Api error details. - :paramtype details: list[~azure.mgmt.compute.v2024_11_01.models.ApiErrorBase] + :paramtype details: list[~azure.mgmt.compute.models.ApiErrorBase] :keyword innererror: The Api inner error. - :paramtype innererror: ~azure.mgmt.compute.v2024_11_01.models.InnerError + :paramtype innererror: ~azure.mgmt.compute.models.InnerError :keyword code: The error code. :paramtype code: str :keyword target: The target of the particular error. @@ -262,8 +292,7 @@ class ApplicationProfile(_serialization.Model): :ivar gallery_applications: Specifies the gallery applications that should be made available to the VM/VMSS. - :vartype gallery_applications: - list[~azure.mgmt.compute.v2024_11_01.models.VMGalleryApplication] + :vartype gallery_applications: list[~azure.mgmt.compute.models.VMGalleryApplication] """ _attribute_map = { @@ -276,8 +305,7 @@ def __init__( """ :keyword gallery_applications: Specifies the gallery applications that should be made available to the VM/VMSS. - :paramtype gallery_applications: - list[~azure.mgmt.compute.v2024_11_01.models.VMGalleryApplication] + :paramtype gallery_applications: list[~azure.mgmt.compute.models.VMGalleryApplication] """ super().__init__(**kwargs) self.gallery_applications = gallery_applications @@ -287,9 +315,9 @@ class AttachDetachDataDisksRequest(_serialization.Model): """Specifies the input for attaching and detaching a list of managed data disks. :ivar data_disks_to_attach: The list of managed data disks to be attached. - :vartype data_disks_to_attach: list[~azure.mgmt.compute.v2024_11_01.models.DataDisksToAttach] + :vartype data_disks_to_attach: list[~azure.mgmt.compute.models.DataDisksToAttach] :ivar data_disks_to_detach: The list of managed data disks to be detached. - :vartype data_disks_to_detach: list[~azure.mgmt.compute.v2024_11_01.models.DataDisksToDetach] + :vartype data_disks_to_detach: list[~azure.mgmt.compute.models.DataDisksToDetach] """ _validation = { @@ -311,9 +339,9 @@ def __init__( ) -> None: """ :keyword data_disks_to_attach: The list of managed data disks to be attached. - :paramtype data_disks_to_attach: list[~azure.mgmt.compute.v2024_11_01.models.DataDisksToAttach] + :paramtype data_disks_to_attach: list[~azure.mgmt.compute.models.DataDisksToAttach] :keyword data_disks_to_detach: The list of managed data disks to be detached. - :paramtype data_disks_to_detach: list[~azure.mgmt.compute.v2024_11_01.models.DataDisksToDetach] + :paramtype data_disks_to_detach: list[~azure.mgmt.compute.models.DataDisksToDetach] """ super().__init__(**kwargs) self.data_disks_to_attach = data_disks_to_attach @@ -431,7 +459,7 @@ class AutomaticRepairsPolicy(_serialization.Model): :ivar repair_action: Type of repair action (replace, restart, reimage) that will be used for repairing unhealthy virtual machines in the scale set. Default value is replace. Known values are: "Replace", "Restart", and "Reimage". - :vartype repair_action: str or ~azure.mgmt.compute.v2024_11_01.models.RepairAction + :vartype repair_action: str or ~azure.mgmt.compute.models.RepairAction """ _attribute_map = { @@ -461,7 +489,7 @@ def __init__( :keyword repair_action: Type of repair action (replace, restart, reimage) that will be used for repairing unhealthy virtual machines in the scale set. Default value is replace. Known values are: "Replace", "Restart", and "Reimage". - :paramtype repair_action: str or ~azure.mgmt.compute.v2024_11_01.models.RepairAction + :paramtype repair_action: str or ~azure.mgmt.compute.models.RepairAction """ super().__init__(**kwargs) self.enabled = enabled @@ -478,11 +506,11 @@ class AutomaticZoneRebalancingPolicy(_serialization.Model): :ivar rebalance_strategy: Type of rebalance strategy that will be used for rebalancing virtual machines in the scale set across availability zones. Default and only supported value for now is Recreate. "Recreate" - :vartype rebalance_strategy: str or ~azure.mgmt.compute.v2024_11_01.models.RebalanceStrategy + :vartype rebalance_strategy: str or ~azure.mgmt.compute.models.RebalanceStrategy :ivar rebalance_behavior: Type of rebalance behavior that will be used for recreating virtual machines in the scale set across availability zones. Default and only supported value for now is CreateBeforeDelete. "CreateBeforeDelete" - :vartype rebalance_behavior: str or ~azure.mgmt.compute.v2024_11_01.models.RebalanceBehavior + :vartype rebalance_behavior: str or ~azure.mgmt.compute.models.RebalanceBehavior """ _attribute_map = { @@ -506,11 +534,11 @@ def __init__( :keyword rebalance_strategy: Type of rebalance strategy that will be used for rebalancing virtual machines in the scale set across availability zones. Default and only supported value for now is Recreate. "Recreate" - :paramtype rebalance_strategy: str or ~azure.mgmt.compute.v2024_11_01.models.RebalanceStrategy + :paramtype rebalance_strategy: str or ~azure.mgmt.compute.models.RebalanceStrategy :keyword rebalance_behavior: Type of rebalance behavior that will be used for recreating virtual machines in the scale set across availability zones. Default and only supported value for now is CreateBeforeDelete. "CreateBeforeDelete" - :paramtype rebalance_behavior: str or ~azure.mgmt.compute.v2024_11_01.models.RebalanceBehavior + :paramtype rebalance_behavior: str or ~azure.mgmt.compute.models.RebalanceBehavior """ super().__init__(**kwargs) self.enabled = enabled @@ -533,7 +561,7 @@ class Resource(_serialization.Model): :vartype type: str :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData + :vartype system_data: ~azure.mgmt.compute.models.SystemData """ _validation = { @@ -577,7 +605,7 @@ class TrackedResource(Resource): :vartype type: str :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData + :vartype system_data: ~azure.mgmt.compute.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. @@ -638,7 +666,7 @@ class AvailabilitySet(TrackedResource): :vartype type: str :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData + :vartype system_data: ~azure.mgmt.compute.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. @@ -647,26 +675,26 @@ class AvailabilitySet(TrackedResource): 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 'Classic'. - :vartype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku + :vartype sku: ~azure.mgmt.compute.models.Sku :ivar platform_update_domain_count: Update Domain count. :vartype platform_update_domain_count: int :ivar platform_fault_domain_count: Fault Domain count. :vartype platform_fault_domain_count: int :ivar virtual_machines: A list of references to all virtual machines in the availability set. - :vartype virtual_machines: list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :vartype virtual_machines: list[~azure.mgmt.compute.models.SubResource] :ivar proximity_placement_group: Specifies information about the proximity placement group that the availability set should be assigned to. Minimum api-version: 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype proximity_placement_group: ~azure.mgmt.compute.models.SubResource :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :vartype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] :ivar scheduled_events_policy: Specifies Redeploy, Reboot and ScheduledEventsAdditionalPublishingTargets Scheduled Event related configurations for the availability set. - :vartype scheduled_events_policy: ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsPolicy + :vartype scheduled_events_policy: ~azure.mgmt.compute.models.ScheduledEventsPolicy :ivar virtual_machine_scale_set_migration_info: Describes the migration properties on the Availability Set. :vartype virtual_machine_scale_set_migration_info: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetMigrationInfo + ~azure.mgmt.compute.models.VirtualMachineScaleSetMigrationInfo """ _validation = { @@ -721,22 +749,21 @@ def __init__( 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 'Classic'. - :paramtype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku + :paramtype sku: ~azure.mgmt.compute.models.Sku :keyword platform_update_domain_count: Update Domain count. :paramtype platform_update_domain_count: int :keyword platform_fault_domain_count: Fault Domain count. :paramtype platform_fault_domain_count: int :keyword virtual_machines: A list of references to all virtual machines in the availability set. - :paramtype virtual_machines: list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :paramtype virtual_machines: list[~azure.mgmt.compute.models.SubResource] :keyword proximity_placement_group: Specifies information about the proximity placement group that the availability set should be assigned to. Minimum api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype proximity_placement_group: ~azure.mgmt.compute.models.SubResource :keyword scheduled_events_policy: Specifies Redeploy, Reboot and ScheduledEventsAdditionalPublishingTargets Scheduled Event related configurations for the availability set. - :paramtype scheduled_events_policy: - ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsPolicy + :paramtype scheduled_events_policy: ~azure.mgmt.compute.models.ScheduledEventsPolicy """ super().__init__(tags=tags, location=location, **kwargs) self.sku = sku @@ -755,7 +782,7 @@ class AvailabilitySetListResult(_serialization.Model): All required parameters must be populated in order to send to server. :ivar value: The list of availability sets. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet] + :vartype value: list[~azure.mgmt.compute.models.AvailabilitySet] :ivar next_link: The URI to fetch the next page of AvailabilitySets. Call ListNext() with this URI to fetch the next page of AvailabilitySets. :vartype next_link: str @@ -775,7 +802,7 @@ def __init__( ) -> None: """ :keyword value: The list of availability sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet] + :paramtype value: list[~azure.mgmt.compute.models.AvailabilitySet] :keyword next_link: The URI to fetch the next page of AvailabilitySets. Call ListNext() with this URI to fetch the next page of AvailabilitySets. :paramtype next_link: str @@ -814,26 +841,26 @@ class AvailabilitySetUpdate(UpdateResource): :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Sku of the availability set. - :vartype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku + :vartype sku: ~azure.mgmt.compute.models.Sku :ivar platform_update_domain_count: Update Domain count. :vartype platform_update_domain_count: int :ivar platform_fault_domain_count: Fault Domain count. :vartype platform_fault_domain_count: int :ivar virtual_machines: A list of references to all virtual machines in the availability set. - :vartype virtual_machines: list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :vartype virtual_machines: list[~azure.mgmt.compute.models.SubResource] :ivar proximity_placement_group: Specifies information about the proximity placement group that the availability set should be assigned to. Minimum api-version: 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype proximity_placement_group: ~azure.mgmt.compute.models.SubResource :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :vartype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] :ivar scheduled_events_policy: Specifies Redeploy, Reboot and ScheduledEventsAdditionalPublishingTargets Scheduled Event related configurations for the availability set. - :vartype scheduled_events_policy: ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsPolicy + :vartype scheduled_events_policy: ~azure.mgmt.compute.models.ScheduledEventsPolicy :ivar virtual_machine_scale_set_migration_info: Describes the migration properties on the Availability Set. :vartype virtual_machine_scale_set_migration_info: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetMigrationInfo + ~azure.mgmt.compute.models.VirtualMachineScaleSetMigrationInfo """ _validation = { @@ -872,22 +899,21 @@ def __init__( :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Sku of the availability set. - :paramtype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku + :paramtype sku: ~azure.mgmt.compute.models.Sku :keyword platform_update_domain_count: Update Domain count. :paramtype platform_update_domain_count: int :keyword platform_fault_domain_count: Fault Domain count. :paramtype platform_fault_domain_count: int :keyword virtual_machines: A list of references to all virtual machines in the availability set. - :paramtype virtual_machines: list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :paramtype virtual_machines: list[~azure.mgmt.compute.models.SubResource] :keyword proximity_placement_group: Specifies information about the proximity placement group that the availability set should be assigned to. Minimum api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype proximity_placement_group: ~azure.mgmt.compute.models.SubResource :keyword scheduled_events_policy: Specifies Redeploy, Reboot and ScheduledEventsAdditionalPublishingTargets Scheduled Event related configurations for the availability set. - :paramtype scheduled_events_policy: - ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsPolicy + :paramtype scheduled_events_policy: ~azure.mgmt.compute.models.ScheduledEventsPolicy """ super().__init__(tags=tags, **kwargs) self.sku = sku @@ -909,7 +935,7 @@ class AvailablePatchSummary(_serialization.Model): until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", and "CompletedWithWarnings". - :vartype status: str or ~azure.mgmt.compute.v2024_11_01.models.PatchOperationStatus + :vartype status: str or ~azure.mgmt.compute.models.PatchOperationStatus :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. :vartype assessment_activity_id: str @@ -928,7 +954,7 @@ class AvailablePatchSummary(_serialization.Model): :vartype last_modified_time: ~datetime.datetime :ivar error: The errors that were encountered during execution of the operation. The details array contains the list of them. - :vartype error: ~azure.mgmt.compute.v2024_11_01.models.ApiError + :vartype error: ~azure.mgmt.compute.models.ApiError """ _validation = { @@ -1054,7 +1080,7 @@ class BootDiagnosticsInstanceView(_serialization.Model): :vartype serial_console_log_blob_uri: str :ivar status: The boot diagnostics status information for the VM. **Note:** It will be set only if there are errors encountered in enabling boot diagnostics. - :vartype status: ~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus + :vartype status: ~azure.mgmt.compute.models.InstanceViewStatus """ _validation = { @@ -1094,7 +1120,7 @@ class CapacityReservation(TrackedResource): :vartype type: str :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData + :vartype system_data: ~azure.mgmt.compute.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. @@ -1104,7 +1130,7 @@ class CapacityReservation(TrackedResource): 'CapacityReservationSupported' set to true are supported. Refer to List Microsoft.Compute SKUs in a region (https://docs.microsoft.com/rest/api/compute/resourceskus/list) for supported values. Required. - :vartype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku + :vartype sku: ~azure.mgmt.compute.models.Sku :ivar zones: The availability zones. :vartype zones: list[str] :ivar reservation_id: A unique id generated and assigned to the capacity reservation by the @@ -1117,14 +1143,13 @@ class CapacityReservation(TrackedResource): :vartype platform_fault_domain_count: int :ivar virtual_machines_associated: A list of all virtual machine resource ids that are associated with the capacity reservation. - :vartype virtual_machines_associated: - list[~azure.mgmt.compute.v2024_11_01.models.SubResourceReadOnly] + :vartype virtual_machines_associated: list[~azure.mgmt.compute.models.SubResourceReadOnly] :ivar provisioning_time: The date time when the capacity reservation was last updated. :vartype provisioning_time: ~datetime.datetime :ivar provisioning_state: The provisioning state, which only appears in the response. :vartype provisioning_state: str :ivar instance_view: The Capacity reservation instance view. - :vartype instance_view: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationInstanceView + :vartype instance_view: ~azure.mgmt.compute.models.CapacityReservationInstanceView :ivar time_created: Specifies the time at which the Capacity Reservation resource was created. Minimum api-version: 2021-11-01. :vartype time_created: ~datetime.datetime @@ -1183,7 +1208,7 @@ def __init__( 'CapacityReservationSupported' set to true are supported. Refer to List Microsoft.Compute SKUs in a region (https://docs.microsoft.com/rest/api/compute/resourceskus/list) for supported values. Required. - :paramtype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku + :paramtype sku: ~azure.mgmt.compute.models.Sku :keyword zones: The availability zones. :paramtype zones: list[str] """ @@ -1219,7 +1244,7 @@ class CapacityReservationGroup(TrackedResource): :vartype type: str :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData + :vartype system_data: ~azure.mgmt.compute.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. @@ -1228,23 +1253,20 @@ class CapacityReservationGroup(TrackedResource): :vartype zones: list[str] :ivar capacity_reservations: A list of all capacity reservation resource ids that belong to capacity reservation group. - :vartype capacity_reservations: - list[~azure.mgmt.compute.v2024_11_01.models.SubResourceReadOnly] + :vartype capacity_reservations: list[~azure.mgmt.compute.models.SubResourceReadOnly] :ivar virtual_machines_associated: A list of references to all virtual machines associated to the capacity reservation group. - :vartype virtual_machines_associated: - list[~azure.mgmt.compute.v2024_11_01.models.SubResourceReadOnly] + :vartype virtual_machines_associated: list[~azure.mgmt.compute.models.SubResourceReadOnly] :ivar instance_view: The capacity reservation group instance view which has the list of instance views for all the capacity reservations that belong to the capacity reservation group. - :vartype instance_view: - ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroupInstanceView + :vartype instance_view: ~azure.mgmt.compute.models.CapacityReservationGroupInstanceView :ivar sharing_profile: Specifies the settings to enable sharing across subscriptions for the capacity reservation group resource. Pls. keep in mind the capacity reservation group resource generally can be shared across subscriptions belonging to a single azure AAD tenant or cross AAD tenant if there is a trust relationship established between the AAD tenants. **Note:** Minimum api-version: 2023-09-01. Please refer to https://aka.ms/computereservationsharing for more details. - :vartype sharing_profile: ~azure.mgmt.compute.v2024_11_01.models.ResourceSharingProfile + :vartype sharing_profile: ~azure.mgmt.compute.models.ResourceSharingProfile """ _validation = { @@ -1294,7 +1316,7 @@ def __init__( AAD tenant if there is a trust relationship established between the AAD tenants. **Note:** Minimum api-version: 2023-09-01. Please refer to https://aka.ms/computereservationsharing for more details. - :paramtype sharing_profile: ~azure.mgmt.compute.v2024_11_01.models.ResourceSharingProfile + :paramtype sharing_profile: ~azure.mgmt.compute.models.ResourceSharingProfile """ super().__init__(tags=tags, location=location, **kwargs) self.zones = zones @@ -1312,12 +1334,11 @@ class CapacityReservationGroupInstanceView(_serialization.Model): :ivar capacity_reservations: List of instance view of the capacity reservations under the capacity reservation group. :vartype capacity_reservations: - list[~azure.mgmt.compute.v2024_11_01.models.CapacityReservationInstanceViewWithName] + list[~azure.mgmt.compute.models.CapacityReservationInstanceViewWithName] :ivar shared_subscription_ids: List of the subscriptions that the capacity reservation group is shared with. **Note:** Minimum api-version: 2023-09-01. Please refer to https://aka.ms/computereservationsharing for more details. - :vartype shared_subscription_ids: - list[~azure.mgmt.compute.v2024_11_01.models.SubResourceReadOnly] + :vartype shared_subscription_ids: list[~azure.mgmt.compute.models.SubResourceReadOnly] """ _validation = { @@ -1343,7 +1364,7 @@ class CapacityReservationGroupListResult(_serialization.Model): All required parameters must be populated in order to send to server. :ivar value: The list of capacity reservation groups. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup] + :vartype value: list[~azure.mgmt.compute.models.CapacityReservationGroup] :ivar next_link: The URI to fetch the next page of capacity reservation groups. Call ListNext() with this URI to fetch the next page of capacity reservation groups. :vartype next_link: str @@ -1363,7 +1384,7 @@ def __init__( ) -> None: """ :keyword value: The list of capacity reservation groups. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup] + :paramtype value: list[~azure.mgmt.compute.models.CapacityReservationGroup] :keyword next_link: The URI to fetch the next page of capacity reservation groups. Call ListNext() with this URI to fetch the next page of capacity reservation groups. :paramtype next_link: str @@ -1382,23 +1403,20 @@ class CapacityReservationGroupUpdate(UpdateResource): :vartype tags: dict[str, str] :ivar capacity_reservations: A list of all capacity reservation resource ids that belong to capacity reservation group. - :vartype capacity_reservations: - list[~azure.mgmt.compute.v2024_11_01.models.SubResourceReadOnly] + :vartype capacity_reservations: list[~azure.mgmt.compute.models.SubResourceReadOnly] :ivar virtual_machines_associated: A list of references to all virtual machines associated to the capacity reservation group. - :vartype virtual_machines_associated: - list[~azure.mgmt.compute.v2024_11_01.models.SubResourceReadOnly] + :vartype virtual_machines_associated: list[~azure.mgmt.compute.models.SubResourceReadOnly] :ivar instance_view: The capacity reservation group instance view which has the list of instance views for all the capacity reservations that belong to the capacity reservation group. - :vartype instance_view: - ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroupInstanceView + :vartype instance_view: ~azure.mgmt.compute.models.CapacityReservationGroupInstanceView :ivar sharing_profile: Specifies the settings to enable sharing across subscriptions for the capacity reservation group resource. Pls. keep in mind the capacity reservation group resource generally can be shared across subscriptions belonging to a single azure AAD tenant or cross AAD tenant if there is a trust relationship established between the AAD tenants. **Note:** Minimum api-version: 2023-09-01. Please refer to https://aka.ms/computereservationsharing for more details. - :vartype sharing_profile: ~azure.mgmt.compute.v2024_11_01.models.ResourceSharingProfile + :vartype sharing_profile: ~azure.mgmt.compute.models.ResourceSharingProfile """ _validation = { @@ -1431,7 +1449,7 @@ def __init__( AAD tenant if there is a trust relationship established between the AAD tenants. **Note:** Minimum api-version: 2023-09-01. Please refer to https://aka.ms/computereservationsharing for more details. - :paramtype sharing_profile: ~azure.mgmt.compute.v2024_11_01.models.ResourceSharingProfile + :paramtype sharing_profile: ~azure.mgmt.compute.models.ResourceSharingProfile """ super().__init__(tags=tags, **kwargs) self.capacity_reservations: Optional[List["_models.SubResourceReadOnly"]] = None @@ -1446,10 +1464,9 @@ class CapacityReservationInstanceView(_serialization.Model): plane operations. :ivar utilization_info: Unutilized capacity of the capacity reservation. - :vartype utilization_info: - ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationUtilization + :vartype utilization_info: ~azure.mgmt.compute.models.CapacityReservationUtilization :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :vartype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] """ _attribute_map = { @@ -1466,10 +1483,9 @@ def __init__( ) -> None: """ :keyword utilization_info: Unutilized capacity of the capacity reservation. - :paramtype utilization_info: - ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationUtilization + :paramtype utilization_info: ~azure.mgmt.compute.models.CapacityReservationUtilization :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :paramtype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] """ super().__init__(**kwargs) self.utilization_info = utilization_info @@ -1483,10 +1499,9 @@ class CapacityReservationInstanceViewWithName(CapacityReservationInstanceView): Variables are only populated by the server, and will be ignored when sending a request. :ivar utilization_info: Unutilized capacity of the capacity reservation. - :vartype utilization_info: - ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationUtilization + :vartype utilization_info: ~azure.mgmt.compute.models.CapacityReservationUtilization :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :vartype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] :ivar name: The name of the capacity reservation. :vartype name: str """ @@ -1510,10 +1525,9 @@ def __init__( ) -> None: """ :keyword utilization_info: Unutilized capacity of the capacity reservation. - :paramtype utilization_info: - ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationUtilization + :paramtype utilization_info: ~azure.mgmt.compute.models.CapacityReservationUtilization :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :paramtype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] """ super().__init__(utilization_info=utilization_info, statuses=statuses, **kwargs) self.name: Optional[str] = None @@ -1525,7 +1539,7 @@ class CapacityReservationListResult(_serialization.Model): All required parameters must be populated in order to send to server. :ivar value: The list of capacity reservations. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] + :vartype value: list[~azure.mgmt.compute.models.CapacityReservation] :ivar next_link: The URI to fetch the next page of capacity reservations. Call ListNext() with this URI to fetch the next page of capacity reservations. :vartype next_link: str @@ -1545,7 +1559,7 @@ def __init__( ) -> None: """ :keyword value: The list of capacity reservations. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] + :paramtype value: list[~azure.mgmt.compute.models.CapacityReservation] :keyword next_link: The URI to fetch the next page of capacity reservations. Call ListNext() with this URI to fetch the next page of capacity reservations. :paramtype next_link: str @@ -1562,7 +1576,7 @@ class CapacityReservationProfile(_serialization.Model): should be used for allocating the virtual machine or scaleset vm instances provided enough capacity has been reserved. Please refer to https://aka.ms/CapacityReservation for more details. - :vartype capacity_reservation_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype capacity_reservation_group: ~azure.mgmt.compute.models.SubResource """ _attribute_map = { @@ -1575,7 +1589,7 @@ def __init__(self, *, capacity_reservation_group: Optional["_models.SubResource" should be used for allocating the virtual machine or scaleset vm instances provided enough capacity has been reserved. Please refer to https://aka.ms/CapacityReservation for more details. - :paramtype capacity_reservation_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype capacity_reservation_group: ~azure.mgmt.compute.models.SubResource """ super().__init__(**kwargs) self.capacity_reservation_group = capacity_reservation_group @@ -1594,7 +1608,7 @@ class CapacityReservationUpdate(UpdateResource): 'CapacityReservationSupported' set to true are supported. Refer to List Microsoft.Compute SKUs in a region (https://docs.microsoft.com/rest/api/compute/resourceskus/list) for supported values. - :vartype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku + :vartype sku: ~azure.mgmt.compute.models.Sku :ivar reservation_id: A unique id generated and assigned to the capacity reservation by the platform which does not change throughout the lifetime of the resource. :vartype reservation_id: str @@ -1605,14 +1619,13 @@ class CapacityReservationUpdate(UpdateResource): :vartype platform_fault_domain_count: int :ivar virtual_machines_associated: A list of all virtual machine resource ids that are associated with the capacity reservation. - :vartype virtual_machines_associated: - list[~azure.mgmt.compute.v2024_11_01.models.SubResourceReadOnly] + :vartype virtual_machines_associated: list[~azure.mgmt.compute.models.SubResourceReadOnly] :ivar provisioning_time: The date time when the capacity reservation was last updated. :vartype provisioning_time: ~datetime.datetime :ivar provisioning_state: The provisioning state, which only appears in the response. :vartype provisioning_state: str :ivar instance_view: The Capacity reservation instance view. - :vartype instance_view: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationInstanceView + :vartype instance_view: ~azure.mgmt.compute.models.CapacityReservationInstanceView :ivar time_created: Specifies the time at which the Capacity Reservation resource was created. Minimum api-version: 2021-11-01. :vartype time_created: ~datetime.datetime @@ -1651,7 +1664,7 @@ def __init__( 'CapacityReservationSupported' set to true are supported. Refer to List Microsoft.Compute SKUs in a region (https://docs.microsoft.com/rest/api/compute/resourceskus/list) for supported values. - :paramtype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku + :paramtype sku: ~azure.mgmt.compute.models.Sku """ super().__init__(tags=tags, **kwargs) self.sku = sku @@ -1675,8 +1688,7 @@ class CapacityReservationUtilization(_serialization.Model): :vartype current_capacity: int :ivar virtual_machines_allocated: A list of all virtual machines resource ids allocated against the capacity reservation. - :vartype virtual_machines_allocated: - list[~azure.mgmt.compute.v2024_11_01.models.SubResourceReadOnly] + :vartype virtual_machines_allocated: list[~azure.mgmt.compute.models.SubResourceReadOnly] """ _validation = { @@ -1696,696 +1708,606 @@ def __init__(self, **kwargs: Any) -> None: self.virtual_machines_allocated: Optional[List["_models.SubResourceReadOnly"]] = None -class ConvertToVirtualMachineScaleSetInput(_serialization.Model): - """Describes the Virtual Machine Scale Set to convert from Availability Set. - - :ivar virtual_machine_scale_set_name: Specifies information about the Virtual Machine Scale Set - that the Availability Set should be converted to. - :vartype virtual_machine_scale_set_name: str - """ - - _attribute_map = { - "virtual_machine_scale_set_name": {"key": "virtualMachineScaleSetName", "type": "str"}, - } - - def __init__(self, *, virtual_machine_scale_set_name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword virtual_machine_scale_set_name: Specifies information about the Virtual Machine Scale - Set that the Availability Set should be converted to. - :paramtype virtual_machine_scale_set_name: str - """ - super().__init__(**kwargs) - self.virtual_machine_scale_set_name = virtual_machine_scale_set_name - - -class DataDisk(_serialization.Model): - """Describes a data disk. +class CloudService(_serialization.Model): + """Describes the cloud service. 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 lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - :ivar name: The disk name. + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. :vartype name: str - :ivar vhd: The virtual hard disk. - :vartype vhd: ~azure.mgmt.compute.v2024_11_01.models.VirtualHardDisk - :ivar image: 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. - :vartype image: ~azure.mgmt.compute.v2024_11_01.models.VirtualHardDisk - :ivar caching: Specifies the caching requirements. Possible values are: **None,** **ReadOnly,** - **ReadWrite.** The defaulting behavior is: **None for Standard storage. ReadOnly for Premium - storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar create_option: Specifies how the virtual machine disk should be created. Possible values - are **Attach:** This value is used when you are using a specialized disk to create the virtual - machine. **FromImage:** This value is used when you are using an image to create the virtual - machine data disk. If you are using a platform image, you should also use the imageReference - element described above. If you are using a marketplace image, you should also use the plan - element previously described. **Empty:** This value is used when creating an empty data disk. - **Copy:** This value is used to create a data disk from a snapshot or another disk. - **Restore:** This value is used to create a data disk from a disk restore point. Required. - Known values are: "FromImage", "Empty", "Attach", "Copy", and "Restore". - :vartype create_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. The property 'diskSizeGB' is - the number of bytes x 1024^3 for the disk and the value cannot be larger than 1023. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: ~azure.mgmt.compute.v2024_11_01.models.ManagedDiskParameters - :ivar source_resource: The source resource identifier. It can be a snapshot, or disk restore - point from which to create a disk. - :vartype source_resource: ~azure.mgmt.compute.v2024_11_01.models.ApiEntityReference - :ivar to_be_detached: Specifies whether the data disk is in process of detachment from the - VirtualMachine/VirtualMachineScaleset. - :vartype to_be_detached: bool - :ivar disk_iops_read_write: Specifies the Read-Write IOPS for the managed disk when - StorageAccountType is UltraSSD_LRS. Returned only for VirtualMachine ScaleSet VM disks. Can be - updated only via updates to the VirtualMachine Scale Set. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: Specifies the bandwidth in MB per second for the managed disk when - StorageAccountType is UltraSSD_LRS. Returned only for VirtualMachine ScaleSet VM disks. Can be - updated only via updates to the VirtualMachine Scale Set. - :vartype disk_m_bps_read_write: int - :ivar detach_option: Specifies the detach behavior to be used while detaching a disk or which - is already in the process of detachment from the virtual machine. Supported values: - **ForceDetach.** detachOption: **ForceDetach** is applicable only for managed data disks. If a - 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. **This feature is still in preview**. To force-detach a data disk - update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. "ForceDetach" - :vartype detach_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskDetachOptionTypes - :ivar delete_option: Specifies whether data disk should be deleted or detached upon VM - deletion. Possible values are: **Delete.** If this value is used, the data disk is deleted when - VM is deleted. **Detach.** If this value is used, the data disk is retained after VM is - deleted. The default value is set to **Detach**. Known values are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskDeleteOptionTypes + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar properties: Cloud service properties. + :vartype properties: ~azure.mgmt.compute.models.CloudServiceProperties + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.compute.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. + :vartype zones: list[str] """ _validation = { - "lun": {"required": True}, - "create_option": {"required": True}, - "disk_iops_read_write": {"readonly": True}, - "disk_m_bps_read_write": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - "lun": {"key": "lun", "type": "int"}, + "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, - "vhd": {"key": "vhd", "type": "VirtualHardDisk"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, - "source_resource": {"key": "sourceResource", "type": "ApiEntityReference"}, - "to_be_detached": {"key": "toBeDetached", "type": "bool"}, - "disk_iops_read_write": {"key": "diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "diskMBpsReadWrite", "type": "int"}, - "detach_option": {"key": "detachOption", "type": "str"}, - "delete_option": {"key": "deleteOption", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "properties": {"key": "properties", "type": "CloudServiceProperties"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "zones": {"key": "zones", "type": "[str]"}, } def __init__( self, *, - lun: int, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - vhd: Optional["_models.VirtualHardDisk"] = None, - image: Optional["_models.VirtualHardDisk"] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.ManagedDiskParameters"] = None, - source_resource: Optional["_models.ApiEntityReference"] = None, - to_be_detached: Optional[bool] = None, - detach_option: Optional[Union[str, "_models.DiskDetachOptionTypes"]] = None, - delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.CloudServiceProperties"] = None, + zones: Optional[List[str]] = None, **kwargs: Any ) -> None: """ - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - :keyword name: The disk name. - :paramtype name: str - :keyword vhd: The virtual hard disk. - :paramtype vhd: ~azure.mgmt.compute.v2024_11_01.models.VirtualHardDisk - :keyword image: 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. - :paramtype image: ~azure.mgmt.compute.v2024_11_01.models.VirtualHardDisk - :keyword caching: Specifies the caching requirements. Possible values are: **None,** - **ReadOnly,** **ReadWrite.** The defaulting behavior is: **None for Standard storage. ReadOnly - for Premium storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword create_option: Specifies how the virtual machine disk should be created. Possible - values are **Attach:** This value is used when you are using a specialized disk to create the - virtual machine. **FromImage:** This value is used when you are using an image to create the - virtual machine data disk. If you are using a platform image, you should also use the - imageReference element described above. If you are using a marketplace image, you should also - use the plan element previously described. **Empty:** This value is used when creating an empty - data disk. **Copy:** This value is used to create a data disk from a snapshot or another disk. - **Restore:** This value is used to create a data disk from a disk restore point. Required. - Known values are: "FromImage", "Empty", "Attach", "Copy", and "Restore". - :paramtype create_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. The property 'diskSizeGB' - is the number of bytes x 1024^3 for the disk and the value cannot be larger than 1023. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: ~azure.mgmt.compute.v2024_11_01.models.ManagedDiskParameters - :keyword source_resource: The source resource identifier. It can be a snapshot, or disk restore - point from which to create a disk. - :paramtype source_resource: ~azure.mgmt.compute.v2024_11_01.models.ApiEntityReference - :keyword to_be_detached: Specifies whether the data disk is in process of detachment from the - VirtualMachine/VirtualMachineScaleset. - :paramtype to_be_detached: bool - :keyword detach_option: Specifies the detach behavior to be used while detaching a disk or - which is already in the process of detachment from the virtual machine. Supported values: - **ForceDetach.** detachOption: **ForceDetach** is applicable only for managed data disks. If a - 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. **This feature is still in preview**. To force-detach a data disk - update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. "ForceDetach" - :paramtype detach_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskDetachOptionTypes - :keyword delete_option: Specifies whether data disk should be deleted or detached upon VM - deletion. Possible values are: **Delete.** If this value is used, the data disk is deleted when - VM is deleted. **Detach.** If this value is used, the data disk is retained after VM is - deleted. The default value is set to **Detach**. Known values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskDeleteOptionTypes + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword properties: Cloud service properties. + :paramtype properties: ~azure.mgmt.compute.models.CloudServiceProperties + :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] """ super().__init__(**kwargs) - self.lun = lun - self.name = name - self.vhd = vhd - self.image = image - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - self.source_resource = source_resource - self.to_be_detached = to_be_detached - self.disk_iops_read_write: Optional[int] = None - self.disk_m_bps_read_write: Optional[int] = None - self.detach_option = detach_option - self.delete_option = delete_option - + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.location = location + self.tags = tags + self.properties = properties + self.system_data: Optional["_models.SystemData"] = None + self.zones = zones -class DataDiskImage(_serialization.Model): - """Contains the data disk images information. - Variables are only populated by the server, and will be ignored when sending a request. +class CloudServiceExtensionProfile(_serialization.Model): + """Describes a cloud service extension profile. - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - :vartype lun: int + :ivar extensions: List of extensions for the cloud service. + :vartype extensions: list[~azure.mgmt.compute.models.Extension] """ - _validation = { - "lun": {"readonly": True}, - } - _attribute_map = { - "lun": {"key": "lun", "type": "int"}, + "extensions": {"key": "extensions", "type": "[Extension]"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, extensions: Optional[List["_models.Extension"]] = None, **kwargs: Any) -> None: + """ + :keyword extensions: List of extensions for the cloud service. + :paramtype extensions: list[~azure.mgmt.compute.models.Extension] + """ super().__init__(**kwargs) - self.lun: Optional[int] = None + self.extensions = extensions -class DataDisksToAttach(_serialization.Model): - """Describes the data disk to be attached. +class CloudServiceExtensionProperties(_serialization.Model): + """Extension Properties. - All required parameters must be populated in order to send to server. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar disk_id: ID of the managed data disk. Required. - :vartype disk_id: str - :ivar lun: The logical unit number of the data disk. This value is used to identify data disks - within the VM and therefore must be unique for each data disk attached to a VM. If not - specified, lun would be auto assigned. - :vartype lun: int - :ivar caching: Specifies the caching requirements. Possible values are: **None,** **ReadOnly,** - **ReadWrite.** The defaulting behavior is: **None for Standard storage. ReadOnly for Premium - storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes - :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 - VM is deleted. **Detach.** If this value is used, the data disk is retained after VM is - deleted. The default value is set to **Detach**. Known values are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskDeleteOptionTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSetParameters - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool + :ivar publisher: The name of the extension handler publisher. + :vartype publisher: str + :ivar type: Specifies the type of the extension. + :vartype type: str + :ivar type_handler_version: Specifies the version of the extension. Specifies the version of + the extension. If this element is not specified or an asterisk (*) is used as the value, the + latest version of the extension is used. If the value is specified with a major version number + and an asterisk as the minor version number (X.), the latest minor version of the specified + major version is selected. If a major version number and a minor version number are specified + (X.Y), the specific extension version is selected. If a version is specified, an auto-upgrade + is performed on the role instance. + :vartype type_handler_version: str + :ivar auto_upgrade_minor_version: Explicitly specify whether platform can automatically upgrade + typeHandlerVersion to higher minor versions when they become available. + :vartype auto_upgrade_minor_version: bool + :ivar settings: Public settings for the extension. For JSON extensions, this is the JSON + settings for the extension. For XML Extension (like RDP), this is the XML setting for the + extension. + :vartype settings: JSON + :ivar protected_settings: Protected settings for the extension which are encrypted before sent + to the role instance. + :vartype protected_settings: JSON + :ivar protected_settings_from_key_vault: Protected settings for the extension, referenced using + KeyVault which are encrypted before sent to the role instance. + :vartype protected_settings_from_key_vault: + ~azure.mgmt.compute.models.CloudServiceVaultAndSecretReference + :ivar force_update_tag: Tag to force apply the provided public and protected settings. + Changing the tag value allows for re-running the extension without changing any of the public + or protected settings. + If forceUpdateTag is not changed, updates to public or protected settings would still be + applied by the handler. + If neither forceUpdateTag nor any of public or protected settings change, extension would flow + to the role instance with the same sequence-number, and + it is up to handler implementation whether to re-run it or not. + :vartype force_update_tag: str + :ivar provisioning_state: The provisioning state, which only appears in the response. + :vartype provisioning_state: str + :ivar roles_applied_to: Optional list of roles to apply this extension. If property is not + specified or '*' is specified, extension is applied to all roles in the cloud service. + :vartype roles_applied_to: list[str] """ _validation = { - "disk_id": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - "disk_id": {"key": "diskId", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - "caching": {"key": "caching", "type": "str"}, - "delete_option": {"key": "deleteOption", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, + "publisher": {"key": "publisher", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, + "auto_upgrade_minor_version": {"key": "autoUpgradeMinorVersion", "type": "bool"}, + "settings": {"key": "settings", "type": "object"}, + "protected_settings": {"key": "protectedSettings", "type": "object"}, + "protected_settings_from_key_vault": { + "key": "protectedSettingsFromKeyVault", + "type": "CloudServiceVaultAndSecretReference", + }, + "force_update_tag": {"key": "forceUpdateTag", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "roles_applied_to": {"key": "rolesAppliedTo", "type": "[str]"}, } def __init__( self, *, - disk_id: str, - lun: Optional[int] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - write_accelerator_enabled: Optional[bool] = None, + publisher: Optional[str] = None, + type: Optional[str] = None, + type_handler_version: Optional[str] = None, + auto_upgrade_minor_version: Optional[bool] = None, + settings: Optional[JSON] = None, + protected_settings: Optional[JSON] = None, + protected_settings_from_key_vault: Optional["_models.CloudServiceVaultAndSecretReference"] = None, + force_update_tag: Optional[str] = None, + roles_applied_to: Optional[List[str]] = None, **kwargs: Any ) -> None: """ - :keyword disk_id: ID of the managed data disk. Required. - :paramtype disk_id: str - :keyword lun: The logical unit number of the data disk. This value is used to identify data - disks within the VM and therefore must be unique for each data disk attached to a VM. If not - specified, lun would be auto assigned. - :paramtype lun: int - :keyword caching: Specifies the caching requirements. Possible values are: **None,** - **ReadOnly,** **ReadWrite.** The defaulting behavior is: **None for Standard storage. ReadOnly - for Premium storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes - :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 - VM is deleted. **Detach.** If this value is used, the data disk is retained after VM is - deleted. The default value is set to **Detach**. Known values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskDeleteOptionTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSetParameters - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool + :keyword publisher: The name of the extension handler publisher. + :paramtype publisher: str + :keyword type: Specifies the type of the extension. + :paramtype type: str + :keyword type_handler_version: Specifies the version of the extension. Specifies the version of + the extension. If this element is not specified or an asterisk (*) is used as the value, the + latest version of the extension is used. If the value is specified with a major version number + and an asterisk as the minor version number (X.), the latest minor version of the specified + major version is selected. If a major version number and a minor version number are specified + (X.Y), the specific extension version is selected. If a version is specified, an auto-upgrade + is performed on the role instance. + :paramtype type_handler_version: str + :keyword auto_upgrade_minor_version: Explicitly specify whether platform can automatically + upgrade typeHandlerVersion to higher minor versions when they become available. + :paramtype auto_upgrade_minor_version: bool + :keyword settings: Public settings for the extension. For JSON extensions, this is the JSON + settings for the extension. For XML Extension (like RDP), this is the XML setting for the + extension. + :paramtype settings: JSON + :keyword protected_settings: Protected settings for the extension which are encrypted before + sent to the role instance. + :paramtype protected_settings: JSON + :keyword protected_settings_from_key_vault: Protected settings for the extension, referenced + using KeyVault which are encrypted before sent to the role instance. + :paramtype protected_settings_from_key_vault: + ~azure.mgmt.compute.models.CloudServiceVaultAndSecretReference + :keyword force_update_tag: Tag to force apply the provided public and protected settings. + Changing the tag value allows for re-running the extension without changing any of the public + or protected settings. + If forceUpdateTag is not changed, updates to public or protected settings would still be + applied by the handler. + If neither forceUpdateTag nor any of public or protected settings change, extension would flow + to the role instance with the same sequence-number, and + it is up to handler implementation whether to re-run it or not. + :paramtype force_update_tag: str + :keyword roles_applied_to: Optional list of roles to apply this extension. If property is not + specified or '*' is specified, extension is applied to all roles in the cloud service. + :paramtype roles_applied_to: list[str] """ super().__init__(**kwargs) - self.disk_id = disk_id - self.lun = lun - self.caching = caching - self.delete_option = delete_option - self.disk_encryption_set = disk_encryption_set - self.write_accelerator_enabled = write_accelerator_enabled + self.publisher = publisher + self.type = type + self.type_handler_version = type_handler_version + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.settings = settings + self.protected_settings = protected_settings + self.protected_settings_from_key_vault = protected_settings_from_key_vault + self.force_update_tag = force_update_tag + self.provisioning_state: Optional[str] = None + self.roles_applied_to = roles_applied_to -class DataDisksToDetach(_serialization.Model): - """Describes the data disk to be detached. +class CloudServiceInstanceView(_serialization.Model): + """InstanceView of CloudService as a whole. - All required parameters must be populated in order to send to server. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar disk_id: ID of the managed data disk. Required. - :vartype disk_id: str - :ivar detach_option: Supported options available for Detach of a disk from a VM. Refer to - DetachOption object reference for more details. "ForceDetach" - :vartype detach_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskDetachOptionTypes + :ivar role_instance: Instance view statuses. + :vartype role_instance: ~azure.mgmt.compute.models.InstanceViewStatusesSummary + :ivar sdk_version: The version of the SDK that was used to generate the package for the cloud + service. + :vartype sdk_version: str + :ivar private_ids: Specifies a list of unique identifiers generated internally for the cloud + service. :code:`
`\\ :code:`
` NOTE: If you are using Azure Diagnostics extension, + this property can be used as 'DeploymentId' for querying details. + :vartype private_ids: list[str] + :ivar statuses: + :vartype statuses: list[~azure.mgmt.compute.models.ResourceInstanceViewStatus] """ _validation = { - "disk_id": {"required": True}, + "sdk_version": {"readonly": True}, + "private_ids": {"readonly": True}, + "statuses": {"readonly": True}, } _attribute_map = { - "disk_id": {"key": "diskId", "type": "str"}, - "detach_option": {"key": "detachOption", "type": "str"}, + "role_instance": {"key": "roleInstance", "type": "InstanceViewStatusesSummary"}, + "sdk_version": {"key": "sdkVersion", "type": "str"}, + "private_ids": {"key": "privateIds", "type": "[str]"}, + "statuses": {"key": "statuses", "type": "[ResourceInstanceViewStatus]"}, } - def __init__( - self, - *, - disk_id: str, - detach_option: Optional[Union[str, "_models.DiskDetachOptionTypes"]] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, role_instance: Optional["_models.InstanceViewStatusesSummary"] = None, **kwargs: Any) -> None: """ - :keyword disk_id: ID of the managed data disk. Required. - :paramtype disk_id: str - :keyword detach_option: Supported options available for Detach of a disk from a VM. Refer to - DetachOption object reference for more details. "ForceDetach" - :paramtype detach_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskDetachOptionTypes + :keyword role_instance: Instance view statuses. + :paramtype role_instance: ~azure.mgmt.compute.models.InstanceViewStatusesSummary """ super().__init__(**kwargs) - self.disk_id = disk_id - self.detach_option = detach_option - + self.role_instance = role_instance + self.sdk_version: Optional[str] = None + self.private_ids: Optional[List[str]] = None + self.statuses: Optional[List["_models.ResourceInstanceViewStatus"]] = None -class DedicatedHost(TrackedResource): - """Specifies information about the Dedicated host. - Variables are only populated by the server, and will be ignored when sending a request. +class CloudServiceListResult(_serialization.Model): + """The list operation result. 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}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar sku: SKU of the dedicated host for Hardware Generation and VM family. Only name is - required to be set. List Microsoft.Compute SKUs for a list of possible values. Required. - :vartype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku - :ivar platform_fault_domain: Fault domain of the dedicated host within a dedicated host group. - :vartype platform_fault_domain: int - :ivar auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :vartype auto_replace_on_failure: bool - :ivar host_id: A unique id generated and assigned to the dedicated host by the platform. Does - not change throughout the lifetime of the host. - :vartype host_id: str - :ivar virtual_machines: A list of references to all virtual machines in the Dedicated Host. - :vartype virtual_machines: list[~azure.mgmt.compute.v2024_11_01.models.SubResourceReadOnly] - :ivar license_type: 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.** The default value is: **None.**. Known values are: "None", - "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :vartype license_type: str or ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostLicenseTypes - :ivar provisioning_time: The date when the host was first provisioned. - :vartype provisioning_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The dedicated host instance view. - :vartype instance_view: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostInstanceView - :ivar time_created: Specifies the time at which the Dedicated Host resource was created. - Minimum api-version: 2021-11-01. - :vartype time_created: ~datetime.datetime + :ivar value: The list of resources. Required. + :vartype value: list[~azure.mgmt.compute.models.CloudService] + :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of + resources. Do this till nextLink is null to fetch all the resources. + :vartype next_link: str """ _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - "sku": {"required": True}, - "host_id": {"readonly": True}, - "virtual_machines": {"readonly": True}, - "provisioning_time": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - "time_created": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { - "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"}, - "sku": {"key": "sku", "type": "Sku"}, - "platform_fault_domain": {"key": "properties.platformFaultDomain", "type": "int"}, - "auto_replace_on_failure": {"key": "properties.autoReplaceOnFailure", "type": "bool"}, - "host_id": {"key": "properties.hostId", "type": "str"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResourceReadOnly]"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "provisioning_time": {"key": "properties.provisioningTime", "type": "iso-8601"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostInstanceView"}, - "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, + "value": {"key": "value", "type": "[CloudService]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - location: str, - sku: "_models.Sku", - tags: Optional[Dict[str, str]] = None, - platform_fault_domain: Optional[int] = None, - auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, value: List["_models.CloudService"], next_link: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword sku: SKU of the dedicated host for Hardware Generation and VM family. Only name is - required to be set. List Microsoft.Compute SKUs for a list of possible values. Required. - :paramtype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku - :keyword platform_fault_domain: Fault domain of the dedicated host within a dedicated host - group. - :paramtype platform_fault_domain: int - :keyword auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :paramtype auto_replace_on_failure: bool - :keyword license_type: 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.** The default value is: **None.**. Known values are: "None", - "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :paramtype license_type: str or - ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostLicenseTypes + :keyword value: The list of resources. Required. + :paramtype value: list[~azure.mgmt.compute.models.CloudService] + :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page + of resources. Do this till nextLink is null to fetch all the resources. + :paramtype next_link: str """ - 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 - self.host_id: Optional[str] = None - self.virtual_machines: Optional[List["_models.SubResourceReadOnly"]] = None - self.license_type = license_type - self.provisioning_time: Optional[datetime.datetime] = None - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.DedicatedHostInstanceView"] = None - self.time_created: Optional[datetime.datetime] = None + super().__init__(**kwargs) + self.value = value + self.next_link = next_link -class DedicatedHostAllocatableVM(_serialization.Model): - """Represents the dedicated host unutilized capacity in terms of a specific VM size. +class CloudServiceNetworkProfile(_serialization.Model): + """Network Profile for the cloud service. - :ivar vm_size: VM size in terms of which the unutilized capacity is represented. - :vartype vm_size: str - :ivar count: Maximum number of VMs of size vmSize that can fit in the dedicated host's - remaining capacity. - :vartype count: float + :ivar load_balancer_configurations: List of Load balancer configurations. Cloud service can + have up to two load balancer configurations, corresponding to a Public Load Balancer and an + Internal Load Balancer. + :vartype load_balancer_configurations: + list[~azure.mgmt.compute.models.LoadBalancerConfiguration] + :ivar slot_type: Slot type for the cloud service. + Possible values are :code:`
`\\ :code:`
`\\ **Production**\\ :code:`
`\\ + :code:`
`\\ **Staging**\\ :code:`
`\\ :code:`
` + If not specified, the default value is Production. Known values are: "Production" and + "Staging". + :vartype slot_type: str or ~azure.mgmt.compute.models.CloudServiceSlotType + :ivar swappable_cloud_service: The id reference of the cloud service containing the target IP + with which the subject cloud service can perform a swap. This property cannot be updated once + it is set. The swappable cloud service referred by this id must be present otherwise an error + will be thrown. + :vartype swappable_cloud_service: ~azure.mgmt.compute.models.SubResource """ _attribute_map = { - "vm_size": {"key": "vmSize", "type": "str"}, - "count": {"key": "count", "type": "float"}, + "load_balancer_configurations": {"key": "loadBalancerConfigurations", "type": "[LoadBalancerConfiguration]"}, + "slot_type": {"key": "slotType", "type": "str"}, + "swappable_cloud_service": {"key": "swappableCloudService", "type": "SubResource"}, } - def __init__(self, *, vm_size: Optional[str] = None, count: Optional[float] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + load_balancer_configurations: Optional[List["_models.LoadBalancerConfiguration"]] = None, + slot_type: Optional[Union[str, "_models.CloudServiceSlotType"]] = None, + swappable_cloud_service: Optional["_models.SubResource"] = None, + **kwargs: Any + ) -> None: """ - :keyword vm_size: VM size in terms of which the unutilized capacity is represented. - :paramtype vm_size: str - :keyword count: Maximum number of VMs of size vmSize that can fit in the dedicated host's - remaining capacity. - :paramtype count: float + :keyword load_balancer_configurations: List of Load balancer configurations. Cloud service can + have up to two load balancer configurations, corresponding to a Public Load Balancer and an + Internal Load Balancer. + :paramtype load_balancer_configurations: + list[~azure.mgmt.compute.models.LoadBalancerConfiguration] + :keyword slot_type: Slot type for the cloud service. + Possible values are :code:`
`\\ :code:`
`\\ **Production**\\ :code:`
`\\ + :code:`
`\\ **Staging**\\ :code:`
`\\ :code:`
` + If not specified, the default value is Production. Known values are: "Production" and + "Staging". + :paramtype slot_type: str or ~azure.mgmt.compute.models.CloudServiceSlotType + :keyword swappable_cloud_service: The id reference of the cloud service containing the target + IP with which the subject cloud service can perform a swap. This property cannot be updated + once it is set. The swappable cloud service referred by this id must be present otherwise an + error will be thrown. + :paramtype swappable_cloud_service: ~azure.mgmt.compute.models.SubResource """ super().__init__(**kwargs) - self.vm_size = vm_size - self.count = count + self.load_balancer_configurations = load_balancer_configurations + self.slot_type = slot_type + self.swappable_cloud_service = swappable_cloud_service -class DedicatedHostAvailableCapacity(_serialization.Model): - """Dedicated host unutilized capacity. +class CloudServiceOsProfile(_serialization.Model): + """Describes the OS profile for the cloud service. - :ivar allocatable_v_ms: The unutilized capacity of the dedicated host represented in terms of - each VM size that is allowed to be deployed to the dedicated host. - :vartype allocatable_v_ms: - list[~azure.mgmt.compute.v2024_11_01.models.DedicatedHostAllocatableVM] + :ivar secrets: Specifies set of certificates that should be installed onto the role instances. + :vartype secrets: list[~azure.mgmt.compute.models.CloudServiceVaultSecretGroup] """ _attribute_map = { - "allocatable_v_ms": {"key": "allocatableVMs", "type": "[DedicatedHostAllocatableVM]"}, + "secrets": {"key": "secrets", "type": "[CloudServiceVaultSecretGroup]"}, } def __init__( - self, *, allocatable_v_ms: Optional[List["_models.DedicatedHostAllocatableVM"]] = None, **kwargs: Any + self, *, secrets: Optional[List["_models.CloudServiceVaultSecretGroup"]] = None, **kwargs: Any ) -> None: """ - :keyword allocatable_v_ms: The unutilized capacity of the dedicated host represented in terms - of each VM size that is allowed to be deployed to the dedicated host. - :paramtype allocatable_v_ms: - list[~azure.mgmt.compute.v2024_11_01.models.DedicatedHostAllocatableVM] + :keyword secrets: Specifies set of certificates that should be installed onto the role + instances. + :paramtype secrets: list[~azure.mgmt.compute.models.CloudServiceVaultSecretGroup] """ super().__init__(**kwargs) - self.allocatable_v_ms = allocatable_v_ms + self.secrets = secrets -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. +class CloudServiceProperties(_serialization.Model): + """Cloud service properties. 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: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar zones: The availability zones. - :vartype zones: list[str] - :ivar platform_fault_domain_count: Number of fault domains that the host group can span. - :vartype platform_fault_domain_count: int - :ivar hosts: A list of references to all dedicated hosts in the dedicated host group. - :vartype hosts: list[~azure.mgmt.compute.v2024_11_01.models.SubResourceReadOnly] - :ivar instance_view: The dedicated host group instance view, which has the list of instance - view of the dedicated hosts under the dedicated host group. - :vartype instance_view: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupInstanceView - :ivar support_automatic_placement: Specifies whether virtual machines or virtual machine scale - sets can be placed automatically on the dedicated host group. Automatic placement means - resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host - group. The value is defaulted to 'false' when not provided. Minimum api-version: 2020-06-01. - :vartype support_automatic_placement: bool - :ivar additional_capabilities: Enables or disables a capability on the dedicated host group. - Minimum api-version: 2022-03-01. - :vartype additional_capabilities: - ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupPropertiesAdditionalCapabilities + :ivar package_url: Specifies a URL that refers to the location of the service package in the + Blob service. The service package URL can be Shared Access Signature (SAS) URI from any storage + account. + This is a write-only property and is not returned in GET calls. + :vartype package_url: str + :ivar configuration: Specifies the XML service configuration (.cscfg) for the cloud service. + :vartype configuration: str + :ivar configuration_url: Specifies a URL that refers to the location of the service + configuration in the Blob service. The service package URL can be Shared Access Signature + (SAS) URI from any storage account. + This is a write-only property and is not returned in GET calls. + :vartype configuration_url: str + :ivar start_cloud_service: (Optional) Indicates whether to start the cloud service immediately + after it is created. The default value is ``true``. + If false, the service model is still deployed, but the code is not run immediately. Instead, + the service is PoweredOff until you call Start, at which time the service will be started. A + deployed service still incurs charges, even if it is poweredoff. + :vartype start_cloud_service: bool + :ivar allow_model_override: (Optional) Indicates whether the role sku properties + (roleProfile.roles.sku) specified in the model/template should override the role instance count + and vm size specified in the .cscfg and .csdef respectively. + The default value is ``false``. + :vartype allow_model_override: bool + :ivar upgrade_mode: Update mode for the cloud service. Role instances are allocated to update + domains when the service is deployed. Updates can be initiated manually in each update domain + or initiated automatically in all update domains. + Possible Values are :code:`
`\\ :code:`
`\\ **Auto**\\ :code:`
`\\ :code:`
`\\ **Manual** :code:`
`\\ :code:`
`\\ **Simultaneous**\\ :code:`
`\\ + :code:`
` + If not specified, the default value is Auto. If set to Manual, PUT UpdateDomain must be called + to apply the update. If set to Auto, the update is automatically applied to each update domain + in sequence. Known values are: "Auto", "Manual", and "Simultaneous". + :vartype upgrade_mode: str or ~azure.mgmt.compute.models.CloudServiceUpgradeMode + :ivar role_profile: Describes the role profile for the cloud service. + :vartype role_profile: ~azure.mgmt.compute.models.CloudServiceRoleProfile + :ivar os_profile: Describes the OS profile for the cloud service. + :vartype os_profile: ~azure.mgmt.compute.models.CloudServiceOsProfile + :ivar network_profile: Network Profile for the cloud service. + :vartype network_profile: ~azure.mgmt.compute.models.CloudServiceNetworkProfile + :ivar extension_profile: Describes a cloud service extension profile. + :vartype extension_profile: ~azure.mgmt.compute.models.CloudServiceExtensionProfile + :ivar provisioning_state: The provisioning state, which only appears in the response. + :vartype provisioning_state: str + :ivar unique_id: The unique identifier for the cloud service. + :vartype unique_id: str """ _validation = { - "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}, - "instance_view": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "unique_id": {"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"}, - "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]"}, - "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostGroupInstanceView"}, - "support_automatic_placement": {"key": "properties.supportAutomaticPlacement", "type": "bool"}, - "additional_capabilities": { - "key": "properties.additionalCapabilities", - "type": "DedicatedHostGroupPropertiesAdditionalCapabilities", - }, + "package_url": {"key": "packageUrl", "type": "str"}, + "configuration": {"key": "configuration", "type": "str"}, + "configuration_url": {"key": "configurationUrl", "type": "str"}, + "start_cloud_service": {"key": "startCloudService", "type": "bool"}, + "allow_model_override": {"key": "allowModelOverride", "type": "bool"}, + "upgrade_mode": {"key": "upgradeMode", "type": "str"}, + "role_profile": {"key": "roleProfile", "type": "CloudServiceRoleProfile"}, + "os_profile": {"key": "osProfile", "type": "CloudServiceOsProfile"}, + "network_profile": {"key": "networkProfile", "type": "CloudServiceNetworkProfile"}, + "extension_profile": {"key": "extensionProfile", "type": "CloudServiceExtensionProfile"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "unique_id": {"key": "uniqueId", "type": "str"}, } def __init__( self, *, - location: str, - tags: Optional[Dict[str, str]] = None, - zones: Optional[List[str]] = None, - platform_fault_domain_count: Optional[int] = None, - support_automatic_placement: Optional[bool] = None, - additional_capabilities: Optional["_models.DedicatedHostGroupPropertiesAdditionalCapabilities"] = None, + package_url: Optional[str] = None, + configuration: Optional[str] = None, + configuration_url: Optional[str] = None, + start_cloud_service: Optional[bool] = None, + allow_model_override: Optional[bool] = None, + upgrade_mode: Optional[Union[str, "_models.CloudServiceUpgradeMode"]] = None, + role_profile: Optional["_models.CloudServiceRoleProfile"] = None, + os_profile: Optional["_models.CloudServiceOsProfile"] = None, + network_profile: Optional["_models.CloudServiceNetworkProfile"] = None, + extension_profile: Optional["_models.CloudServiceExtensionProfile"] = None, **kwargs: Any ) -> None: """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword zones: The availability zones. - :paramtype zones: list[str] - :keyword platform_fault_domain_count: Number of fault domains that the host group can span. - :paramtype platform_fault_domain_count: int - :keyword support_automatic_placement: Specifies whether virtual machines or virtual machine - scale sets can be placed automatically on the dedicated host group. Automatic placement means - resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host - group. The value is defaulted to 'false' when not provided. Minimum api-version: 2020-06-01. - :paramtype support_automatic_placement: bool - :keyword additional_capabilities: Enables or disables a capability on the dedicated host group. - Minimum api-version: 2022-03-01. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupPropertiesAdditionalCapabilities + :keyword package_url: Specifies a URL that refers to the location of the service package in the + Blob service. The service package URL can be Shared Access Signature (SAS) URI from any storage + account. + This is a write-only property and is not returned in GET calls. + :paramtype package_url: str + :keyword configuration: Specifies the XML service configuration (.cscfg) for the cloud service. + :paramtype configuration: str + :keyword configuration_url: Specifies a URL that refers to the location of the service + configuration in the Blob service. The service package URL can be Shared Access Signature + (SAS) URI from any storage account. + This is a write-only property and is not returned in GET calls. + :paramtype configuration_url: str + :keyword start_cloud_service: (Optional) Indicates whether to start the cloud service + immediately after it is created. The default value is ``true``. + If false, the service model is still deployed, but the code is not run immediately. Instead, + the service is PoweredOff until you call Start, at which time the service will be started. A + deployed service still incurs charges, even if it is poweredoff. + :paramtype start_cloud_service: bool + :keyword allow_model_override: (Optional) Indicates whether the role sku properties + (roleProfile.roles.sku) specified in the model/template should override the role instance count + and vm size specified in the .cscfg and .csdef respectively. + The default value is ``false``. + :paramtype allow_model_override: bool + :keyword upgrade_mode: Update mode for the cloud service. Role instances are allocated to + update domains when the service is deployed. Updates can be initiated manually in each update + domain or initiated automatically in all update domains. + Possible Values are :code:`
`\\ :code:`
`\\ **Auto**\\ :code:`
`\\ :code:`
`\\ **Manual** :code:`
`\\ :code:`
`\\ **Simultaneous**\\ :code:`
`\\ + :code:`
` + If not specified, the default value is Auto. If set to Manual, PUT UpdateDomain must be called + to apply the update. If set to Auto, the update is automatically applied to each update domain + in sequence. Known values are: "Auto", "Manual", and "Simultaneous". + :paramtype upgrade_mode: str or ~azure.mgmt.compute.models.CloudServiceUpgradeMode + :keyword role_profile: Describes the role profile for the cloud service. + :paramtype role_profile: ~azure.mgmt.compute.models.CloudServiceRoleProfile + :keyword os_profile: Describes the OS profile for the cloud service. + :paramtype os_profile: ~azure.mgmt.compute.models.CloudServiceOsProfile + :keyword network_profile: Network Profile for the cloud service. + :paramtype network_profile: ~azure.mgmt.compute.models.CloudServiceNetworkProfile + :keyword extension_profile: Describes a cloud service extension profile. + :paramtype extension_profile: ~azure.mgmt.compute.models.CloudServiceExtensionProfile """ - super().__init__(tags=tags, location=location, **kwargs) - self.zones = zones - self.platform_fault_domain_count = platform_fault_domain_count - self.hosts: Optional[List["_models.SubResourceReadOnly"]] = None - self.instance_view: Optional["_models.DedicatedHostGroupInstanceView"] = None - self.support_automatic_placement = support_automatic_placement - self.additional_capabilities = additional_capabilities + super().__init__(**kwargs) + self.package_url = package_url + self.configuration = configuration + self.configuration_url = configuration_url + self.start_cloud_service = start_cloud_service + self.allow_model_override = allow_model_override + self.upgrade_mode = upgrade_mode + self.role_profile = role_profile + self.os_profile = os_profile + self.network_profile = network_profile + self.extension_profile = extension_profile + self.provisioning_state: Optional[str] = None + self.unique_id: Optional[str] = None -class DedicatedHostGroupInstanceView(_serialization.Model): - """DedicatedHostGroupInstanceView. +class CloudServiceRole(_serialization.Model): + """Describes a role of the cloud service. - :ivar hosts: List of instance view of the dedicated hosts under the dedicated host group. - :vartype hosts: list[~azure.mgmt.compute.v2024_11_01.models.DedicatedHostInstanceViewWithName] + Variables are only populated by the server, and will be ignored when sending a request. + + :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. + :vartype location: str + :ivar sku: Describes the cloud service role sku. + :vartype sku: ~azure.mgmt.compute.models.CloudServiceRoleSku + :ivar properties: The cloud service role properties. + :vartype properties: ~azure.mgmt.compute.models.CloudServiceRoleProperties """ + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + } + _attribute_map = { - "hosts": {"key": "hosts", "type": "[DedicatedHostInstanceViewWithName]"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "CloudServiceRoleSku"}, + "properties": {"key": "properties", "type": "CloudServiceRoleProperties"}, } def __init__( - self, *, hosts: Optional[List["_models.DedicatedHostInstanceViewWithName"]] = None, **kwargs: Any + self, + *, + sku: Optional["_models.CloudServiceRoleSku"] = None, + properties: Optional["_models.CloudServiceRoleProperties"] = None, + **kwargs: Any ) -> None: """ - :keyword hosts: List of instance view of the dedicated hosts under the dedicated host group. - :paramtype hosts: - list[~azure.mgmt.compute.v2024_11_01.models.DedicatedHostInstanceViewWithName] + :keyword sku: Describes the cloud service role sku. + :paramtype sku: ~azure.mgmt.compute.models.CloudServiceRoleSku + :keyword properties: The cloud service role properties. + :paramtype properties: ~azure.mgmt.compute.models.CloudServiceRoleProperties """ super().__init__(**kwargs) - self.hosts = hosts + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.location: Optional[str] = None + self.sku = sku + self.properties = properties -class DedicatedHostGroupListResult(_serialization.Model): - """The List Dedicated Host Group with resource group response. +class CloudServiceRoleListResult(_serialization.Model): + """The list operation result. All required parameters must be populated in order to send to server. - :ivar value: The list of dedicated host groups. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup] - :ivar next_link: The URI to fetch the next page of Dedicated Host Groups. Call ListNext() with - this URI to fetch the next page of Dedicated Host Groups. + :ivar value: The list of resources. Required. + :vartype value: list[~azure.mgmt.compute.models.CloudServiceRole] + :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of + resources. Do this till nextLink is null to fetch all the resources. :vartype next_link: str """ @@ -2394,18 +2316,18 @@ class DedicatedHostGroupListResult(_serialization.Model): } _attribute_map = { - "value": {"key": "value", "type": "[DedicatedHostGroup]"}, + "value": {"key": "value", "type": "[CloudServiceRole]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, *, value: List["_models.DedicatedHostGroup"], next_link: Optional[str] = None, **kwargs: Any + self, *, value: List["_models.CloudServiceRole"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: The list of dedicated host groups. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup] - :keyword next_link: The URI to fetch the next page of Dedicated Host Groups. Call ListNext() - with this URI to fetch the next page of Dedicated Host Groups. + :keyword value: The list of resources. Required. + :paramtype value: list[~azure.mgmt.compute.models.CloudServiceRole] + :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page + of resources. Do this till nextLink is null to fetch all the resources. :paramtype next_link: str """ super().__init__(**kwargs) @@ -2413,4149 +2335,4312 @@ def __init__( self.next_link = next_link -class DedicatedHostGroupPropertiesAdditionalCapabilities(_serialization.Model): # pylint: disable=name-too-long - """Enables or disables a capability on the dedicated host group. Minimum api-version: 2022-03-01. +class CloudServiceRoleProfile(_serialization.Model): + """Describes the role profile for the cloud service. - :ivar ultra_ssd_enabled: The flag that enables or disables a capability to have UltraSSD - Enabled Virtual Machines on Dedicated Hosts of the Dedicated Host Group. For the Virtual - Machines to be UltraSSD Enabled, UltraSSDEnabled flag for the resource needs to be set true as - well. The value is defaulted to 'false' when not provided. Please refer to - https://docs.microsoft.com/en-us/azure/virtual-machines/disks-enable-ultra-ssd for more details - on Ultra SSD feature. **Note:** The ultraSSDEnabled setting can only be enabled for Host Groups - that are created as zonal. Minimum api-version: 2022-03-01. - :vartype ultra_ssd_enabled: bool + :ivar roles: List of roles for the cloud service. + :vartype roles: list[~azure.mgmt.compute.models.CloudServiceRoleProfileProperties] """ _attribute_map = { - "ultra_ssd_enabled": {"key": "ultraSSDEnabled", "type": "bool"}, + "roles": {"key": "roles", "type": "[CloudServiceRoleProfileProperties]"}, } - def __init__(self, *, ultra_ssd_enabled: Optional[bool] = None, **kwargs: Any) -> None: + def __init__( + self, *, roles: Optional[List["_models.CloudServiceRoleProfileProperties"]] = None, **kwargs: Any + ) -> None: """ - :keyword ultra_ssd_enabled: The flag that enables or disables a capability to have UltraSSD - Enabled Virtual Machines on Dedicated Hosts of the Dedicated Host Group. For the Virtual - Machines to be UltraSSD Enabled, UltraSSDEnabled flag for the resource needs to be set true as - well. The value is defaulted to 'false' when not provided. Please refer to - https://docs.microsoft.com/en-us/azure/virtual-machines/disks-enable-ultra-ssd for more details - on Ultra SSD feature. **Note:** The ultraSSDEnabled setting can only be enabled for Host Groups - that are created as zonal. Minimum api-version: 2022-03-01. - :paramtype ultra_ssd_enabled: bool + :keyword roles: List of roles for the cloud service. + :paramtype roles: list[~azure.mgmt.compute.models.CloudServiceRoleProfileProperties] """ super().__init__(**kwargs) - self.ultra_ssd_enabled = ultra_ssd_enabled - + self.roles = roles -class DedicatedHostGroupUpdate(UpdateResource): - """Specifies information about the dedicated host group that the dedicated host should be assigned - to. Only tags may be updated. - Variables are only populated by the server, and will be ignored when sending a request. +class CloudServiceRoleProfileProperties(_serialization.Model): + """Describes the role properties. - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar zones: Availability Zone to use for this host group. Only single zone is supported. The - zone can be assigned only during creation. If not provided, the group supports all zones in the - region. If provided, enforces each host in the group to be in the same zone. - :vartype zones: list[str] - :ivar platform_fault_domain_count: Number of fault domains that the host group can span. - :vartype platform_fault_domain_count: int - :ivar hosts: A list of references to all dedicated hosts in the dedicated host group. - :vartype hosts: list[~azure.mgmt.compute.v2024_11_01.models.SubResourceReadOnly] - :ivar instance_view: The dedicated host group instance view, which has the list of instance - view of the dedicated hosts under the dedicated host group. - :vartype instance_view: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupInstanceView - :ivar support_automatic_placement: Specifies whether virtual machines or virtual machine scale - sets can be placed automatically on the dedicated host group. Automatic placement means - resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host - group. The value is defaulted to 'false' when not provided. Minimum api-version: 2020-06-01. - :vartype support_automatic_placement: bool - :ivar additional_capabilities: Enables or disables a capability on the dedicated host group. - Minimum api-version: 2022-03-01. - :vartype additional_capabilities: - ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupPropertiesAdditionalCapabilities + :ivar name: Resource name. + :vartype name: str + :ivar sku: Describes the cloud service role sku. + :vartype sku: ~azure.mgmt.compute.models.CloudServiceRoleSku """ - _validation = { - "platform_fault_domain_count": {"minimum": 1}, - "hosts": {"readonly": True}, - "instance_view": {"readonly": True}, - } - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "zones": {"key": "zones", "type": "[str]"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "hosts": {"key": "properties.hosts", "type": "[SubResourceReadOnly]"}, - "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostGroupInstanceView"}, - "support_automatic_placement": {"key": "properties.supportAutomaticPlacement", "type": "bool"}, - "additional_capabilities": { - "key": "properties.additionalCapabilities", - "type": "DedicatedHostGroupPropertiesAdditionalCapabilities", - }, + "name": {"key": "name", "type": "str"}, + "sku": {"key": "sku", "type": "CloudServiceRoleSku"}, } def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - zones: Optional[List[str]] = None, - platform_fault_domain_count: Optional[int] = None, - support_automatic_placement: Optional[bool] = None, - additional_capabilities: Optional["_models.DedicatedHostGroupPropertiesAdditionalCapabilities"] = None, - **kwargs: Any + self, *, name: Optional[str] = None, sku: Optional["_models.CloudServiceRoleSku"] = None, **kwargs: Any ) -> None: """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword zones: Availability Zone to use for this host group. Only single zone is supported. - The zone can be assigned only during creation. If not provided, the group supports all zones in - the region. If provided, enforces each host in the group to be in the same zone. - :paramtype zones: list[str] - :keyword platform_fault_domain_count: Number of fault domains that the host group can span. - :paramtype platform_fault_domain_count: int - :keyword support_automatic_placement: Specifies whether virtual machines or virtual machine - scale sets can be placed automatically on the dedicated host group. Automatic placement means - resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host - group. The value is defaulted to 'false' when not provided. Minimum api-version: 2020-06-01. - :paramtype support_automatic_placement: bool - :keyword additional_capabilities: Enables or disables a capability on the dedicated host group. - Minimum api-version: 2022-03-01. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupPropertiesAdditionalCapabilities + :keyword name: Resource name. + :paramtype name: str + :keyword sku: Describes the cloud service role sku. + :paramtype sku: ~azure.mgmt.compute.models.CloudServiceRoleSku """ - super().__init__(tags=tags, **kwargs) - self.zones = zones - self.platform_fault_domain_count = platform_fault_domain_count - self.hosts: Optional[List["_models.SubResourceReadOnly"]] = None - self.instance_view: Optional["_models.DedicatedHostGroupInstanceView"] = None - self.support_automatic_placement = support_automatic_placement - self.additional_capabilities = additional_capabilities + super().__init__(**kwargs) + self.name = name + self.sku = sku -class DedicatedHostInstanceView(_serialization.Model): - """The instance view of a dedicated host. +class CloudServiceRoleProperties(_serialization.Model): + """The cloud service role properties. Variables are only populated by the server, and will be ignored when sending a request. - :ivar asset_id: Specifies the unique id of the dedicated physical machine on which the - dedicated host resides. - :vartype asset_id: str - :ivar available_capacity: Unutilized capacity of the dedicated host. - :vartype available_capacity: - ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostAvailableCapacity - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :ivar unique_id: Specifies the ID which uniquely identifies a cloud service role. + :vartype unique_id: str """ _validation = { - "asset_id": {"readonly": True}, + "unique_id": {"readonly": True}, } _attribute_map = { - "asset_id": {"key": "assetId", "type": "str"}, - "available_capacity": {"key": "availableCapacity", "type": "DedicatedHostAvailableCapacity"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, + "unique_id": {"key": "uniqueId", "type": "str"}, } - def __init__( - self, - *, - available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword available_capacity: Unutilized capacity of the dedicated host. - :paramtype available_capacity: - ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostAvailableCapacity - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.asset_id: Optional[str] = None - self.available_capacity = available_capacity - self.statuses = statuses - + self.unique_id: Optional[str] = None -class DedicatedHostInstanceViewWithName(DedicatedHostInstanceView): - """The instance view of a dedicated host that includes the name of the dedicated host. It is used - for the response to the instance view of a dedicated host group. - Variables are only populated by the server, and will be ignored when sending a request. +class CloudServiceRoleSku(_serialization.Model): + """Describes the cloud service role sku. - :ivar asset_id: Specifies the unique id of the dedicated physical machine on which the - dedicated host resides. - :vartype asset_id: str - :ivar available_capacity: Unutilized capacity of the dedicated host. - :vartype available_capacity: - ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostAvailableCapacity - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] - :ivar name: The name of the dedicated host. + :ivar name: The sku name. NOTE: If the new SKU is not supported on the hardware the cloud + service is currently on, you need to delete and recreate the cloud service or move back to the + old sku. :vartype name: str + :ivar tier: Specifies the tier of the cloud service. Possible Values are :code:`
`\\ + :code:`
` **Standard** :code:`
`\\ :code:`
` **Basic**. + :vartype tier: str + :ivar capacity: Specifies the number of role instances in the cloud service. + :vartype capacity: int """ - _validation = { - "asset_id": {"readonly": True}, - "name": {"readonly": True}, - } - _attribute_map = { - "asset_id": {"key": "assetId", "type": "str"}, - "available_capacity": {"key": "availableCapacity", "type": "DedicatedHostAvailableCapacity"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( - self, - *, - available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any + self, *, name: Optional[str] = None, tier: Optional[str] = None, capacity: Optional[int] = None, **kwargs: Any ) -> None: """ - :keyword available_capacity: Unutilized capacity of the dedicated host. - :paramtype available_capacity: - ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostAvailableCapacity - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :keyword name: The sku name. NOTE: If the new SKU is not supported on the hardware the cloud + service is currently on, you need to delete and recreate the cloud service or move back to the + old sku. + :paramtype name: str + :keyword tier: Specifies the tier of the cloud service. Possible Values are :code:`
`\\ + :code:`
` **Standard** :code:`
`\\ :code:`
` **Basic**. + :paramtype tier: str + :keyword capacity: Specifies the number of role instances in the cloud service. + :paramtype capacity: int """ - super().__init__(available_capacity=available_capacity, statuses=statuses, **kwargs) - self.name: Optional[str] = None - + super().__init__(**kwargs) + self.name = name + self.tier = tier + self.capacity = capacity -class DedicatedHostListResult(_serialization.Model): - """The list dedicated host operation response. - All required parameters must be populated in order to send to server. +class CloudServiceUpdate(_serialization.Model): + """CloudServiceUpdate. - :ivar value: The list of dedicated hosts. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] - :ivar next_link: The URI to fetch the next page of dedicated hosts. Call ListNext() with this - URI to fetch the next page of dedicated hosts. - :vartype next_link: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] """ - _validation = { - "value": {"required": True}, - } - _attribute_map = { - "value": {"key": "value", "type": "[DedicatedHost]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, value: List["_models.DedicatedHost"], next_link: Optional[str] = None, **kwargs: Any) -> None: + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ - :keyword value: The list of dedicated hosts. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] - :keyword next_link: The URI to fetch the next page of dedicated hosts. Call ListNext() with - this URI to fetch the next page of dedicated hosts. - :paramtype next_link: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] """ super().__init__(**kwargs) - self.value = value - self.next_link = next_link + self.tags = tags -class DedicatedHostSizeListResult(_serialization.Model): - """The List Dedicated Host sizes operation response. +class CloudServiceVaultAndSecretReference(_serialization.Model): + """Protected settings for the extension, referenced using KeyVault which are encrypted before sent + to the role instance. - :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 + :ivar source_vault: The ARM Resource ID of the Key Vault. + :vartype source_vault: ~azure.mgmt.compute.models.SubResource + :ivar secret_url: Secret URL which contains the protected settings of the extension. + :vartype secret_url: str """ _attribute_map = { - "value": {"key": "value", "type": "[str]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "source_vault": {"key": "sourceVault", "type": "SubResource"}, + "secret_url": {"key": "secretUrl", "type": "str"}, } - def __init__(self, *, value: Optional[List[str]] = None, next_link: Optional[str] = None, **kwargs: Any) -> None: + def __init__( + self, *, source_vault: Optional["_models.SubResource"] = None, secret_url: 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 + :keyword source_vault: The ARM Resource ID of the Key Vault. + :paramtype source_vault: ~azure.mgmt.compute.models.SubResource + :keyword secret_url: Secret URL which contains the protected settings of the extension. + :paramtype secret_url: str """ super().__init__(**kwargs) - self.value = value - self.next_link = next_link - + self.source_vault = source_vault + self.secret_url = secret_url -class DedicatedHostUpdate(UpdateResource): - """Specifies information about the dedicated host. Only tags, autoReplaceOnFailure and licenseType - may be updated. - Variables are only populated by the server, and will be ignored when sending a request. +class CloudServiceVaultCertificate(_serialization.Model): + """Describes a single certificate reference in a Key Vault, and where the certificate should + reside on the role instance. - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: [List all available dedicated host sizes for resizing] - (https://docs.microsoft.com/rest/api/compute/dedicated-hosts/listavailablesizes). Resizing can - be only used to scale up DedicatedHost. Only name is required to be set. - :vartype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku - :ivar platform_fault_domain: Fault domain of the dedicated host within a dedicated host group. - :vartype platform_fault_domain: int - :ivar auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :vartype auto_replace_on_failure: bool - :ivar host_id: A unique id generated and assigned to the dedicated host by the platform. Does - not change throughout the lifetime of the host. - :vartype host_id: str - :ivar virtual_machines: A list of references to all virtual machines in the Dedicated Host. - :vartype virtual_machines: list[~azure.mgmt.compute.v2024_11_01.models.SubResourceReadOnly] - :ivar license_type: 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.** The default value is: **None.**. Known values are: "None", - "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :vartype license_type: str or ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostLicenseTypes - :ivar provisioning_time: The date when the host was first provisioned. - :vartype provisioning_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The dedicated host instance view. - :vartype instance_view: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostInstanceView - :ivar time_created: Specifies the time at which the Dedicated Host resource was created. - Minimum api-version: 2021-11-01. - :vartype time_created: ~datetime.datetime + :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as + a secret. + :vartype certificate_url: str + :ivar is_bootstrap_certificate: Flag indicating if the certificate provided is a bootstrap + certificate to be used by the Key Vault Extension to fetch the remaining certificates. + :vartype is_bootstrap_certificate: bool """ - _validation = { - "host_id": {"readonly": True}, - "virtual_machines": {"readonly": True}, - "provisioning_time": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - "time_created": {"readonly": True}, + _attribute_map = { + "certificate_url": {"key": "certificateUrl", "type": "str"}, + "is_bootstrap_certificate": {"key": "isBootstrapCertificate", "type": "bool"}, } + def __init__( + self, *, certificate_url: Optional[str] = None, is_bootstrap_certificate: Optional[bool] = None, **kwargs: Any + ) -> None: + """ + :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault + as a secret. + :paramtype certificate_url: str + :keyword is_bootstrap_certificate: Flag indicating if the certificate provided is a bootstrap + certificate to be used by the Key Vault Extension to fetch the remaining certificates. + :paramtype is_bootstrap_certificate: bool + """ + super().__init__(**kwargs) + self.certificate_url = certificate_url + self.is_bootstrap_certificate = is_bootstrap_certificate + + +class CloudServiceVaultSecretGroup(_serialization.Model): + """Describes a set of certificates which are all in the same Key Vault. + + :ivar source_vault: The relative URL of the Key Vault containing all of the certificates in + VaultCertificates. + :vartype source_vault: ~azure.mgmt.compute.models.SubResource + :ivar vault_certificates: The list of key vault references in SourceVault which contain + certificates. + :vartype vault_certificates: list[~azure.mgmt.compute.models.CloudServiceVaultCertificate] + """ + _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "platform_fault_domain": {"key": "properties.platformFaultDomain", "type": "int"}, - "auto_replace_on_failure": {"key": "properties.autoReplaceOnFailure", "type": "bool"}, - "host_id": {"key": "properties.hostId", "type": "str"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResourceReadOnly]"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "provisioning_time": {"key": "properties.provisioningTime", "type": "iso-8601"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostInstanceView"}, - "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, + "source_vault": {"key": "sourceVault", "type": "SubResource"}, + "vault_certificates": {"key": "vaultCertificates", "type": "[CloudServiceVaultCertificate]"}, } def __init__( self, *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - platform_fault_domain: Optional[int] = None, - auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.CloudServiceVaultCertificate"]] = None, **kwargs: Any ) -> None: """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: [List all available dedicated host sizes for resizing] - (https://docs.microsoft.com/rest/api/compute/dedicated-hosts/listavailablesizes). Resizing can - be only used to scale up DedicatedHost. Only name is required to be set. - :paramtype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku - :keyword platform_fault_domain: Fault domain of the dedicated host within a dedicated host - group. - :paramtype platform_fault_domain: int - :keyword auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :paramtype auto_replace_on_failure: bool - :keyword license_type: 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.** The default value is: **None.**. Known values are: "None", - "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :paramtype license_type: str or - ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostLicenseTypes + :keyword source_vault: The relative URL of the Key Vault containing all of the certificates in + VaultCertificates. + :paramtype source_vault: ~azure.mgmt.compute.models.SubResource + :keyword vault_certificates: The list of key vault references in SourceVault which contain + certificates. + :paramtype vault_certificates: list[~azure.mgmt.compute.models.CloudServiceVaultCertificate] """ - super().__init__(tags=tags, **kwargs) - self.sku = sku - self.platform_fault_domain = platform_fault_domain - self.auto_replace_on_failure = auto_replace_on_failure - self.host_id: Optional[str] = None - self.virtual_machines: Optional[List["_models.SubResourceReadOnly"]] = None - self.license_type = license_type - self.provisioning_time: Optional[datetime.datetime] = None - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.DedicatedHostInstanceView"] = None - self.time_created: Optional[datetime.datetime] = None + super().__init__(**kwargs) + self.source_vault = source_vault + self.vault_certificates = vault_certificates -class DefaultVirtualMachineScaleSetInfo(_serialization.Model): - """Indicates the target Virtual Machine ScaleSet properties upon triggering a seamless migration - without downtime of the VMs via the ConvertToVirtualMachineScaleSet API. +class PirCommunityGalleryResource(_serialization.Model): + """Base information about the community gallery resource in azure compute gallery. Variables are only populated by the server, and will be ignored when sending a request. - :ivar constrained_maximum_capacity: Indicates if the the maximum capacity of the default - migrated Virtual Machine Scale Set after its migration will be constrained to a limited number - of VMs. - :vartype constrained_maximum_capacity: bool - :ivar default_virtual_machine_scale_set: The default Virtual Machine ScaleSet Uri that the - Availability Set will be moved to upon triggering a seamless migration via the - ConvertToVirtualMachineScaleSet API. - :vartype default_virtual_machine_scale_set: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :ivar name: Resource name. + :vartype name: str + :ivar location: Resource location. + :vartype location: str + :ivar type: Resource type. + :vartype type: str + :ivar unique_id: The unique id of this community gallery. + :vartype unique_id: str """ _validation = { - "constrained_maximum_capacity": {"readonly": True}, - "default_virtual_machine_scale_set": {"readonly": True}, + "name": {"readonly": True}, + "location": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - "constrained_maximum_capacity": {"key": "constrainedMaximumCapacity", "type": "bool"}, - "default_virtual_machine_scale_set": {"key": "defaultVirtualMachineScaleSet", "type": "SubResource"}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "unique_id": {"key": "identifier.uniqueId", "type": "str"}, } - def __init__(self, **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 + """ super().__init__(**kwargs) - self.constrained_maximum_capacity: Optional[bool] = None - self.default_virtual_machine_scale_set: Optional["_models.SubResource"] = None + self.name: Optional[str] = None + self.location: Optional[str] = None + self.type: Optional[str] = None + self.unique_id = unique_id -class DiagnosticsProfile(_serialization.Model): - """Specifies the boot diagnostic settings state. Minimum api-version: 2015-06-15. +class CommunityGallery(PirCommunityGalleryResource): + """Specifies information about the Community Gallery that you want to create or update. - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. **NOTE**\\ : If storageUri is being - specified then ensure that the storage account is in the same region and subscription as the - VM. You can easily view the output of your console log. Azure also enables you to see a - screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2024_11_01.models.BootDiagnostics + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Resource name. + :vartype name: str + :ivar location: Resource location. + :vartype location: str + :ivar type: Resource type. + :vartype type: str + :ivar unique_id: The unique id of this community gallery. + :vartype unique_id: str + :ivar disclaimer: The disclaimer for a community gallery resource. + :vartype disclaimer: str + :ivar artifact_tags: The artifact tags of a community gallery resource. + :vartype artifact_tags: dict[str, str] + :ivar community_metadata: The metadata of community gallery. + :vartype community_metadata: ~azure.mgmt.compute.models.CommunityGalleryMetadata """ - _attribute_map = { - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnostics"}, + _validation = { + "name": {"readonly": True}, + "location": {"readonly": True}, + "type": {"readonly": True}, } - def __init__(self, *, boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs: Any) -> None: - """ - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. **NOTE**\\ : If storageUri is being - specified then ensure that the storage account is in the same region and subscription as the - VM. You can easily view the output of your console log. Azure also enables you to see a - screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2024_11_01.models.BootDiagnostics - """ - super().__init__(**kwargs) - self.boot_diagnostics = boot_diagnostics - - -class DiffDiskSettings(_serialization.Model): - """Describes the parameters of ephemeral disk settings that can be specified for operating system - disk. **Note:** The ephemeral disk settings can only be specified for managed disk. - - :ivar option: Specifies the ephemeral disk settings for operating system disk. "Local" - :vartype option: str or ~azure.mgmt.compute.v2024_11_01.models.DiffDiskOptions - :ivar placement: Specifies the ephemeral disk placement for operating system disk. Possible - values are: **CacheDisk,** **ResourceDisk,** **NvmeDisk.** The defaulting behavior is: - **CacheDisk** if one is configured for the VM size otherwise **ResourceDisk** or **NvmeDisk** - is used. Refer to the VM size documentation for Windows VM at - https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at - https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM sizes exposes a - cache disk. Minimum api-version for NvmeDisk: 2024-03-01. Known values are: "CacheDisk", - "ResourceDisk", and "NvmeDisk". - :vartype placement: str or ~azure.mgmt.compute.v2024_11_01.models.DiffDiskPlacement - """ - _attribute_map = { - "option": {"key": "option", "type": "str"}, - "placement": {"key": "placement", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "unique_id": {"key": "identifier.uniqueId", "type": "str"}, + "disclaimer": {"key": "properties.disclaimer", "type": "str"}, + "artifact_tags": {"key": "properties.artifactTags", "type": "{str}"}, + "community_metadata": {"key": "properties.communityMetadata", "type": "CommunityGalleryMetadata"}, } def __init__( self, *, - option: Optional[Union[str, "_models.DiffDiskOptions"]] = None, - placement: Optional[Union[str, "_models.DiffDiskPlacement"]] = None, + 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: """ - :keyword option: Specifies the ephemeral disk settings for operating system disk. "Local" - :paramtype option: str or ~azure.mgmt.compute.v2024_11_01.models.DiffDiskOptions - :keyword placement: Specifies the ephemeral disk placement for operating system disk. Possible - values are: **CacheDisk,** **ResourceDisk,** **NvmeDisk.** The defaulting behavior is: - **CacheDisk** if one is configured for the VM size otherwise **ResourceDisk** or **NvmeDisk** - is used. Refer to the VM size documentation for Windows VM at - https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at - https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM sizes exposes a - cache disk. Minimum api-version for NvmeDisk: 2024-03-01. Known values are: "CacheDisk", - "ResourceDisk", and "NvmeDisk". - :paramtype placement: str or ~azure.mgmt.compute.v2024_11_01.models.DiffDiskPlacement + :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.models.CommunityGalleryMetadata """ - super().__init__(**kwargs) - self.option = option - self.placement = placement + super().__init__(unique_id=unique_id, **kwargs) + self.disclaimer = disclaimer + self.artifact_tags = artifact_tags + self.community_metadata = community_metadata -class DisallowedConfiguration(_serialization.Model): - """Specifies the disallowed configuration for a virtual machine image. +class CommunityGalleryImage(PirCommunityGalleryResource): + """Specifies information about the gallery image definition that you want to create or update. - :ivar vm_disk_type: VM disk types which are disallowed. Known values are: "None" and - "Unmanaged". - :vartype vm_disk_type: str or ~azure.mgmt.compute.v2024_11_01.models.VmDiskTypes + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Resource name. + :vartype name: str + :ivar location: Resource location. + :vartype location: str + :ivar type: Resource type. + :vartype type: str + :ivar unique_id: The unique id of this community gallery. + :vartype unique_id: str + :ivar 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". + :vartype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :ivar 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". + :vartype os_state: str or ~azure.mgmt.compute.models.OperatingSystemStateTypes + :ivar 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. + :vartype end_of_life_date: ~datetime.datetime + :ivar identifier: This is the community gallery image definition identifier. + :vartype identifier: ~azure.mgmt.compute.models.CommunityGalleryImageIdentifier + :ivar recommended: The properties describe the recommended machine configuration for this Image + Definition. These properties are updatable. + :vartype recommended: ~azure.mgmt.compute.models.RecommendedMachineConfiguration + :ivar disallowed: Describes the disallowed disk types. + :vartype disallowed: ~azure.mgmt.compute.models.Disallowed + :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS + disks only. Known values are: "V1" and "V2". + :vartype hyper_v_generation: str or ~azure.mgmt.compute.models.HyperVGeneration + :ivar features: A list of gallery image features. + :vartype features: list[~azure.mgmt.compute.models.GalleryImageFeature] + :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by + marketplace images. + :vartype purchase_plan: ~azure.mgmt.compute.models.ImagePurchasePlan + :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values + are: "x64" and "Arm64". + :vartype architecture: str or ~azure.mgmt.compute.models.Architecture + :ivar privacy_statement_uri: Privacy statement URI for the current community gallery image. + :vartype privacy_statement_uri: str + :ivar eula: The end-user license agreement for the current community gallery image. + :vartype eula: str + :ivar disclaimer: The disclaimer for a community gallery resource. + :vartype disclaimer: str + :ivar artifact_tags: The artifact tags of a community gallery resource. + :vartype artifact_tags: dict[str, str] """ + _validation = { + "name": {"readonly": True}, + "location": {"readonly": True}, + "type": {"readonly": True}, + } + _attribute_map = { - "vm_disk_type": {"key": "vmDiskType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "unique_id": {"key": "identifier.uniqueId", "type": "str"}, + "os_type": {"key": "properties.osType", "type": "str"}, + "os_state": {"key": "properties.osState", "type": "str"}, + "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, + "identifier": {"key": "properties.identifier", "type": "CommunityGalleryImageIdentifier"}, + "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, + "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, + "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, + "features": {"key": "properties.features", "type": "[GalleryImageFeature]"}, + "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, + "architecture": {"key": "properties.architecture", "type": "str"}, + "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, + "eula": {"key": "properties.eula", "type": "str"}, + "disclaimer": {"key": "properties.disclaimer", "type": "str"}, + "artifact_tags": {"key": "properties.artifactTags", "type": "{str}"}, } - def __init__(self, *, vm_disk_type: Optional[Union[str, "_models.VmDiskTypes"]] = None, **kwargs: Any) -> None: - """ - :keyword vm_disk_type: VM disk types which are disallowed. Known values are: "None" and - "Unmanaged". - :paramtype vm_disk_type: str or ~azure.mgmt.compute.v2024_11_01.models.VmDiskTypes + 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 + ) -> None: """ - super().__init__(**kwargs) - self.vm_disk_type = vm_disk_type + :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.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.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.models.CommunityGalleryImageIdentifier + :keyword recommended: The properties describe the recommended machine configuration for this + Image Definition. These properties are updatable. + :paramtype recommended: ~azure.mgmt.compute.models.RecommendedMachineConfiguration + :keyword disallowed: Describes the disallowed disk types. + :paramtype disallowed: ~azure.mgmt.compute.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.models.HyperVGeneration + :keyword features: A list of gallery image features. + :paramtype features: list[~azure.mgmt.compute.models.GalleryImageFeature] + :keyword purchase_plan: Describes the gallery image definition purchase plan. This is used by + marketplace images. + :paramtype purchase_plan: ~azure.mgmt.compute.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.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.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 -class SubResource(_serialization.Model): - """SubResource. +class CommunityGalleryImageIdentifier(_serialization.Model): + """This is the community gallery image definition identifier. - :ivar id: Resource Id. - :vartype id: str + :ivar publisher: The name of the gallery image definition publisher. + :vartype publisher: str + :ivar offer: The name of the gallery image definition offer. + :vartype offer: str + :ivar sku: The name of the gallery image definition SKU. + :vartype sku: str """ _attribute_map = { - "id": {"key": "id", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "offer": {"key": "offer", "type": "str"}, + "sku": {"key": "sku", "type": "str"}, } - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + def __init__( + self, *, publisher: Optional[str] = None, offer: Optional[str] = None, sku: Optional[str] = None, **kwargs: Any + ) -> None: """ - :keyword id: Resource Id. - :paramtype id: str + :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 """ super().__init__(**kwargs) - self.id = id - - -class DiskEncryptionSetParameters(SubResource): - """Describes the parameter of customer managed disk encryption set resource id that can be - specified for disk. **Note:** The disk encryption set resource id can only be specified for - managed disk. Please refer https://aka.ms/mdssewithcmkoverview for more details. + self.publisher = publisher + self.offer = offer + self.sku = sku - :ivar id: Resource Id. - :vartype id: str - """ +class CommunityGalleryImageList(_serialization.Model): + """The List Community Gallery Images operation response. -class DiskEncryptionSettings(_serialization.Model): - """Describes a Encryption Settings for a Disk. + All required parameters must be populated in order to send to server. - :ivar disk_encryption_key: Specifies the location of the disk encryption key, which is a Key - Vault Secret. - :vartype disk_encryption_key: ~azure.mgmt.compute.v2024_11_01.models.KeyVaultSecretReference - :ivar key_encryption_key: Specifies the location of the key encryption key in Key Vault. - :vartype key_encryption_key: ~azure.mgmt.compute.v2024_11_01.models.KeyVaultKeyReference - :ivar enabled: Specifies whether disk encryption should be enabled on the virtual machine. - :vartype enabled: bool + :ivar value: A list of community gallery images. Required. + :vartype value: list[~azure.mgmt.compute.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. + :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { - "disk_encryption_key": {"key": "diskEncryptionKey", "type": "KeyVaultSecretReference"}, - "key_encryption_key": {"key": "keyEncryptionKey", "type": "KeyVaultKeyReference"}, - "enabled": {"key": "enabled", "type": "bool"}, + "value": {"key": "value", "type": "[CommunityGalleryImage]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, - key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, - enabled: Optional[bool] = None, - **kwargs: Any + self, *, value: List["_models.CommunityGalleryImage"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword disk_encryption_key: Specifies the location of the disk encryption key, which is a Key - Vault Secret. - :paramtype disk_encryption_key: ~azure.mgmt.compute.v2024_11_01.models.KeyVaultSecretReference - :keyword key_encryption_key: Specifies the location of the key encryption key in Key Vault. - :paramtype key_encryption_key: ~azure.mgmt.compute.v2024_11_01.models.KeyVaultKeyReference - :keyword enabled: Specifies whether disk encryption should be enabled on the virtual machine. - :paramtype enabled: bool + :keyword value: A list of community gallery images. Required. + :paramtype value: list[~azure.mgmt.compute.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. + :paramtype next_link: str """ super().__init__(**kwargs) - self.disk_encryption_key = disk_encryption_key - self.key_encryption_key = key_encryption_key - self.enabled = enabled + self.value = value + self.next_link = next_link -class DiskInstanceView(_serialization.Model): - """The instance view of the disk. +class CommunityGalleryImageVersion(PirCommunityGalleryResource): + """Specifies information about the gallery image version that you want to create or update. - :ivar name: The disk name. + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Resource name. :vartype name: str - :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`\\ - :code:`
` Minimum api-version: 2015-06-15. - :vartype encryption_settings: - list[~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSettings] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :ivar location: Resource location. + :vartype location: str + :ivar type: Resource type. + :vartype type: str + :ivar unique_id: The unique id of this community gallery. + :vartype unique_id: str + :ivar published_date: The published date of the gallery image version Definition. This property + can be used for decommissioning purposes. This property is updatable. + :vartype published_date: ~datetime.datetime + :ivar 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. + :vartype end_of_life_date: ~datetime.datetime + :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of + the Image Definition won't use this Image Version. + :vartype exclude_from_latest: bool + :ivar storage_profile: Describes the storage profile of the image version. + :vartype storage_profile: ~azure.mgmt.compute.models.SharedGalleryImageVersionStorageProfile + :ivar disclaimer: The disclaimer for a community gallery resource. + :vartype disclaimer: str + :ivar artifact_tags: The artifact tags of a community gallery resource. + :vartype artifact_tags: dict[str, str] """ + _validation = { + "name": {"readonly": True}, + "location": {"readonly": True}, + "type": {"readonly": True}, + } + _attribute_map = { "name": {"key": "name", "type": "str"}, - "encryption_settings": {"key": "encryptionSettings", "type": "[DiskEncryptionSettings]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, + "location": {"key": "location", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "unique_id": {"key": "identifier.uniqueId", "type": "str"}, + "published_date": {"key": "properties.publishedDate", "type": "iso-8601"}, + "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, + "exclude_from_latest": {"key": "properties.excludeFromLatest", "type": "bool"}, + "storage_profile": {"key": "properties.storageProfile", "type": "SharedGalleryImageVersionStorageProfile"}, + "disclaimer": {"key": "properties.disclaimer", "type": "str"}, + "artifact_tags": {"key": "properties.artifactTags", "type": "{str}"}, } def __init__( self, *, - name: Optional[str] = None, - encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, + 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: """ - :keyword name: The disk name. - :paramtype name: str - :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`\\ - :code:`
` Minimum api-version: 2015-06-15. - :paramtype encryption_settings: - list[~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSettings] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.name = name - self.encryption_settings = encryption_settings - self.statuses = statuses + :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.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 -class SubResourceReadOnly(_serialization.Model): - """SubResourceReadOnly. +class CommunityGalleryImageVersionList(_serialization.Model): + """The List Community Gallery Image versions operation response. - 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 value: A list of community gallery image versions. Required. + :vartype value: list[~azure.mgmt.compute.models.CommunityGalleryImageVersion] + :ivar next_link: The URI to fetch the next page of community gallery image versions. Call + ListNext() with this to fetch the next page of community gallery image versions. + :vartype next_link: str """ _validation = { - "id": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { - "id": {"key": "id", "type": "str"}, + "value": {"key": "value", "type": "[CommunityGalleryImageVersion]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, *, value: List["_models.CommunityGalleryImageVersion"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: A list of community gallery image versions. Required. + :paramtype value: list[~azure.mgmt.compute.models.CommunityGalleryImageVersion] + :keyword next_link: The URI to fetch the next page of community gallery image versions. Call + ListNext() with this to fetch the next page of community gallery image versions. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.id: Optional[str] = None + self.value = value + self.next_link = next_link -class DiskRestorePointAttributes(SubResourceReadOnly): - """Disk Restore Point details. +class CommunityGalleryInfo(_serialization.Model): + """Information of community gallery if current gallery is shared to community. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. - :vartype id: str - :ivar encryption: Encryption at rest settings for disk restore point. It is an optional - property that can be specified in the input while creating a restore point. - :vartype encryption: ~azure.mgmt.compute.v2024_11_01.models.RestorePointEncryption - :ivar source_disk_restore_point: Resource Id of the source disk restore point. - :vartype source_disk_restore_point: ~azure.mgmt.compute.v2024_11_01.models.ApiEntityReference + :ivar publisher_uri: The link to the publisher website. Visible to all users. + :vartype publisher_uri: str + :ivar publisher_contact: Community gallery publisher support email. The email address of the + publisher. Visible to all users. + :vartype publisher_contact: str + :ivar eula: End-user license agreement for community gallery image. + :vartype eula: str + :ivar public_name_prefix: The prefix of the gallery name that will be displayed publicly. + Visible to all users. + :vartype public_name_prefix: str + :ivar community_gallery_enabled: Contains info about whether community gallery sharing is + enabled. + :vartype community_gallery_enabled: bool + :ivar public_names: Community gallery public name list. + :vartype public_names: list[str] """ _validation = { - "id": {"readonly": True}, + "community_gallery_enabled": {"readonly": True}, + "public_names": {"readonly": True}, } _attribute_map = { - "id": {"key": "id", "type": "str"}, - "encryption": {"key": "encryption", "type": "RestorePointEncryption"}, - "source_disk_restore_point": {"key": "sourceDiskRestorePoint", "type": "ApiEntityReference"}, + "publisher_uri": {"key": "publisherUri", "type": "str"}, + "publisher_contact": {"key": "publisherContact", "type": "str"}, + "eula": {"key": "eula", "type": "str"}, + "public_name_prefix": {"key": "publicNamePrefix", "type": "str"}, + "community_gallery_enabled": {"key": "communityGalleryEnabled", "type": "bool"}, + "public_names": {"key": "publicNames", "type": "[str]"}, } def __init__( self, *, - encryption: Optional["_models.RestorePointEncryption"] = None, - source_disk_restore_point: Optional["_models.ApiEntityReference"] = None, + publisher_uri: Optional[str] = None, + publisher_contact: Optional[str] = None, + eula: Optional[str] = None, + public_name_prefix: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword encryption: Encryption at rest settings for disk restore point. It is an optional - property that can be specified in the input while creating a restore point. - :paramtype encryption: ~azure.mgmt.compute.v2024_11_01.models.RestorePointEncryption - :keyword source_disk_restore_point: Resource Id of the source disk restore point. - :paramtype source_disk_restore_point: ~azure.mgmt.compute.v2024_11_01.models.ApiEntityReference + :keyword publisher_uri: The link to the publisher website. Visible to all users. + :paramtype publisher_uri: str + :keyword publisher_contact: Community gallery publisher support email. The email address of the + publisher. Visible to all users. + :paramtype publisher_contact: str + :keyword eula: End-user license agreement for community gallery image. + :paramtype eula: str + :keyword public_name_prefix: The prefix of the gallery name that will be displayed publicly. + Visible to all users. + :paramtype public_name_prefix: str """ super().__init__(**kwargs) - self.encryption = encryption - self.source_disk_restore_point = source_disk_restore_point + self.publisher_uri = publisher_uri + self.publisher_contact = publisher_contact + self.eula = eula + self.public_name_prefix = public_name_prefix + self.community_gallery_enabled: Optional[bool] = None + self.public_names: Optional[List[str]] = None -class DiskRestorePointInstanceView(_serialization.Model): - """The instance view of a disk restore point. +class CommunityGalleryMetadata(_serialization.Model): + """The metadata of community gallery. - :ivar id: Disk restore point Id. - :vartype id: str - :ivar replication_status: The disk restore point replication status information. - :vartype replication_status: - ~azure.mgmt.compute.v2024_11_01.models.DiskRestorePointReplicationStatus + All required parameters must be populated in order to send to server. + + :ivar publisher_uri: The publisher URI of this community gallery. + :vartype publisher_uri: str + :ivar publisher_contact: The publisher email id of this community gallery. Required. + :vartype publisher_contact: str + :ivar eula: The end-user license agreement for this community gallery. + :vartype eula: str + :ivar public_names: A list of public names the gallery has. Required. + :vartype public_names: list[str] + :ivar privacy_statement_uri: The link for the privacy statement of this community gallery from + the gallery publisher. + :vartype privacy_statement_uri: str """ + _validation = { + "publisher_contact": {"required": True}, + "public_names": {"required": True}, + } + _attribute_map = { - "id": {"key": "id", "type": "str"}, - "replication_status": {"key": "replicationStatus", "type": "DiskRestorePointReplicationStatus"}, + "publisher_uri": {"key": "publisherUri", "type": "str"}, + "publisher_contact": {"key": "publisherContact", "type": "str"}, + "eula": {"key": "eula", "type": "str"}, + "public_names": {"key": "publicNames", "type": "[str]"}, + "privacy_statement_uri": {"key": "privacyStatementUri", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - replication_status: Optional["_models.DiskRestorePointReplicationStatus"] = None, + 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 id: Disk restore point Id. - :paramtype id: str - :keyword replication_status: The disk restore point replication status information. - :paramtype replication_status: - ~azure.mgmt.compute.v2024_11_01.models.DiskRestorePointReplicationStatus + :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 """ super().__init__(**kwargs) - self.id = id - self.replication_status = replication_status + 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 -class DiskRestorePointReplicationStatus(_serialization.Model): - """The instance view of a disk restore point. +class ConvertToVirtualMachineScaleSetInput(_serialization.Model): + """Describes the Virtual Machine Scale Set to convert from Availability Set. - :ivar status: The resource status information. - :vartype status: ~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus - :ivar completion_percent: Replication completion percentage. - :vartype completion_percent: int + :ivar virtual_machine_scale_set_name: Specifies information about the Virtual Machine Scale Set + that the Availability Set should be converted to. + :vartype virtual_machine_scale_set_name: str """ _attribute_map = { - "status": {"key": "status", "type": "InstanceViewStatus"}, - "completion_percent": {"key": "completionPercent", "type": "int"}, + "virtual_machine_scale_set_name": {"key": "virtualMachineScaleSetName", "type": "str"}, } - def __init__( - self, - *, - status: Optional["_models.InstanceViewStatus"] = None, - completion_percent: Optional[int] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, virtual_machine_scale_set_name: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword status: The resource status information. - :paramtype status: ~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus - :keyword completion_percent: Replication completion percentage. - :paramtype completion_percent: int + :keyword virtual_machine_scale_set_name: Specifies information about the Virtual Machine Scale + Set that the Availability Set should be converted to. + :paramtype virtual_machine_scale_set_name: str """ super().__init__(**kwargs) - self.status = status - self.completion_percent = completion_percent + self.virtual_machine_scale_set_name = virtual_machine_scale_set_name -class EncryptionIdentity(_serialization.Model): - """Specifies the Managed Identity used by ADE to get access token for keyvault operations. +class CopyCompletionError(_serialization.Model): + """Indicates the error details if the background copy of a resource created via the CopyStart + operation fails. - :ivar user_assigned_identity_resource_id: Specifies ARM Resource ID of one of the user - identities associated with the VM. - :vartype user_assigned_identity_resource_id: str + All required parameters must be populated in order to send to server. + + :ivar error_code: Indicates the error code if the background copy of a resource created via the + CopyStart operation fails. Required. "CopySourceNotFound" + :vartype error_code: str or ~azure.mgmt.compute.models.CopyCompletionErrorReason + :ivar error_message: Indicates the error message if the background copy of a resource created + via the CopyStart operation fails. Required. + :vartype error_message: str """ + _validation = { + "error_code": {"required": True}, + "error_message": {"required": True}, + } + _attribute_map = { - "user_assigned_identity_resource_id": {"key": "userAssignedIdentityResourceId", "type": "str"}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, } - def __init__(self, *, user_assigned_identity_resource_id: Optional[str] = None, **kwargs: Any) -> None: + def __init__( + self, *, error_code: Union[str, "_models.CopyCompletionErrorReason"], error_message: str, **kwargs: Any + ) -> None: """ - :keyword user_assigned_identity_resource_id: Specifies ARM Resource ID of one of the user - identities associated with the VM. - :paramtype user_assigned_identity_resource_id: str + :keyword error_code: Indicates the error code if the background copy of a resource created via + the CopyStart operation fails. Required. "CopySourceNotFound" + :paramtype error_code: str or ~azure.mgmt.compute.models.CopyCompletionErrorReason + :keyword error_message: Indicates the error message if the background copy of a resource + created via the CopyStart operation fails. Required. + :paramtype error_message: str """ super().__init__(**kwargs) - self.user_assigned_identity_resource_id = user_assigned_identity_resource_id + self.error_code = error_code + self.error_message = error_message -class EventGridAndResourceGraph(_serialization.Model): - """Specifies eventGridAndResourceGraph related Scheduled Event related configurations. +class CreationData(_serialization.Model): + """Data used when creating a disk. - :ivar enable: Specifies if event grid and resource graph is enabled for Scheduled event related - configurations. - :vartype enable: bool + 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 create_option: This enumerates the possible sources of a disk's creation. Required. Known + values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", "CopyStart", + "ImportSecure", "UploadPreparedSecure", "CopyFromSanSnapshot", and "Import". + :vartype create_option: str or ~azure.mgmt.compute.models.DiskCreateOption + :ivar storage_account_id: Required if createOption is Import. The Azure Resource Manager + identifier of the storage account containing the blob to import as a disk. + :vartype storage_account_id: str + :ivar image_reference: Disk source information for PIR or user images. + :vartype image_reference: ~azure.mgmt.compute.models.ImageDiskReference + :ivar gallery_image_reference: Required if creating from a Gallery Image. The + id/sharedGalleryImageId/communityGalleryImageId of the ImageDiskReference will be the ARM id of + the shared galley image version from which to create a disk. + :vartype gallery_image_reference: ~azure.mgmt.compute.models.ImageDiskReference + :ivar source_uri: If createOption is Import, this is the URI of a blob to be imported into a + managed disk. + :vartype source_uri: str + :ivar source_resource_id: If createOption is Copy, this is the ARM id of the source snapshot or + disk. + :vartype source_resource_id: str + :ivar source_unique_id: If this field is set, this is the unique id identifying the source of + this resource. + :vartype source_unique_id: str + :ivar upload_size_bytes: If createOption is Upload, this is the size of the contents of the + upload including the VHD footer. This value should be between 20972032 (20 MiB + 512 bytes for + the VHD footer) and 35183298347520 bytes (32 TiB + 512 bytes for the VHD footer). + :vartype upload_size_bytes: int + :ivar logical_sector_size: Logical sector size in bytes for Ultra disks. Supported values are + 512 ad 4096. 4096 is the default. + :vartype logical_sector_size: int + :ivar security_data_uri: If createOption is ImportSecure, this is the URI of a blob to be + imported into VM guest state. + :vartype security_data_uri: str + :ivar performance_plus: Set this flag to true to get a boost on the performance target of the + disk deployed, see here on the respective performance target. This flag can only be set on disk + creation time and cannot be disabled after enabled. + :vartype performance_plus: bool + :ivar elastic_san_resource_id: Required if createOption is CopyFromSanSnapshot. This is the ARM + id of the source elastic san volume snapshot. + :vartype elastic_san_resource_id: str + :ivar provisioned_bandwidth_copy_speed: If this field is set on a snapshot and createOption is + CopyStart, the snapshot will be copied at a quicker speed. Known values are: "None" and + "Enhanced". + :vartype provisioned_bandwidth_copy_speed: str or + ~azure.mgmt.compute.models.ProvisionedBandwidthCopyOption """ + _validation = { + "create_option": {"required": True}, + "source_unique_id": {"readonly": True}, + } + _attribute_map = { - "enable": {"key": "enable", "type": "bool"}, + "create_option": {"key": "createOption", "type": "str"}, + "storage_account_id": {"key": "storageAccountId", "type": "str"}, + "image_reference": {"key": "imageReference", "type": "ImageDiskReference"}, + "gallery_image_reference": {"key": "galleryImageReference", "type": "ImageDiskReference"}, + "source_uri": {"key": "sourceUri", "type": "str"}, + "source_resource_id": {"key": "sourceResourceId", "type": "str"}, + "source_unique_id": {"key": "sourceUniqueId", "type": "str"}, + "upload_size_bytes": {"key": "uploadSizeBytes", "type": "int"}, + "logical_sector_size": {"key": "logicalSectorSize", "type": "int"}, + "security_data_uri": {"key": "securityDataUri", "type": "str"}, + "performance_plus": {"key": "performancePlus", "type": "bool"}, + "elastic_san_resource_id": {"key": "elasticSanResourceId", "type": "str"}, + "provisioned_bandwidth_copy_speed": {"key": "provisionedBandwidthCopySpeed", "type": "str"}, } - def __init__(self, *, enable: Optional[bool] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + create_option: Union[str, "_models.DiskCreateOption"], + storage_account_id: Optional[str] = None, + image_reference: Optional["_models.ImageDiskReference"] = None, + gallery_image_reference: Optional["_models.ImageDiskReference"] = None, + source_uri: Optional[str] = None, + source_resource_id: Optional[str] = None, + upload_size_bytes: Optional[int] = None, + logical_sector_size: Optional[int] = None, + security_data_uri: Optional[str] = None, + performance_plus: Optional[bool] = None, + elastic_san_resource_id: Optional[str] = None, + provisioned_bandwidth_copy_speed: Optional[Union[str, "_models.ProvisionedBandwidthCopyOption"]] = None, + **kwargs: Any + ) -> None: """ - :keyword enable: Specifies if event grid and resource graph is enabled for Scheduled event - related configurations. - :paramtype enable: bool + :keyword create_option: This enumerates the possible sources of a disk's creation. Required. + Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", + "CopyStart", "ImportSecure", "UploadPreparedSecure", "CopyFromSanSnapshot", and "Import". + :paramtype create_option: str or ~azure.mgmt.compute.models.DiskCreateOption + :keyword storage_account_id: Required if createOption is Import. The Azure Resource Manager + identifier of the storage account containing the blob to import as a disk. + :paramtype storage_account_id: str + :keyword image_reference: Disk source information for PIR or user images. + :paramtype image_reference: ~azure.mgmt.compute.models.ImageDiskReference + :keyword gallery_image_reference: Required if creating from a Gallery Image. The + id/sharedGalleryImageId/communityGalleryImageId of the ImageDiskReference will be the ARM id of + the shared galley image version from which to create a disk. + :paramtype gallery_image_reference: ~azure.mgmt.compute.models.ImageDiskReference + :keyword source_uri: If createOption is Import, this is the URI of a blob to be imported into a + managed disk. + :paramtype source_uri: str + :keyword source_resource_id: If createOption is Copy, this is the ARM id of the source snapshot + or disk. + :paramtype source_resource_id: str + :keyword upload_size_bytes: If createOption is Upload, this is the size of the contents of the + upload including the VHD footer. This value should be between 20972032 (20 MiB + 512 bytes for + the VHD footer) and 35183298347520 bytes (32 TiB + 512 bytes for the VHD footer). + :paramtype upload_size_bytes: int + :keyword logical_sector_size: Logical sector size in bytes for Ultra disks. Supported values + are 512 ad 4096. 4096 is the default. + :paramtype logical_sector_size: int + :keyword security_data_uri: If createOption is ImportSecure, this is the URI of a blob to be + imported into VM guest state. + :paramtype security_data_uri: str + :keyword performance_plus: Set this flag to true to get a boost on the performance target of + the disk deployed, see here on the respective performance target. This flag can only be set on + disk creation time and cannot be disabled after enabled. + :paramtype performance_plus: bool + :keyword elastic_san_resource_id: Required if createOption is CopyFromSanSnapshot. This is the + ARM id of the source elastic san volume snapshot. + :paramtype elastic_san_resource_id: str + :keyword provisioned_bandwidth_copy_speed: If this field is set on a snapshot and createOption + is CopyStart, the snapshot will be copied at a quicker speed. Known values are: "None" and + "Enhanced". + :paramtype provisioned_bandwidth_copy_speed: str or + ~azure.mgmt.compute.models.ProvisionedBandwidthCopyOption """ super().__init__(**kwargs) - self.enable = enable + self.create_option = create_option + self.storage_account_id = storage_account_id + self.image_reference = image_reference + self.gallery_image_reference = gallery_image_reference + self.source_uri = source_uri + self.source_resource_id = source_resource_id + self.source_unique_id: Optional[str] = None + self.upload_size_bytes = upload_size_bytes + self.logical_sector_size = logical_sector_size + self.security_data_uri = security_data_uri + self.performance_plus = performance_plus + self.elastic_san_resource_id = elastic_san_resource_id + self.provisioned_bandwidth_copy_speed = provisioned_bandwidth_copy_speed -class ExtendedLocation(_serialization.Model): - """The complex type of the extended location. +class DataDisk(_serialization.Model): + """Describes a data disk. - :ivar name: The name of the extended 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 lun: Specifies the logical unit number of the data disk. This value is used to identify + data disks within the VM and therefore must be unique for each data disk attached to a VM. + Required. + :vartype lun: int + :ivar name: The disk name. :vartype name: str - :ivar type: The type of the extended location. "EdgeZone" - :vartype type: str or ~azure.mgmt.compute.v2024_11_01.models.ExtendedLocationTypes + :ivar vhd: The virtual hard disk. + :vartype vhd: ~azure.mgmt.compute.models.VirtualHardDisk + :ivar image: 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. + :vartype image: ~azure.mgmt.compute.models.VirtualHardDisk + :ivar caching: Specifies the caching requirements. Possible values are: **None,** **ReadOnly,** + **ReadWrite.** The defaulting behavior is: **None for Standard storage. ReadOnly for Premium + storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". + :vartype caching: str or ~azure.mgmt.compute.models.CachingTypes + :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or + disabled on the disk. + :vartype write_accelerator_enabled: bool + :ivar create_option: Specifies how the virtual machine disk should be created. Possible values + are **Attach:** This value is used when you are using a specialized disk to create the virtual + machine. **FromImage:** This value is used when you are using an image to create the virtual + machine data disk. If you are using a platform image, you should also use the imageReference + element described above. If you are using a marketplace image, you should also use the plan + element previously described. **Empty:** This value is used when creating an empty data disk. + **Copy:** This value is used to create a data disk from a snapshot or another disk. + **Restore:** This value is used to create a data disk from a disk restore point. Required. + Known values are: "FromImage", "Empty", "Attach", "Copy", and "Restore". + :vartype create_option: str or ~azure.mgmt.compute.models.DiskCreateOptionTypes + :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be + used to overwrite the size of the disk in a virtual machine image. The property 'diskSizeGB' is + the number of bytes x 1024^3 for the disk and the value cannot be larger than 1023. + :vartype disk_size_gb: int + :ivar managed_disk: The managed disk parameters. + :vartype managed_disk: ~azure.mgmt.compute.models.ManagedDiskParameters + :ivar source_resource: The source resource identifier. It can be a snapshot, or disk restore + point from which to create a disk. + :vartype source_resource: ~azure.mgmt.compute.models.ApiEntityReference + :ivar to_be_detached: Specifies whether the data disk is in process of detachment from the + VirtualMachine/VirtualMachineScaleset. + :vartype to_be_detached: bool + :ivar disk_iops_read_write: Specifies the Read-Write IOPS for the managed disk when + StorageAccountType is UltraSSD_LRS. Returned only for VirtualMachine ScaleSet VM disks. Can be + updated only via updates to the VirtualMachine Scale Set. + :vartype disk_iops_read_write: int + :ivar disk_m_bps_read_write: Specifies the bandwidth in MB per second for the managed disk when + StorageAccountType is UltraSSD_LRS. Returned only for VirtualMachine ScaleSet VM disks. Can be + updated only via updates to the VirtualMachine Scale Set. + :vartype disk_m_bps_read_write: int + :ivar detach_option: Specifies the detach behavior to be used while detaching a disk or which + is already in the process of detachment from the virtual machine. Supported values: + **ForceDetach.** detachOption: **ForceDetach** is applicable only for managed data disks. If a + 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. **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.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 + VM is deleted. **Detach.** If this value is used, the data disk is retained after VM is + deleted. The default value is set to **Detach**. Known values are: "Delete" and "Detach". + :vartype delete_option: str or ~azure.mgmt.compute.models.DiskDeleteOptionTypes """ + _validation = { + "lun": {"required": True}, + "create_option": {"required": True}, + "disk_iops_read_write": {"readonly": True}, + "disk_m_bps_read_write": {"readonly": True}, + } + _attribute_map = { + "lun": {"key": "lun", "type": "int"}, "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, + "vhd": {"key": "vhd", "type": "VirtualHardDisk"}, + "image": {"key": "image", "type": "VirtualHardDisk"}, + "caching": {"key": "caching", "type": "str"}, + "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, + "create_option": {"key": "createOption", "type": "str"}, + "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, + "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, + "source_resource": {"key": "sourceResource", "type": "ApiEntityReference"}, + "to_be_detached": {"key": "toBeDetached", "type": "bool"}, + "disk_iops_read_write": {"key": "diskIOPSReadWrite", "type": "int"}, + "disk_m_bps_read_write": {"key": "diskMBpsReadWrite", "type": "int"}, + "detach_option": {"key": "detachOption", "type": "str"}, + "delete_option": {"key": "deleteOption", "type": "str"}, } def __init__( self, *, + lun: int, + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, + write_accelerator_enabled: Optional[bool] = None, + disk_size_gb: Optional[int] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + source_resource: Optional["_models.ApiEntityReference"] = None, + to_be_detached: Optional[bool] = None, + detach_option: Optional[Union[str, "_models.DiskDetachOptionTypes"]] = None, + delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, **kwargs: Any ) -> None: """ - :keyword name: The name of the extended location. + :keyword lun: Specifies the logical unit number of the data disk. This value is used to + identify data disks within the VM and therefore must be unique for each data disk attached to a + VM. Required. + :paramtype lun: int + :keyword name: The disk name. :paramtype name: str - :keyword type: The type of the extended location. "EdgeZone" - :paramtype type: str or ~azure.mgmt.compute.v2024_11_01.models.ExtendedLocationTypes + :keyword vhd: The virtual hard disk. + :paramtype vhd: ~azure.mgmt.compute.models.VirtualHardDisk + :keyword image: 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. + :paramtype image: ~azure.mgmt.compute.models.VirtualHardDisk + :keyword caching: Specifies the caching requirements. Possible values are: **None,** + **ReadOnly,** **ReadWrite.** The defaulting behavior is: **None for Standard storage. ReadOnly + for Premium storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". + :paramtype caching: str or ~azure.mgmt.compute.models.CachingTypes + :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or + disabled on the disk. + :paramtype write_accelerator_enabled: bool + :keyword create_option: Specifies how the virtual machine disk should be created. Possible + values are **Attach:** This value is used when you are using a specialized disk to create the + virtual machine. **FromImage:** This value is used when you are using an image to create the + virtual machine data disk. If you are using a platform image, you should also use the + imageReference element described above. If you are using a marketplace image, you should also + use the plan element previously described. **Empty:** This value is used when creating an empty + data disk. **Copy:** This value is used to create a data disk from a snapshot or another disk. + **Restore:** This value is used to create a data disk from a disk restore point. Required. + Known values are: "FromImage", "Empty", "Attach", "Copy", and "Restore". + :paramtype create_option: str or ~azure.mgmt.compute.models.DiskCreateOptionTypes + :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can + be used to overwrite the size of the disk in a virtual machine image. The property 'diskSizeGB' + is the number of bytes x 1024^3 for the disk and the value cannot be larger than 1023. + :paramtype disk_size_gb: int + :keyword managed_disk: The managed disk parameters. + :paramtype managed_disk: ~azure.mgmt.compute.models.ManagedDiskParameters + :keyword source_resource: The source resource identifier. It can be a snapshot, or disk restore + point from which to create a disk. + :paramtype source_resource: ~azure.mgmt.compute.models.ApiEntityReference + :keyword to_be_detached: Specifies whether the data disk is in process of detachment from the + VirtualMachine/VirtualMachineScaleset. + :paramtype to_be_detached: bool + :keyword detach_option: Specifies the detach behavior to be used while detaching a disk or + which is already in the process of detachment from the virtual machine. Supported values: + **ForceDetach.** detachOption: **ForceDetach** is applicable only for managed data disks. If a + 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. **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.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 + VM is deleted. **Detach.** If this value is used, the data disk is retained after VM is + deleted. The default value is set to **Detach**. Known values are: "Delete" and "Detach". + :paramtype delete_option: str or ~azure.mgmt.compute.models.DiskDeleteOptionTypes """ super().__init__(**kwargs) + self.lun = lun self.name = name - self.type = type - - -class HardwareProfile(_serialization.Model): - """Specifies the hardware settings for the virtual machine. - - :ivar vm_size: Specifies the size of the virtual machine. The enum data type is currently - deprecated and will be removed by December 23rd 2023. The recommended way to get the list of - available sizes is using these APIs: `List all available virtual machine sizes in an - availability set - `_\\ , `List - all available virtual machine sizes in a region - `_\\ , `List all available - virtual machine sizes for resizing - `_. For more - information about virtual machine sizes, see `Sizes for virtual machines - `_. The available VM sizes depend on - region and availability set. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", - "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", - "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", - "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", - "Standard_A2m_v2", "Standard_A4m_v2", "Standard_A8m_v2", "Standard_B1s", "Standard_B1ms", - "Standard_B2s", "Standard_B2ms", "Standard_B4ms", "Standard_B8ms", "Standard_D1", - "Standard_D2", "Standard_D3", "Standard_D4", "Standard_D11", "Standard_D12", "Standard_D13", - "Standard_D14", "Standard_D1_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", - "Standard_D5_v2", "Standard_D2_v3", "Standard_D4_v3", "Standard_D8_v3", "Standard_D16_v3", - "Standard_D32_v3", "Standard_D64_v3", "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", - "Standard_D16s_v3", "Standard_D32s_v3", "Standard_D64s_v3", "Standard_D11_v2", - "Standard_D12_v2", "Standard_D13_v2", "Standard_D14_v2", "Standard_D15_v2", "Standard_DS1", - "Standard_DS2", "Standard_DS3", "Standard_DS4", "Standard_DS11", "Standard_DS12", - "Standard_DS13", "Standard_DS14", "Standard_DS1_v2", "Standard_DS2_v2", "Standard_DS3_v2", - "Standard_DS4_v2", "Standard_DS5_v2", "Standard_DS11_v2", "Standard_DS12_v2", - "Standard_DS13_v2", "Standard_DS14_v2", "Standard_DS15_v2", "Standard_DS13-4_v2", - "Standard_DS13-2_v2", "Standard_DS14-8_v2", "Standard_DS14-4_v2", "Standard_E2_v3", - "Standard_E4_v3", "Standard_E8_v3", "Standard_E16_v3", "Standard_E32_v3", "Standard_E64_v3", - "Standard_E2s_v3", "Standard_E4s_v3", "Standard_E8s_v3", "Standard_E16s_v3", - "Standard_E32s_v3", "Standard_E64s_v3", "Standard_E32-16_v3", "Standard_E32-8s_v3", - "Standard_E64-32s_v3", "Standard_E64-16s_v3", "Standard_F1", "Standard_F2", "Standard_F4", - "Standard_F8", "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", - "Standard_F16s", "Standard_F2s_v2", "Standard_F4s_v2", "Standard_F8s_v2", "Standard_F16s_v2", - "Standard_F32s_v2", "Standard_F64s_v2", "Standard_F72s_v2", "Standard_G1", "Standard_G2", - "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", "Standard_GS3", - "Standard_GS4", "Standard_GS5", "Standard_GS4-8", "Standard_GS4-4", "Standard_GS5-16", - "Standard_GS5-8", "Standard_H8", "Standard_H16", "Standard_H8m", "Standard_H16m", - "Standard_H16r", "Standard_H16mr", "Standard_L4s", "Standard_L8s", "Standard_L16s", - "Standard_L32s", "Standard_M64s", "Standard_M64ms", "Standard_M128s", "Standard_M128ms", - "Standard_M64-32ms", "Standard_M64-16ms", "Standard_M128-64ms", "Standard_M128-32ms", - "Standard_NC6", "Standard_NC12", "Standard_NC24", "Standard_NC24r", "Standard_NC6s_v2", - "Standard_NC12s_v2", "Standard_NC24s_v2", "Standard_NC24rs_v2", "Standard_NC6s_v3", - "Standard_NC12s_v3", "Standard_NC24s_v3", "Standard_NC24rs_v3", "Standard_ND6s", - "Standard_ND12s", "Standard_ND24s", "Standard_ND24rs", "Standard_NV6", "Standard_NV12", and - "Standard_NV24". - :vartype vm_size: str or ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSizeTypes - :ivar vm_size_properties: Specifies the properties for customizing the size of the virtual - machine. Minimum api-version: 2021-07-01. This feature is still in preview mode and is not - supported for VirtualMachineScaleSet. Please follow the instructions in `VM Customization - `_ for more details. - :vartype vm_size_properties: ~azure.mgmt.compute.v2024_11_01.models.VMSizeProperties + self.vhd = vhd + self.image = image + self.caching = caching + self.write_accelerator_enabled = write_accelerator_enabled + self.create_option = create_option + self.disk_size_gb = disk_size_gb + self.managed_disk = managed_disk + self.source_resource = source_resource + self.to_be_detached = to_be_detached + self.disk_iops_read_write: Optional[int] = None + self.disk_m_bps_read_write: Optional[int] = None + self.detach_option = detach_option + self.delete_option = delete_option + + +class DataDiskImage(_serialization.Model): + """Contains the data disk images information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify + data disks within the VM and therefore must be unique for each data disk attached to a VM. + :vartype lun: int """ + _validation = { + "lun": {"readonly": True}, + } + _attribute_map = { - "vm_size": {"key": "vmSize", "type": "str"}, - "vm_size_properties": {"key": "vmSizeProperties", "type": "VMSizeProperties"}, + "lun": {"key": "lun", "type": "int"}, } - def __init__( - self, - *, - vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, - vm_size_properties: Optional["_models.VMSizeProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword vm_size: Specifies the size of the virtual machine. The enum data type is currently - deprecated and will be removed by December 23rd 2023. The recommended way to get the list of - available sizes is using these APIs: `List all available virtual machine sizes in an - availability set - `_\\ , `List - all available virtual machine sizes in a region - `_\\ , `List all available - virtual machine sizes for resizing - `_. For more - information about virtual machine sizes, see `Sizes for virtual machines - `_. The available VM sizes depend on - region and availability set. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", - "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", - "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", - "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", - "Standard_A2m_v2", "Standard_A4m_v2", "Standard_A8m_v2", "Standard_B1s", "Standard_B1ms", - "Standard_B2s", "Standard_B2ms", "Standard_B4ms", "Standard_B8ms", "Standard_D1", - "Standard_D2", "Standard_D3", "Standard_D4", "Standard_D11", "Standard_D12", "Standard_D13", - "Standard_D14", "Standard_D1_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", - "Standard_D5_v2", "Standard_D2_v3", "Standard_D4_v3", "Standard_D8_v3", "Standard_D16_v3", - "Standard_D32_v3", "Standard_D64_v3", "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", - "Standard_D16s_v3", "Standard_D32s_v3", "Standard_D64s_v3", "Standard_D11_v2", - "Standard_D12_v2", "Standard_D13_v2", "Standard_D14_v2", "Standard_D15_v2", "Standard_DS1", - "Standard_DS2", "Standard_DS3", "Standard_DS4", "Standard_DS11", "Standard_DS12", - "Standard_DS13", "Standard_DS14", "Standard_DS1_v2", "Standard_DS2_v2", "Standard_DS3_v2", - "Standard_DS4_v2", "Standard_DS5_v2", "Standard_DS11_v2", "Standard_DS12_v2", - "Standard_DS13_v2", "Standard_DS14_v2", "Standard_DS15_v2", "Standard_DS13-4_v2", - "Standard_DS13-2_v2", "Standard_DS14-8_v2", "Standard_DS14-4_v2", "Standard_E2_v3", - "Standard_E4_v3", "Standard_E8_v3", "Standard_E16_v3", "Standard_E32_v3", "Standard_E64_v3", - "Standard_E2s_v3", "Standard_E4s_v3", "Standard_E8s_v3", "Standard_E16s_v3", - "Standard_E32s_v3", "Standard_E64s_v3", "Standard_E32-16_v3", "Standard_E32-8s_v3", - "Standard_E64-32s_v3", "Standard_E64-16s_v3", "Standard_F1", "Standard_F2", "Standard_F4", - "Standard_F8", "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", - "Standard_F16s", "Standard_F2s_v2", "Standard_F4s_v2", "Standard_F8s_v2", "Standard_F16s_v2", - "Standard_F32s_v2", "Standard_F64s_v2", "Standard_F72s_v2", "Standard_G1", "Standard_G2", - "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", "Standard_GS3", - "Standard_GS4", "Standard_GS5", "Standard_GS4-8", "Standard_GS4-4", "Standard_GS5-16", - "Standard_GS5-8", "Standard_H8", "Standard_H16", "Standard_H8m", "Standard_H16m", - "Standard_H16r", "Standard_H16mr", "Standard_L4s", "Standard_L8s", "Standard_L16s", - "Standard_L32s", "Standard_M64s", "Standard_M64ms", "Standard_M128s", "Standard_M128ms", - "Standard_M64-32ms", "Standard_M64-16ms", "Standard_M128-64ms", "Standard_M128-32ms", - "Standard_NC6", "Standard_NC12", "Standard_NC24", "Standard_NC24r", "Standard_NC6s_v2", - "Standard_NC12s_v2", "Standard_NC24s_v2", "Standard_NC24rs_v2", "Standard_NC6s_v3", - "Standard_NC12s_v3", "Standard_NC24s_v3", "Standard_NC24rs_v3", "Standard_ND6s", - "Standard_ND12s", "Standard_ND24s", "Standard_ND24rs", "Standard_NV6", "Standard_NV12", and - "Standard_NV24". - :paramtype vm_size: str or ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSizeTypes - :keyword vm_size_properties: Specifies the properties for customizing the size of the virtual - machine. Minimum api-version: 2021-07-01. This feature is still in preview mode and is not - supported for VirtualMachineScaleSet. Please follow the instructions in `VM Customization - `_ for more details. - :paramtype vm_size_properties: ~azure.mgmt.compute.v2024_11_01.models.VMSizeProperties - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.vm_size = vm_size - self.vm_size_properties = vm_size_properties + self.lun: Optional[int] = None -class HostEndpointSettings(_serialization.Model): - """Specifies particular host endpoint settings. +class DiskImageEncryption(_serialization.Model): + """This is the disk image encryption base class. - :ivar mode: Specifies the execution mode. In Audit mode, the system acts as if it is enforcing - the access control policy, including emitting access denial entries in the logs but it does not - actually deny any requests to host endpoints. In Enforce mode, the system will enforce the - access control and it is the recommended mode of operation. Known values are: "Audit", - "Enforce", and "Disabled". - :vartype mode: str or ~azure.mgmt.compute.v2024_11_01.models.Modes - :ivar in_vm_access_control_profile_reference_id: Specifies the InVMAccessControlProfileVersion - resource id in the format of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/inVMAccessControlProfiles/{profile}/versions/{version}. - :vartype in_vm_access_control_profile_reference_id: str + :ivar disk_encryption_set_id: A relative URI containing the resource ID of the disk encryption + set. + :vartype disk_encryption_set_id: str """ _attribute_map = { - "mode": {"key": "mode", "type": "str"}, - "in_vm_access_control_profile_reference_id": {"key": "inVMAccessControlProfileReferenceId", "type": "str"}, + "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, } - def __init__( - self, - *, - mode: Optional[Union[str, "_models.Modes"]] = None, - in_vm_access_control_profile_reference_id: Optional[str] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, disk_encryption_set_id: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword mode: Specifies the execution mode. In Audit mode, the system acts as if it is - enforcing the access control policy, including emitting access denial entries in the logs but - it does not actually deny any requests to host endpoints. In Enforce mode, the system will - enforce the access control and it is the recommended mode of operation. Known values are: - "Audit", "Enforce", and "Disabled". - :paramtype mode: str or ~azure.mgmt.compute.v2024_11_01.models.Modes - :keyword in_vm_access_control_profile_reference_id: Specifies the - InVMAccessControlProfileVersion resource id in the format of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/inVMAccessControlProfiles/{profile}/versions/{version}. - :paramtype in_vm_access_control_profile_reference_id: str + :keyword disk_encryption_set_id: A relative URI containing the resource ID of the disk + encryption set. + :paramtype disk_encryption_set_id: str """ super().__init__(**kwargs) - self.mode = mode - self.in_vm_access_control_profile_reference_id = in_vm_access_control_profile_reference_id - + self.disk_encryption_set_id = disk_encryption_set_id -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. - Variables are only populated by the server, and will be ignored when sending a request. +class DataDiskImageEncryption(DiskImageEncryption): + """Contains encryption settings for a data disk image. 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}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar extended_location: The extended location of the Image. - :vartype extended_location: ~azure.mgmt.compute.v2024_11_01.models.ExtendedLocation - :ivar source_virtual_machine: The source virtual machine from which Image is created. - :vartype source_virtual_machine: ~azure.mgmt.compute.v2024_11_01.models.SubResource - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2024_11_01.models.ImageStorageProfile - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str - :ivar hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created from - the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to - specify the value, if the source is managed resource like disk or snapshot, we may require the - user to specify the property if we cannot deduce it from the source managed resource. Known - values are: "V1" and "V2". - :vartype hyper_v_generation: str or - ~azure.mgmt.compute.v2024_11_01.models.HyperVGenerationTypes + :ivar disk_encryption_set_id: A relative URI containing the resource ID of the disk encryption + set. + :vartype disk_encryption_set_id: str + :ivar 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. + :vartype lun: int """ _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, + "lun": {"required": True}, } _attribute_map = { - "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"}, - "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - "source_virtual_machine": {"key": "properties.sourceVirtualMachine", "type": "SubResource"}, - "storage_profile": {"key": "properties.storageProfile", "type": "ImageStorageProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, + "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, + "lun": {"key": "lun", "type": "int"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - extended_location: Optional["_models.ExtendedLocation"] = None, - source_virtual_machine: Optional["_models.SubResource"] = None, - storage_profile: Optional["_models.ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, lun: int, disk_encryption_set_id: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword extended_location: The extended location of the Image. - :paramtype extended_location: ~azure.mgmt.compute.v2024_11_01.models.ExtendedLocation - :keyword source_virtual_machine: The source virtual machine from which Image is created. - :paramtype source_virtual_machine: ~azure.mgmt.compute.v2024_11_01.models.SubResource - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2024_11_01.models.ImageStorageProfile - :keyword hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created - from the image. From API Version 2019-03-01 if the image source is a blob, then we need the - user to specify the value, if the source is managed resource like disk or snapshot, we may - require the user to specify the property if we cannot deduce it from the source managed - resource. Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2024_11_01.models.HyperVGenerationTypes + :keyword disk_encryption_set_id: A relative URI containing the resource ID of the disk + encryption set. + :paramtype disk_encryption_set_id: str + :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__(tags=tags, location=location, **kwargs) - self.extended_location = extended_location - self.source_virtual_machine = source_virtual_machine - self.storage_profile = storage_profile - self.provisioning_state: Optional[str] = None - self.hyper_v_generation = hyper_v_generation + super().__init__(disk_encryption_set_id=disk_encryption_set_id, **kwargs) + self.lun = lun -class ImageDisk(_serialization.Model): - """Describes a image disk. +class DataDisksToAttach(_serialization.Model): + """Describes the data disk to be attached. - :ivar snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2024_11_01.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2024_11_01.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str + All required parameters must be populated in order to send to server. + + :ivar disk_id: ID of the managed data disk. Required. + :vartype disk_id: str + :ivar lun: The logical unit number of the data disk. This value is used to identify data disks + within the VM and therefore must be unique for each data disk attached to a VM. If not + specified, lun would be auto assigned. + :vartype lun: int :ivar caching: Specifies the caching requirements. Possible values are: **None,** **ReadOnly,** - **ReadWrite.** The default values are: **None for Standard storage. ReadOnly for Premium + **ReadWrite.** The defaulting behavior is: **None for Standard storage. ReadOnly for Premium storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. This value cannot be larger - than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", - "StandardSSD_ZRS", and "PremiumV2_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2024_11_01.models.StorageAccountTypes + :vartype caching: str or ~azure.mgmt.compute.models.CachingTypes + :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 + VM is deleted. **Detach.** If this value is used, the data disk is retained after VM is + deleted. The default value is set to **Detach**. Known values are: "Delete" and "Detach". + :vartype delete_option: str or ~azure.mgmt.compute.models.DiskDeleteOptionTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed image disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSetParameters + the managed disk. + :vartype disk_encryption_set: ~azure.mgmt.compute.models.DiskEncryptionSetParameters + :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or + disabled on the disk. + :vartype write_accelerator_enabled: bool """ + _validation = { + "disk_id": {"required": True}, + } + _attribute_map = { - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, + "disk_id": {"key": "diskId", "type": "str"}, + "lun": {"key": "lun", "type": "int"}, "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, + "delete_option": {"key": "deleteOption", "type": "str"}, "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, + "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, } def __init__( self, *, - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, + disk_id: str, + lun: Optional[int] = None, caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, + write_accelerator_enabled: Optional[bool] = None, **kwargs: Any ) -> None: """ - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2024_11_01.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2024_11_01.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str + :keyword disk_id: ID of the managed data disk. Required. + :paramtype disk_id: str + :keyword lun: The logical unit number of the data disk. This value is used to identify data + disks within the VM and therefore must be unique for each data disk attached to a VM. If not + specified, lun would be auto assigned. + :paramtype lun: int :keyword caching: Specifies the caching requirements. Possible values are: **None,** - **ReadOnly,** **ReadWrite.** The default values are: **None for Standard storage. ReadOnly for - Premium storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. This value cannot be larger - than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", - "StandardSSD_ZRS", and "PremiumV2_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2024_11_01.models.StorageAccountTypes + **ReadOnly,** **ReadWrite.** The defaulting behavior is: **None for Standard storage. ReadOnly + for Premium storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". + :paramtype caching: str or ~azure.mgmt.compute.models.CachingTypes + :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 + VM is deleted. **Detach.** If this value is used, the data disk is retained after VM is + deleted. The default value is set to **Detach**. Known values are: "Delete" and "Detach". + :paramtype delete_option: str or ~azure.mgmt.compute.models.DiskDeleteOptionTypes :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed image disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSetParameters + for the managed disk. + :paramtype disk_encryption_set: ~azure.mgmt.compute.models.DiskEncryptionSetParameters + :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or + disabled on the disk. + :paramtype write_accelerator_enabled: bool """ super().__init__(**kwargs) - self.snapshot = snapshot - self.managed_disk = managed_disk - self.blob_uri = blob_uri + self.disk_id = disk_id + self.lun = lun self.caching = caching - self.disk_size_gb = disk_size_gb - self.storage_account_type = storage_account_type + self.delete_option = delete_option self.disk_encryption_set = disk_encryption_set + self.write_accelerator_enabled = write_accelerator_enabled -class ImageDataDisk(ImageDisk): - """Describes a data disk. +class DataDisksToDetach(_serialization.Model): + """Describes the data disk to be detached. All required parameters must be populated in order to send to server. - :ivar snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2024_11_01.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2024_11_01.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str - :ivar caching: Specifies the caching requirements. Possible values are: **None,** **ReadOnly,** - **ReadWrite.** The default values are: **None for Standard storage. ReadOnly for Premium - storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. This value cannot be larger - than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", - "StandardSSD_ZRS", and "PremiumV2_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2024_11_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed image disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSetParameters - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int + :ivar disk_id: ID of the managed data disk. Required. + :vartype disk_id: str + :ivar detach_option: Supported options available for Detach of a disk from a VM. Refer to + DetachOption object reference for more details. "ForceDetach" + :vartype detach_option: str or ~azure.mgmt.compute.models.DiskDetachOptionTypes """ _validation = { - "lun": {"required": True}, + "disk_id": {"required": True}, } _attribute_map = { - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - "lun": {"key": "lun", "type": "int"}, + "disk_id": {"key": "diskId", "type": "str"}, + "detach_option": {"key": "detachOption", "type": "str"}, } def __init__( self, *, - lun: int, - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, + disk_id: str, + detach_option: Optional[Union[str, "_models.DiskDetachOptionTypes"]] = None, **kwargs: Any ) -> None: """ - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2024_11_01.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2024_11_01.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str - :keyword caching: Specifies the caching requirements. Possible values are: **None,** - **ReadOnly,** **ReadWrite.** The default values are: **None for Standard storage. ReadOnly for - Premium storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. This value cannot be larger - than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", - "StandardSSD_ZRS", and "PremiumV2_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2024_11_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed image disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSetParameters - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int + :keyword disk_id: ID of the managed data disk. Required. + :paramtype disk_id: str + :keyword detach_option: Supported options available for Detach of a disk from a VM. Refer to + DetachOption object reference for more details. "ForceDetach" + :paramtype detach_option: str or ~azure.mgmt.compute.models.DiskDetachOptionTypes """ - super().__init__( - snapshot=snapshot, - managed_disk=managed_disk, - blob_uri=blob_uri, - caching=caching, - disk_size_gb=disk_size_gb, - storage_account_type=storage_account_type, - disk_encryption_set=disk_encryption_set, - **kwargs - ) - self.lun = lun + super().__init__(**kwargs) + self.disk_id = disk_id + self.detach_option = detach_option -class ImageDeprecationStatus(_serialization.Model): - """Describes image deprecation status properties on the image. +class DedicatedHost(TrackedResource): + """Specifies information about the Dedicated host. - :ivar image_state: Describes the state of the image. Known values are: "Active", - "ScheduledForDeprecation", and "Deprecated". - :vartype image_state: str or ~azure.mgmt.compute.v2024_11_01.models.ImageState - :ivar scheduled_deprecation_time: The time, in future, at which this image will be marked as - deprecated. This scheduled time is chosen by the Publisher. - :vartype scheduled_deprecation_time: ~datetime.datetime - :ivar alternative_option: Describes the alternative option specified by the Publisher for this - image when this image is deprecated. - :vartype alternative_option: ~azure.mgmt.compute.v2024_11_01.models.AlternativeOption + 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: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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.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.models.Sku + :ivar platform_fault_domain: Fault domain of the dedicated host within a dedicated host group. + :vartype platform_fault_domain: int + :ivar auto_replace_on_failure: Specifies whether the dedicated host should be replaced + automatically in case of a failure. The value is defaulted to 'true' when not provided. + :vartype auto_replace_on_failure: bool + :ivar host_id: A unique id generated and assigned to the dedicated host by the platform. Does + not change throughout the lifetime of the host. + :vartype host_id: str + :ivar virtual_machines: A list of references to all virtual machines in the Dedicated Host. + :vartype virtual_machines: list[~azure.mgmt.compute.models.SubResourceReadOnly] + :ivar license_type: 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.** The default value is: **None.**. Known values are: "None", + "Windows_Server_Hybrid", and "Windows_Server_Perpetual". + :vartype license_type: str or ~azure.mgmt.compute.models.DedicatedHostLicenseTypes + :ivar provisioning_time: The date when the host was first provisioned. + :vartype provisioning_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state, which only appears in the response. + :vartype provisioning_state: str + :ivar instance_view: The dedicated host instance view. + :vartype instance_view: ~azure.mgmt.compute.models.DedicatedHostInstanceView + :ivar time_created: Specifies the time at which the Dedicated Host resource was created. + Minimum api-version: 2021-11-01. + :vartype time_created: ~datetime.datetime """ - _attribute_map = { - "image_state": {"key": "imageState", "type": "str"}, - "scheduled_deprecation_time": {"key": "scheduledDeprecationTime", "type": "iso-8601"}, - "alternative_option": {"key": "alternativeOption", "type": "AlternativeOption"}, + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, + "host_id": {"readonly": True}, + "virtual_machines": {"readonly": True}, + "provisioning_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "instance_view": {"readonly": True}, + "time_created": {"readonly": True}, } - def __init__( - self, - *, - image_state: Optional[Union[str, "_models.ImageState"]] = None, - scheduled_deprecation_time: Optional[datetime.datetime] = None, - alternative_option: Optional["_models.AlternativeOption"] = None, + _attribute_map = { + "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"}, + "sku": {"key": "sku", "type": "Sku"}, + "platform_fault_domain": {"key": "properties.platformFaultDomain", "type": "int"}, + "auto_replace_on_failure": {"key": "properties.autoReplaceOnFailure", "type": "bool"}, + "host_id": {"key": "properties.hostId", "type": "str"}, + "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResourceReadOnly]"}, + "license_type": {"key": "properties.licenseType", "type": "str"}, + "provisioning_time": {"key": "properties.provisioningTime", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostInstanceView"}, + "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, + } + + def __init__( + self, + *, + location: str, + sku: "_models.Sku", + tags: Optional[Dict[str, str]] = None, + platform_fault_domain: Optional[int] = None, + auto_replace_on_failure: Optional[bool] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs: Any ) -> None: """ - :keyword image_state: Describes the state of the image. Known values are: "Active", - "ScheduledForDeprecation", and "Deprecated". - :paramtype image_state: str or ~azure.mgmt.compute.v2024_11_01.models.ImageState - :keyword scheduled_deprecation_time: The time, in future, at which this image will be marked as - deprecated. This scheduled time is chosen by the Publisher. - :paramtype scheduled_deprecation_time: ~datetime.datetime - :keyword alternative_option: Describes the alternative option specified by the Publisher for - this image when this image is deprecated. - :paramtype alternative_option: ~azure.mgmt.compute.v2024_11_01.models.AlternativeOption + :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.models.Sku + :keyword platform_fault_domain: Fault domain of the dedicated host within a dedicated host + group. + :paramtype platform_fault_domain: int + :keyword auto_replace_on_failure: Specifies whether the dedicated host should be replaced + automatically in case of a failure. The value is defaulted to 'true' when not provided. + :paramtype auto_replace_on_failure: bool + :keyword license_type: 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.** The default value is: **None.**. Known values are: "None", + "Windows_Server_Hybrid", and "Windows_Server_Perpetual". + :paramtype license_type: str or ~azure.mgmt.compute.models.DedicatedHostLicenseTypes """ - super().__init__(**kwargs) - self.image_state = image_state - self.scheduled_deprecation_time = scheduled_deprecation_time - self.alternative_option = alternative_option - + 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 + self.host_id: Optional[str] = None + self.virtual_machines: Optional[List["_models.SubResourceReadOnly"]] = None + self.license_type = license_type + self.provisioning_time: Optional[datetime.datetime] = None + self.provisioning_state: Optional[str] = None + self.instance_view: Optional["_models.DedicatedHostInstanceView"] = None + self.time_created: Optional[datetime.datetime] = None -class ImageListResult(_serialization.Model): - """The List Image operation response. - All required parameters must be populated in order to send to server. +class DedicatedHostAllocatableVM(_serialization.Model): + """Represents the dedicated host unutilized capacity in terms of a specific VM size. - :ivar value: The list of Images. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.Image] - :ivar next_link: The uri to fetch the next page of Images. Call ListNext() with this to fetch - the next page of Images. - :vartype next_link: str + :ivar vm_size: VM size in terms of which the unutilized capacity is represented. + :vartype vm_size: str + :ivar count: Maximum number of VMs of size vmSize that can fit in the dedicated host's + remaining capacity. + :vartype count: float """ - _validation = { - "value": {"required": True}, + _attribute_map = { + "vm_size": {"key": "vmSize", "type": "str"}, + "count": {"key": "count", "type": "float"}, } + def __init__(self, *, vm_size: Optional[str] = None, count: Optional[float] = None, **kwargs: Any) -> None: + """ + :keyword vm_size: VM size in terms of which the unutilized capacity is represented. + :paramtype vm_size: str + :keyword count: Maximum number of VMs of size vmSize that can fit in the dedicated host's + remaining capacity. + :paramtype count: float + """ + super().__init__(**kwargs) + self.vm_size = vm_size + self.count = count + + +class DedicatedHostAvailableCapacity(_serialization.Model): + """Dedicated host unutilized capacity. + + :ivar allocatable_v_ms: The unutilized capacity of the dedicated host represented in terms of + each VM size that is allowed to be deployed to the dedicated host. + :vartype allocatable_v_ms: list[~azure.mgmt.compute.models.DedicatedHostAllocatableVM] + """ + _attribute_map = { - "value": {"key": "value", "type": "[Image]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "allocatable_v_ms": {"key": "allocatableVMs", "type": "[DedicatedHostAllocatableVM]"}, } - def __init__(self, *, value: List["_models.Image"], next_link: Optional[str] = None, **kwargs: Any) -> None: + def __init__( + self, *, allocatable_v_ms: Optional[List["_models.DedicatedHostAllocatableVM"]] = None, **kwargs: Any + ) -> None: """ - :keyword value: The list of Images. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.Image] - :keyword next_link: The uri to fetch the next page of Images. Call ListNext() with this to - fetch the next page of Images. - :paramtype next_link: str + :keyword allocatable_v_ms: The unutilized capacity of the dedicated host represented in terms + of each VM size that is allowed to be deployed to the dedicated host. + :paramtype allocatable_v_ms: list[~azure.mgmt.compute.models.DedicatedHostAllocatableVM] """ super().__init__(**kwargs) - self.value = value - self.next_link = next_link + self.allocatable_v_ms = allocatable_v_ms -class ImageOSDisk(ImageDisk): - """Describes an Operating System disk. +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. + + 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 snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2024_11_01.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2024_11_01.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str - :ivar caching: Specifies the caching requirements. Possible values are: **None,** **ReadOnly,** - **ReadWrite.** The default values are: **None for Standard storage. ReadOnly for Premium - storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. This value cannot be larger - than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", - "StandardSSD_ZRS", and "PremiumV2_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2024_11_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed image disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSetParameters - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from a custom image. Possible values are: **Windows,** **Linux.**. - Required. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2024_11_01.models.OperatingSystemTypes - :ivar os_state: The OS State. For managed images, use Generalized. Required. Known values are: - "Generalized" and "Specialized". - :vartype os_state: str or ~azure.mgmt.compute.v2024_11_01.models.OperatingSystemStateTypes + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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.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: The availability zones. + :vartype zones: list[str] + :ivar platform_fault_domain_count: Number of fault domains that the host group can span. + :vartype platform_fault_domain_count: int + :ivar hosts: A list of references to all dedicated hosts in the dedicated host group. + :vartype hosts: list[~azure.mgmt.compute.models.SubResourceReadOnly] + :ivar instance_view: The dedicated host group instance view, which has the list of instance + view of the dedicated hosts under the dedicated host group. + :vartype instance_view: ~azure.mgmt.compute.models.DedicatedHostGroupInstanceView + :ivar support_automatic_placement: Specifies whether virtual machines or virtual machine scale + sets can be placed automatically on the dedicated host group. Automatic placement means + resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host + group. The value is defaulted to 'false' when not provided. Minimum api-version: 2020-06-01. + :vartype support_automatic_placement: bool + :ivar additional_capabilities: Enables or disables a capability on the dedicated host group. + Minimum api-version: 2022-03-01. + :vartype additional_capabilities: + ~azure.mgmt.compute.models.DedicatedHostGroupPropertiesAdditionalCapabilities """ _validation = { - "os_type": {"required": True}, - "os_state": {"required": True}, + "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}, + "instance_view": {"readonly": True}, } _attribute_map = { - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - "os_type": {"key": "osType", "type": "str"}, - "os_state": {"key": "osState", "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"}, + "zones": {"key": "zones", "type": "[str]"}, + "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, + "hosts": {"key": "properties.hosts", "type": "[SubResourceReadOnly]"}, + "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostGroupInstanceView"}, + "support_automatic_placement": {"key": "properties.supportAutomaticPlacement", "type": "bool"}, + "additional_capabilities": { + "key": "properties.additionalCapabilities", + "type": "DedicatedHostGroupPropertiesAdditionalCapabilities", + }, } def __init__( self, *, - os_type: Union[str, "_models.OperatingSystemTypes"], - os_state: Union[str, "_models.OperatingSystemStateTypes"], - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, + location: str, + tags: Optional[Dict[str, str]] = None, + zones: Optional[List[str]] = None, + platform_fault_domain_count: Optional[int] = None, + support_automatic_placement: Optional[bool] = None, + additional_capabilities: Optional["_models.DedicatedHostGroupPropertiesAdditionalCapabilities"] = None, **kwargs: Any ) -> None: """ - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2024_11_01.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2024_11_01.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str - :keyword caching: Specifies the caching requirements. Possible values are: **None,** - **ReadOnly,** **ReadWrite.** The default values are: **None for Standard storage. ReadOnly for - Premium storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. This value cannot be larger - than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", - "StandardSSD_ZRS", and "PremiumV2_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2024_11_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed image disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSetParameters - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from a custom image. Possible values are: **Windows,** **Linux.**. - Required. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2024_11_01.models.OperatingSystemTypes - :keyword os_state: The OS State. For managed images, use Generalized. Required. Known values - are: "Generalized" and "Specialized". - :paramtype os_state: str or ~azure.mgmt.compute.v2024_11_01.models.OperatingSystemStateTypes - """ - super().__init__( - snapshot=snapshot, - managed_disk=managed_disk, - blob_uri=blob_uri, - caching=caching, - disk_size_gb=disk_size_gb, - storage_account_type=storage_account_type, - disk_encryption_set=disk_encryption_set, - **kwargs - ) - self.os_type = os_type - self.os_state = os_state + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword zones: The availability zones. + :paramtype zones: list[str] + :keyword platform_fault_domain_count: Number of fault domains that the host group can span. + :paramtype platform_fault_domain_count: int + :keyword support_automatic_placement: Specifies whether virtual machines or virtual machine + scale sets can be placed automatically on the dedicated host group. Automatic placement means + resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host + group. The value is defaulted to 'false' when not provided. Minimum api-version: 2020-06-01. + :paramtype support_automatic_placement: bool + :keyword additional_capabilities: Enables or disables a capability on the dedicated host group. + Minimum api-version: 2022-03-01. + :paramtype additional_capabilities: + ~azure.mgmt.compute.models.DedicatedHostGroupPropertiesAdditionalCapabilities + """ + super().__init__(tags=tags, location=location, **kwargs) + self.zones = zones + self.platform_fault_domain_count = platform_fault_domain_count + self.hosts: Optional[List["_models.SubResourceReadOnly"]] = None + self.instance_view: Optional["_models.DedicatedHostGroupInstanceView"] = None + self.support_automatic_placement = support_automatic_placement + self.additional_capabilities = additional_capabilities -class ImageReference(SubResource): - """Specifies information about the image to use. You can specify information about platform - images, marketplace images, or virtual machine images. This element is required when you want - to use a platform image, marketplace image, or virtual machine image, but is not used in other - creation operations. NOTE: Image reference publisher and offer can only be set when you create - the scale set. +class DedicatedHostGroupInstanceView(_serialization.Model): + """DedicatedHostGroupInstanceView. - Variables are only populated by the server, and will be ignored when sending a request. + :ivar hosts: List of instance view of the dedicated hosts under the dedicated host group. + :vartype hosts: list[~azure.mgmt.compute.models.DedicatedHostInstanceViewWithName] + """ - :ivar id: Resource Id. - :vartype id: str - :ivar publisher: The image publisher. - :vartype publisher: str - :ivar offer: Specifies the offer of the platform image or marketplace image used to create the - virtual machine. - :vartype offer: str - :ivar sku: The image SKU. - :vartype sku: str - :ivar version: Specifies the version of the platform image or marketplace image used to create - the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and - Build are decimal numbers. Specify 'latest' to use the latest version of an image available at - deploy time. Even if you use 'latest', the VM image will not automatically update after deploy - time even if a new version becomes available. Please do not use field 'version' for gallery - image deployment, gallery image should always use 'id' field for deployment, to use 'latest' - version of gallery image, just set - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageName}' - in the 'id' field without version input. - :vartype version: str - :ivar exact_version: Specifies in decimal numbers, the version of platform image or marketplace - image used to create the virtual machine. This readonly field differs from 'version', only if - the value specified in 'version' field is 'latest'. - :vartype exact_version: str - :ivar shared_gallery_image_id: Specified the shared gallery image unique id for vm deployment. - This can be fetched from shared gallery image GET call. - :vartype shared_gallery_image_id: str - :ivar community_gallery_image_id: Specified the community gallery image unique id for vm - deployment. This can be fetched from community gallery image GET call. - :vartype community_gallery_image_id: str + _attribute_map = { + "hosts": {"key": "hosts", "type": "[DedicatedHostInstanceViewWithName]"}, + } + + def __init__( + self, *, hosts: Optional[List["_models.DedicatedHostInstanceViewWithName"]] = None, **kwargs: Any + ) -> None: + """ + :keyword hosts: List of instance view of the dedicated hosts under the dedicated host group. + :paramtype hosts: list[~azure.mgmt.compute.models.DedicatedHostInstanceViewWithName] + """ + super().__init__(**kwargs) + self.hosts = hosts + + +class DedicatedHostGroupListResult(_serialization.Model): + """The List Dedicated Host Group with resource group response. + + All required parameters must be populated in order to send to server. + + :ivar value: The list of dedicated host groups. Required. + :vartype value: list[~azure.mgmt.compute.models.DedicatedHostGroup] + :ivar next_link: The URI to fetch the next page of Dedicated Host Groups. Call ListNext() with + this URI to fetch the next page of Dedicated Host Groups. + :vartype next_link: str """ _validation = { - "exact_version": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { - "id": {"key": "id", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "offer": {"key": "offer", "type": "str"}, - "sku": {"key": "sku", "type": "str"}, - "version": {"key": "version", "type": "str"}, - "exact_version": {"key": "exactVersion", "type": "str"}, - "shared_gallery_image_id": {"key": "sharedGalleryImageId", "type": "str"}, - "community_gallery_image_id": {"key": "communityGalleryImageId", "type": "str"}, + "value": {"key": "value", "type": "[DedicatedHostGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - publisher: Optional[str] = None, - offer: Optional[str] = None, - sku: Optional[str] = None, - version: Optional[str] = None, - shared_gallery_image_id: Optional[str] = None, - community_gallery_image_id: Optional[str] = None, - **kwargs: Any + self, *, value: List["_models.DedicatedHostGroup"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword id: Resource Id. - :paramtype id: str - :keyword publisher: The image publisher. - :paramtype publisher: str - :keyword offer: Specifies the offer of the platform image or marketplace image used to create - the virtual machine. - :paramtype offer: str - :keyword sku: The image SKU. - :paramtype sku: str - :keyword version: Specifies the version of the platform image or marketplace image used to - create the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, - Minor, and Build are decimal numbers. Specify 'latest' to use the latest version of an image - available at deploy time. Even if you use 'latest', the VM image will not automatically update - after deploy time even if a new version becomes available. Please do not use field 'version' - for gallery image deployment, gallery image should always use 'id' field for deployment, to use - 'latest' version of gallery image, just set - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageName}' - in the 'id' field without version input. - :paramtype version: str - :keyword shared_gallery_image_id: Specified the shared gallery image unique id for vm - deployment. This can be fetched from shared gallery image GET call. - :paramtype shared_gallery_image_id: str - :keyword community_gallery_image_id: Specified the community gallery image unique id for vm - deployment. This can be fetched from community gallery image GET call. - :paramtype community_gallery_image_id: str + :keyword value: The list of dedicated host groups. Required. + :paramtype value: list[~azure.mgmt.compute.models.DedicatedHostGroup] + :keyword next_link: The URI to fetch the next page of Dedicated Host Groups. Call ListNext() + with this URI to fetch the next page of Dedicated Host Groups. + :paramtype next_link: str """ - super().__init__(id=id, **kwargs) - self.publisher = publisher - self.offer = offer - self.sku = sku - self.version = version - self.exact_version: Optional[str] = None - self.shared_gallery_image_id = shared_gallery_image_id - self.community_gallery_image_id = community_gallery_image_id + super().__init__(**kwargs) + self.value = value + self.next_link = next_link -class ImageStorageProfile(_serialization.Model): - """Describes a storage profile. +class DedicatedHostGroupPropertiesAdditionalCapabilities(_serialization.Model): # pylint: disable=name-too-long + """Enables or disables a capability on the dedicated host group. Minimum api-version: 2022-03-01. - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
`\\ :code:`
` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2024_11_01.models.ImageOSDisk - :ivar data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
`\\ :code:`
` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype data_disks: list[~azure.mgmt.compute.v2024_11_01.models.ImageDataDisk] - :ivar zone_resilient: Specifies whether an image is zone resilient or not. Default is false. - Zone resilient images can be created only in regions that provide Zone Redundant Storage (ZRS). - :vartype zone_resilient: bool + :ivar ultra_ssd_enabled: The flag that enables or disables a capability to have UltraSSD + Enabled Virtual Machines on Dedicated Hosts of the Dedicated Host Group. For the Virtual + Machines to be UltraSSD Enabled, UltraSSDEnabled flag for the resource needs to be set true as + well. The value is defaulted to 'false' when not provided. Please refer to + https://docs.microsoft.com/en-us/azure/virtual-machines/disks-enable-ultra-ssd for more details + on Ultra SSD feature. **Note:** The ultraSSDEnabled setting can only be enabled for Host Groups + that are created as zonal. Minimum api-version: 2022-03-01. + :vartype ultra_ssd_enabled: bool """ _attribute_map = { - "os_disk": {"key": "osDisk", "type": "ImageOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[ImageDataDisk]"}, - "zone_resilient": {"key": "zoneResilient", "type": "bool"}, + "ultra_ssd_enabled": {"key": "ultraSSDEnabled", "type": "bool"}, } - def __init__( - self, - *, - os_disk: Optional["_models.ImageOSDisk"] = None, - data_disks: Optional[List["_models.ImageDataDisk"]] = None, - zone_resilient: Optional[bool] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, ultra_ssd_enabled: Optional[bool] = None, **kwargs: Any) -> None: """ - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
`\\ :code:`
` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2024_11_01.models.ImageOSDisk - :keyword data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
`\\ :code:`
` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype data_disks: list[~azure.mgmt.compute.v2024_11_01.models.ImageDataDisk] - :keyword zone_resilient: Specifies whether an image is zone resilient or not. Default is false. - Zone resilient images can be created only in regions that provide Zone Redundant Storage (ZRS). - :paramtype zone_resilient: bool + :keyword ultra_ssd_enabled: The flag that enables or disables a capability to have UltraSSD + Enabled Virtual Machines on Dedicated Hosts of the Dedicated Host Group. For the Virtual + Machines to be UltraSSD Enabled, UltraSSDEnabled flag for the resource needs to be set true as + well. The value is defaulted to 'false' when not provided. Please refer to + https://docs.microsoft.com/en-us/azure/virtual-machines/disks-enable-ultra-ssd for more details + on Ultra SSD feature. **Note:** The ultraSSDEnabled setting can only be enabled for Host Groups + that are created as zonal. Minimum api-version: 2022-03-01. + :paramtype ultra_ssd_enabled: bool """ super().__init__(**kwargs) - self.os_disk = os_disk - self.data_disks = data_disks - self.zone_resilient = zone_resilient + self.ultra_ssd_enabled = ultra_ssd_enabled -class ImageUpdate(UpdateResource): - """The source user image virtual hard disk. Only tags may be updated. +class DedicatedHostGroupUpdate(UpdateResource): + """Specifies information about the dedicated host group that the dedicated host should be assigned + to. Only tags may be updated. Variables are only populated by the server, and will be ignored when sending a request. :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar source_virtual_machine: The source virtual machine from which Image is created. - :vartype source_virtual_machine: ~azure.mgmt.compute.v2024_11_01.models.SubResource - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2024_11_01.models.ImageStorageProfile - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str - :ivar hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created from - the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to - specify the value, if the source is managed resource like disk or snapshot, we may require the - user to specify the property if we cannot deduce it from the source managed resource. Known - values are: "V1" and "V2". - :vartype hyper_v_generation: str or - ~azure.mgmt.compute.v2024_11_01.models.HyperVGenerationTypes + :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. + :vartype zones: list[str] + :ivar platform_fault_domain_count: Number of fault domains that the host group can span. + :vartype platform_fault_domain_count: int + :ivar hosts: A list of references to all dedicated hosts in the dedicated host group. + :vartype hosts: list[~azure.mgmt.compute.models.SubResourceReadOnly] + :ivar instance_view: The dedicated host group instance view, which has the list of instance + view of the dedicated hosts under the dedicated host group. + :vartype instance_view: ~azure.mgmt.compute.models.DedicatedHostGroupInstanceView + :ivar support_automatic_placement: Specifies whether virtual machines or virtual machine scale + sets can be placed automatically on the dedicated host group. Automatic placement means + resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host + group. The value is defaulted to 'false' when not provided. Minimum api-version: 2020-06-01. + :vartype support_automatic_placement: bool + :ivar additional_capabilities: Enables or disables a capability on the dedicated host group. + Minimum api-version: 2022-03-01. + :vartype additional_capabilities: + ~azure.mgmt.compute.models.DedicatedHostGroupPropertiesAdditionalCapabilities """ _validation = { - "provisioning_state": {"readonly": True}, + "platform_fault_domain_count": {"minimum": 1}, + "hosts": {"readonly": True}, + "instance_view": {"readonly": True}, } _attribute_map = { "tags": {"key": "tags", "type": "{str}"}, - "source_virtual_machine": {"key": "properties.sourceVirtualMachine", "type": "SubResource"}, - "storage_profile": {"key": "properties.storageProfile", "type": "ImageStorageProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, + "hosts": {"key": "properties.hosts", "type": "[SubResourceReadOnly]"}, + "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostGroupInstanceView"}, + "support_automatic_placement": {"key": "properties.supportAutomaticPlacement", "type": "bool"}, + "additional_capabilities": { + "key": "properties.additionalCapabilities", + "type": "DedicatedHostGroupPropertiesAdditionalCapabilities", + }, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["_models.SubResource"] = None, - storage_profile: Optional["_models.ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, + zones: Optional[List[str]] = None, + platform_fault_domain_count: Optional[int] = None, + support_automatic_placement: Optional[bool] = None, + additional_capabilities: Optional["_models.DedicatedHostGroupPropertiesAdditionalCapabilities"] = None, **kwargs: Any ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword source_virtual_machine: The source virtual machine from which Image is created. - :paramtype source_virtual_machine: ~azure.mgmt.compute.v2024_11_01.models.SubResource - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2024_11_01.models.ImageStorageProfile - :keyword hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created - from the image. From API Version 2019-03-01 if the image source is a blob, then we need the - user to specify the value, if the source is managed resource like disk or snapshot, we may - require the user to specify the property if we cannot deduce it from the source managed - resource. Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2024_11_01.models.HyperVGenerationTypes + :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. + :paramtype zones: list[str] + :keyword platform_fault_domain_count: Number of fault domains that the host group can span. + :paramtype platform_fault_domain_count: int + :keyword support_automatic_placement: Specifies whether virtual machines or virtual machine + scale sets can be placed automatically on the dedicated host group. Automatic placement means + resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host + group. The value is defaulted to 'false' when not provided. Minimum api-version: 2020-06-01. + :paramtype support_automatic_placement: bool + :keyword additional_capabilities: Enables or disables a capability on the dedicated host group. + Minimum api-version: 2022-03-01. + :paramtype additional_capabilities: + ~azure.mgmt.compute.models.DedicatedHostGroupPropertiesAdditionalCapabilities """ super().__init__(tags=tags, **kwargs) - self.source_virtual_machine = source_virtual_machine - self.storage_profile = storage_profile - self.provisioning_state: Optional[str] = None - self.hyper_v_generation = hyper_v_generation + self.zones = zones + self.platform_fault_domain_count = platform_fault_domain_count + self.hosts: Optional[List["_models.SubResourceReadOnly"]] = None + self.instance_view: Optional["_models.DedicatedHostGroupInstanceView"] = None + self.support_automatic_placement = support_automatic_placement + self.additional_capabilities = additional_capabilities -class InnerError(_serialization.Model): - """Inner error details. +class DedicatedHostInstanceView(_serialization.Model): + """The instance view of a dedicated host. - :ivar exceptiontype: The exception type. - :vartype exceptiontype: str - :ivar errordetail: The internal error message or exception dump. - :vartype errordetail: str + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar asset_id: Specifies the unique id of the dedicated physical machine on which the + dedicated host resides. + :vartype asset_id: str + :ivar available_capacity: Unutilized capacity of the dedicated host. + :vartype available_capacity: ~azure.mgmt.compute.models.DedicatedHostAvailableCapacity + :ivar statuses: The resource status information. + :vartype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] """ + _validation = { + "asset_id": {"readonly": True}, + } + _attribute_map = { - "exceptiontype": {"key": "exceptiontype", "type": "str"}, - "errordetail": {"key": "errordetail", "type": "str"}, + "asset_id": {"key": "assetId", "type": "str"}, + "available_capacity": {"key": "availableCapacity", "type": "DedicatedHostAvailableCapacity"}, + "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, } def __init__( - self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any + self, + *, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, + **kwargs: Any ) -> None: """ - :keyword exceptiontype: The exception type. - :paramtype exceptiontype: str - :keyword errordetail: The internal error message or exception dump. - :paramtype errordetail: str + :keyword available_capacity: Unutilized capacity of the dedicated host. + :paramtype available_capacity: ~azure.mgmt.compute.models.DedicatedHostAvailableCapacity + :keyword statuses: The resource status information. + :paramtype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] """ super().__init__(**kwargs) - self.exceptiontype = exceptiontype - self.errordetail = errordetail + self.asset_id: Optional[str] = None + self.available_capacity = available_capacity + self.statuses = statuses -class InstanceViewStatus(_serialization.Model): - """Instance view status. +class DedicatedHostInstanceViewWithName(DedicatedHostInstanceView): + """The instance view of a dedicated host that includes the name of the dedicated host. It is used + for the response to the instance view of a dedicated host group. - :ivar code: The status code. - :vartype code: str - :ivar level: The level code. Known values are: "Info", "Warning", and "Error". - :vartype level: str or ~azure.mgmt.compute.v2024_11_01.models.StatusLevelTypes - :ivar display_status: The short localizable label for the status. - :vartype display_status: str - :ivar message: The detailed status message, including for alerts and error messages. - :vartype message: str - :ivar time: The time of the status. - :vartype time: ~datetime.datetime + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar asset_id: Specifies the unique id of the dedicated physical machine on which the + dedicated host resides. + :vartype asset_id: str + :ivar available_capacity: Unutilized capacity of the dedicated host. + :vartype available_capacity: ~azure.mgmt.compute.models.DedicatedHostAvailableCapacity + :ivar statuses: The resource status information. + :vartype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] + :ivar name: The name of the dedicated host. + :vartype name: str """ + _validation = { + "asset_id": {"readonly": True}, + "name": {"readonly": True}, + } + _attribute_map = { - "code": {"key": "code", "type": "str"}, - "level": {"key": "level", "type": "str"}, - "display_status": {"key": "displayStatus", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "time": {"key": "time", "type": "iso-8601"}, + "asset_id": {"key": "assetId", "type": "str"}, + "available_capacity": {"key": "availableCapacity", "type": "DedicatedHostAvailableCapacity"}, + "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, - code: Optional[str] = None, - level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, - display_status: Optional[str] = None, - message: Optional[str] = None, - time: Optional[datetime.datetime] = None, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs: Any ) -> None: """ - :keyword code: The status code. - :paramtype code: str - :keyword level: The level code. Known values are: "Info", "Warning", and "Error". - :paramtype level: str or ~azure.mgmt.compute.v2024_11_01.models.StatusLevelTypes - :keyword display_status: The short localizable label for the status. - :paramtype display_status: str - :keyword message: The detailed status message, including for alerts and error messages. - :paramtype message: str - :keyword time: The time of the status. - :paramtype time: ~datetime.datetime + :keyword available_capacity: Unutilized capacity of the dedicated host. + :paramtype available_capacity: ~azure.mgmt.compute.models.DedicatedHostAvailableCapacity + :keyword statuses: The resource status information. + :paramtype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] """ - super().__init__(**kwargs) - self.code = code - self.level = level - self.display_status = display_status - self.message = message - self.time = time + super().__init__(available_capacity=available_capacity, statuses=statuses, **kwargs) + self.name: Optional[str] = None -class KeyVaultKeyReference(_serialization.Model): - """Describes a reference to Key Vault Key. +class DedicatedHostListResult(_serialization.Model): + """The list dedicated host operation response. All required parameters must be populated in order to send to server. - :ivar key_url: The URL referencing a key encryption key in Key Vault. Required. - :vartype key_url: str - :ivar source_vault: The relative URL of the Key Vault containing the key. Required. - :vartype source_vault: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :ivar value: The list of dedicated hosts. Required. + :vartype value: list[~azure.mgmt.compute.models.DedicatedHost] + :ivar next_link: The URI to fetch the next page of dedicated hosts. Call ListNext() with this + URI to fetch the next page of dedicated hosts. + :vartype next_link: str """ _validation = { - "key_url": {"required": True}, - "source_vault": {"required": True}, + "value": {"required": True}, } _attribute_map = { - "key_url": {"key": "keyUrl", "type": "str"}, - "source_vault": {"key": "sourceVault", "type": "SubResource"}, + "value": {"key": "value", "type": "[DedicatedHost]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, key_url: str, source_vault: "_models.SubResource", **kwargs: Any) -> None: + def __init__(self, *, value: List["_models.DedicatedHost"], next_link: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword key_url: The URL referencing a key encryption key in Key Vault. Required. - :paramtype key_url: str - :keyword source_vault: The relative URL of the Key Vault containing the key. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :keyword value: The list of dedicated hosts. Required. + :paramtype value: list[~azure.mgmt.compute.models.DedicatedHost] + :keyword next_link: The URI to fetch the next page of dedicated hosts. Call ListNext() with + this URI to fetch the next page of dedicated hosts. + :paramtype next_link: str """ super().__init__(**kwargs) - self.key_url = key_url - self.source_vault = source_vault - + self.value = value + self.next_link = next_link -class KeyVaultSecretReference(_serialization.Model): - """Describes a reference to Key Vault Secret. - All required parameters must be populated in order to send to server. +class DedicatedHostSizeListResult(_serialization.Model): + """The List Dedicated Host sizes operation response. - :ivar secret_url: The URL referencing a secret in a Key Vault. Required. - :vartype secret_url: str - :ivar source_vault: The relative URL of the Key Vault containing the secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :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 """ - _validation = { - "secret_url": {"required": True}, - "source_vault": {"required": True}, - } - _attribute_map = { - "secret_url": {"key": "secretUrl", "type": "str"}, - "source_vault": {"key": "sourceVault", "type": "SubResource"}, + "value": {"key": "value", "type": "[str]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, secret_url: str, source_vault: "_models.SubResource", **kwargs: Any) -> None: + def __init__(self, *, value: Optional[List[str]] = None, next_link: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword secret_url: The URL referencing a secret in a Key Vault. Required. - :paramtype secret_url: str - :keyword source_vault: The relative URL of the Key Vault containing the secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :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.secret_url = secret_url - self.source_vault = source_vault + self.value = value + self.next_link = next_link -class LastPatchInstallationSummary(_serialization.Model): - """Describes the properties of the last installed patch summary. +class DedicatedHostUpdate(UpdateResource): + """Specifies information about the dedicated host. Only tags, autoReplaceOnFailure and licenseType + may be updated. Variables are only populated by the server, and will be ignored when sending a request. - :ivar status: The overall success or failure status of the operation. It remains "InProgress" - until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", - and "CompletedWithWarnings". - :vartype status: str or ~azure.mgmt.compute.v2024_11_01.models.PatchOperationStatus - :ivar installation_activity_id: The activity ID of the operation that produced this result. It - is used to correlate across CRP and extension logs. - :vartype installation_activity_id: str - :ivar maintenance_window_exceeded: Describes whether the operation ran out of time before it - completed all its intended actions. - :vartype maintenance_window_exceeded: bool - :ivar not_selected_patch_count: The number of all available patches but not going to be - installed because it didn't match a classification or inclusion list entry. - :vartype not_selected_patch_count: int - :ivar excluded_patch_count: The number of all available patches but excluded explicitly by a - customer-specified exclusion list match. - :vartype excluded_patch_count: int - :ivar pending_patch_count: The number of all available patches expected to be installed over - the course of the patch installation operation. - :vartype pending_patch_count: int - :ivar installed_patch_count: The count of patches that successfully installed. - :vartype installed_patch_count: int - :ivar failed_patch_count: The count of patches that failed installation. - :vartype failed_patch_count: int - :ivar start_time: The UTC timestamp when the operation began. - :vartype start_time: ~datetime.datetime - :ivar last_modified_time: The UTC timestamp when the operation began. - :vartype last_modified_time: ~datetime.datetime - :ivar error: The errors that were encountered during execution of the operation. The details - array contains the list of them. - :vartype error: ~azure.mgmt.compute.v2024_11_01.models.ApiError - """ - - _validation = { - "status": {"readonly": True}, - "installation_activity_id": {"readonly": True}, - "maintenance_window_exceeded": {"readonly": True}, - "not_selected_patch_count": {"readonly": True}, - "excluded_patch_count": {"readonly": True}, - "pending_patch_count": {"readonly": True}, - "installed_patch_count": {"readonly": True}, - "failed_patch_count": {"readonly": True}, - "start_time": {"readonly": True}, - "last_modified_time": {"readonly": True}, - "error": {"readonly": True}, + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar sku: [List all available dedicated host sizes for resizing] + (https://docs.microsoft.com/rest/api/compute/dedicated-hosts/listavailablesizes). Resizing can + be only used to scale up DedicatedHost. Only name is required to be set. + :vartype sku: ~azure.mgmt.compute.models.Sku + :ivar platform_fault_domain: Fault domain of the dedicated host within a dedicated host group. + :vartype platform_fault_domain: int + :ivar auto_replace_on_failure: Specifies whether the dedicated host should be replaced + automatically in case of a failure. The value is defaulted to 'true' when not provided. + :vartype auto_replace_on_failure: bool + :ivar host_id: A unique id generated and assigned to the dedicated host by the platform. Does + not change throughout the lifetime of the host. + :vartype host_id: str + :ivar virtual_machines: A list of references to all virtual machines in the Dedicated Host. + :vartype virtual_machines: list[~azure.mgmt.compute.models.SubResourceReadOnly] + :ivar license_type: 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.** The default value is: **None.**. Known values are: "None", + "Windows_Server_Hybrid", and "Windows_Server_Perpetual". + :vartype license_type: str or ~azure.mgmt.compute.models.DedicatedHostLicenseTypes + :ivar provisioning_time: The date when the host was first provisioned. + :vartype provisioning_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state, which only appears in the response. + :vartype provisioning_state: str + :ivar instance_view: The dedicated host instance view. + :vartype instance_view: ~azure.mgmt.compute.models.DedicatedHostInstanceView + :ivar time_created: Specifies the time at which the Dedicated Host resource was created. + Minimum api-version: 2021-11-01. + :vartype time_created: ~datetime.datetime + """ + + _validation = { + "host_id": {"readonly": True}, + "virtual_machines": {"readonly": True}, + "provisioning_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "instance_view": {"readonly": True}, + "time_created": {"readonly": True}, } _attribute_map = { - "status": {"key": "status", "type": "str"}, - "installation_activity_id": {"key": "installationActivityId", "type": "str"}, - "maintenance_window_exceeded": {"key": "maintenanceWindowExceeded", "type": "bool"}, - "not_selected_patch_count": {"key": "notSelectedPatchCount", "type": "int"}, - "excluded_patch_count": {"key": "excludedPatchCount", "type": "int"}, - "pending_patch_count": {"key": "pendingPatchCount", "type": "int"}, - "installed_patch_count": {"key": "installedPatchCount", "type": "int"}, - "failed_patch_count": {"key": "failedPatchCount", "type": "int"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "last_modified_time": {"key": "lastModifiedTime", "type": "iso-8601"}, - "error": {"key": "error", "type": "ApiError"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "platform_fault_domain": {"key": "properties.platformFaultDomain", "type": "int"}, + "auto_replace_on_failure": {"key": "properties.autoReplaceOnFailure", "type": "bool"}, + "host_id": {"key": "properties.hostId", "type": "str"}, + "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResourceReadOnly]"}, + "license_type": {"key": "properties.licenseType", "type": "str"}, + "provisioning_time": {"key": "properties.provisioningTime", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostInstanceView"}, + "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + sku: Optional["_models.Sku"] = None, + platform_fault_domain: Optional[int] = None, + auto_replace_on_failure: Optional[bool] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: [List all available dedicated host sizes for resizing] + (https://docs.microsoft.com/rest/api/compute/dedicated-hosts/listavailablesizes). Resizing can + be only used to scale up DedicatedHost. Only name is required to be set. + :paramtype sku: ~azure.mgmt.compute.models.Sku + :keyword platform_fault_domain: Fault domain of the dedicated host within a dedicated host + group. + :paramtype platform_fault_domain: int + :keyword auto_replace_on_failure: Specifies whether the dedicated host should be replaced + automatically in case of a failure. The value is defaulted to 'true' when not provided. + :paramtype auto_replace_on_failure: bool + :keyword license_type: 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.** The default value is: **None.**. Known values are: "None", + "Windows_Server_Hybrid", and "Windows_Server_Perpetual". + :paramtype license_type: str or ~azure.mgmt.compute.models.DedicatedHostLicenseTypes + """ + super().__init__(tags=tags, **kwargs) + self.sku = sku + self.platform_fault_domain = platform_fault_domain + self.auto_replace_on_failure = auto_replace_on_failure + self.host_id: Optional[str] = None + self.virtual_machines: Optional[List["_models.SubResourceReadOnly"]] = None + self.license_type = license_type + self.provisioning_time: Optional[datetime.datetime] = None + self.provisioning_state: Optional[str] = None + self.instance_view: Optional["_models.DedicatedHostInstanceView"] = None + self.time_created: Optional[datetime.datetime] = None + + +class DefaultVirtualMachineScaleSetInfo(_serialization.Model): + """Indicates the target Virtual Machine ScaleSet properties upon triggering a seamless migration + without downtime of the VMs via the ConvertToVirtualMachineScaleSet API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar constrained_maximum_capacity: Indicates if the the maximum capacity of the default + migrated Virtual Machine Scale Set after its migration will be constrained to a limited number + of VMs. + :vartype constrained_maximum_capacity: bool + :ivar default_virtual_machine_scale_set: The default Virtual Machine ScaleSet Uri that the + Availability Set will be moved to upon triggering a seamless migration via the + ConvertToVirtualMachineScaleSet API. + :vartype default_virtual_machine_scale_set: ~azure.mgmt.compute.models.SubResource + """ + + _validation = { + "constrained_maximum_capacity": {"readonly": True}, + "default_virtual_machine_scale_set": {"readonly": True}, + } + + _attribute_map = { + "constrained_maximum_capacity": {"key": "constrainedMaximumCapacity", "type": "bool"}, + "default_virtual_machine_scale_set": {"key": "defaultVirtualMachineScaleSet", "type": "SubResource"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.status: Optional[Union[str, "_models.PatchOperationStatus"]] = None - self.installation_activity_id: Optional[str] = None - self.maintenance_window_exceeded: Optional[bool] = None - self.not_selected_patch_count: Optional[int] = None - self.excluded_patch_count: Optional[int] = None - self.pending_patch_count: Optional[int] = None - self.installed_patch_count: Optional[int] = None - self.failed_patch_count: Optional[int] = None - self.start_time: Optional[datetime.datetime] = None - self.last_modified_time: Optional[datetime.datetime] = None - self.error: Optional["_models.ApiError"] = None + self.constrained_maximum_capacity: Optional[bool] = None + self.default_virtual_machine_scale_set: Optional["_models.SubResource"] = None -class LinuxConfiguration(_serialization.Model): - """Specifies the Linux operating system settings on the virtual machine. For a list of supported - Linux distributions, see `Linux on Azure-Endorsed Distributions - `_. +class DiagnosticsProfile(_serialization.Model): + """Specifies the boot diagnostic settings state. Minimum api-version: 2015-06-15. - :ivar disable_password_authentication: Specifies whether password authentication should be - disabled. - :vartype disable_password_authentication: bool - :ivar ssh: Specifies the ssh key configuration for a Linux OS. - :vartype ssh: ~azure.mgmt.compute.v2024_11_01.models.SshConfiguration - :ivar provision_vm_agent: Indicates whether virtual machine agent should be provisioned on the - virtual machine. When this property is not specified in the request body, default behavior is - to set it to true. This will ensure that VM Agent is installed on the VM so that extensions can - be added to the VM later. - :vartype provision_vm_agent: bool - :ivar patch_settings: [Preview Feature] Specifies settings related to VM Guest Patching on - Linux. - :vartype patch_settings: ~azure.mgmt.compute.v2024_11_01.models.LinuxPatchSettings - :ivar enable_vm_agent_platform_updates: Indicates whether VMAgent Platform Updates is enabled - for the Linux virtual machine. Default value is false. - :vartype enable_vm_agent_platform_updates: bool + :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view + Console Output and Screenshot to diagnose VM status. **NOTE**\\ : If storageUri is being + specified then ensure that the storage account is in the same region and subscription as the + VM. You can easily view the output of your console log. Azure also enables you to see a + screenshot of the VM from the hypervisor. + :vartype boot_diagnostics: ~azure.mgmt.compute.models.BootDiagnostics """ _attribute_map = { - "disable_password_authentication": {"key": "disablePasswordAuthentication", "type": "bool"}, - "ssh": {"key": "ssh", "type": "SshConfiguration"}, - "provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"}, - "patch_settings": {"key": "patchSettings", "type": "LinuxPatchSettings"}, - "enable_vm_agent_platform_updates": {"key": "enableVMAgentPlatformUpdates", "type": "bool"}, + "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnostics"}, } - def __init__( - self, - *, - disable_password_authentication: Optional[bool] = None, - ssh: Optional["_models.SshConfiguration"] = None, - provision_vm_agent: Optional[bool] = None, - patch_settings: Optional["_models.LinuxPatchSettings"] = None, - enable_vm_agent_platform_updates: Optional[bool] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs: Any) -> None: """ - :keyword disable_password_authentication: Specifies whether password authentication should be - disabled. - :paramtype disable_password_authentication: bool - :keyword ssh: Specifies the ssh key configuration for a Linux OS. - :paramtype ssh: ~azure.mgmt.compute.v2024_11_01.models.SshConfiguration - :keyword provision_vm_agent: Indicates whether virtual machine agent should be provisioned on - the virtual machine. When this property is not specified in the request body, default behavior - is to set it to true. This will ensure that VM Agent is installed on the VM so that extensions - can be added to the VM later. - :paramtype provision_vm_agent: bool - :keyword patch_settings: [Preview Feature] Specifies settings related to VM Guest Patching on - Linux. - :paramtype patch_settings: ~azure.mgmt.compute.v2024_11_01.models.LinuxPatchSettings - :keyword enable_vm_agent_platform_updates: Indicates whether VMAgent Platform Updates is - enabled for the Linux virtual machine. Default value is false. - :paramtype enable_vm_agent_platform_updates: bool + :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view + Console Output and Screenshot to diagnose VM status. **NOTE**\\ : If storageUri is being + specified then ensure that the storage account is in the same region and subscription as the + VM. You can easily view the output of your console log. Azure also enables you to see a + screenshot of the VM from the hypervisor. + :paramtype boot_diagnostics: ~azure.mgmt.compute.models.BootDiagnostics """ super().__init__(**kwargs) - self.disable_password_authentication = disable_password_authentication - self.ssh = ssh - self.provision_vm_agent = provision_vm_agent - self.patch_settings = patch_settings - self.enable_vm_agent_platform_updates = enable_vm_agent_platform_updates + self.boot_diagnostics = boot_diagnostics -class LinuxParameters(_serialization.Model): - """Input for InstallPatches on a Linux VM, as directly received by the API. +class DiffDiskSettings(_serialization.Model): + """Describes the parameters of ephemeral disk settings that can be specified for operating system + disk. **Note:** The ephemeral disk settings can only be specified for managed disk. - :ivar classifications_to_include: The update classifications to select when installing patches - for Linux. - :vartype classifications_to_include: list[str or - ~azure.mgmt.compute.v2024_11_01.models.VMGuestPatchClassificationLinux] - :ivar package_name_masks_to_include: packages to include in the patch operation. Format: - packageName_packageVersion. - :vartype package_name_masks_to_include: list[str] - :ivar package_name_masks_to_exclude: packages to exclude in the patch operation. Format: - packageName_packageVersion. - :vartype package_name_masks_to_exclude: list[str] - :ivar maintenance_run_id: This is used as a maintenance run identifier for Auto VM Guest - Patching in Linux. - :vartype maintenance_run_id: str + :ivar option: Specifies the ephemeral disk settings for operating system disk. "Local" + :vartype option: str or ~azure.mgmt.compute.models.DiffDiskOptions + :ivar placement: Specifies the ephemeral disk placement for operating system disk. Possible + values are: **CacheDisk,** **ResourceDisk,** **NvmeDisk.** The defaulting behavior is: + **CacheDisk** if one is configured for the VM size otherwise **ResourceDisk** or **NvmeDisk** + is used. Refer to the VM size documentation for Windows VM at + https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at + https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM sizes exposes a + cache disk. Minimum api-version for NvmeDisk: 2024-03-01. Known values are: "CacheDisk", + "ResourceDisk", and "NvmeDisk". + :vartype placement: str or ~azure.mgmt.compute.models.DiffDiskPlacement """ _attribute_map = { - "classifications_to_include": {"key": "classificationsToInclude", "type": "[str]"}, - "package_name_masks_to_include": {"key": "packageNameMasksToInclude", "type": "[str]"}, - "package_name_masks_to_exclude": {"key": "packageNameMasksToExclude", "type": "[str]"}, - "maintenance_run_id": {"key": "maintenanceRunId", "type": "str"}, + "option": {"key": "option", "type": "str"}, + "placement": {"key": "placement", "type": "str"}, } def __init__( self, *, - classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationLinux"]]] = None, - package_name_masks_to_include: Optional[List[str]] = None, - package_name_masks_to_exclude: Optional[List[str]] = None, - maintenance_run_id: Optional[str] = None, + option: Optional[Union[str, "_models.DiffDiskOptions"]] = None, + placement: Optional[Union[str, "_models.DiffDiskPlacement"]] = None, **kwargs: Any ) -> None: """ - :keyword classifications_to_include: The update classifications to select when installing - patches for Linux. - :paramtype classifications_to_include: list[str or - ~azure.mgmt.compute.v2024_11_01.models.VMGuestPatchClassificationLinux] - :keyword package_name_masks_to_include: packages to include in the patch operation. Format: - packageName_packageVersion. - :paramtype package_name_masks_to_include: list[str] - :keyword package_name_masks_to_exclude: packages to exclude in the patch operation. Format: - packageName_packageVersion. - :paramtype package_name_masks_to_exclude: list[str] - :keyword maintenance_run_id: This is used as a maintenance run identifier for Auto VM Guest - Patching in Linux. - :paramtype maintenance_run_id: str + :keyword option: Specifies the ephemeral disk settings for operating system disk. "Local" + :paramtype option: str or ~azure.mgmt.compute.models.DiffDiskOptions + :keyword placement: Specifies the ephemeral disk placement for operating system disk. Possible + values are: **CacheDisk,** **ResourceDisk,** **NvmeDisk.** The defaulting behavior is: + **CacheDisk** if one is configured for the VM size otherwise **ResourceDisk** or **NvmeDisk** + is used. Refer to the VM size documentation for Windows VM at + https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at + https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM sizes exposes a + cache disk. Minimum api-version for NvmeDisk: 2024-03-01. Known values are: "CacheDisk", + "ResourceDisk", and "NvmeDisk". + :paramtype placement: str or ~azure.mgmt.compute.models.DiffDiskPlacement """ super().__init__(**kwargs) - self.classifications_to_include = classifications_to_include - self.package_name_masks_to_include = package_name_masks_to_include - self.package_name_masks_to_exclude = package_name_masks_to_exclude - self.maintenance_run_id = maintenance_run_id + self.option = option + self.placement = placement -class LinuxPatchSettings(_serialization.Model): - """Specifies settings related to VM Guest Patching on Linux. +class Disallowed(_serialization.Model): + """Describes the disallowed disk types. - :ivar patch_mode: Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual - machines associated to virtual machine scale set with OrchestrationMode as Flexible.\\ - :code:`
`\\ :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` - **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
`\\ :code:`
` **AutomaticByPlatform** - The virtual machine will be automatically - updated by the platform. The property provisionVMAgent must be true. Known values are: - "ImageDefault" and "AutomaticByPlatform". - :vartype patch_mode: str or ~azure.mgmt.compute.v2024_11_01.models.LinuxVMGuestPatchMode - :ivar assessment_mode: Specifies the mode of VM Guest Patch Assessment for the IaaS virtual - machine.\\ :code:`
`\\ :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. - :code:`
`\\ :code:`
` **AutomaticByPlatform** - The platform will trigger periodic - patch assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault" - and "AutomaticByPlatform". - :vartype assessment_mode: str or - ~azure.mgmt.compute.v2024_11_01.models.LinuxPatchAssessmentMode - :ivar automatic_by_platform_settings: Specifies additional settings for patch mode - AutomaticByPlatform in VM Guest Patching on Linux. - :vartype automatic_by_platform_settings: - ~azure.mgmt.compute.v2024_11_01.models.LinuxVMGuestPatchAutomaticByPlatformSettings + :ivar disk_types: A list of disk types. + :vartype disk_types: list[str] """ _attribute_map = { - "patch_mode": {"key": "patchMode", "type": "str"}, - "assessment_mode": {"key": "assessmentMode", "type": "str"}, - "automatic_by_platform_settings": { - "key": "automaticByPlatformSettings", - "type": "LinuxVMGuestPatchAutomaticByPlatformSettings", - }, + "disk_types": {"key": "diskTypes", "type": "[str]"}, } - def __init__( - self, - *, - patch_mode: Optional[Union[str, "_models.LinuxVMGuestPatchMode"]] = None, - assessment_mode: Optional[Union[str, "_models.LinuxPatchAssessmentMode"]] = None, - automatic_by_platform_settings: Optional["_models.LinuxVMGuestPatchAutomaticByPlatformSettings"] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, disk_types: Optional[List[str]] = None, **kwargs: Any) -> None: """ - :keyword patch_mode: Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual - machines associated to virtual machine scale set with OrchestrationMode as Flexible.\\ - :code:`
`\\ :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` - **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
`\\ :code:`
` **AutomaticByPlatform** - The virtual machine will be automatically - updated by the platform. The property provisionVMAgent must be true. Known values are: - "ImageDefault" and "AutomaticByPlatform". - :paramtype patch_mode: str or ~azure.mgmt.compute.v2024_11_01.models.LinuxVMGuestPatchMode - :keyword assessment_mode: Specifies the mode of VM Guest Patch Assessment for the IaaS virtual - machine.\\ :code:`
`\\ :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. - :code:`
`\\ :code:`
` **AutomaticByPlatform** - The platform will trigger periodic - patch assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault" - and "AutomaticByPlatform". - :paramtype assessment_mode: str or - ~azure.mgmt.compute.v2024_11_01.models.LinuxPatchAssessmentMode - :keyword automatic_by_platform_settings: Specifies additional settings for patch mode - AutomaticByPlatform in VM Guest Patching on Linux. - :paramtype automatic_by_platform_settings: - ~azure.mgmt.compute.v2024_11_01.models.LinuxVMGuestPatchAutomaticByPlatformSettings + :keyword disk_types: A list of disk types. + :paramtype disk_types: list[str] """ super().__init__(**kwargs) - self.patch_mode = patch_mode - self.assessment_mode = assessment_mode - self.automatic_by_platform_settings = automatic_by_platform_settings + self.disk_types = disk_types -class LinuxVMGuestPatchAutomaticByPlatformSettings(_serialization.Model): # pylint: disable=name-too-long - """Specifies additional settings to be applied when patch mode AutomaticByPlatform is selected in - Linux patch settings. +class DisallowedConfiguration(_serialization.Model): + """Specifies the disallowed configuration for a virtual machine image. - :ivar reboot_setting: Specifies the reboot setting for all AutomaticByPlatform patch - installation operations. Known values are: "Unknown", "IfRequired", "Never", and "Always". - :vartype reboot_setting: str or - ~azure.mgmt.compute.v2024_11_01.models.LinuxVMGuestPatchAutomaticByPlatformRebootSetting - :ivar bypass_platform_safety_checks_on_user_schedule: Enables customer to schedule patching - without accidental upgrades. - :vartype bypass_platform_safety_checks_on_user_schedule: bool + :ivar vm_disk_type: VM disk types which are disallowed. Known values are: "None" and + "Unmanaged". + :vartype vm_disk_type: str or ~azure.mgmt.compute.models.VmDiskTypes """ _attribute_map = { - "reboot_setting": {"key": "rebootSetting", "type": "str"}, - "bypass_platform_safety_checks_on_user_schedule": { - "key": "bypassPlatformSafetyChecksOnUserSchedule", - "type": "bool", - }, + "vm_disk_type": {"key": "vmDiskType", "type": "str"}, } - def __init__( - self, - *, - reboot_setting: Optional[Union[str, "_models.LinuxVMGuestPatchAutomaticByPlatformRebootSetting"]] = None, - bypass_platform_safety_checks_on_user_schedule: Optional[bool] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, vm_disk_type: Optional[Union[str, "_models.VmDiskTypes"]] = None, **kwargs: Any) -> None: """ - :keyword reboot_setting: Specifies the reboot setting for all AutomaticByPlatform patch - installation operations. Known values are: "Unknown", "IfRequired", "Never", and "Always". - :paramtype reboot_setting: str or - ~azure.mgmt.compute.v2024_11_01.models.LinuxVMGuestPatchAutomaticByPlatformRebootSetting - :keyword bypass_platform_safety_checks_on_user_schedule: Enables customer to schedule patching - without accidental upgrades. - :paramtype bypass_platform_safety_checks_on_user_schedule: bool + :keyword vm_disk_type: VM disk types which are disallowed. Known values are: "None" and + "Unmanaged". + :paramtype vm_disk_type: str or ~azure.mgmt.compute.models.VmDiskTypes """ super().__init__(**kwargs) - self.reboot_setting = reboot_setting - self.bypass_platform_safety_checks_on_user_schedule = bypass_platform_safety_checks_on_user_schedule + self.vm_disk_type = vm_disk_type -class ListUsagesResult(_serialization.Model): - """The List Usages operation response. +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 value: The list of compute resource usages. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.Usage] - :ivar next_link: The URI to fetch the next page of compute resource usage information. Call - ListNext() with this to fetch the next page of compute resource usage information. - :vartype next_link: str + :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 = { - "value": {"required": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - "value": {"key": "value", "type": "[Usage]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "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, *, value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs: Any) -> None: + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ - :keyword value: The list of compute resource usages. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.Usage] - :keyword next_link: The URI to fetch the next page of compute resource usage information. Call - ListNext() with this to fetch the next page of compute resource usage information. - :paramtype next_link: str + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] """ super().__init__(**kwargs) - self.value = value - self.next_link = next_link + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.location = location + self.tags = tags -class LogAnalyticsInputBase(_serialization.Model): - """Api input base class for LogAnalytics Api. +class Disk(ResourceAutoGenerated): + """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 blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api - writes output logs to. Required. - :vartype blob_container_sas_uri: str - :ivar from_time: From time of the query. Required. - :vartype from_time: ~datetime.datetime - :ivar to_time: To time of the query. Required. - :vartype to_time: ~datetime.datetime - :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. - :vartype group_by_throttle_policy: bool - :ivar group_by_operation_name: Group query result by Operation Name. - :vartype group_by_operation_name: bool - :ivar group_by_resource_name: Group query result by Resource Name. - :vartype group_by_resource_name: bool - :ivar group_by_client_application_id: Group query result by Client Application ID. - :vartype group_by_client_application_id: bool - :ivar group_by_user_agent: Group query result by User Agent. - :vartype group_by_user_agent: bool + :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] + :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 + disk attached. maxShares should be set to a value greater than one for disks to allow attaching + them to multiple VMs. + :vartype managed_by_extended: list[str] + :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, + Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS. + :vartype sku: ~azure.mgmt.compute.models.DiskSku + :ivar zones: The Logical zone list for Disk. + :vartype zones: list[str] + :ivar extended_location: The extended location where the disk will be created. Extended + location cannot be changed. + :vartype extended_location: ~azure.mgmt.compute.models.ExtendedLocation + :ivar time_created: The time when the disk was created. + :vartype time_created: ~datetime.datetime + :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". + :vartype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS + disks only. Known values are: "V1" and "V2". + :vartype hyper_v_generation: str or ~azure.mgmt.compute.models.HyperVGeneration + :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.models.PurchasePlanAutoGenerated + :ivar supported_capabilities: List of supported capabilities for the image from which the OS + disk was created. + :vartype supported_capabilities: ~azure.mgmt.compute.models.SupportedCapabilities + :ivar creation_data: Disk source information. CreationData information cannot be changed after + the disk has been created. + :vartype creation_data: ~azure.mgmt.compute.models.CreationData + :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it + indicates the size of the disk to create. If this field is present for updates or creation with + other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a + running VM, and can only increase the disk's size. + :vartype disk_size_gb: int + :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. + :vartype disk_size_bytes: int + :ivar unique_id: Unique Guid identifying the resource. + :vartype unique_id: str + :ivar encryption_settings_collection: Encryption settings collection used for Azure Disk + Encryption, can contain multiple encryption settings per disk or snapshot. + :vartype encryption_settings_collection: + ~azure.mgmt.compute.models.EncryptionSettingsCollection + :ivar provisioning_state: The disk provisioning state. + :vartype provisioning_state: str + :ivar disk_iops_read_write: The number of IOPS allowed for this disk; only settable for + UltraSSD disks. One operation can transfer between 4k and 256k bytes. + :vartype disk_iops_read_write: int + :ivar disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD + disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of + 10. + :vartype disk_m_bps_read_write: int + :ivar disk_iops_read_only: The total number of IOPS that will be allowed across all VMs + mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. + :vartype disk_iops_read_only: int + :ivar disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs + mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses + the ISO notation, of powers of 10. + :vartype disk_m_bps_read_only: int + :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", + "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", and "ActiveUpload". + :vartype disk_state: str or ~azure.mgmt.compute.models.DiskState + :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed + keys or platform managed keys. + :vartype encryption: ~azure.mgmt.compute.models.Encryption + :ivar max_shares: The maximum number of VMs that can attach to the disk at the same time. Value + greater than one indicates a disk that can be mounted on multiple VMs at the same time. + :vartype max_shares: int + :ivar share_info: Details of the list of all VMs that have the disk attached. maxShares should + be set to a value greater than one for disks to allow attaching them to multiple VMs. + :vartype share_info: list[~azure.mgmt.compute.models.ShareInfoElement] + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", and "DenyAll". + :vartype network_access_policy: str or ~azure.mgmt.compute.models.NetworkAccessPolicy + :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. + :vartype disk_access_id: str + :ivar bursting_enabled_time: Latest time when bursting was last enabled on a disk. + :vartype bursting_enabled_time: ~datetime.datetime + :ivar tier: Performance tier of the disk (e.g, P4, S10) as described here: + https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra + disks. + :vartype tier: str + :ivar bursting_enabled: Set to true to enable bursting beyond the provisioned performance + target of the disk. Bursting is disabled by default. Does not apply to Ultra disks. + :vartype bursting_enabled: bool + :ivar property_updates_in_progress: Properties of the disk for which update is pending. + :vartype property_updates_in_progress: ~azure.mgmt.compute.models.PropertyUpdatesInProgress + :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. + :vartype supports_hibernation: bool + :ivar security_profile: Contains the security related information for the resource. + :vartype security_profile: ~azure.mgmt.compute.models.DiskSecurityProfile + :ivar completion_percent: Percentage complete for the background copy when a resource is + created via the CopyStart operation. + :vartype completion_percent: float + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled" and "Disabled". + :vartype public_network_access: str or ~azure.mgmt.compute.models.PublicNetworkAccess + :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading + to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". + :vartype data_access_auth_mode: str or ~azure.mgmt.compute.models.DataAccessAuthMode + :ivar optimized_for_frequent_attach: Setting this property to true improves reliability and + performance of data disks that are frequently (more than 5 times a day) by detached from one + virtual machine and attached to another. This property should not be set for disks that are not + detached and attached frequently as it causes the disks to not align with the fault domain of + the virtual machine. + :vartype optimized_for_frequent_attach: bool + :ivar last_ownership_update_time: The UTC time when the ownership state of the disk was last + changed i.e., the time the disk was last attached or detached from a VM or the time when the VM + to which the disk was attached was deallocated or started. + :vartype last_ownership_update_time: ~datetime.datetime """ _validation = { - "blob_container_sas_uri": {"required": True}, - "from_time": {"required": True}, - "to_time": {"required": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "managed_by": {"readonly": True}, + "managed_by_extended": {"readonly": True}, + "time_created": {"readonly": True}, + "disk_size_bytes": {"readonly": True}, + "unique_id": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "disk_state": {"readonly": True}, + "share_info": {"readonly": True}, + "bursting_enabled_time": {"readonly": True}, + "property_updates_in_progress": {"readonly": True}, + "last_ownership_update_time": {"readonly": True}, } _attribute_map = { - "blob_container_sas_uri": {"key": "blobContainerSasUri", "type": "str"}, - "from_time": {"key": "fromTime", "type": "iso-8601"}, - "to_time": {"key": "toTime", "type": "iso-8601"}, - "group_by_throttle_policy": {"key": "groupByThrottlePolicy", "type": "bool"}, - "group_by_operation_name": {"key": "groupByOperationName", "type": "bool"}, - "group_by_resource_name": {"key": "groupByResourceName", "type": "bool"}, - "group_by_client_application_id": {"key": "groupByClientApplicationId", "type": "bool"}, - "group_by_user_agent": {"key": "groupByUserAgent", "type": "bool"}, + "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}"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "managed_by_extended": {"key": "managedByExtended", "type": "[str]"}, + "sku": {"key": "sku", "type": "DiskSku"}, + "zones": {"key": "zones", "type": "[str]"}, + "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": "PurchasePlanAutoGenerated"}, + "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, + "creation_data": {"key": "properties.creationData", "type": "CreationData"}, + "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, + "disk_size_bytes": {"key": "properties.diskSizeBytes", "type": "int"}, + "unique_id": {"key": "properties.uniqueId", "type": "str"}, + "encryption_settings_collection": { + "key": "properties.encryptionSettingsCollection", + "type": "EncryptionSettingsCollection", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "disk_iops_read_write": {"key": "properties.diskIOPSReadWrite", "type": "int"}, + "disk_m_bps_read_write": {"key": "properties.diskMBpsReadWrite", "type": "int"}, + "disk_iops_read_only": {"key": "properties.diskIOPSReadOnly", "type": "int"}, + "disk_m_bps_read_only": {"key": "properties.diskMBpsReadOnly", "type": "int"}, + "disk_state": {"key": "properties.diskState", "type": "str"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "max_shares": {"key": "properties.maxShares", "type": "int"}, + "share_info": {"key": "properties.shareInfo", "type": "[ShareInfoElement]"}, + "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, + "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, + "bursting_enabled_time": {"key": "properties.burstingEnabledTime", "type": "iso-8601"}, + "tier": {"key": "properties.tier", "type": "str"}, + "bursting_enabled": {"key": "properties.burstingEnabled", "type": "bool"}, + "property_updates_in_progress": { + "key": "properties.propertyUpdatesInProgress", + "type": "PropertyUpdatesInProgress", + }, + "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, + "security_profile": {"key": "properties.securityProfile", "type": "DiskSecurityProfile"}, + "completion_percent": {"key": "properties.completionPercent", "type": "float"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, + "optimized_for_frequent_attach": {"key": "properties.optimizedForFrequentAttach", "type": "bool"}, + "last_ownership_update_time": {"key": "properties.LastOwnershipUpdateTime", "type": "iso-8601"}, } - def __init__( + def __init__( # pylint: disable=too-many-locals self, *, - blob_container_sas_uri: str, - from_time: datetime.datetime, - to_time: datetime.datetime, - group_by_throttle_policy: Optional[bool] = None, - group_by_operation_name: Optional[bool] = None, - group_by_resource_name: Optional[bool] = None, - group_by_client_application_id: Optional[bool] = None, - group_by_user_agent: Optional[bool] = None, + location: str, + tags: Optional[Dict[str, str]] = None, + sku: Optional["_models.DiskSku"] = None, + zones: Optional[List[str]] = None, + 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.PurchasePlanAutoGenerated"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, + creation_data: Optional["_models.CreationData"] = None, + disk_size_gb: Optional[int] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, + disk_iops_read_write: Optional[int] = None, + disk_m_bps_read_write: Optional[int] = None, + disk_iops_read_only: Optional[int] = None, + disk_m_bps_read_only: Optional[int] = None, + encryption: Optional["_models.Encryption"] = None, + max_shares: Optional[int] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, + disk_access_id: Optional[str] = None, + tier: Optional[str] = None, + bursting_enabled: Optional[bool] = None, + supports_hibernation: Optional[bool] = None, + security_profile: Optional["_models.DiskSecurityProfile"] = None, + completion_percent: Optional[float] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, + optimized_for_frequent_attach: Optional[bool] = None, **kwargs: Any ) -> None: """ - :keyword blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics - Api writes output logs to. Required. - :paramtype blob_container_sas_uri: str - :keyword from_time: From time of the query. Required. - :paramtype from_time: ~datetime.datetime - :keyword to_time: To time of the query. Required. - :paramtype to_time: ~datetime.datetime - :keyword group_by_throttle_policy: Group query result by Throttle Policy applied. - :paramtype group_by_throttle_policy: bool - :keyword group_by_operation_name: Group query result by Operation Name. - :paramtype group_by_operation_name: bool - :keyword group_by_resource_name: Group query result by Resource Name. - :paramtype group_by_resource_name: bool - :keyword group_by_client_application_id: Group query result by Client Application ID. - :paramtype group_by_client_application_id: bool - :keyword group_by_user_agent: Group query result by User Agent. - :paramtype group_by_user_agent: bool + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, 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.models.DiskSku + :keyword zones: The Logical zone list for Disk. + :paramtype zones: list[str] + :keyword extended_location: The extended location where the disk will be created. Extended + location cannot be changed. + :paramtype extended_location: ~azure.mgmt.compute.models.ExtendedLocation + :keyword os_type: The Operating System type. Known values are: "Windows" and "Linux". + :paramtype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :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.models.HyperVGeneration + :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.models.PurchasePlanAutoGenerated + :keyword supported_capabilities: List of supported capabilities for the image from which the OS + disk was created. + :paramtype supported_capabilities: ~azure.mgmt.compute.models.SupportedCapabilities + :keyword creation_data: Disk source information. CreationData information cannot be changed + after the disk has been created. + :paramtype creation_data: ~azure.mgmt.compute.models.CreationData + :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it + indicates the size of the disk to create. If this field is present for updates or creation with + other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a + running VM, and can only increase the disk's size. + :paramtype disk_size_gb: int + :keyword encryption_settings_collection: Encryption settings collection used for Azure Disk + Encryption, can contain multiple encryption settings per disk or snapshot. + :paramtype encryption_settings_collection: + ~azure.mgmt.compute.models.EncryptionSettingsCollection + :keyword disk_iops_read_write: The number of IOPS allowed for this disk; only settable for + UltraSSD disks. One operation can transfer between 4k and 256k bytes. + :paramtype disk_iops_read_write: int + :keyword disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD + disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of + 10. + :paramtype disk_m_bps_read_write: int + :keyword disk_iops_read_only: The total number of IOPS that will be allowed across all VMs + mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. + :paramtype disk_iops_read_only: int + :keyword disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs + mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses + the ISO notation, of powers of 10. + :paramtype disk_m_bps_read_only: int + :keyword encryption: Encryption property can be used to encrypt data at rest with customer + managed keys or platform managed keys. + :paramtype encryption: ~azure.mgmt.compute.models.Encryption + :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. + Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. + :paramtype max_shares: int + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", and "DenyAll". + :paramtype network_access_policy: str or ~azure.mgmt.compute.models.NetworkAccessPolicy + :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on + disks. + :paramtype disk_access_id: str + :keyword tier: Performance tier of the disk (e.g, P4, S10) as described here: + https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra + disks. + :paramtype tier: str + :keyword bursting_enabled: Set to true to enable bursting beyond the provisioned performance + target of the disk. Bursting is disabled by default. Does not apply to Ultra disks. + :paramtype bursting_enabled: bool + :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. + :paramtype supports_hibernation: bool + :keyword security_profile: Contains the security related information for the resource. + :paramtype security_profile: ~azure.mgmt.compute.models.DiskSecurityProfile + :keyword completion_percent: Percentage complete for the background copy when a resource is + created via the CopyStart operation. + :paramtype completion_percent: float + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled" and "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.compute.models.PublicNetworkAccess + :keyword data_access_auth_mode: Additional authentication requirements when exporting or + uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". + :paramtype data_access_auth_mode: str or ~azure.mgmt.compute.models.DataAccessAuthMode + :keyword optimized_for_frequent_attach: Setting this property to true improves reliability and + performance of data disks that are frequently (more than 5 times a day) by detached from one + virtual machine and attached to another. This property should not be set for disks that are not + detached and attached frequently as it causes the disks to not align with the fault domain of + the virtual machine. + :paramtype optimized_for_frequent_attach: bool """ - super().__init__(**kwargs) - self.blob_container_sas_uri = blob_container_sas_uri - self.from_time = from_time - self.to_time = to_time - self.group_by_throttle_policy = group_by_throttle_policy - self.group_by_operation_name = group_by_operation_name - self.group_by_resource_name = group_by_resource_name - self.group_by_client_application_id = group_by_client_application_id - self.group_by_user_agent = group_by_user_agent + super().__init__(location=location, tags=tags, **kwargs) + self.managed_by: Optional[str] = None + self.managed_by_extended: Optional[List[str]] = None + self.sku = sku + self.zones = zones + self.extended_location = extended_location + self.time_created: Optional[datetime.datetime] = None + self.os_type = os_type + self.hyper_v_generation = hyper_v_generation + self.purchase_plan = purchase_plan + self.supported_capabilities = supported_capabilities + self.creation_data = creation_data + self.disk_size_gb = disk_size_gb + self.disk_size_bytes: Optional[int] = None + self.unique_id: Optional[str] = None + self.encryption_settings_collection = encryption_settings_collection + self.provisioning_state: Optional[str] = None + self.disk_iops_read_write = disk_iops_read_write + self.disk_m_bps_read_write = disk_m_bps_read_write + self.disk_iops_read_only = disk_iops_read_only + self.disk_m_bps_read_only = disk_m_bps_read_only + self.disk_state: Optional[Union[str, "_models.DiskState"]] = None + self.encryption = encryption + self.max_shares = max_shares + self.share_info: Optional[List["_models.ShareInfoElement"]] = None + self.network_access_policy = network_access_policy + self.disk_access_id = disk_access_id + self.bursting_enabled_time: Optional[datetime.datetime] = None + self.tier = tier + self.bursting_enabled = bursting_enabled + self.property_updates_in_progress: Optional["_models.PropertyUpdatesInProgress"] = None + self.supports_hibernation = supports_hibernation + self.security_profile = security_profile + self.completion_percent = completion_percent + self.public_network_access = public_network_access + self.data_access_auth_mode = data_access_auth_mode + self.optimized_for_frequent_attach = optimized_for_frequent_attach + self.last_ownership_update_time: Optional[datetime.datetime] = None -class LogAnalyticsOperationResult(_serialization.Model): - """LogAnalytics operation status response. +class DiskAccess(ResourceAutoGenerated): + """disk access resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar properties: LogAnalyticsOutput. - :vartype properties: ~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOutput + 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] + :ivar extended_location: The extended location where the disk access will be created. Extended + location cannot be changed. + :vartype extended_location: ~azure.mgmt.compute.models.ExtendedLocation + :ivar private_endpoint_connections: A readonly collection of private endpoint connections + created on the disk. Currently only one endpoint connection is supported. + :vartype private_endpoint_connections: + list[~azure.mgmt.compute.models.PrivateEndpointConnection] + :ivar provisioning_state: The disk access resource provisioning state. + :vartype provisioning_state: str + :ivar time_created: The time when the disk access was created. + :vartype time_created: ~datetime.datetime """ _validation = { - "properties": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "private_endpoint_connections": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "time_created": {"readonly": True}, } _attribute_map = { - "properties": {"key": "properties", "type": "LogAnalyticsOutput"}, + "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}"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.properties: Optional["_models.LogAnalyticsOutput"] = None + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, 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.models.ExtendedLocation + """ + super().__init__(location=location, tags=tags, **kwargs) + self.extended_location = extended_location + self.private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None + self.provisioning_state: Optional[str] = None + self.time_created: Optional[datetime.datetime] = None -class LogAnalyticsOutput(_serialization.Model): - """LogAnalytics output properties. +class DiskAccessList(_serialization.Model): + """The List disk access operation response. - 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 output: Output file Uri path to blob container. - :vartype output: str + :ivar value: A list of disk access resources. Required. + :vartype value: list[~azure.mgmt.compute.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. + :vartype next_link: str """ _validation = { - "output": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { - "output": {"key": "output", "type": "str"}, + "value": {"key": "value", "type": "[DiskAccess]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, value: List["_models.DiskAccess"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of disk access resources. Required. + :paramtype value: list[~azure.mgmt.compute.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. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.output: Optional[str] = None + self.value = value + self.next_link = next_link -class MaintenanceRedeployStatus(_serialization.Model): - """Maintenance Operation Status. +class DiskAccessUpdate(_serialization.Model): + """Used for updating a disk access resource. - :ivar is_customer_initiated_maintenance_allowed: True, if customer is allowed to perform - Maintenance. - :vartype is_customer_initiated_maintenance_allowed: bool - :ivar pre_maintenance_window_start_time: Start Time for the Pre Maintenance Window. - :vartype pre_maintenance_window_start_time: ~datetime.datetime - :ivar pre_maintenance_window_end_time: End Time for the Pre Maintenance Window. - :vartype pre_maintenance_window_end_time: ~datetime.datetime - :ivar maintenance_window_start_time: Start Time for the Maintenance Window. - :vartype maintenance_window_start_time: ~datetime.datetime - :ivar maintenance_window_end_time: End Time for the Maintenance Window. - :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: - "None", "RetryLater", "MaintenanceAborted", and "MaintenanceCompleted". - :vartype last_operation_result_code: str or - ~azure.mgmt.compute.v2024_11_01.models.MaintenanceOperationResultCodeTypes - :ivar last_operation_message: Message returned for the last Maintenance Operation. - :vartype last_operation_message: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { - "is_customer_initiated_maintenance_allowed": {"key": "isCustomerInitiatedMaintenanceAllowed", "type": "bool"}, - "pre_maintenance_window_start_time": {"key": "preMaintenanceWindowStartTime", "type": "iso-8601"}, - "pre_maintenance_window_end_time": {"key": "preMaintenanceWindowEndTime", "type": "iso-8601"}, - "maintenance_window_start_time": {"key": "maintenanceWindowStartTime", "type": "iso-8601"}, - "maintenance_window_end_time": {"key": "maintenanceWindowEndTime", "type": "iso-8601"}, - "last_operation_result_code": {"key": "lastOperationResultCode", "type": "str"}, - "last_operation_message": {"key": "lastOperationMessage", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - is_customer_initiated_maintenance_allowed: Optional[bool] = None, - pre_maintenance_window_start_time: Optional[datetime.datetime] = None, - pre_maintenance_window_end_time: Optional[datetime.datetime] = None, - maintenance_window_start_time: Optional[datetime.datetime] = None, - maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, - last_operation_message: Optional[str] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ - :keyword is_customer_initiated_maintenance_allowed: True, if customer is allowed to perform - Maintenance. - :paramtype is_customer_initiated_maintenance_allowed: bool - :keyword pre_maintenance_window_start_time: Start Time for the Pre Maintenance Window. - :paramtype pre_maintenance_window_start_time: ~datetime.datetime - :keyword pre_maintenance_window_end_time: End Time for the Pre Maintenance Window. - :paramtype pre_maintenance_window_end_time: ~datetime.datetime - :keyword maintenance_window_start_time: Start Time for the Maintenance Window. - :paramtype maintenance_window_start_time: ~datetime.datetime - :keyword maintenance_window_end_time: End Time for the Maintenance Window. - :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values - are: "None", "RetryLater", "MaintenanceAborted", and "MaintenanceCompleted". - :paramtype last_operation_result_code: str or - ~azure.mgmt.compute.v2024_11_01.models.MaintenanceOperationResultCodeTypes - :keyword last_operation_message: Message returned for the last Maintenance Operation. - :paramtype last_operation_message: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] """ super().__init__(**kwargs) - self.is_customer_initiated_maintenance_allowed = is_customer_initiated_maintenance_allowed - self.pre_maintenance_window_start_time = pre_maintenance_window_start_time - self.pre_maintenance_window_end_time = pre_maintenance_window_end_time - self.maintenance_window_start_time = maintenance_window_start_time - self.maintenance_window_end_time = maintenance_window_end_time - self.last_operation_result_code = last_operation_result_code - self.last_operation_message = last_operation_message + self.tags = tags -class ManagedDiskParameters(SubResource): - """The parameters of a managed disk. +class DiskEncryptionSet(ResourceAutoGenerated): + """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. :vartype id: str - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", - "StandardSSD_ZRS", and "PremiumV2_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2024_11_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSetParameters - :ivar security_profile: Specifies the security profile for the managed disk. - :vartype security_profile: ~azure.mgmt.compute.v2024_11_01.models.VMDiskSecurityProfile + :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] + :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.models.EncryptionSetIdentity + :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and + "ConfidentialVmEncryptedWithCustomerKey". + :vartype encryption_type: str or ~azure.mgmt.compute.models.DiskEncryptionSetType + :ivar active_key: The key vault key which is currently used by this disk encryption set. + :vartype active_key: ~azure.mgmt.compute.models.KeyForDiskEncryptionSet + :ivar previous_keys: A readonly collection of key vault keys previously used by this disk + encryption set while a key rotation is in progress. It will be empty if there is no ongoing key + rotation. + :vartype previous_keys: list[~azure.mgmt.compute.models.KeyForDiskEncryptionSet] + :ivar provisioning_state: The disk encryption set provisioning state. + :vartype provisioning_state: str + :ivar rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating of + this disk encryption set to the latest key version. + :vartype rotation_to_latest_key_version_enabled: bool + :ivar last_key_rotation_timestamp: The time when the active key of this disk encryption set was + updated. + :vartype last_key_rotation_timestamp: ~datetime.datetime + :ivar auto_key_rotation_error: The error that was encountered during auto-key rotation. If an + error is present, then auto-key rotation will not be attempted until the error on this disk + encryption set is fixed. + :vartype auto_key_rotation_error: ~azure.mgmt.compute.models.ApiError + :ivar federated_client_id: Multi-tenant application client id to access key vault in a + different tenant. Setting the value to 'None' will clear the property. + :vartype federated_client_id: str """ + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "previous_keys": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, + "auto_key_rotation_error": {"readonly": True}, + } + _attribute_map = { "id": {"key": "id", "type": "str"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - "security_profile": {"key": "securityProfile", "type": "VMDiskSecurityProfile"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "EncryptionSetIdentity"}, + "encryption_type": {"key": "properties.encryptionType", "type": "str"}, + "active_key": {"key": "properties.activeKey", "type": "KeyForDiskEncryptionSet"}, + "previous_keys": {"key": "properties.previousKeys", "type": "[KeyForDiskEncryptionSet]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "rotation_to_latest_key_version_enabled": { + "key": "properties.rotationToLatestKeyVersionEnabled", + "type": "bool", + }, + "last_key_rotation_timestamp": {"key": "properties.lastKeyRotationTimestamp", "type": "iso-8601"}, + "auto_key_rotation_error": {"key": "properties.autoKeyRotationError", "type": "ApiError"}, + "federated_client_id": {"key": "properties.federatedClientId", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - security_profile: Optional["_models.VMDiskSecurityProfile"] = None, + location: str, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.EncryptionSetIdentity"] = None, + encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, + active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, + rotation_to_latest_key_version_enabled: Optional[bool] = None, + federated_client_id: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword id: Resource Id. - :paramtype id: str - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", - "StandardSSD_ZRS", and "PremiumV2_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2024_11_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSetParameters - :keyword security_profile: Specifies the security profile for the managed disk. - :paramtype security_profile: ~azure.mgmt.compute.v2024_11_01.models.VMDiskSecurityProfile - """ - super().__init__(id=id, **kwargs) - self.storage_account_type = storage_account_type - self.disk_encryption_set = disk_encryption_set - self.security_profile = security_profile + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, 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.models.EncryptionSetIdentity + :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and + "ConfidentialVmEncryptedWithCustomerKey". + :paramtype encryption_type: str or ~azure.mgmt.compute.models.DiskEncryptionSetType + :keyword active_key: The key vault key which is currently used by this disk encryption set. + :paramtype active_key: ~azure.mgmt.compute.models.KeyForDiskEncryptionSet + :keyword rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating + of this disk encryption set to the latest key version. + :paramtype rotation_to_latest_key_version_enabled: bool + :keyword federated_client_id: Multi-tenant application client id to access key vault in a + different tenant. Setting the value to 'None' will clear the property. + :paramtype federated_client_id: str + """ + super().__init__(location=location, tags=tags, **kwargs) + self.identity = identity + self.encryption_type = encryption_type + self.active_key = active_key + self.previous_keys: Optional[List["_models.KeyForDiskEncryptionSet"]] = None + self.provisioning_state: Optional[str] = None + self.rotation_to_latest_key_version_enabled = rotation_to_latest_key_version_enabled + self.last_key_rotation_timestamp: Optional[datetime.datetime] = None + self.auto_key_rotation_error: Optional["_models.ApiError"] = None + self.federated_client_id = federated_client_id -class MigrateToVirtualMachineScaleSetInput(_serialization.Model): - """Describes the Virtual Machine Scale Set to migrate from Availability Set. +class DiskEncryptionSetList(_serialization.Model): + """The List disk encryption set operation response. All required parameters must be populated in order to send to server. - :ivar virtual_machine_scale_set_flexible: Specifies information about the Virtual Machine Scale - Set that the Availability Set should be migrated to. Minimum api‐version: 2024‐11‐01. Required. - :vartype virtual_machine_scale_set_flexible: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :ivar value: A list of disk encryption sets. Required. + :vartype value: list[~azure.mgmt.compute.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. + :vartype next_link: str """ _validation = { - "virtual_machine_scale_set_flexible": {"required": True}, + "value": {"required": True}, } _attribute_map = { - "virtual_machine_scale_set_flexible": {"key": "virtualMachineScaleSetFlexible", "type": "SubResource"}, + "value": {"key": "value", "type": "[DiskEncryptionSet]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, virtual_machine_scale_set_flexible: "_models.SubResource", **kwargs: Any) -> None: + def __init__( + self, *, value: List["_models.DiskEncryptionSet"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ - :keyword virtual_machine_scale_set_flexible: Specifies information about the Virtual Machine - Scale Set that the Availability Set should be migrated to. Minimum api‐version: 2024‐11‐01. - Required. - :paramtype virtual_machine_scale_set_flexible: - ~azure.mgmt.compute.v2024_11_01.models.SubResource + :keyword value: A list of disk encryption sets. Required. + :paramtype value: list[~azure.mgmt.compute.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. + :paramtype next_link: str """ super().__init__(**kwargs) - self.virtual_machine_scale_set_flexible = virtual_machine_scale_set_flexible + self.value = value + self.next_link = next_link -class MigrateVMToVirtualMachineScaleSetInput(_serialization.Model): - """The input of virtual machine migration from Availability Set to Flexible Virtual Machine Scale - Set. +class SubResource(_serialization.Model): + """SubResource. - :ivar target_zone: The target zone of VM migration to Flexible Virtual Machine Scale Set. - :vartype target_zone: str - :ivar target_fault_domain: The target compute fault domain of VM migration to Flexible Virtual - Machine Scale Set. - :vartype target_fault_domain: int - :ivar target_vm_size: The target Virtual Machine size of VM migration to Flexible Virtual - Machine Scale Set. - :vartype target_vm_size: str + :ivar id: Resource Id. + :vartype id: str """ _attribute_map = { - "target_zone": {"key": "targetZone", "type": "str"}, - "target_fault_domain": {"key": "targetFaultDomain", "type": "int"}, - "target_vm_size": {"key": "targetVMSize", "type": "str"}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - target_zone: Optional[str] = None, - target_fault_domain: Optional[int] = None, - target_vm_size: Optional[str] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin """ - :keyword target_zone: The target zone of VM migration to Flexible Virtual Machine Scale Set. - :paramtype target_zone: str - :keyword target_fault_domain: The target compute fault domain of VM migration to Flexible - Virtual Machine Scale Set. - :paramtype target_fault_domain: int - :keyword target_vm_size: The target Virtual Machine size of VM migration to Flexible Virtual - Machine Scale Set. - :paramtype target_vm_size: str + :keyword id: Resource Id. + :paramtype id: str """ super().__init__(**kwargs) - self.target_zone = target_zone - self.target_fault_domain = target_fault_domain - self.target_vm_size = target_vm_size + self.id = id -class NetworkInterfaceReference(SubResource): - """Describes a network interface reference. +class DiskEncryptionSetParameters(SubResource): + """Describes the parameter of customer managed disk encryption set resource id that can be + specified for disk. **Note:** The disk encryption set resource id can only be specified for + managed disk. Please refer https://aka.ms/mdssewithcmkoverview for more details. :ivar id: Resource Id. :vartype id: str - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Known values are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DeleteOptions + """ + + +class DiskEncryptionSettings(_serialization.Model): + """Describes a Encryption Settings for a Disk. + + :ivar disk_encryption_key: Specifies the location of the disk encryption key, which is a Key + Vault Secret. + :vartype disk_encryption_key: ~azure.mgmt.compute.models.KeyVaultSecretReference + :ivar key_encryption_key: Specifies the location of the key encryption key in Key Vault. + :vartype key_encryption_key: ~azure.mgmt.compute.models.KeyVaultKeyReference + :ivar enabled: Specifies whether disk encryption should be enabled on the virtual machine. + :vartype enabled: bool """ _attribute_map = { - "id": {"key": "id", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "delete_option": {"key": "properties.deleteOption", "type": "str"}, + "disk_encryption_key": {"key": "diskEncryptionKey", "type": "KeyVaultSecretReference"}, + "key_encryption_key": {"key": "keyEncryptionKey", "type": "KeyVaultKeyReference"}, + "enabled": {"key": "enabled", "type": "bool"}, } def __init__( self, *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - primary: Optional[bool] = None, - delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, + disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, + enabled: Optional[bool] = None, **kwargs: Any ) -> None: """ - :keyword id: Resource Id. - :paramtype id: str - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Known values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DeleteOptions + :keyword disk_encryption_key: Specifies the location of the disk encryption key, which is a Key + Vault Secret. + :paramtype disk_encryption_key: ~azure.mgmt.compute.models.KeyVaultSecretReference + :keyword key_encryption_key: Specifies the location of the key encryption key in Key Vault. + :paramtype key_encryption_key: ~azure.mgmt.compute.models.KeyVaultKeyReference + :keyword enabled: Specifies whether disk encryption should be enabled on the virtual machine. + :paramtype enabled: bool """ - super().__init__(id=id, **kwargs) - self.primary = primary - self.delete_option = delete_option + super().__init__(**kwargs) + self.disk_encryption_key = disk_encryption_key + self.key_encryption_key = key_encryption_key + self.enabled = enabled -class NetworkProfile(_serialization.Model): - """Specifies the network interfaces or the networking configuration of the virtual machine. +class DiskEncryptionSetUpdate(_serialization.Model): + """disk encryption set update resource. - :ivar network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the virtual machine. - :vartype network_interfaces: - list[~azure.mgmt.compute.v2024_11_01.models.NetworkInterfaceReference] - :ivar network_api_version: specifies the Microsoft.Network API version used when creating - networking resources in the Network Interface Configurations. Known values are: "2020-11-01" - and "2022-11-01". - :vartype network_api_version: str or ~azure.mgmt.compute.v2024_11_01.models.NetworkApiVersion - :ivar network_interface_configurations: Specifies the networking configurations that will be - used to create the virtual machine networking resources. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineNetworkInterfaceConfiguration] + :ivar tags: Resource tags. + :vartype tags: dict[str, 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.models.EncryptionSetIdentity + :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and + "ConfidentialVmEncryptedWithCustomerKey". + :vartype encryption_type: str or ~azure.mgmt.compute.models.DiskEncryptionSetType + :ivar active_key: Key Vault Key Url to be used for server side encryption of Managed Disks and + Snapshots. + :vartype active_key: ~azure.mgmt.compute.models.KeyForDiskEncryptionSet + :ivar rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating of + this disk encryption set to the latest key version. + :vartype rotation_to_latest_key_version_enabled: bool + :ivar federated_client_id: Multi-tenant application client id to access key vault in a + different tenant. Setting the value to 'None' will clear the property. + :vartype federated_client_id: str """ _attribute_map = { - "network_interfaces": {"key": "networkInterfaces", "type": "[NetworkInterfaceReference]"}, - "network_api_version": {"key": "networkApiVersion", "type": "str"}, - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineNetworkInterfaceConfiguration]", + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "EncryptionSetIdentity"}, + "encryption_type": {"key": "properties.encryptionType", "type": "str"}, + "active_key": {"key": "properties.activeKey", "type": "KeyForDiskEncryptionSet"}, + "rotation_to_latest_key_version_enabled": { + "key": "properties.rotationToLatestKeyVersionEnabled", + "type": "bool", }, + "federated_client_id": {"key": "properties.federatedClientId", "type": "str"}, } def __init__( self, *, - network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, - network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, - network_interface_configurations: Optional[List["_models.VirtualMachineNetworkInterfaceConfiguration"]] = None, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.EncryptionSetIdentity"] = None, + encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, + active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, + rotation_to_latest_key_version_enabled: Optional[bool] = None, + federated_client_id: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the virtual machine. - :paramtype network_interfaces: - list[~azure.mgmt.compute.v2024_11_01.models.NetworkInterfaceReference] - :keyword network_api_version: specifies the Microsoft.Network API version used when creating - networking resources in the Network Interface Configurations. Known values are: "2020-11-01" - and "2022-11-01". - :paramtype network_api_version: str or ~azure.mgmt.compute.v2024_11_01.models.NetworkApiVersion - :keyword network_interface_configurations: Specifies the networking configurations that will be - used to create the virtual machine networking resources. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineNetworkInterfaceConfiguration] + :keyword tags: Resource tags. + :paramtype tags: dict[str, 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.models.EncryptionSetIdentity + :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and + "ConfidentialVmEncryptedWithCustomerKey". + :paramtype encryption_type: str or ~azure.mgmt.compute.models.DiskEncryptionSetType + :keyword active_key: Key Vault Key Url to be used for server side encryption of Managed Disks + and Snapshots. + :paramtype active_key: ~azure.mgmt.compute.models.KeyForDiskEncryptionSet + :keyword rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating + of this disk encryption set to the latest key version. + :paramtype rotation_to_latest_key_version_enabled: bool + :keyword federated_client_id: Multi-tenant application client id to access key vault in a + different tenant. Setting the value to 'None' will clear the property. + :paramtype federated_client_id: str """ super().__init__(**kwargs) - self.network_interfaces = network_interfaces - self.network_api_version = network_api_version - self.network_interface_configurations = network_interface_configurations - + self.tags = tags + self.identity = identity + self.encryption_type = encryption_type + self.active_key = active_key + self.rotation_to_latest_key_version_enabled = rotation_to_latest_key_version_enabled + self.federated_client_id = federated_client_id -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. +class DiskInstanceView(_serialization.Model): + """The instance view of the disk. - :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: - "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :ivar name: The disk name. :vartype name: str - :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for - data-plane operations and "false" for ARM/control-plane operations. - :vartype is_data_action: bool - :ivar display: Localized display information for this particular operation. - :vartype display: ~azure.mgmt.compute.v2024_11_01.models.OperationDisplay - :ivar origin: The intended executor of the operation; as in Resource Based Access Control - (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", - and "user,system". - :vartype origin: str or ~azure.mgmt.compute.v2024_11_01.models.Origin - :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. "Internal" - :vartype action_type: str or ~azure.mgmt.compute.v2024_11_01.models.ActionType + :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`\\ + :code:`
` Minimum api-version: 2015-06-15. + :vartype encryption_settings: list[~azure.mgmt.compute.models.DiskEncryptionSettings] + :ivar statuses: The resource status information. + :vartype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] """ - _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"}, + "encryption_settings": {"key": "encryptionSettings", "type": "[DiskEncryptionSettings]"}, + "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, } - def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, + **kwargs: Any + ) -> None: """ - :keyword display: Localized display information for this particular operation. - :paramtype display: ~azure.mgmt.compute.v2024_11_01.models.OperationDisplay + :keyword name: The disk name. + :paramtype name: str + :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`\\ + :code:`
` Minimum api-version: 2015-06-15. + :paramtype encryption_settings: list[~azure.mgmt.compute.models.DiskEncryptionSettings] + :keyword statuses: The resource status information. + :paramtype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] """ super().__init__(**kwargs) - self.name: Optional[str] = None - self.is_data_action: Optional[bool] = None - self.display = display - self.origin: Optional[Union[str, "_models.Origin"]] = None - self.action_type: Optional[Union[str, "_models.ActionType"]] = None + self.name = name + self.encryption_settings = encryption_settings + self.statuses = statuses -class OperationDisplay(_serialization.Model): - """Localized display information for this particular operation. +class DiskList(_serialization.Model): + """The List Disks operation response. - 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 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 + :ivar value: A list of disks. Required. + :vartype value: list[~azure.mgmt.compute.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. + :vartype next_link: str """ _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, + "value": {"key": "value", "type": "[Disk]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of disks. Required. + :paramtype value: list[~azure.mgmt.compute.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. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.provider: Optional[str] = None - self.resource: Optional[str] = None - self.operation: Optional[str] = None - self.description: Optional[str] = None + self.value = value + self.next_link = next_link -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. +class ProxyOnlyResource(_serialization.Model): + """The ProxyOnly Resource model definition. Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: List of operations supported by the resource provider. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.Operation] - :ivar next_link: URL to get the next set of operation list results (if there are any). - :vartype next_link: str - """ - + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "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.value: Optional[List["_models.Operation"]] = None - self.next_link: Optional[str] = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None -class OrchestrationServiceStateInput(_serialization.Model): - """The input for OrchestrationServiceState. +class DiskRestorePoint(ProxyOnlyResource): + """Properties of disk restore point. - All required parameters must be populated in order to send to server. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar service_name: The name of the service. Required. "AutomaticRepairs" - :vartype service_name: str or ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceNames - :ivar action: The action to be performed. Required. Known values are: "Resume" and "Suspend". - :vartype action: str or ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceStateAction + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :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. + :vartype source_resource_id: str + :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". + :vartype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS + disks only. Known values are: "V1" and "V2". + :vartype hyper_v_generation: str or ~azure.mgmt.compute.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.models.PurchasePlanAutoGenerated + :ivar supported_capabilities: List of supported capabilities for the image from which the OS + disk was created. + :vartype supported_capabilities: ~azure.mgmt.compute.models.SupportedCapabilities + :ivar family_id: id of the backing snapshot's MIS family. + :vartype family_id: str + :ivar source_unique_id: unique incarnation id of the source disk. + :vartype source_unique_id: str + :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed + keys or platform managed keys. + :vartype encryption: ~azure.mgmt.compute.models.Encryption + :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. + :vartype supports_hibernation: bool + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", and "DenyAll". + :vartype network_access_policy: str or ~azure.mgmt.compute.models.NetworkAccessPolicy + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled" and "Disabled". + :vartype public_network_access: str or ~azure.mgmt.compute.models.PublicNetworkAccess + :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. + :vartype disk_access_id: str + :ivar completion_percent: Percentage complete for the background copy of disk restore point + when source resource is from a different region. + :vartype completion_percent: float + :ivar replication_state: Replication state of disk restore point when source resource is from a + different region. + :vartype replication_state: str + :ivar source_resource_location: Location of source disk or source disk restore point when + source resource is from a different region. + :vartype source_resource_location: str + :ivar security_profile: Contains the security related information for the resource. + :vartype security_profile: ~azure.mgmt.compute.models.DiskSecurityProfile """ _validation = { - "service_name": {"required": True}, - "action": {"required": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "time_created": {"readonly": True}, + "source_resource_id": {"readonly": True}, + "os_type": {"readonly": True}, + "family_id": {"readonly": True}, + "source_unique_id": {"readonly": True}, + "encryption": {"readonly": True}, + "replication_state": {"readonly": True}, + "source_resource_location": {"readonly": True}, } _attribute_map = { - "service_name": {"key": "serviceName", "type": "str"}, - "action": {"key": "action", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "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": "PurchasePlanAutoGenerated"}, + "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, + "family_id": {"key": "properties.familyId", "type": "str"}, + "source_unique_id": {"key": "properties.sourceUniqueId", "type": "str"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, + "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, + "completion_percent": {"key": "properties.completionPercent", "type": "float"}, + "replication_state": {"key": "properties.replicationState", "type": "str"}, + "source_resource_location": {"key": "properties.sourceResourceLocation", "type": "str"}, + "security_profile": {"key": "properties.securityProfile", "type": "DiskSecurityProfile"}, } def __init__( self, *, - service_name: Union[str, "_models.OrchestrationServiceNames"], - action: Union[str, "_models.OrchestrationServiceStateAction"], + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlanAutoGenerated"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, + supports_hibernation: Optional[bool] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + disk_access_id: Optional[str] = None, + completion_percent: Optional[float] = None, + security_profile: Optional["_models.DiskSecurityProfile"] = None, **kwargs: Any ) -> None: """ - :keyword service_name: The name of the service. Required. "AutomaticRepairs" - :paramtype service_name: str or - ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceNames - :keyword action: The action to be performed. Required. Known values are: "Resume" and - "Suspend". - :paramtype action: str or - ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceStateAction + :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.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.models.PurchasePlanAutoGenerated + :keyword supported_capabilities: List of supported capabilities for the image from which the OS + disk was created. + :paramtype supported_capabilities: ~azure.mgmt.compute.models.SupportedCapabilities + :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. + :paramtype supports_hibernation: bool + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", and "DenyAll". + :paramtype network_access_policy: str or ~azure.mgmt.compute.models.NetworkAccessPolicy + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled" and "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.compute.models.PublicNetworkAccess + :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on + disks. + :paramtype disk_access_id: str + :keyword completion_percent: Percentage complete for the background copy of disk restore point + when source resource is from a different region. + :paramtype completion_percent: float + :keyword security_profile: Contains the security related information for the resource. + :paramtype security_profile: ~azure.mgmt.compute.models.DiskSecurityProfile """ super().__init__(**kwargs) - self.service_name = service_name - self.action = action + self.time_created: Optional[datetime.datetime] = None + self.source_resource_id: Optional[str] = None + self.os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None + self.hyper_v_generation = hyper_v_generation + self.purchase_plan = purchase_plan + self.supported_capabilities = supported_capabilities + self.family_id: Optional[str] = None + self.source_unique_id: Optional[str] = None + self.encryption: Optional["_models.Encryption"] = None + self.supports_hibernation = supports_hibernation + self.network_access_policy = network_access_policy + self.public_network_access = public_network_access + self.disk_access_id = disk_access_id + self.completion_percent = completion_percent + self.replication_state: Optional[str] = None + self.source_resource_location: Optional[str] = None + self.security_profile = security_profile -class OrchestrationServiceSummary(_serialization.Model): - """Summary for an orchestration service of a virtual machine scale set. +class SubResourceReadOnly(_serialization.Model): + """SubResourceReadOnly. Variables are only populated by the server, and will be ignored when sending a request. - :ivar service_name: The name of the service. "AutomaticRepairs" - :vartype service_name: str or ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceNames - :ivar service_state: The current state of the service. Known values are: "NotRunning", - "Running", and "Suspended". - :vartype service_state: str or ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceState + :ivar id: Resource Id. + :vartype id: str """ _validation = { - "service_name": {"readonly": True}, - "service_state": {"readonly": True}, + "id": {"readonly": True}, } _attribute_map = { - "service_name": {"key": "serviceName", "type": "str"}, - "service_state": {"key": "serviceState", "type": "str"}, + "id": {"key": "id", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.service_name: Optional[Union[str, "_models.OrchestrationServiceNames"]] = None - self.service_state: Optional[Union[str, "_models.OrchestrationServiceState"]] = None + self.id: Optional[str] = None -class OSDisk(_serialization.Model): - """Specifies information about the operating system disk used by the virtual machine. For more - information about disks, see `About disks and VHDs for Azure virtual machines - `_. +class DiskRestorePointAttributes(SubResourceReadOnly): + """Disk Restore Point details. - All required parameters must be populated in order to send to server. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from user-image or a specialized VHD. Possible values are: **Windows,** - **Linux.**. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2024_11_01.models.OperatingSystemTypes - :ivar encryption_settings: Specifies the encryption settings for the OS Disk. Minimum - api-version: 2015-06-15. - :vartype encryption_settings: ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSettings - :ivar name: The disk name. - :vartype name: str - :ivar vhd: The virtual hard disk. - :vartype vhd: ~azure.mgmt.compute.v2024_11_01.models.VirtualHardDisk - :ivar image: 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. - :vartype image: ~azure.mgmt.compute.v2024_11_01.models.VirtualHardDisk - :ivar caching: Specifies the caching requirements. Possible values are: **None,** **ReadOnly,** - **ReadWrite.** The defaulting behavior is: **None for Standard storage. ReadOnly for Premium - storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar diff_disk_settings: Specifies the ephemeral Disk Settings for the operating system disk - used by the virtual machine. - :vartype diff_disk_settings: ~azure.mgmt.compute.v2024_11_01.models.DiffDiskSettings - :ivar create_option: Specifies how the virtual machine disk should be created. Possible values - are **Attach:** This value is used when you are using a specialized disk to create the virtual - machine. **FromImage:** This value is used when you are using an image to create the virtual - machine. If you are using a platform image, you should also use the imageReference element - described above. If you are using a marketplace image, you should also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", "Attach", "Copy", and - "Restore". - :vartype create_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. The property 'diskSizeGB' is - the number of bytes x 1024^3 for the disk and the value cannot be larger than 1023. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: ~azure.mgmt.compute.v2024_11_01.models.ManagedDiskParameters - :ivar delete_option: Specifies whether OS Disk should be deleted or detached upon VM deletion. - Possible values are: **Delete.** If this value is used, the OS disk is deleted when VM is - deleted. **Detach.** If this value is used, the os disk is retained after VM is deleted. The - default value is set to **Detach**. For an ephemeral OS Disk, the default value is set to - **Delete**. The user cannot change the delete option for an ephemeral OS Disk. Known values - are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskDeleteOptionTypes + :ivar id: Resource Id. + :vartype id: str + :ivar encryption: Encryption at rest settings for disk restore point. It is an optional + property that can be specified in the input while creating a restore point. + :vartype encryption: ~azure.mgmt.compute.models.RestorePointEncryption + :ivar source_disk_restore_point: Resource Id of the source disk restore point. + :vartype source_disk_restore_point: ~azure.mgmt.compute.models.ApiEntityReference """ _validation = { - "create_option": {"required": True}, + "id": {"readonly": True}, } _attribute_map = { - "os_type": {"key": "osType", "type": "str"}, - "encryption_settings": {"key": "encryptionSettings", "type": "DiskEncryptionSettings"}, - "name": {"key": "name", "type": "str"}, - "vhd": {"key": "vhd", "type": "VirtualHardDisk"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "diff_disk_settings": {"key": "diffDiskSettings", "type": "DiffDiskSettings"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, - "delete_option": {"key": "deleteOption", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "encryption": {"key": "encryption", "type": "RestorePointEncryption"}, + "source_disk_restore_point": {"key": "sourceDiskRestorePoint", "type": "ApiEntityReference"}, } def __init__( self, *, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, - name: Optional[str] = None, - vhd: Optional["_models.VirtualHardDisk"] = None, - image: Optional["_models.VirtualHardDisk"] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.ManagedDiskParameters"] = None, - delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, + encryption: Optional["_models.RestorePointEncryption"] = None, + source_disk_restore_point: Optional["_models.ApiEntityReference"] = None, **kwargs: Any ) -> None: """ - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from user-image or a specialized VHD. Possible values are: - **Windows,** **Linux.**. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2024_11_01.models.OperatingSystemTypes - :keyword encryption_settings: Specifies the encryption settings for the OS Disk. Minimum - api-version: 2015-06-15. - :paramtype encryption_settings: ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSettings - :keyword name: The disk name. - :paramtype name: str - :keyword vhd: The virtual hard disk. - :paramtype vhd: ~azure.mgmt.compute.v2024_11_01.models.VirtualHardDisk - :keyword image: 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. - :paramtype image: ~azure.mgmt.compute.v2024_11_01.models.VirtualHardDisk - :keyword caching: Specifies the caching requirements. Possible values are: **None,** - **ReadOnly,** **ReadWrite.** The defaulting behavior is: **None for Standard storage. ReadOnly - for Premium storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword diff_disk_settings: Specifies the ephemeral Disk Settings for the operating system - disk used by the virtual machine. - :paramtype diff_disk_settings: ~azure.mgmt.compute.v2024_11_01.models.DiffDiskSettings - :keyword create_option: Specifies how the virtual machine disk should be created. Possible - values are **Attach:** This value is used when you are using a specialized disk to create the - virtual machine. **FromImage:** This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you should also use the imageReference - element described above. If you are using a marketplace image, you should also use the plan - element previously described. Required. Known values are: "FromImage", "Empty", "Attach", - "Copy", and "Restore". - :paramtype create_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. The property 'diskSizeGB' - is the number of bytes x 1024^3 for the disk and the value cannot be larger than 1023. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: ~azure.mgmt.compute.v2024_11_01.models.ManagedDiskParameters - :keyword delete_option: Specifies whether OS Disk should be deleted or detached upon VM - deletion. Possible values are: **Delete.** If this value is used, the OS disk is deleted when - VM is deleted. **Detach.** If this value is used, the os disk is retained after VM is deleted. - The default value is set to **Detach**. For an ephemeral OS Disk, the default value is set to - **Delete**. The user cannot change the delete option for an ephemeral OS Disk. Known values - are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskDeleteOptionTypes + :keyword encryption: Encryption at rest settings for disk restore point. It is an optional + property that can be specified in the input while creating a restore point. + :paramtype encryption: ~azure.mgmt.compute.models.RestorePointEncryption + :keyword source_disk_restore_point: Resource Id of the source disk restore point. + :paramtype source_disk_restore_point: ~azure.mgmt.compute.models.ApiEntityReference """ super().__init__(**kwargs) - self.os_type = os_type - self.encryption_settings = encryption_settings - self.name = name - self.vhd = vhd - self.image = image - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.diff_disk_settings = diff_disk_settings - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - self.delete_option = delete_option - + self.encryption = encryption + self.source_disk_restore_point = source_disk_restore_point -class OSDiskImage(_serialization.Model): - """Contains the os disk image information. - All required parameters must be populated in order to send to server. +class DiskRestorePointInstanceView(_serialization.Model): + """The instance view of a disk restore point. - :ivar operating_system: The operating system of the osDiskImage. Required. Known values are: - "Windows" and "Linux". - :vartype operating_system: str or ~azure.mgmt.compute.v2024_11_01.models.OperatingSystemTypes + :ivar id: Disk restore point Id. + :vartype id: str + :ivar replication_status: The disk restore point replication status information. + :vartype replication_status: ~azure.mgmt.compute.models.DiskRestorePointReplicationStatus """ - _validation = { - "operating_system": {"required": True}, - } - _attribute_map = { - "operating_system": {"key": "operatingSystem", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "replication_status": {"key": "replicationStatus", "type": "DiskRestorePointReplicationStatus"}, } - def __init__(self, *, operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs: Any) -> None: + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + replication_status: Optional["_models.DiskRestorePointReplicationStatus"] = None, + **kwargs: Any + ) -> None: """ - :keyword operating_system: The operating system of the osDiskImage. Required. Known values are: - "Windows" and "Linux". - :paramtype operating_system: str or ~azure.mgmt.compute.v2024_11_01.models.OperatingSystemTypes + :keyword id: Disk restore point Id. + :paramtype id: str + :keyword replication_status: The disk restore point replication status information. + :paramtype replication_status: ~azure.mgmt.compute.models.DiskRestorePointReplicationStatus """ super().__init__(**kwargs) - self.operating_system = operating_system + self.id = id + self.replication_status = replication_status -class OSImageNotificationProfile(_serialization.Model): - """OSImageNotificationProfile. +class DiskRestorePointList(_serialization.Model): + """The List Disk Restore Points operation response. - :ivar not_before_timeout: Length of time a Virtual Machine being reimaged or having its OS - upgraded will have to potentially approve the OS Image Scheduled Event before the event is auto - approved (timed out). The configuration is specified in ISO 8601 format, and the value must be - 15 minutes (PT15M). - :vartype not_before_timeout: str - :ivar enable: Specifies whether the OS Image Scheduled event is enabled or disabled. - :vartype enable: bool + 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.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 = { - "not_before_timeout": {"key": "notBeforeTimeout", "type": "str"}, - "enable": {"key": "enable", "type": "bool"}, + "value": {"key": "value", "type": "[DiskRestorePoint]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, *, not_before_timeout: Optional[str] = None, enable: Optional[bool] = None, **kwargs: Any + self, *, value: List["_models.DiskRestorePoint"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword not_before_timeout: Length of time a Virtual Machine being reimaged or having its OS - upgraded will have to potentially approve the OS Image Scheduled Event before the event is auto - approved (timed out). The configuration is specified in ISO 8601 format, and the value must be - 15 minutes (PT15M). - :paramtype not_before_timeout: str - :keyword enable: Specifies whether the OS Image Scheduled event is enabled or disabled. - :paramtype enable: bool + :keyword value: A list of disk restore points. Required. + :paramtype value: list[~azure.mgmt.compute.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.not_before_timeout = not_before_timeout - self.enable = enable + self.value = value + self.next_link = next_link -class OSProfile(_serialization.Model): - """Specifies the operating system settings for the virtual machine. Some of the settings cannot be - changed once VM is provisioned. +class DiskRestorePointReplicationStatus(_serialization.Model): + """The instance view of a disk restore point. - :ivar computer_name: Specifies the host OS name of the virtual machine. This name cannot be - updated after the VM is created. **Max-length (Windows):** 15 characters. **Max-length - (Linux):** 64 characters. For naming conventions and restrictions see `Azure infrastructure - services implementation guidelines - `_. - :vartype computer_name: str - :ivar admin_username: Specifies the name of the administrator account. :code:`
`\\ - :code:`
` This property cannot be updated after the VM is created. :code:`
`\\ - :code:`
` **Windows-only restriction:** Cannot end in "." :code:`
`\\ :code:`
` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
`\\ :code:`
` **Minimum-length - (Linux):** 1 character :code:`
`\\ :code:`
` **Max-length (Linux):** 64 characters - :code:`
`\\ :code:`
` **Max-length (Windows):** 20 characters. - :vartype admin_username: str - :ivar admin_password: Specifies the password of the administrator account. :code:`
`\\ - :code:`
` **Minimum-length (Windows):** 8 characters :code:`
`\\ :code:`
` - **Minimum-length (Linux):** 6 characters :code:`
`\\ :code:`
` **Max-length (Windows):** - 123 characters :code:`
`\\ :code:`
` **Max-length (Linux):** 72 characters :code:`
`\\ - :code:`
` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
` Has lower characters :code:`
`Has upper characters :code:`
` Has a digit - :code:`
` Has a special character (Regex match [\\W_]) :code:`
`\\ :code:`
` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
`\\ :code:`
` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM `_ - :code:`
`\\ :code:`
` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :vartype admin_password: str - :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. **Note: Do not pass any secrets or passwords in - customData property.** This property cannot be updated after the VM is created. The property - 'customData' is passed to the VM to be saved as a file, for more information see `Custom Data - on Azure VMs `_. - For using cloud-init for your Linux VM, see `Using cloud-init to customize a Linux VM during - creation `_. - :vartype custom_data: str - :ivar windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :vartype windows_configuration: ~azure.mgmt.compute.v2024_11_01.models.WindowsConfiguration - :ivar linux_configuration: Specifies the Linux operating system settings on the virtual - machine. For a list of supported Linux distributions, see `Linux on Azure-Endorsed - Distributions `_. - :vartype linux_configuration: ~azure.mgmt.compute.v2024_11_01.models.LinuxConfiguration - :ivar secrets: Specifies set of certificates that should be installed onto the virtual machine. - To install certificates on a virtual machine it is recommended to use the `Azure Key Vault - virtual machine extension for Linux - `_ or the `Azure - Key Vault virtual machine extension for Windows - `_. - :vartype secrets: list[~azure.mgmt.compute.v2024_11_01.models.VaultSecretGroup] - :ivar allow_extension_operations: Specifies whether extension operations should be allowed on - the virtual machine. This may only be set to False when no extensions are present on the - virtual machine. - :vartype allow_extension_operations: bool - :ivar require_guest_provision_signal: Optional property which must either be set to True or - omitted. - :vartype require_guest_provision_signal: bool + :ivar status: The resource status information. + :vartype status: ~azure.mgmt.compute.models.InstanceViewStatus + :ivar completion_percent: Replication completion percentage. + :vartype completion_percent: int """ _attribute_map = { - "computer_name": {"key": "computerName", "type": "str"}, - "admin_username": {"key": "adminUsername", "type": "str"}, - "admin_password": {"key": "adminPassword", "type": "str"}, - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - "allow_extension_operations": {"key": "allowExtensionOperations", "type": "bool"}, - "require_guest_provision_signal": {"key": "requireGuestProvisionSignal", "type": "bool"}, + "status": {"key": "status", "type": "InstanceViewStatus"}, + "completion_percent": {"key": "completionPercent", "type": "int"}, } def __init__( self, *, - computer_name: Optional[str] = None, - admin_username: Optional[str] = None, - admin_password: Optional[str] = None, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - allow_extension_operations: Optional[bool] = None, - require_guest_provision_signal: Optional[bool] = None, + status: Optional["_models.InstanceViewStatus"] = None, + completion_percent: Optional[int] = None, **kwargs: Any ) -> None: """ - :keyword computer_name: Specifies the host OS name of the virtual machine. This name cannot be - updated after the VM is created. **Max-length (Windows):** 15 characters. **Max-length - (Linux):** 64 characters. For naming conventions and restrictions see `Azure infrastructure - services implementation guidelines - `_. - :paramtype computer_name: str - :keyword admin_username: Specifies the name of the administrator account. :code:`
`\\ - :code:`
` This property cannot be updated after the VM is created. :code:`
`\\ - :code:`
` **Windows-only restriction:** Cannot end in "." :code:`
`\\ :code:`
` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
`\\ :code:`
` **Minimum-length - (Linux):** 1 character :code:`
`\\ :code:`
` **Max-length (Linux):** 64 characters - :code:`
`\\ :code:`
` **Max-length (Windows):** 20 characters. - :paramtype admin_username: str - :keyword admin_password: Specifies the password of the administrator account. :code:`
`\\ - :code:`
` **Minimum-length (Windows):** 8 characters :code:`
`\\ :code:`
` - **Minimum-length (Linux):** 6 characters :code:`
`\\ :code:`
` **Max-length (Windows):** - 123 characters :code:`
`\\ :code:`
` **Max-length (Linux):** 72 characters :code:`
`\\ - :code:`
` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
` Has lower characters :code:`
`Has upper characters :code:`
` Has a digit - :code:`
` Has a special character (Regex match [\\W_]) :code:`
`\\ :code:`
` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
`\\ :code:`
` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM `_ - :code:`
`\\ :code:`
` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :paramtype admin_password: str - :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. **Note: Do not pass any secrets or passwords in - customData property.** This property cannot be updated after the VM is created. The property - 'customData' is passed to the VM to be saved as a file, for more information see `Custom Data - on Azure VMs `_. - For using cloud-init for your Linux VM, see `Using cloud-init to customize a Linux VM during - creation `_. - :paramtype custom_data: str - :keyword windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :paramtype windows_configuration: ~azure.mgmt.compute.v2024_11_01.models.WindowsConfiguration - :keyword linux_configuration: Specifies the Linux operating system settings on the virtual - machine. For a list of supported Linux distributions, see `Linux on Azure-Endorsed - Distributions `_. - :paramtype linux_configuration: ~azure.mgmt.compute.v2024_11_01.models.LinuxConfiguration - :keyword secrets: Specifies set of certificates that should be installed onto the virtual - machine. To install certificates on a virtual machine it is recommended to use the `Azure Key - Vault virtual machine extension for Linux - `_ or the `Azure - Key Vault virtual machine extension for Windows - `_. - :paramtype secrets: list[~azure.mgmt.compute.v2024_11_01.models.VaultSecretGroup] - :keyword allow_extension_operations: Specifies whether extension operations should be allowed - on the virtual machine. This may only be set to False when no extensions are present on the - virtual machine. - :paramtype allow_extension_operations: bool - :keyword require_guest_provision_signal: Optional property which must either be set to True or - omitted. - :paramtype require_guest_provision_signal: bool + :keyword status: The resource status information. + :paramtype status: ~azure.mgmt.compute.models.InstanceViewStatus + :keyword completion_percent: Replication completion percentage. + :paramtype completion_percent: int """ super().__init__(**kwargs) - self.computer_name = computer_name - self.admin_username = admin_username - self.admin_password = admin_password - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - self.allow_extension_operations = allow_extension_operations - self.require_guest_provision_signal = require_guest_provision_signal + self.status = status + self.completion_percent = completion_percent -class OSProfileProvisioningData(_serialization.Model): - """Additional parameters for Reimaging Non-Ephemeral Virtual Machine. +class DiskSecurityProfile(_serialization.Model): + """Contains the security related information for the resource. - :ivar admin_password: Specifies the password of the administrator account. :code:`
`\\ - :code:`
` **Minimum-length (Windows):** 8 characters :code:`
`\\ :code:`
` - **Minimum-length (Linux):** 6 characters :code:`
`\\ :code:`
` **Max-length (Windows):** - 123 characters :code:`
`\\ :code:`
` **Max-length (Linux):** 72 characters :code:`
`\\ - :code:`
` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
` Has lower characters :code:`
`Has upper characters :code:`
` Has a digit - :code:`
` Has a special character (Regex match [\\W_]) :code:`
`\\ :code:`
` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
`\\ :code:`
` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM `_ - :code:`
`\\ :code:`
` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :vartype admin_password: str - :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. **Note: Do not pass any secrets or passwords in - customData property.** This property cannot be updated after the VM is created. The property - customData is passed to the VM to be saved as a file, for more information see `Custom Data on - Azure VMs `_. If - using cloud-init for your Linux VM, see `Using cloud-init to customize a Linux VM during - creation `_. - :vartype custom_data: str + :ivar security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. Known + values are: "TrustedLaunch", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", + "ConfidentialVM_DiskEncryptedWithPlatformKey", "ConfidentialVM_DiskEncryptedWithCustomerKey", + and "ConfidentialVM_NonPersistedTPM". + :vartype security_type: str or ~azure.mgmt.compute.models.DiskSecurityTypes + :ivar secure_vm_disk_encryption_set_id: ResourceId of the disk encryption set associated to + Confidential VM supported disk encrypted with customer managed key. + :vartype secure_vm_disk_encryption_set_id: str """ _attribute_map = { - "admin_password": {"key": "adminPassword", "type": "str"}, - "custom_data": {"key": "customData", "type": "str"}, + "security_type": {"key": "securityType", "type": "str"}, + "secure_vm_disk_encryption_set_id": {"key": "secureVMDiskEncryptionSetId", "type": "str"}, } def __init__( - self, *, admin_password: Optional[str] = None, custom_data: Optional[str] = None, **kwargs: Any + self, + *, + security_type: Optional[Union[str, "_models.DiskSecurityTypes"]] = None, + secure_vm_disk_encryption_set_id: Optional[str] = None, + **kwargs: Any ) -> None: """ - :keyword admin_password: Specifies the password of the administrator account. :code:`
`\\ - :code:`
` **Minimum-length (Windows):** 8 characters :code:`
`\\ :code:`
` - **Minimum-length (Linux):** 6 characters :code:`
`\\ :code:`
` **Max-length (Windows):** - 123 characters :code:`
`\\ :code:`
` **Max-length (Linux):** 72 characters :code:`
`\\ - :code:`
` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
` Has lower characters :code:`
`Has upper characters :code:`
` Has a digit - :code:`
` Has a special character (Regex match [\\W_]) :code:`
`\\ :code:`
` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
`\\ :code:`
` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM `_ - :code:`
`\\ :code:`
` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :paramtype admin_password: str - :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. **Note: Do not pass any secrets or passwords in - customData property.** This property cannot be updated after the VM is created. The property - customData is passed to the VM to be saved as a file, for more information see `Custom Data on - Azure VMs `_. If - using cloud-init for your Linux VM, see `Using cloud-init to customize a Linux VM during - creation `_. - :paramtype custom_data: str + :keyword security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. + Known values are: "TrustedLaunch", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", + "ConfidentialVM_DiskEncryptedWithPlatformKey", "ConfidentialVM_DiskEncryptedWithCustomerKey", + and "ConfidentialVM_NonPersistedTPM". + :paramtype security_type: str or ~azure.mgmt.compute.models.DiskSecurityTypes + :keyword secure_vm_disk_encryption_set_id: ResourceId of the disk encryption set associated to + Confidential VM supported disk encrypted with customer managed key. + :paramtype secure_vm_disk_encryption_set_id: str """ super().__init__(**kwargs) - self.admin_password = admin_password - self.custom_data = custom_data + self.security_type = security_type + self.secure_vm_disk_encryption_set_id = secure_vm_disk_encryption_set_id -class PatchInstallationDetail(_serialization.Model): - """Information about a specific patch that was encountered during an installation action. +class DiskSku(_serialization.Model): + """The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, + Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS. Variables are only populated by the server, and will be ignored when sending a request. - :ivar patch_id: A unique identifier for the patch. - :vartype patch_id: str - :ivar name: The friendly name of the patch. - :vartype name: str - :ivar version: The version string of the package. It may conform to Semantic Versioning. Only - applies to Linux. - :vartype version: str - :ivar kb_id: The KBID of the patch. Only applies to Windows patches. - :vartype kb_id: str - :ivar classifications: The classification(s) of the patch as provided by the patch publisher. - :vartype classifications: list[str] - :ivar installation_state: The state of the patch after the installation operation completed. - Known values are: "Unknown", "Installed", "Failed", "Excluded", "NotSelected", and "Pending". - :vartype installation_state: str or - ~azure.mgmt.compute.v2024_11_01.models.PatchInstallationState + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", + "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", and "PremiumV2_LRS". + :vartype name: str or ~azure.mgmt.compute.models.DiskStorageAccountTypes + :ivar tier: The sku tier. + :vartype tier: str """ _validation = { - "patch_id": {"readonly": True}, - "name": {"readonly": True}, - "version": {"readonly": True}, - "kb_id": {"readonly": True}, - "classifications": {"readonly": True}, - "installation_state": {"readonly": True}, + "tier": {"readonly": True}, } _attribute_map = { - "patch_id": {"key": "patchId", "type": "str"}, "name": {"key": "name", "type": "str"}, - "version": {"key": "version", "type": "str"}, - "kb_id": {"key": "kbId", "type": "str"}, - "classifications": {"key": "classifications", "type": "[str]"}, - "installation_state": {"key": "installationState", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs: Any) -> None: + """ + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", + "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", and "PremiumV2_LRS". + :paramtype name: str or ~azure.mgmt.compute.models.DiskStorageAccountTypes + """ super().__init__(**kwargs) - self.patch_id: Optional[str] = None - self.name: Optional[str] = None - self.version: Optional[str] = None - self.kb_id: Optional[str] = None - self.classifications: Optional[List[str]] = None - self.installation_state: Optional[Union[str, "_models.PatchInstallationState"]] = None + self.name = name + self.tier: Optional[str] = None -class PatchSettings(_serialization.Model): - """Specifies settings related to VM Guest Patching on Windows. +class DiskUpdate(_serialization.Model): + """Disk update resource. - :ivar patch_mode: Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual - machines associated to virtual machine scale set with OrchestrationMode as Flexible.\\ - :code:`
`\\ :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` - **Manual** - You control the application of patches to a virtual machine. You do this by - applying patches manually inside the VM. In this mode, automatic updates are disabled; the - property WindowsConfiguration.enableAutomaticUpdates must be false\\ :code:`
`\\ - :code:`
` **AutomaticByOS** - The virtual machine will automatically be updated by the OS. - The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
`\\ - :code:`
` **AutomaticByPlatform** - the virtual machine will automatically updated by the - platform. The properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must - be true. Known values are: "Manual", "AutomaticByOS", and "AutomaticByPlatform". - :vartype patch_mode: str or ~azure.mgmt.compute.v2024_11_01.models.WindowsVMGuestPatchMode - :ivar enable_hotpatching: Enables customers to patch their Azure VMs without requiring a - reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must - be set to 'AutomaticByPlatform'. - :vartype enable_hotpatching: bool - :ivar assessment_mode: Specifies the mode of VM Guest patch assessment for the IaaS virtual - machine.\\ :code:`
`\\ :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.\\ - :code:`
`\\ :code:`
` **AutomaticByPlatform** - The platform will trigger periodic - patch assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault" - and "AutomaticByPlatform". - :vartype assessment_mode: str or - ~azure.mgmt.compute.v2024_11_01.models.WindowsPatchAssessmentMode - :ivar automatic_by_platform_settings: Specifies additional settings for patch mode - AutomaticByPlatform in VM Guest Patching on Windows. - :vartype automatic_by_platform_settings: - ~azure.mgmt.compute.v2024_11_01.models.WindowsVMGuestPatchAutomaticByPlatformSettings + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, + Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS. + :vartype sku: ~azure.mgmt.compute.models.DiskSku + :ivar os_type: the Operating System type. Known values are: "Windows" and "Linux". + :vartype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it + indicates the size of the disk to create. If this field is present for updates or creation with + other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a + running VM, and can only increase the disk's size. + :vartype disk_size_gb: int + :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk + Encryption, can contain multiple encryption settings per disk or snapshot. + :vartype encryption_settings_collection: + ~azure.mgmt.compute.models.EncryptionSettingsCollection + :ivar disk_iops_read_write: The number of IOPS allowed for this disk; only settable for + UltraSSD disks. One operation can transfer between 4k and 256k bytes. + :vartype disk_iops_read_write: int + :ivar disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD + disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of + 10. + :vartype disk_m_bps_read_write: int + :ivar disk_iops_read_only: The total number of IOPS that will be allowed across all VMs + mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. + :vartype disk_iops_read_only: int + :ivar disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs + mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses + the ISO notation, of powers of 10. + :vartype disk_m_bps_read_only: int + :ivar max_shares: The maximum number of VMs that can attach to the disk at the same time. Value + greater than one indicates a disk that can be mounted on multiple VMs at the same time. + :vartype max_shares: int + :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed + keys or platform managed keys. + :vartype encryption: ~azure.mgmt.compute.models.Encryption + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", and "DenyAll". + :vartype network_access_policy: str or ~azure.mgmt.compute.models.NetworkAccessPolicy + :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. + :vartype disk_access_id: str + :ivar tier: Performance tier of the disk (e.g, P4, S10) as described here: + https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra + disks. + :vartype tier: str + :ivar bursting_enabled: Set to true to enable bursting beyond the provisioned performance + 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.models.PurchasePlanAutoGenerated + :ivar supported_capabilities: List of supported capabilities to be added on the OS disk. + :vartype supported_capabilities: ~azure.mgmt.compute.models.SupportedCapabilities + :ivar property_updates_in_progress: Properties of the disk for which update is pending. + :vartype property_updates_in_progress: ~azure.mgmt.compute.models.PropertyUpdatesInProgress + :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. + :vartype supports_hibernation: bool + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled" and "Disabled". + :vartype public_network_access: str or ~azure.mgmt.compute.models.PublicNetworkAccess + :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading + to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". + :vartype data_access_auth_mode: str or ~azure.mgmt.compute.models.DataAccessAuthMode + :ivar optimized_for_frequent_attach: Setting this property to true improves reliability and + performance of data disks that are frequently (more than 5 times a day) by detached from one + virtual machine and attached to another. This property should not be set for disks that are not + detached and attached frequently as it causes the disks to not align with the fault domain of + the virtual machine. + :vartype optimized_for_frequent_attach: bool """ + _validation = { + "property_updates_in_progress": {"readonly": True}, + } + _attribute_map = { - "patch_mode": {"key": "patchMode", "type": "str"}, - "enable_hotpatching": {"key": "enableHotpatching", "type": "bool"}, - "assessment_mode": {"key": "assessmentMode", "type": "str"}, - "automatic_by_platform_settings": { - "key": "automaticByPlatformSettings", - "type": "WindowsVMGuestPatchAutomaticByPlatformSettings", + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "DiskSku"}, + "os_type": {"key": "properties.osType", "type": "str"}, + "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, + "encryption_settings_collection": { + "key": "properties.encryptionSettingsCollection", + "type": "EncryptionSettingsCollection", }, + "disk_iops_read_write": {"key": "properties.diskIOPSReadWrite", "type": "int"}, + "disk_m_bps_read_write": {"key": "properties.diskMBpsReadWrite", "type": "int"}, + "disk_iops_read_only": {"key": "properties.diskIOPSReadOnly", "type": "int"}, + "disk_m_bps_read_only": {"key": "properties.diskMBpsReadOnly", "type": "int"}, + "max_shares": {"key": "properties.maxShares", "type": "int"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, + "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": "PurchasePlanAutoGenerated"}, + "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, + "property_updates_in_progress": { + "key": "properties.propertyUpdatesInProgress", + "type": "PropertyUpdatesInProgress", + }, + "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, + "optimized_for_frequent_attach": {"key": "properties.optimizedForFrequentAttach", "type": "bool"}, } def __init__( self, *, - patch_mode: Optional[Union[str, "_models.WindowsVMGuestPatchMode"]] = None, - enable_hotpatching: Optional[bool] = None, - assessment_mode: Optional[Union[str, "_models.WindowsPatchAssessmentMode"]] = None, - automatic_by_platform_settings: Optional["_models.WindowsVMGuestPatchAutomaticByPlatformSettings"] = None, + tags: Optional[Dict[str, str]] = None, + sku: Optional["_models.DiskSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + disk_size_gb: Optional[int] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, + disk_iops_read_write: Optional[int] = None, + disk_m_bps_read_write: Optional[int] = None, + disk_iops_read_only: Optional[int] = None, + disk_m_bps_read_only: Optional[int] = None, + max_shares: Optional[int] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, + disk_access_id: Optional[str] = None, + tier: Optional[str] = None, + bursting_enabled: Optional[bool] = None, + purchase_plan: Optional["_models.PurchasePlanAutoGenerated"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, + supports_hibernation: Optional[bool] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, + optimized_for_frequent_attach: Optional[bool] = None, **kwargs: Any ) -> None: """ - :keyword patch_mode: Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual - machines associated to virtual machine scale set with OrchestrationMode as Flexible.\\ - :code:`
`\\ :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` - **Manual** - You control the application of patches to a virtual machine. You do this by - applying patches manually inside the VM. In this mode, automatic updates are disabled; the - property WindowsConfiguration.enableAutomaticUpdates must be false\\ :code:`
`\\ - :code:`
` **AutomaticByOS** - The virtual machine will automatically be updated by the OS. - The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
`\\ - :code:`
` **AutomaticByPlatform** - the virtual machine will automatically updated by the - platform. The properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must - be true. Known values are: "Manual", "AutomaticByOS", and "AutomaticByPlatform". - :paramtype patch_mode: str or ~azure.mgmt.compute.v2024_11_01.models.WindowsVMGuestPatchMode - :keyword enable_hotpatching: Enables customers to patch their Azure VMs without requiring a - reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must - be set to 'AutomaticByPlatform'. - :paramtype enable_hotpatching: bool - :keyword assessment_mode: Specifies the mode of VM Guest patch assessment for the IaaS virtual - machine.\\ :code:`
`\\ :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.\\ - :code:`
`\\ :code:`
` **AutomaticByPlatform** - The platform will trigger periodic - patch assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault" - and "AutomaticByPlatform". - :paramtype assessment_mode: str or - ~azure.mgmt.compute.v2024_11_01.models.WindowsPatchAssessmentMode - :keyword automatic_by_platform_settings: Specifies additional settings for patch mode - AutomaticByPlatform in VM Guest Patching on Windows. - :paramtype automatic_by_platform_settings: - ~azure.mgmt.compute.v2024_11_01.models.WindowsVMGuestPatchAutomaticByPlatformSettings + :keyword tags: Resource tags. + :paramtype tags: dict[str, 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.models.DiskSku + :keyword os_type: the Operating System type. Known values are: "Windows" and "Linux". + :paramtype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it + indicates the size of the disk to create. If this field is present for updates or creation with + other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a + running VM, and can only increase the disk's size. + :paramtype disk_size_gb: int + :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk + Encryption, can contain multiple encryption settings per disk or snapshot. + :paramtype encryption_settings_collection: + ~azure.mgmt.compute.models.EncryptionSettingsCollection + :keyword disk_iops_read_write: The number of IOPS allowed for this disk; only settable for + UltraSSD disks. One operation can transfer between 4k and 256k bytes. + :paramtype disk_iops_read_write: int + :keyword disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD + disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of + 10. + :paramtype disk_m_bps_read_write: int + :keyword disk_iops_read_only: The total number of IOPS that will be allowed across all VMs + mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. + :paramtype disk_iops_read_only: int + :keyword disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs + mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses + the ISO notation, of powers of 10. + :paramtype disk_m_bps_read_only: int + :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. + Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. + :paramtype max_shares: int + :keyword encryption: Encryption property can be used to encrypt data at rest with customer + managed keys or platform managed keys. + :paramtype encryption: ~azure.mgmt.compute.models.Encryption + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", and "DenyAll". + :paramtype network_access_policy: str or ~azure.mgmt.compute.models.NetworkAccessPolicy + :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on + disks. + :paramtype disk_access_id: str + :keyword tier: Performance tier of the disk (e.g, P4, S10) as described here: + https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra + disks. + :paramtype tier: str + :keyword bursting_enabled: Set to true to enable bursting beyond the provisioned performance + 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.models.PurchasePlanAutoGenerated + :keyword supported_capabilities: List of supported capabilities to be added on the OS disk. + :paramtype supported_capabilities: ~azure.mgmt.compute.models.SupportedCapabilities + :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. + :paramtype supports_hibernation: bool + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled" and "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.compute.models.PublicNetworkAccess + :keyword data_access_auth_mode: Additional authentication requirements when exporting or + uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". + :paramtype data_access_auth_mode: str or ~azure.mgmt.compute.models.DataAccessAuthMode + :keyword optimized_for_frequent_attach: Setting this property to true improves reliability and + performance of data disks that are frequently (more than 5 times a day) by detached from one + virtual machine and attached to another. This property should not be set for disks that are not + detached and attached frequently as it causes the disks to not align with the fault domain of + the virtual machine. + :paramtype optimized_for_frequent_attach: bool """ super().__init__(**kwargs) - self.patch_mode = patch_mode - self.enable_hotpatching = enable_hotpatching - self.assessment_mode = assessment_mode - self.automatic_by_platform_settings = automatic_by_platform_settings - - -class Placement(_serialization.Model): - """Describes the user-defined constraints for virtual machine hardware placement. - - :ivar zone_placement_policy: Specifies the policy for virtual machine's placement in - availability zone. Possible values are: **Any** - An availability zone will be automatically - picked by system as part of virtual machine creation. "Any" - :vartype zone_placement_policy: str or - ~azure.mgmt.compute.v2024_11_01.models.ZonePlacementPolicyType - :ivar include_zones: This property supplements the 'zonePlacementPolicy' property. If - 'zonePlacementPolicy' is set to 'Any', availability zone selected by the system must be present - in the list of availability zones passed with 'includeZones'. If 'includeZones' is not - provided, all availability zones in region will be considered for selection. - :vartype include_zones: list[str] - :ivar exclude_zones: This property supplements the 'zonePlacementPolicy' property. If - 'zonePlacementPolicy' is set to 'Any', availability zone selected by the system must not be - present in the list of availability zones passed with 'excludeZones'. If 'excludeZones' is not - provided, all availability zones in region will be considered for selection. - :vartype exclude_zones: list[str] + self.tags = tags + self.sku = sku + self.os_type = os_type + self.disk_size_gb = disk_size_gb + self.encryption_settings_collection = encryption_settings_collection + self.disk_iops_read_write = disk_iops_read_write + self.disk_m_bps_read_write = disk_m_bps_read_write + self.disk_iops_read_only = disk_iops_read_only + self.disk_m_bps_read_only = disk_m_bps_read_only + self.max_shares = max_shares + self.encryption = encryption + self.network_access_policy = network_access_policy + self.disk_access_id = disk_access_id + self.tier = tier + self.bursting_enabled = bursting_enabled + self.purchase_plan = purchase_plan + self.supported_capabilities = supported_capabilities + self.property_updates_in_progress: Optional["_models.PropertyUpdatesInProgress"] = None + self.supports_hibernation = supports_hibernation + self.public_network_access = public_network_access + self.data_access_auth_mode = data_access_auth_mode + self.optimized_for_frequent_attach = optimized_for_frequent_attach + + +class Encryption(_serialization.Model): + """Encryption at rest settings for disk or snapshot. + + :ivar disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling + encryption at rest. + :vartype disk_encryption_set_id: str + :ivar type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and + "EncryptionAtRestWithPlatformAndCustomerKeys". + :vartype type: str or ~azure.mgmt.compute.models.EncryptionType """ _attribute_map = { - "zone_placement_policy": {"key": "zonePlacementPolicy", "type": "str"}, - "include_zones": {"key": "includeZones", "type": "[str]"}, - "exclude_zones": {"key": "excludeZones", "type": "[str]"}, + "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( self, *, - zone_placement_policy: Optional[Union[str, "_models.ZonePlacementPolicyType"]] = None, - include_zones: Optional[List[str]] = None, - exclude_zones: Optional[List[str]] = None, + disk_encryption_set_id: Optional[str] = None, + type: Optional[Union[str, "_models.EncryptionType"]] = None, **kwargs: Any ) -> None: """ - :keyword zone_placement_policy: Specifies the policy for virtual machine's placement in - availability zone. Possible values are: **Any** - An availability zone will be automatically - picked by system as part of virtual machine creation. "Any" - :paramtype zone_placement_policy: str or - ~azure.mgmt.compute.v2024_11_01.models.ZonePlacementPolicyType - :keyword include_zones: This property supplements the 'zonePlacementPolicy' property. If - 'zonePlacementPolicy' is set to 'Any', availability zone selected by the system must be present - in the list of availability zones passed with 'includeZones'. If 'includeZones' is not - provided, all availability zones in region will be considered for selection. - :paramtype include_zones: list[str] - :keyword exclude_zones: This property supplements the 'zonePlacementPolicy' property. If - 'zonePlacementPolicy' is set to 'Any', availability zone selected by the system must not be - present in the list of availability zones passed with 'excludeZones'. If 'excludeZones' is not - provided, all availability zones in region will be considered for selection. - :paramtype exclude_zones: list[str] + :keyword disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling + encryption at rest. + :paramtype disk_encryption_set_id: str + :keyword type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and + "EncryptionAtRestWithPlatformAndCustomerKeys". + :paramtype type: str or ~azure.mgmt.compute.models.EncryptionType """ super().__init__(**kwargs) - self.zone_placement_policy = zone_placement_policy - self.include_zones = include_zones - self.exclude_zones = exclude_zones + self.disk_encryption_set_id = disk_encryption_set_id + self.type = type -class Plan(_serialization.Model): - """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 the marketplace - image that you want to use and then click **Want to deploy programmatically, Get Started ->**. - Enter any required information and then click **Save**. +class EncryptionIdentity(_serialization.Model): + """Specifies the Managed Identity used by ADE to get access token for keyvault operations. - :ivar name: The plan ID. - :vartype name: str - :ivar publisher: The publisher ID. - :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. - :vartype product: str - :ivar promotion_code: The promotion code. - :vartype promotion_code: str + :ivar user_assigned_identity_resource_id: Specifies ARM Resource ID of one of the user + identities associated with the VM. + :vartype user_assigned_identity_resource_id: str """ _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - "promotion_code": {"key": "promotionCode", "type": "str"}, + "user_assigned_identity_resource_id": {"key": "userAssignedIdentityResourceId", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - publisher: Optional[str] = None, - product: Optional[str] = None, - promotion_code: Optional[str] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, user_assigned_identity_resource_id: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword name: The plan ID. - :paramtype name: str - :keyword publisher: The publisher ID. - :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. - :paramtype product: str - :keyword promotion_code: The promotion code. - :paramtype promotion_code: str + :keyword user_assigned_identity_resource_id: Specifies ARM Resource ID of one of the user + identities associated with the VM. + :paramtype user_assigned_identity_resource_id: str """ super().__init__(**kwargs) - self.name = name - self.publisher = publisher - self.product = product - self.promotion_code = promotion_code + self.user_assigned_identity_resource_id = user_assigned_identity_resource_id -class PriorityMixPolicy(_serialization.Model): - """Specifies the target splits for Spot and Regular priority VMs within a scale set with flexible - orchestration mode. With this property the customer is able to specify the base number of - regular priority VMs created as the VMSS flex instance scales out and the split between Spot - and Regular priority VMs after this base target has been reached. +class EncryptionImages(_serialization.Model): + """Optional. Allows users to provide customer managed keys for encrypting the OS and data disks in + the gallery artifact. - :ivar base_regular_priority_count: The base number of regular priority VMs that will be created - in this scale set as it scales out. - :vartype base_regular_priority_count: int - :ivar regular_priority_percentage_above_base: The percentage of VM instances, after the base - regular priority count has been reached, that are expected to use regular priority. - :vartype regular_priority_percentage_above_base: int + :ivar os_disk_image: Contains encryption settings for an OS disk image. + :vartype os_disk_image: ~azure.mgmt.compute.models.OSDiskImageEncryption + :ivar data_disk_images: A list of encryption specifications for data disk images. + :vartype data_disk_images: list[~azure.mgmt.compute.models.DataDiskImageEncryption] """ - _validation = { - "regular_priority_percentage_above_base": {"maximum": 100}, - } - _attribute_map = { - "base_regular_priority_count": {"key": "baseRegularPriorityCount", "type": "int"}, - "regular_priority_percentage_above_base": {"key": "regularPriorityPercentageAboveBase", "type": "int"}, + "os_disk_image": {"key": "osDiskImage", "type": "OSDiskImageEncryption"}, + "data_disk_images": {"key": "dataDiskImages", "type": "[DataDiskImageEncryption]"}, } def __init__( self, *, - base_regular_priority_count: Optional[int] = None, - regular_priority_percentage_above_base: Optional[int] = None, + os_disk_image: Optional["_models.OSDiskImageEncryption"] = None, + data_disk_images: Optional[List["_models.DataDiskImageEncryption"]] = None, **kwargs: Any ) -> None: """ - :keyword base_regular_priority_count: The base number of regular priority VMs that will be - created in this scale set as it scales out. - :paramtype base_regular_priority_count: int - :keyword regular_priority_percentage_above_base: The percentage of VM instances, after the base - regular priority count has been reached, that are expected to use regular priority. - :paramtype regular_priority_percentage_above_base: int + :keyword os_disk_image: Contains encryption settings for an OS disk image. + :paramtype os_disk_image: ~azure.mgmt.compute.models.OSDiskImageEncryption + :keyword data_disk_images: A list of encryption specifications for data disk images. + :paramtype data_disk_images: list[~azure.mgmt.compute.models.DataDiskImageEncryption] """ super().__init__(**kwargs) - self.base_regular_priority_count = base_regular_priority_count - self.regular_priority_percentage_above_base = regular_priority_percentage_above_base + self.os_disk_image = os_disk_image + self.data_disk_images = data_disk_images -class ProximityPlacementGroup(TrackedResource): - """Specifies information about the proximity placement group. +class EncryptionSetIdentity(_serialization.Model): + """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. 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: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar zones: The availability zones. - :vartype zones: list[str] - :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. - Possible values are: **Standard** : Co-locate resources within an Azure region or Availability - Zone. **Ultra** : For future use. Known values are: "Standard" and "Ultra". - :vartype proximity_placement_group_type: str or - ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroupType - :ivar virtual_machines: A list of references to all virtual machines in the proximity placement - group. - :vartype virtual_machines: - list[~azure.mgmt.compute.v2024_11_01.models.SubResourceWithColocationStatus] - :ivar virtual_machine_scale_sets: A list of references to all virtual machine scale sets in the - proximity placement group. - :vartype virtual_machine_scale_sets: - list[~azure.mgmt.compute.v2024_11_01.models.SubResourceWithColocationStatus] - :ivar availability_sets: A list of references to all availability sets in the proximity - placement group. - :vartype availability_sets: - list[~azure.mgmt.compute.v2024_11_01.models.SubResourceWithColocationStatus] - :ivar colocation_status: Describes colocation status of the Proximity Placement Group. - :vartype colocation_status: ~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus - :ivar intent: Specifies the user intent of the proximity placement group. - :vartype intent: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroupPropertiesIntent + :ivar type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is + supported for new creations. Disk Encryption Sets can be updated with Identity type None during + migration of subscription to a new Azure Active Directory tenant; it will cause the encrypted + resources to lose access to the keys. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", and "None". + :vartype type: str or ~azure.mgmt.compute.models.DiskEncryptionSetIdentityType + :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP + from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a + systemAssigned(implicit) identity. + :vartype principal_id: str + :ivar tenant_id: The tenant id of the Managed Identity Resource. This will be sent to the RP + from ARM via the x-ms-client-tenant-id header in the PUT request if the resource has a + systemAssigned(implicit) identity. + :vartype tenant_id: str + :ivar user_assigned_identities: The list of user identities associated with the disk encryption + set. The user identity dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.compute.models.UserAssignedIdentitiesValueAutoGenerated] """ _validation = { - "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}, - "availability_sets": {"readonly": True}, + "principal_id": {"readonly": True}, + "tenant_id": {"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"}, - "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]"}, - "virtual_machine_scale_sets": { - "key": "properties.virtualMachineScaleSets", - "type": "[SubResourceWithColocationStatus]", + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "user_assigned_identities": { + "key": "userAssignedIdentities", + "type": "{UserAssignedIdentitiesValueAutoGenerated}", }, - "availability_sets": {"key": "properties.availabilitySets", "type": "[SubResourceWithColocationStatus]"}, - "colocation_status": {"key": "properties.colocationStatus", "type": "InstanceViewStatus"}, - "intent": {"key": "properties.intent", "type": "ProximityPlacementGroupPropertiesIntent"}, } def __init__( self, *, - location: str, - tags: Optional[Dict[str, str]] = None, - zones: Optional[List[str]] = None, - proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, - colocation_status: Optional["_models.InstanceViewStatus"] = None, - intent: Optional["_models.ProximityPlacementGroupPropertiesIntent"] = None, + type: Optional[Union[str, "_models.DiskEncryptionSetIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValueAutoGenerated"]] = None, **kwargs: Any ) -> None: """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword zones: The availability zones. - :paramtype zones: list[str] - :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. - Possible values are: **Standard** : Co-locate resources within an Azure region or Availability - Zone. **Ultra** : For future use. Known values are: "Standard" and "Ultra". - :paramtype proximity_placement_group_type: str or - ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroupType - :keyword colocation_status: Describes colocation status of the Proximity Placement Group. - :paramtype colocation_status: ~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus - :keyword intent: Specifies the user intent of the proximity placement group. - :paramtype intent: - ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroupPropertiesIntent + :keyword type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned + is supported for new creations. Disk Encryption Sets can be updated with Identity type None + during migration of subscription to a new Azure Active Directory tenant; it will cause the + encrypted resources to lose access to the keys. Known values are: "SystemAssigned", + "UserAssigned", "SystemAssigned, UserAssigned", and "None". + :paramtype type: str or ~azure.mgmt.compute.models.DiskEncryptionSetIdentityType + :keyword user_assigned_identities: The list of user identities associated with the disk + encryption set. The user identity dictionary key references will be ARM resource ids in the + form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.compute.models.UserAssignedIdentitiesValueAutoGenerated] """ - super().__init__(tags=tags, location=location, **kwargs) - self.zones = zones - self.proximity_placement_group_type = proximity_placement_group_type - self.virtual_machines: Optional[List["_models.SubResourceWithColocationStatus"]] = None - self.virtual_machine_scale_sets: Optional[List["_models.SubResourceWithColocationStatus"]] = None - self.availability_sets: Optional[List["_models.SubResourceWithColocationStatus"]] = None - self.colocation_status = colocation_status - self.intent = intent + super().__init__(**kwargs) + self.type = type + self.principal_id: Optional[str] = None + self.tenant_id: Optional[str] = None + self.user_assigned_identities = user_assigned_identities -class ProximityPlacementGroupListResult(_serialization.Model): - """The List Proximity Placement Group operation response. +class EncryptionSettingsCollection(_serialization.Model): + """Encryption settings for disk or snapshot. All required parameters must be populated in order to send to server. - :ivar value: The list of proximity placement groups. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup] - :ivar next_link: The URI to fetch the next page of proximity placement groups. - :vartype next_link: str + :ivar enabled: Set this flag to true and provide DiskEncryptionKey and optional + KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and + KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, + the existing settings remain unchanged. Required. + :vartype enabled: bool + :ivar encryption_settings: A collection of encryption settings, one for each disk volume. + :vartype encryption_settings: list[~azure.mgmt.compute.models.EncryptionSettingsElement] + :ivar encryption_settings_version: Describes what type of encryption is used for the disks. + Once this field is set, it cannot be overwritten. '1.0' corresponds to Azure Disk Encryption + with AAD app.'1.1' corresponds to Azure Disk Encryption. + :vartype encryption_settings_version: str """ _validation = { - "value": {"required": True}, + "enabled": {"required": True}, } _attribute_map = { - "value": {"key": "value", "type": "[ProximityPlacementGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + "encryption_settings": {"key": "encryptionSettings", "type": "[EncryptionSettingsElement]"}, + "encryption_settings_version": {"key": "encryptionSettingsVersion", "type": "str"}, } def __init__( - self, *, value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs: Any + self, + *, + enabled: bool, + encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, + encryption_settings_version: Optional[str] = None, + **kwargs: Any ) -> None: """ - :keyword value: The list of proximity placement groups. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup] - :keyword next_link: The URI to fetch the next page of proximity placement groups. - :paramtype next_link: str + :keyword enabled: Set this flag to true and provide DiskEncryptionKey and optional + KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and + KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, + the existing settings remain unchanged. Required. + :paramtype enabled: bool + :keyword encryption_settings: A collection of encryption settings, one for each disk volume. + :paramtype encryption_settings: list[~azure.mgmt.compute.models.EncryptionSettingsElement] + :keyword encryption_settings_version: Describes what type of encryption is used for the disks. + Once this field is set, it cannot be overwritten. '1.0' corresponds to Azure Disk Encryption + with AAD app.'1.1' corresponds to Azure Disk Encryption. + :paramtype encryption_settings_version: str """ super().__init__(**kwargs) - self.value = value - self.next_link = next_link + self.enabled = enabled + self.encryption_settings = encryption_settings + self.encryption_settings_version = encryption_settings_version -class ProximityPlacementGroupPropertiesIntent(_serialization.Model): - """Specifies the user intent of the proximity placement group. +class EncryptionSettingsElement(_serialization.Model): + """Encryption settings for one disk volume. - :ivar vm_sizes: Specifies possible sizes of virtual machines that can be created in the - proximity placement group. - :vartype vm_sizes: list[str] + :ivar disk_encryption_key: Key Vault Secret Url and vault id of the disk encryption key. + :vartype disk_encryption_key: ~azure.mgmt.compute.models.KeyVaultAndSecretReference + :ivar key_encryption_key: Key Vault Key Url and vault id of the key encryption key. + KeyEncryptionKey is optional and when provided is used to unwrap the disk encryption key. + :vartype key_encryption_key: ~azure.mgmt.compute.models.KeyVaultAndKeyReference """ _attribute_map = { - "vm_sizes": {"key": "vmSizes", "type": "[str]"}, + "disk_encryption_key": {"key": "diskEncryptionKey", "type": "KeyVaultAndSecretReference"}, + "key_encryption_key": {"key": "keyEncryptionKey", "type": "KeyVaultAndKeyReference"}, } - def __init__(self, *, vm_sizes: Optional[List[str]] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, + **kwargs: Any + ) -> None: """ - :keyword vm_sizes: Specifies possible sizes of virtual machines that can be created in the - proximity placement group. - :paramtype vm_sizes: list[str] + :keyword disk_encryption_key: Key Vault Secret Url and vault id of the disk encryption key. + :paramtype disk_encryption_key: ~azure.mgmt.compute.models.KeyVaultAndSecretReference + :keyword key_encryption_key: Key Vault Key Url and vault id of the key encryption key. + KeyEncryptionKey is optional and when provided is used to unwrap the disk encryption key. + :paramtype key_encryption_key: ~azure.mgmt.compute.models.KeyVaultAndKeyReference """ super().__init__(**kwargs) - self.vm_sizes = vm_sizes - - -class ProximityPlacementGroupUpdate(UpdateResource): - """Specifies information about the proximity placement group. + self.disk_encryption_key = disk_encryption_key + self.key_encryption_key = key_encryption_key - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. -class ProxyAgentSettings(_serialization.Model): - """Specifies ProxyAgent settings for the virtual machine or virtual machine scale set. Minimum - api-version: 2023-09-01. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar enabled: Specifies whether ProxyAgent feature should be enabled on the virtual machine or - virtual machine scale set. - :vartype enabled: bool - :ivar mode: Specifies the mode that ProxyAgent will execute on. Warning: this property has been - deprecated, please specify 'mode' under particular hostendpoint setting. Known values are: - "Audit" and "Enforce". - :vartype mode: str or ~azure.mgmt.compute.v2024_11_01.models.Mode - :ivar key_incarnation_id: Increase the value of this property allows users to reset the key - used for securing communication channel between guest and host. - :vartype key_incarnation_id: int - :ivar wire_server: Specifies the Wire Server endpoint settings while creating the virtual - machine or virtual machine scale set. Minimum api-version: 2024-03-01. - :vartype wire_server: ~azure.mgmt.compute.v2024_11_01.models.HostEndpointSettings - :ivar imds: Specifies the IMDS endpoint settings while creating the virtual machine or virtual - machine scale set. Minimum api-version: 2024-03-01. - :vartype imds: ~azure.mgmt.compute.v2024_11_01.models.HostEndpointSettings + :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 = { - "enabled": {"key": "enabled", "type": "bool"}, - "mode": {"key": "mode", "type": "str"}, - "key_incarnation_id": {"key": "keyIncarnationId", "type": "int"}, - "wire_server": {"key": "wireServer", "type": "HostEndpointSettings"}, - "imds": {"key": "imds", "type": "HostEndpointSettings"}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - mode: Optional[Union[str, "_models.Mode"]] = None, - key_incarnation_id: Optional[int] = None, - wire_server: Optional["_models.HostEndpointSettings"] = None, - imds: Optional["_models.HostEndpointSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Specifies whether ProxyAgent feature should be enabled on the virtual machine - or virtual machine scale set. - :paramtype enabled: bool - :keyword mode: Specifies the mode that ProxyAgent will execute on. Warning: this property has - been deprecated, please specify 'mode' under particular hostendpoint setting. Known values are: - "Audit" and "Enforce". - :paramtype mode: str or ~azure.mgmt.compute.v2024_11_01.models.Mode - :keyword key_incarnation_id: Increase the value of this property allows users to reset the key - used for securing communication channel between guest and host. - :paramtype key_incarnation_id: int - :keyword wire_server: Specifies the Wire Server endpoint settings while creating the virtual - machine or virtual machine scale set. Minimum api-version: 2024-03-01. - :paramtype wire_server: ~azure.mgmt.compute.v2024_11_01.models.HostEndpointSettings - :keyword imds: Specifies the IMDS endpoint settings while creating the virtual machine or - virtual machine scale set. Minimum api-version: 2024-03-01. - :paramtype imds: ~azure.mgmt.compute.v2024_11_01.models.HostEndpointSettings - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.enabled = enabled - self.mode = mode - self.key_incarnation_id = key_incarnation_id - self.wire_server = wire_server - self.imds = imds + self.type: Optional[str] = None + self.info: Optional[JSON] = None -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have - tags and a location. +class ErrorDetail(_serialization.Model): + """The error detail. 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}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData + :ivar 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.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.compute.models.ErrorAdditionalInfo] """ + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } -class PublicIPAddressSku(_serialization.Model): - """Describes the public IP Sku. It can only be set with OrchestrationMode as Flexible. + _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]"}, + } - :ivar name: Specify public IP sku name. Known values are: "Basic" and "Standard". - :vartype name: str or ~azure.mgmt.compute.v2024_11_01.models.PublicIPAddressSkuName - :ivar tier: Specify public IP sku tier. Known values are: "Regional", "Global", and "Global". - :vartype tier: str or ~azure.mgmt.compute.v2024_11_01.models.PublicIPAddressSkuTier + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code: Optional[str] = None + self.message: Optional[str] = None + self.target: Optional[str] = None + self.details: Optional[List["_models.ErrorDetail"]] = None + self.additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = 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.models.ErrorDetail """ _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - name: Optional[Union[str, "_models.PublicIPAddressSkuName"]] = None, - tier: Optional[Union[str, "_models.PublicIPAddressSkuTier"]] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ - :keyword name: Specify public IP sku name. Known values are: "Basic" and "Standard". - :paramtype name: str or ~azure.mgmt.compute.v2024_11_01.models.PublicIPAddressSkuName - :keyword tier: Specify public IP sku tier. Known values are: "Regional", "Global", and - "Global". - :paramtype tier: str or ~azure.mgmt.compute.v2024_11_01.models.PublicIPAddressSkuTier + :keyword error: The error object. + :paramtype error: ~azure.mgmt.compute.models.ErrorDetail """ super().__init__(**kwargs) - self.name = name - self.tier = tier + self.error = error -class PurchasePlan(_serialization.Model): - """Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. +class EventGridAndResourceGraph(_serialization.Model): + """Specifies eventGridAndResourceGraph related Scheduled Event related configurations. - All required parameters must be populated in order to send to server. - - :ivar publisher: The publisher ID. Required. - :vartype publisher: str - :ivar name: The plan ID. Required. - :vartype name: 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 enable: Specifies if event grid and resource graph is enabled for Scheduled event related + configurations. + :vartype enable: bool """ - _validation = { - "publisher": {"required": True}, - "name": {"required": True}, - "product": {"required": True}, - } - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "product": {"key": "product", "type": "str"}, + "enable": {"key": "enable", "type": "bool"}, } - def __init__(self, *, publisher: str, name: str, product: str, **kwargs: Any) -> None: + def __init__(self, *, enable: Optional[bool] = None, **kwargs: Any) -> None: """ - :keyword publisher: The publisher ID. Required. - :paramtype publisher: str - :keyword name: The plan ID. Required. - :paramtype name: 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 enable: Specifies if event grid and resource graph is enabled for Scheduled event + related configurations. + :paramtype enable: bool """ super().__init__(**kwargs) - self.publisher = publisher - self.name = name - self.product = product - - -class RecoveryWalkResponse(_serialization.Model): - """Response after calling a manual recovery walk. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar walk_performed: Whether the recovery walk was performed. - :vartype walk_performed: bool - :ivar next_platform_update_domain: The next update domain that needs to be walked. Null means - walk spanning all update domains has been completed. - :vartype next_platform_update_domain: int - """ - - _validation = { - "walk_performed": {"readonly": True}, - "next_platform_update_domain": {"readonly": True}, - } - - _attribute_map = { - "walk_performed": {"key": "walkPerformed", "type": "bool"}, - "next_platform_update_domain": {"key": "nextPlatformUpdateDomain", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.walk_performed: Optional[bool] = None - self.next_platform_update_domain: Optional[int] = None - + self.enable = enable -class RequestRateByIntervalInput(LogAnalyticsInputBase): - """Api request input for LogAnalytics getRequestRateByInterval Api. - All required parameters must be populated in order to send to server. +class ExtendedLocation(_serialization.Model): + """The complex type of the extended location. - :ivar blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api - writes output logs to. Required. - :vartype blob_container_sas_uri: str - :ivar from_time: From time of the query. Required. - :vartype from_time: ~datetime.datetime - :ivar to_time: To time of the query. Required. - :vartype to_time: ~datetime.datetime - :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. - :vartype group_by_throttle_policy: bool - :ivar group_by_operation_name: Group query result by Operation Name. - :vartype group_by_operation_name: bool - :ivar group_by_resource_name: Group query result by Resource Name. - :vartype group_by_resource_name: bool - :ivar group_by_client_application_id: Group query result by Client Application ID. - :vartype group_by_client_application_id: bool - :ivar group_by_user_agent: Group query result by User Agent. - :vartype group_by_user_agent: bool - :ivar interval_length: Interval value in minutes used to create LogAnalytics call rate logs. - Required. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", and "SixtyMins". - :vartype interval_length: str or ~azure.mgmt.compute.v2024_11_01.models.IntervalInMins + :ivar name: The name of the extended location. + :vartype name: str + :ivar type: The type of the extended location. "EdgeZone" + :vartype type: str or ~azure.mgmt.compute.models.ExtendedLocationTypes """ - _validation = { - "blob_container_sas_uri": {"required": True}, - "from_time": {"required": True}, - "to_time": {"required": True}, - "interval_length": {"required": True}, - } - _attribute_map = { - "blob_container_sas_uri": {"key": "blobContainerSasUri", "type": "str"}, - "from_time": {"key": "fromTime", "type": "iso-8601"}, - "to_time": {"key": "toTime", "type": "iso-8601"}, - "group_by_throttle_policy": {"key": "groupByThrottlePolicy", "type": "bool"}, - "group_by_operation_name": {"key": "groupByOperationName", "type": "bool"}, - "group_by_resource_name": {"key": "groupByResourceName", "type": "bool"}, - "group_by_client_application_id": {"key": "groupByClientApplicationId", "type": "bool"}, - "group_by_user_agent": {"key": "groupByUserAgent", "type": "bool"}, - "interval_length": {"key": "intervalLength", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( self, *, - blob_container_sas_uri: str, - from_time: datetime.datetime, - to_time: datetime.datetime, - interval_length: Union[str, "_models.IntervalInMins"], - group_by_throttle_policy: Optional[bool] = None, - group_by_operation_name: Optional[bool] = None, - group_by_resource_name: Optional[bool] = None, - group_by_client_application_id: Optional[bool] = None, - group_by_user_agent: Optional[bool] = None, + name: Optional[str] = None, + type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, **kwargs: Any ) -> None: """ - :keyword blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics - Api writes output logs to. Required. - :paramtype blob_container_sas_uri: str - :keyword from_time: From time of the query. Required. - :paramtype from_time: ~datetime.datetime - :keyword to_time: To time of the query. Required. - :paramtype to_time: ~datetime.datetime - :keyword group_by_throttle_policy: Group query result by Throttle Policy applied. - :paramtype group_by_throttle_policy: bool - :keyword group_by_operation_name: Group query result by Operation Name. - :paramtype group_by_operation_name: bool - :keyword group_by_resource_name: Group query result by Resource Name. - :paramtype group_by_resource_name: bool - :keyword group_by_client_application_id: Group query result by Client Application ID. - :paramtype group_by_client_application_id: bool - :keyword group_by_user_agent: Group query result by User Agent. - :paramtype group_by_user_agent: bool - :keyword interval_length: Interval value in minutes used to create LogAnalytics call rate logs. - Required. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", and "SixtyMins". - :paramtype interval_length: str or ~azure.mgmt.compute.v2024_11_01.models.IntervalInMins + :keyword name: The name of the extended location. + :paramtype name: str + :keyword type: The type of the extended location. "EdgeZone" + :paramtype type: str or ~azure.mgmt.compute.models.ExtendedLocationTypes """ - super().__init__( - blob_container_sas_uri=blob_container_sas_uri, - from_time=from_time, - to_time=to_time, - group_by_throttle_policy=group_by_throttle_policy, - group_by_operation_name=group_by_operation_name, - group_by_resource_name=group_by_resource_name, - group_by_client_application_id=group_by_client_application_id, - group_by_user_agent=group_by_user_agent, - **kwargs - ) - self.interval_length = interval_length + super().__init__(**kwargs) + self.name = name + self.type = type -class ResiliencyPolicy(_serialization.Model): - """Describes an resiliency policy - AutomaticZoneRebalancingPolicy, ResilientVMCreationPolicy - and/or ResilientVMDeletionPolicy. +class Extension(_serialization.Model): + """Describes a cloud service Extension. - :ivar resilient_vm_creation_policy: The configuration parameters used while performing - resilient VM creation. - :vartype resilient_vm_creation_policy: - ~azure.mgmt.compute.v2024_11_01.models.ResilientVMCreationPolicy - :ivar resilient_vm_deletion_policy: The configuration parameters used while performing - resilient VM deletion. - :vartype resilient_vm_deletion_policy: - ~azure.mgmt.compute.v2024_11_01.models.ResilientVMDeletionPolicy - :ivar automatic_zone_rebalancing_policy: The configuration parameters used while performing - automatic AZ balancing. - :vartype automatic_zone_rebalancing_policy: - ~azure.mgmt.compute.v2024_11_01.models.AutomaticZoneRebalancingPolicy + :ivar name: The name of the extension. + :vartype name: str + :ivar properties: Extension Properties. + :vartype properties: ~azure.mgmt.compute.models.CloudServiceExtensionProperties """ _attribute_map = { - "resilient_vm_creation_policy": {"key": "resilientVMCreationPolicy", "type": "ResilientVMCreationPolicy"}, - "resilient_vm_deletion_policy": {"key": "resilientVMDeletionPolicy", "type": "ResilientVMDeletionPolicy"}, - "automatic_zone_rebalancing_policy": { - "key": "automaticZoneRebalancingPolicy", - "type": "AutomaticZoneRebalancingPolicy", - }, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "CloudServiceExtensionProperties"}, } def __init__( self, *, - resilient_vm_creation_policy: Optional["_models.ResilientVMCreationPolicy"] = None, - resilient_vm_deletion_policy: Optional["_models.ResilientVMDeletionPolicy"] = None, - automatic_zone_rebalancing_policy: Optional["_models.AutomaticZoneRebalancingPolicy"] = None, + name: Optional[str] = None, + properties: Optional["_models.CloudServiceExtensionProperties"] = None, **kwargs: Any ) -> None: """ - :keyword resilient_vm_creation_policy: The configuration parameters used while performing - resilient VM creation. - :paramtype resilient_vm_creation_policy: - ~azure.mgmt.compute.v2024_11_01.models.ResilientVMCreationPolicy - :keyword resilient_vm_deletion_policy: The configuration parameters used while performing - resilient VM deletion. - :paramtype resilient_vm_deletion_policy: - ~azure.mgmt.compute.v2024_11_01.models.ResilientVMDeletionPolicy - :keyword automatic_zone_rebalancing_policy: The configuration parameters used while performing - automatic AZ balancing. - :paramtype automatic_zone_rebalancing_policy: - ~azure.mgmt.compute.v2024_11_01.models.AutomaticZoneRebalancingPolicy - """ - super().__init__(**kwargs) - self.resilient_vm_creation_policy = resilient_vm_creation_policy - self.resilient_vm_deletion_policy = resilient_vm_deletion_policy - self.automatic_zone_rebalancing_policy = automatic_zone_rebalancing_policy - - -class ResilientVMCreationPolicy(_serialization.Model): - """The configuration parameters used while performing resilient VM creation. - - :ivar enabled: Specifies whether resilient VM creation should be enabled on the virtual machine - scale set. The default value is false. - :vartype enabled: bool - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Specifies whether resilient VM creation should be enabled on the virtual - machine scale set. The default value is false. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.enabled = enabled - - -class ResilientVMDeletionPolicy(_serialization.Model): - """The configuration parameters used while performing resilient VM deletion. - - :ivar enabled: Specifies whether resilient VM deletion should be enabled on the virtual machine - scale set. The default value is false. - :vartype enabled: bool - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - } - - 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 + :keyword name: The name of the extension. + :paramtype name: str + :keyword properties: Extension Properties. + :paramtype properties: ~azure.mgmt.compute.models.CloudServiceExtensionProperties """ super().__init__(**kwargs) - self.enabled = enabled + self.name = name + self.properties = properties -class ResourceAutoGenerated(_serialization.Model): - """The Resource model definition. +class Gallery(ResourceAutoGenerated): + """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. @@ -6571,6 +6656,20 @@ class ResourceAutoGenerated(_serialization.Model): :vartype location: str :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar description: The description of this Shared Image Gallery resource. This property is + updatable. + :vartype description: str + :ivar identifier: Describes the gallery unique name. + :vartype identifier: ~azure.mgmt.compute.models.GalleryIdentifier + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". + :vartype provisioning_state: str or ~azure.mgmt.compute.models.GalleryProvisioningState + :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. + :vartype sharing_profile: ~azure.mgmt.compute.models.SharingProfile + :ivar soft_delete_policy: Contains information about the soft deletion policy of the gallery. + :vartype soft_delete_policy: ~azure.mgmt.compute.models.SoftDeletePolicy + :ivar sharing_status: Sharing status of current gallery. + :vartype sharing_status: ~azure.mgmt.compute.models.SharingStatus """ _validation = { @@ -6578,6 +6677,8 @@ class ResourceAutoGenerated(_serialization.Model): "name": {"readonly": True}, "type": {"readonly": True}, "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "sharing_status": {"readonly": True}, } _attribute_map = { @@ -6586,54 +6687,324 @@ class ResourceAutoGenerated(_serialization.Model): "type": {"key": "type", "type": "str"}, "location": {"key": "location", "type": "str"}, "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "identifier": {"key": "properties.identifier", "type": "GalleryIdentifier"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "sharing_profile": {"key": "properties.sharingProfile", "type": "SharingProfile"}, + "soft_delete_policy": {"key": "properties.softDeletePolicy", "type": "SoftDeletePolicy"}, + "sharing_status": {"key": "properties.sharingStatus", "type": "SharingStatus"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + description: Optional[str] = None, + identifier: Optional["_models.GalleryIdentifier"] = None, + sharing_profile: Optional["_models.SharingProfile"] = None, + soft_delete_policy: Optional["_models.SoftDeletePolicy"] = 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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags + :keyword description: The description of this Shared Image Gallery resource. This property is + updatable. + :paramtype description: str + :keyword identifier: Describes the gallery unique name. + :paramtype identifier: ~azure.mgmt.compute.models.GalleryIdentifier + :keyword sharing_profile: Profile for gallery sharing to subscription or tenant. + :paramtype sharing_profile: ~azure.mgmt.compute.models.SharingProfile + :keyword soft_delete_policy: Contains information about the soft deletion policy of the + gallery. + :paramtype soft_delete_policy: ~azure.mgmt.compute.models.SoftDeletePolicy + """ + super().__init__(location=location, tags=tags, **kwargs) + self.description = description + self.identifier = identifier + self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None + self.sharing_profile = sharing_profile + self.soft_delete_policy = soft_delete_policy + self.sharing_status: Optional["_models.SharingStatus"] = None -class ResourceSharingProfile(_serialization.Model): - """ResourceSharingProfile. +class GalleryApplication(ResourceAutoGenerated): + """Specifies information about the gallery Application Definition that you want to create or + update. - :ivar subscription_ids: Specifies an array of subscription resource IDs that capacity - reservation group is shared with. **Note:** Minimum api-version: 2023-09-01. Please refer to - https://aka.ms/computereservationsharing for more details. - :vartype subscription_ids: list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + 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] + :ivar description: The description of this gallery Application Definition resource. This + property is updatable. + :vartype description: str + :ivar eula: The Eula agreement for the gallery Application Definition. + :vartype eula: str + :ivar privacy_statement_uri: The privacy statement uri. + :vartype privacy_statement_uri: str + :ivar release_note_uri: The release note uri. + :vartype release_note_uri: str + :ivar end_of_life_date: The end of life date of the gallery Application Definition. This + property can be used for decommissioning purposes. This property is updatable. + :vartype end_of_life_date: ~datetime.datetime + :ivar supported_os_type: This property allows you to specify the supported type of the OS that + application is built for. Possible values are: **Windows,** **Linux.**. Known values are: + "Windows" and "Linux". + :vartype supported_os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :ivar custom_actions: A list of custom actions that can be performed with all of the Gallery + Application Versions within this Gallery Application. + :vartype custom_actions: list[~azure.mgmt.compute.models.GalleryApplicationCustomAction] """ + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + } + _attribute_map = { - "subscription_ids": {"key": "subscriptionIds", "type": "[SubResource]"}, + "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}"}, + "description": {"key": "properties.description", "type": "str"}, + "eula": {"key": "properties.eula", "type": "str"}, + "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, + "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, + "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, + "supported_os_type": {"key": "properties.supportedOSType", "type": "str"}, + "custom_actions": {"key": "properties.customActions", "type": "[GalleryApplicationCustomAction]"}, } - def __init__(self, *, subscription_ids: Optional[List["_models.SubResource"]] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + description: Optional[str] = None, + eula: Optional[str] = None, + privacy_statement_uri: Optional[str] = None, + release_note_uri: Optional[str] = None, + end_of_life_date: Optional[datetime.datetime] = None, + supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + custom_actions: Optional[List["_models.GalleryApplicationCustomAction"]] = None, + **kwargs: Any + ) -> None: """ - :keyword subscription_ids: Specifies an array of subscription resource IDs that capacity - reservation group is shared with. **Note:** Minimum api-version: 2023-09-01. Please refer to - https://aka.ms/computereservationsharing for more details. - :paramtype subscription_ids: list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword description: The description of this gallery Application Definition resource. This + property is updatable. + :paramtype description: str + :keyword eula: The Eula agreement for the gallery Application Definition. + :paramtype eula: str + :keyword privacy_statement_uri: The privacy statement uri. + :paramtype privacy_statement_uri: str + :keyword release_note_uri: The release note uri. + :paramtype release_note_uri: str + :keyword end_of_life_date: The end of life date of the gallery Application Definition. This + property can be used for decommissioning purposes. This property is updatable. + :paramtype end_of_life_date: ~datetime.datetime + :keyword supported_os_type: This property allows you to specify the supported type of the OS + that application is built for. Possible values are: **Windows,** **Linux.**. Known values are: + "Windows" and "Linux". + :paramtype supported_os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :keyword custom_actions: A list of custom actions that can be performed with all of the Gallery + Application Versions within this Gallery Application. + :paramtype custom_actions: list[~azure.mgmt.compute.models.GalleryApplicationCustomAction] + """ + super().__init__(location=location, tags=tags, **kwargs) + self.description = description + self.eula = eula + self.privacy_statement_uri = privacy_statement_uri + self.release_note_uri = release_note_uri + self.end_of_life_date = end_of_life_date + self.supported_os_type = supported_os_type + self.custom_actions = custom_actions + + +class GalleryApplicationCustomAction(_serialization.Model): + """A custom action that can be performed with a Gallery Application Version. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the custom action. Must be unique within the Gallery Application + Version. Required. + :vartype name: str + :ivar script: The script to run when executing this custom action. Required. + :vartype script: str + :ivar description: Description to help the users understand what this custom action does. + :vartype description: str + :ivar parameters: The parameters that this custom action uses. + :vartype parameters: list[~azure.mgmt.compute.models.GalleryApplicationCustomActionParameter] + """ + + _validation = { + "name": {"required": True}, + "script": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "script": {"key": "script", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "parameters": {"key": "parameters", "type": "[GalleryApplicationCustomActionParameter]"}, + } + + def __init__( + self, + *, + name: str, + script: str, + description: Optional[str] = None, + parameters: Optional[List["_models.GalleryApplicationCustomActionParameter"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the custom action. Must be unique within the Gallery Application + Version. Required. + :paramtype name: str + :keyword script: The script to run when executing this custom action. Required. + :paramtype script: str + :keyword description: Description to help the users understand what this custom action does. + :paramtype description: str + :keyword parameters: The parameters that this custom action uses. + :paramtype parameters: list[~azure.mgmt.compute.models.GalleryApplicationCustomActionParameter] """ super().__init__(**kwargs) - self.subscription_ids = subscription_ids + self.name = name + self.script = script + self.description = description + self.parameters = parameters -class ResourceWithOptionalLocation(_serialization.Model): - """The Resource model definition with location property as optional. +class GalleryApplicationCustomActionParameter(_serialization.Model): + """The definition of a parameter that can be passed to a custom action of a Gallery Application + Version. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the custom action. Must be unique within the Gallery Application + Version. Required. + :vartype name: str + :ivar required: Indicates whether this parameter must be passed when running the custom action. + :vartype required: bool + :ivar type: Specifies the type of the custom action parameter. Possible values are: String, + ConfigurationDataBlob or LogOutputBlob. Known values are: "String", "ConfigurationDataBlob", + and "LogOutputBlob". + :vartype type: str or ~azure.mgmt.compute.models.GalleryApplicationCustomActionParameterType + :ivar default_value: The default value of the parameter. Only applies to string types. + :vartype default_value: str + :ivar description: A description to help users understand what this parameter means. + :vartype description: str + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "required": {"key": "required", "type": "bool"}, + "type": {"key": "type", "type": "str"}, + "default_value": {"key": "defaultValue", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + required: Optional[bool] = None, + type: Optional[Union[str, "_models.GalleryApplicationCustomActionParameterType"]] = None, + default_value: Optional[str] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the custom action. Must be unique within the Gallery Application + Version. Required. + :paramtype name: str + :keyword required: Indicates whether this parameter must be passed when running the custom + action. + :paramtype required: bool + :keyword type: Specifies the type of the custom action parameter. Possible values are: String, + ConfigurationDataBlob or LogOutputBlob. Known values are: "String", "ConfigurationDataBlob", + and "LogOutputBlob". + :paramtype type: str or ~azure.mgmt.compute.models.GalleryApplicationCustomActionParameterType + :keyword default_value: The default value of the parameter. Only applies to string types. + :paramtype default_value: str + :keyword description: A description to help users understand what this parameter means. + :paramtype description: str + """ + super().__init__(**kwargs) + self.name = name + self.required = required + self.type = type + self.default_value = default_value + self.description = description + + +class GalleryApplicationList(_serialization.Model): + """The List Gallery Applications operation response. + + All required parameters must be populated in order to send to server. + + :ivar value: A list of Gallery Applications. Required. + :vartype value: list[~azure.mgmt.compute.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. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[GalleryApplication]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.GalleryApplication"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: A list of Gallery Applications. Required. + :paramtype value: list[~azure.mgmt.compute.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. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class UpdateResourceDefinition(_serialization.Model): + """The Update Resource model definition. 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. @@ -6651,35 +7022,29 @@ class ResourceWithOptionalLocation(_serialization.Model): } _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: + def __init__(self, *, 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: Optional[str] = None self.name: Optional[str] = None self.type: Optional[str] = None self.tags = tags -class ResourceWithOptionalLocationAutoGenerated(_serialization.Model): # pylint: disable=name-too-long - """The Resource model definition with location property as optional. +class GalleryApplicationUpdate(UpdateResourceDefinition): + """Specifies information about the gallery Application Definition that you want to update. 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. @@ -6688,6 +7053,25 @@ class ResourceWithOptionalLocationAutoGenerated(_serialization.Model): # pylint :vartype type: str :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar description: The description of this gallery Application Definition resource. This + property is updatable. + :vartype description: str + :ivar eula: The Eula agreement for the gallery Application Definition. + :vartype eula: str + :ivar privacy_statement_uri: The privacy statement uri. + :vartype privacy_statement_uri: str + :ivar release_note_uri: The release note uri. + :vartype release_note_uri: str + :ivar end_of_life_date: The end of life date of the gallery Application Definition. This + property can be used for decommissioning purposes. This property is updatable. + :vartype end_of_life_date: ~datetime.datetime + :ivar supported_os_type: This property allows you to specify the supported type of the OS that + application is built for. Possible values are: **Windows,** **Linux.**. Known values are: + "Windows" and "Linux". + :vartype supported_os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :ivar custom_actions: A list of custom actions that can be performed with all of the Gallery + Application Versions within this Gallery Application. + :vartype custom_actions: list[~azure.mgmt.compute.models.GalleryApplicationCustomAction] """ _validation = { @@ -6697,1744 +7081,9679 @@ class ResourceWithOptionalLocationAutoGenerated(_serialization.Model): # pylint } _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}"}, + "description": {"key": "properties.description", "type": "str"}, + "eula": {"key": "properties.eula", "type": "str"}, + "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, + "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, + "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, + "supported_os_type": {"key": "properties.supportedOSType", "type": "str"}, + "custom_actions": {"key": "properties.customActions", "type": "[GalleryApplicationCustomAction]"}, } - def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + description: Optional[str] = None, + eula: Optional[str] = None, + privacy_statement_uri: Optional[str] = None, + release_note_uri: Optional[str] = None, + end_of_life_date: Optional[datetime.datetime] = None, + supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + custom_actions: Optional[List["_models.GalleryApplicationCustomAction"]] = None, + **kwargs: Any + ) -> None: """ - :keyword location: Resource location. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword description: The description of this gallery Application Definition resource. This + property is updatable. + :paramtype description: str + :keyword eula: The Eula agreement for the gallery Application Definition. + :paramtype eula: str + :keyword privacy_statement_uri: The privacy statement uri. + :paramtype privacy_statement_uri: str + :keyword release_note_uri: The release note uri. + :paramtype release_note_uri: str + :keyword end_of_life_date: The end of life date of the gallery Application Definition. This + property can be used for decommissioning purposes. This property is updatable. + :paramtype end_of_life_date: ~datetime.datetime + :keyword supported_os_type: This property allows you to specify the supported type of the OS + that application is built for. Possible values are: **Windows,** **Linux.**. Known values are: + "Windows" and "Linux". + :paramtype supported_os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :keyword custom_actions: A list of custom actions that can be performed with all of the Gallery + Application Versions within this Gallery Application. + :paramtype custom_actions: list[~azure.mgmt.compute.models.GalleryApplicationCustomAction] """ - super().__init__(**kwargs) - self.location = location - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.tags = tags + super().__init__(tags=tags, **kwargs) + self.description = description + self.eula = eula + self.privacy_statement_uri = privacy_statement_uri + self.release_note_uri = release_note_uri + self.end_of_life_date = end_of_life_date + self.supported_os_type = supported_os_type + self.custom_actions = custom_actions -class RestorePoint(ProxyResource): - """Restore Point details. +class GalleryApplicationVersion(ResourceAutoGenerated): + """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. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + All required parameters must be populated in order to send to server. + + :ivar id: Resource Id. :vartype id: str - :ivar name: The name of the resource. + :ivar name: Resource name. :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". + :ivar type: Resource type. :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData - :ivar exclude_disks: List of disk resource ids that the customer wishes to exclude from the - restore point. If no disks are specified, all disks will be included. - :vartype exclude_disks: list[~azure.mgmt.compute.v2024_11_01.models.ApiEntityReference] - :ivar source_metadata: Gets the details of the VM captured at the time of the restore point - creation. - :vartype source_metadata: ~azure.mgmt.compute.v2024_11_01.models.RestorePointSourceMetadata - :ivar provisioning_state: Gets the provisioning state of the restore point. - :vartype provisioning_state: str - :ivar consistency_mode: ConsistencyMode of the RestorePoint. Can be specified in the input - while creating a restore point. For now, only CrashConsistent is accepted as a valid input. - Please refer to https://aka.ms/RestorePoints for more details. Known values are: - "CrashConsistent", "FileSystemConsistent", and "ApplicationConsistent". - :vartype consistency_mode: str or ~azure.mgmt.compute.v2024_11_01.models.ConsistencyModeTypes - :ivar time_created: Gets the creation time of the restore point. - :vartype time_created: ~datetime.datetime - :ivar source_restore_point: Resource Id of the source restore point from which a copy needs to - be created. - :vartype source_restore_point: ~azure.mgmt.compute.v2024_11_01.models.ApiEntityReference - :ivar instance_view: The restore point instance view. - :vartype instance_view: ~azure.mgmt.compute.v2024_11_01.models.RestorePointInstanceView + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar publishing_profile: The publishing profile of a gallery image version. + :vartype publishing_profile: + ~azure.mgmt.compute.models.GalleryApplicationVersionPublishingProfile + :ivar safety_profile: The safety profile of the Gallery Application Version. + :vartype safety_profile: ~azure.mgmt.compute.models.GalleryApplicationVersionSafetyProfile + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". + :vartype provisioning_state: str or ~azure.mgmt.compute.models.GalleryProvisioningState + :ivar replication_status: This is the replication status of the gallery image version. + :vartype replication_status: ~azure.mgmt.compute.models.ReplicationStatus """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, - "system_data": {"readonly": True}, + "location": {"required": True}, "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, + "replication_status": {"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"}, - "exclude_disks": {"key": "properties.excludeDisks", "type": "[ApiEntityReference]"}, - "source_metadata": {"key": "properties.sourceMetadata", "type": "RestorePointSourceMetadata"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "publishing_profile": { + "key": "properties.publishingProfile", + "type": "GalleryApplicationVersionPublishingProfile", + }, + "safety_profile": {"key": "properties.safetyProfile", "type": "GalleryApplicationVersionSafetyProfile"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "consistency_mode": {"key": "properties.consistencyMode", "type": "str"}, - "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, - "source_restore_point": {"key": "properties.sourceRestorePoint", "type": "ApiEntityReference"}, - "instance_view": {"key": "properties.instanceView", "type": "RestorePointInstanceView"}, + "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, } def __init__( self, *, - exclude_disks: Optional[List["_models.ApiEntityReference"]] = None, - source_metadata: Optional["_models.RestorePointSourceMetadata"] = None, - consistency_mode: Optional[Union[str, "_models.ConsistencyModeTypes"]] = None, - time_created: Optional[datetime.datetime] = None, - source_restore_point: Optional["_models.ApiEntityReference"] = None, + location: str, + tags: Optional[Dict[str, str]] = None, + publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, + safety_profile: Optional["_models.GalleryApplicationVersionSafetyProfile"] = None, **kwargs: Any ) -> None: """ - :keyword 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. - :paramtype exclude_disks: list[~azure.mgmt.compute.v2024_11_01.models.ApiEntityReference] - :keyword source_metadata: Gets the details of the VM captured at the time of the restore point - creation. - :paramtype source_metadata: ~azure.mgmt.compute.v2024_11_01.models.RestorePointSourceMetadata - :keyword consistency_mode: ConsistencyMode of the RestorePoint. Can be specified in the input - while creating a restore point. For now, only CrashConsistent is accepted as a valid input. - Please refer to https://aka.ms/RestorePoints for more details. Known values are: - "CrashConsistent", "FileSystemConsistent", and "ApplicationConsistent". - :paramtype consistency_mode: str or ~azure.mgmt.compute.v2024_11_01.models.ConsistencyModeTypes - :keyword time_created: Gets the creation time of the restore point. - :paramtype time_created: ~datetime.datetime - :keyword source_restore_point: Resource Id of the source restore point from which a copy needs - to be created. - :paramtype source_restore_point: ~azure.mgmt.compute.v2024_11_01.models.ApiEntityReference + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword publishing_profile: The publishing profile of a gallery image version. + :paramtype publishing_profile: + ~azure.mgmt.compute.models.GalleryApplicationVersionPublishingProfile + :keyword safety_profile: The safety profile of the Gallery Application Version. + :paramtype safety_profile: ~azure.mgmt.compute.models.GalleryApplicationVersionSafetyProfile """ - super().__init__(**kwargs) - self.exclude_disks = exclude_disks - self.source_metadata = source_metadata - self.provisioning_state: Optional[str] = None - self.consistency_mode = consistency_mode - self.time_created = time_created - self.source_restore_point = source_restore_point - self.instance_view: Optional["_models.RestorePointInstanceView"] = None + super().__init__(location=location, tags=tags, **kwargs) + self.publishing_profile = publishing_profile + self.safety_profile = safety_profile + self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None + self.replication_status: Optional["_models.ReplicationStatus"] = None -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. +class GalleryApplicationVersionList(_serialization.Model): + """The List Gallery Application version operation response. 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}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar source: The properties of the source resource that this restore point collection is - created from. - :vartype source: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionSourceProperties - :ivar provisioning_state: The provisioning state of the restore point collection. - :vartype provisioning_state: str - :ivar restore_point_collection_id: The unique id of the restore point collection. - :vartype restore_point_collection_id: str - :ivar restore_points: A list containing all restore points created under this restore point - collection. - :vartype restore_points: list[~azure.mgmt.compute.v2024_11_01.models.RestorePoint] + :ivar value: A list of gallery Application Versions. Required. + :vartype value: list[~azure.mgmt.compute.models.GalleryApplicationVersion] + :ivar next_link: The uri to fetch the next page of gallery Application Versions. Call + ListNext() with this to fetch the next page of gallery Application Versions. + :vartype next_link: str """ _validation = { - "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}, - "restore_points": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { - "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"}, - "source": {"key": "properties.source", "type": "RestorePointCollectionSourceProperties"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "restore_point_collection_id": {"key": "properties.restorePointCollectionId", "type": "str"}, - "restore_points": {"key": "properties.restorePoints", "type": "[RestorePoint]"}, + "value": {"key": "value", "type": "[GalleryApplicationVersion]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - source: Optional["_models.RestorePointCollectionSourceProperties"] = None, - **kwargs: Any + self, *, value: List["_models.GalleryApplicationVersion"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword source: The properties of the source resource that this restore point collection is - created from. - :paramtype source: - ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionSourceProperties + :keyword value: A list of gallery Application Versions. Required. + :paramtype value: list[~azure.mgmt.compute.models.GalleryApplicationVersion] + :keyword next_link: The uri to fetch the next page of gallery Application Versions. Call + ListNext() with this to fetch the next page of gallery Application Versions. + :paramtype next_link: str """ - super().__init__(tags=tags, location=location, **kwargs) - self.source = source - self.provisioning_state: Optional[str] = None - self.restore_point_collection_id: Optional[str] = None - self.restore_points: Optional[List["_models.RestorePoint"]] = None + super().__init__(**kwargs) + self.value = value + self.next_link = next_link -class RestorePointCollectionListResult(_serialization.Model): - """The List restore point collection operation response. +class GalleryArtifactPublishingProfileBase(_serialization.Model): + """Describes the basic gallery artifact publishing profile. - All required parameters must be populated in order to send to server. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: Gets the list of restore point collections. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection] - :ivar next_link: The uri to fetch the next page of RestorePointCollections. Call ListNext() - with this to fetch the next page of RestorePointCollections. - :vartype next_link: str + :ivar target_regions: The target regions where the Image Version is going to be replicated to. + This property is updatable. + :vartype target_regions: list[~azure.mgmt.compute.models.TargetRegion] + :ivar replica_count: The number of replicas of the Image Version to be created per region. This + property would take effect for a region when regionalReplicaCount is not specified. This + property is updatable. + :vartype replica_count: int + :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of + the Image Definition won't use this Image Version. + :vartype exclude_from_latest: bool + :ivar published_date: The timestamp for when the gallery image version is published. + :vartype published_date: ~datetime.datetime + :ivar end_of_life_date: The end of life date of the gallery image version. This property can be + used for decommissioning purposes. This property is updatable. + :vartype end_of_life_date: ~datetime.datetime + :ivar storage_account_type: Specifies the storage account type to be used to store the image. + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and + "Premium_LRS". + :vartype storage_account_type: str or ~azure.mgmt.compute.models.StorageAccountType + :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. + This property is not updatable. Known values are: "Full" and "Shallow". + :vartype replication_mode: str or ~azure.mgmt.compute.models.ReplicationMode + :ivar target_extended_locations: The target extended locations where the Image Version is going + to be replicated to. This property is updatable. + :vartype target_extended_locations: + list[~azure.mgmt.compute.models.GalleryTargetExtendedLocation] """ _validation = { - "value": {"required": True}, + "published_date": {"readonly": True}, } _attribute_map = { - "value": {"key": "value", "type": "[RestorePointCollection]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "target_regions": {"key": "targetRegions", "type": "[TargetRegion]"}, + "replica_count": {"key": "replicaCount", "type": "int"}, + "exclude_from_latest": {"key": "excludeFromLatest", "type": "bool"}, + "published_date": {"key": "publishedDate", "type": "iso-8601"}, + "end_of_life_date": {"key": "endOfLifeDate", "type": "iso-8601"}, + "storage_account_type": {"key": "storageAccountType", "type": "str"}, + "replication_mode": {"key": "replicationMode", "type": "str"}, + "target_extended_locations": {"key": "targetExtendedLocations", "type": "[GalleryTargetExtendedLocation]"}, } def __init__( - self, *, value: List["_models.RestorePointCollection"], next_link: Optional[str] = None, **kwargs: Any + self, + *, + target_regions: Optional[List["_models.TargetRegion"]] = None, + replica_count: Optional[int] = None, + exclude_from_latest: Optional[bool] = None, + end_of_life_date: Optional[datetime.datetime] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, + target_extended_locations: Optional[List["_models.GalleryTargetExtendedLocation"]] = None, + **kwargs: Any ) -> None: """ - :keyword value: Gets the list of restore point collections. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection] - :keyword next_link: The uri to fetch the next page of RestorePointCollections. Call ListNext() - with this to fetch the next page of RestorePointCollections. - :paramtype next_link: str + :keyword target_regions: The target regions where the Image Version is going to be replicated + to. This property is updatable. + :paramtype target_regions: list[~azure.mgmt.compute.models.TargetRegion] + :keyword replica_count: The number of replicas of the Image Version to be created per region. + This property would take effect for a region when regionalReplicaCount is not specified. This + property is updatable. + :paramtype replica_count: int + :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 end_of_life_date: The end of life date of the gallery image version. This property can + be used for decommissioning purposes. This property is updatable. + :paramtype end_of_life_date: ~datetime.datetime + :keyword storage_account_type: Specifies the storage account type to be used to store the + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and + "Premium_LRS". + :paramtype storage_account_type: str or ~azure.mgmt.compute.models.StorageAccountType + :keyword replication_mode: Optional parameter which specifies the mode to be used for + replication. This property is not updatable. Known values are: "Full" and "Shallow". + :paramtype replication_mode: str or ~azure.mgmt.compute.models.ReplicationMode + :keyword target_extended_locations: The target extended locations where the Image Version is + going to be replicated to. This property is updatable. + :paramtype target_extended_locations: + list[~azure.mgmt.compute.models.GalleryTargetExtendedLocation] """ super().__init__(**kwargs) - self.value = value - self.next_link = next_link + self.target_regions = target_regions + self.replica_count = replica_count + self.exclude_from_latest = exclude_from_latest + self.published_date: Optional[datetime.datetime] = None + self.end_of_life_date = end_of_life_date + self.storage_account_type = storage_account_type + self.replication_mode = replication_mode + self.target_extended_locations = target_extended_locations -class RestorePointCollectionSourceProperties(_serialization.Model): - """The properties of the source resource that this restore point collection is created from. +class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfileBase): # pylint: disable=name-too-long + """The publishing profile of a gallery image version. Variables are only populated by the server, and will be ignored when sending a request. - :ivar location: Location of the source resource used to create this restore point collection. - :vartype location: str - :ivar id: Resource Id of the source resource used to create this restore point collection. - :vartype id: str + All required parameters must be populated in order to send to server. + + :ivar target_regions: The target regions where the Image Version is going to be replicated to. + This property is updatable. + :vartype target_regions: list[~azure.mgmt.compute.models.TargetRegion] + :ivar replica_count: The number of replicas of the Image Version to be created per region. This + property would take effect for a region when regionalReplicaCount is not specified. This + property is updatable. + :vartype replica_count: int + :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of + the Image Definition won't use this Image Version. + :vartype exclude_from_latest: bool + :ivar published_date: The timestamp for when the gallery image version is published. + :vartype published_date: ~datetime.datetime + :ivar end_of_life_date: The end of life date of the gallery image version. This property can be + used for decommissioning purposes. This property is updatable. + :vartype end_of_life_date: ~datetime.datetime + :ivar storage_account_type: Specifies the storage account type to be used to store the image. + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and + "Premium_LRS". + :vartype storage_account_type: str or ~azure.mgmt.compute.models.StorageAccountType + :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. + This property is not updatable. Known values are: "Full" and "Shallow". + :vartype replication_mode: str or ~azure.mgmt.compute.models.ReplicationMode + :ivar target_extended_locations: The target extended locations where the Image Version is going + to be replicated to. This property is updatable. + :vartype target_extended_locations: + list[~azure.mgmt.compute.models.GalleryTargetExtendedLocation] + :ivar source: The source image from which the Image Version is going to be created. Required. + :vartype source: ~azure.mgmt.compute.models.UserArtifactSource + :ivar manage_actions: + :vartype manage_actions: ~azure.mgmt.compute.models.UserArtifactManage + :ivar settings: Additional settings for the VM app that contains the target package and config + file name when it is deployed to target VM or VM scale set. + :vartype settings: ~azure.mgmt.compute.models.UserArtifactSettings + :ivar advanced_settings: Optional. Additional settings to pass to the vm-application-manager + extension. For advanced use only. + :vartype advanced_settings: dict[str, str] + :ivar enable_health_check: Optional. Whether or not this application reports health. + :vartype enable_health_check: bool + :ivar custom_actions: A list of custom actions that can be performed with this Gallery + Application Version. + :vartype custom_actions: list[~azure.mgmt.compute.models.GalleryApplicationCustomAction] """ _validation = { - "location": {"readonly": True}, + "published_date": {"readonly": True}, + "source": {"required": True}, } _attribute_map = { - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, + "target_regions": {"key": "targetRegions", "type": "[TargetRegion]"}, + "replica_count": {"key": "replicaCount", "type": "int"}, + "exclude_from_latest": {"key": "excludeFromLatest", "type": "bool"}, + "published_date": {"key": "publishedDate", "type": "iso-8601"}, + "end_of_life_date": {"key": "endOfLifeDate", "type": "iso-8601"}, + "storage_account_type": {"key": "storageAccountType", "type": "str"}, + "replication_mode": {"key": "replicationMode", "type": "str"}, + "target_extended_locations": {"key": "targetExtendedLocations", "type": "[GalleryTargetExtendedLocation]"}, + "source": {"key": "source", "type": "UserArtifactSource"}, + "manage_actions": {"key": "manageActions", "type": "UserArtifactManage"}, + "settings": {"key": "settings", "type": "UserArtifactSettings"}, + "advanced_settings": {"key": "advancedSettings", "type": "{str}"}, + "enable_health_check": {"key": "enableHealthCheck", "type": "bool"}, + "custom_actions": {"key": "customActions", "type": "[GalleryApplicationCustomAction]"}, } - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + def __init__( + self, + *, + source: "_models.UserArtifactSource", + target_regions: Optional[List["_models.TargetRegion"]] = None, + replica_count: Optional[int] = None, + exclude_from_latest: Optional[bool] = None, + end_of_life_date: Optional[datetime.datetime] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, + target_extended_locations: Optional[List["_models.GalleryTargetExtendedLocation"]] = None, + manage_actions: Optional["_models.UserArtifactManage"] = None, + settings: Optional["_models.UserArtifactSettings"] = None, + advanced_settings: Optional[Dict[str, str]] = None, + enable_health_check: Optional[bool] = None, + custom_actions: Optional[List["_models.GalleryApplicationCustomAction"]] = None, + **kwargs: Any + ) -> None: """ - :keyword id: Resource Id of the source resource used to create this restore point collection. - :paramtype id: str + :keyword target_regions: The target regions where the Image Version is going to be replicated + to. This property is updatable. + :paramtype target_regions: list[~azure.mgmt.compute.models.TargetRegion] + :keyword replica_count: The number of replicas of the Image Version to be created per region. + This property would take effect for a region when regionalReplicaCount is not specified. This + property is updatable. + :paramtype replica_count: int + :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 end_of_life_date: The end of life date of the gallery image version. This property can + be used for decommissioning purposes. This property is updatable. + :paramtype end_of_life_date: ~datetime.datetime + :keyword storage_account_type: Specifies the storage account type to be used to store the + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and + "Premium_LRS". + :paramtype storage_account_type: str or ~azure.mgmt.compute.models.StorageAccountType + :keyword replication_mode: Optional parameter which specifies the mode to be used for + replication. This property is not updatable. Known values are: "Full" and "Shallow". + :paramtype replication_mode: str or ~azure.mgmt.compute.models.ReplicationMode + :keyword target_extended_locations: The target extended locations where the Image Version is + going to be replicated to. This property is updatable. + :paramtype target_extended_locations: + list[~azure.mgmt.compute.models.GalleryTargetExtendedLocation] + :keyword source: The source image from which the Image Version is going to be created. + Required. + :paramtype source: ~azure.mgmt.compute.models.UserArtifactSource + :keyword manage_actions: + :paramtype manage_actions: ~azure.mgmt.compute.models.UserArtifactManage + :keyword settings: Additional settings for the VM app that contains the target package and + config file name when it is deployed to target VM or VM scale set. + :paramtype settings: ~azure.mgmt.compute.models.UserArtifactSettings + :keyword advanced_settings: Optional. Additional settings to pass to the vm-application-manager + extension. For advanced use only. + :paramtype advanced_settings: dict[str, str] + :keyword enable_health_check: Optional. Whether or not this application reports health. + :paramtype enable_health_check: bool + :keyword custom_actions: A list of custom actions that can be performed with this Gallery + Application Version. + :paramtype custom_actions: list[~azure.mgmt.compute.models.GalleryApplicationCustomAction] + """ + super().__init__( + target_regions=target_regions, + replica_count=replica_count, + exclude_from_latest=exclude_from_latest, + end_of_life_date=end_of_life_date, + storage_account_type=storage_account_type, + replication_mode=replication_mode, + target_extended_locations=target_extended_locations, + **kwargs + ) + self.source = source + self.manage_actions = manage_actions + self.settings = settings + self.advanced_settings = advanced_settings + self.enable_health_check = enable_health_check + self.custom_actions = custom_actions + + +class GalleryArtifactSafetyProfileBase(_serialization.Model): + """This is the safety profile of the Gallery Artifact Version. + + :ivar allow_deletion_of_replicated_locations: Indicates whether or not removing this Gallery + Image Version from replicated regions is allowed. + :vartype allow_deletion_of_replicated_locations: bool + """ + + _attribute_map = { + "allow_deletion_of_replicated_locations": {"key": "allowDeletionOfReplicatedLocations", "type": "bool"}, + } + + def __init__(self, *, allow_deletion_of_replicated_locations: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword allow_deletion_of_replicated_locations: Indicates whether or not removing this Gallery + Image Version from replicated regions is allowed. + :paramtype allow_deletion_of_replicated_locations: bool """ super().__init__(**kwargs) - self.location: Optional[str] = None - self.id = id + self.allow_deletion_of_replicated_locations = allow_deletion_of_replicated_locations -class RestorePointCollectionUpdate(UpdateResource): - """Update Restore Point collection parameters. +class GalleryApplicationVersionSafetyProfile(GalleryArtifactSafetyProfileBase): + """The safety profile of the Gallery Application Version. + + :ivar allow_deletion_of_replicated_locations: Indicates whether or not removing this Gallery + Image Version from replicated regions is allowed. + :vartype allow_deletion_of_replicated_locations: bool + """ + + +class GalleryApplicationVersionUpdate(UpdateResourceDefinition): + """Specifies information about the gallery Application Version that you want to update. Variables are only populated by the server, and will be ignored when sending a request. + :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] - :ivar source: The properties of the source resource that this restore point collection is - created from. - :vartype source: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionSourceProperties - :ivar provisioning_state: The provisioning state of the restore point collection. - :vartype provisioning_state: str - :ivar restore_point_collection_id: The unique id of the restore point collection. - :vartype restore_point_collection_id: str - :ivar restore_points: A list containing all restore points created under this restore point - collection. - :vartype restore_points: list[~azure.mgmt.compute.v2024_11_01.models.RestorePoint] + :ivar publishing_profile: The publishing profile of a gallery image version. + :vartype publishing_profile: + ~azure.mgmt.compute.models.GalleryApplicationVersionPublishingProfile + :ivar safety_profile: The safety profile of the Gallery Application Version. + :vartype safety_profile: ~azure.mgmt.compute.models.GalleryApplicationVersionSafetyProfile + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". + :vartype provisioning_state: str or ~azure.mgmt.compute.models.GalleryProvisioningState + :ivar replication_status: This is the replication status of the gallery image version. + :vartype replication_status: ~azure.mgmt.compute.models.ReplicationStatus """ _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, "provisioning_state": {"readonly": True}, - "restore_point_collection_id": {"readonly": True}, - "restore_points": {"readonly": True}, + "replication_status": {"readonly": True}, } _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, "tags": {"key": "tags", "type": "{str}"}, - "source": {"key": "properties.source", "type": "RestorePointCollectionSourceProperties"}, + "publishing_profile": { + "key": "properties.publishingProfile", + "type": "GalleryApplicationVersionPublishingProfile", + }, + "safety_profile": {"key": "properties.safetyProfile", "type": "GalleryApplicationVersionSafetyProfile"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "restore_point_collection_id": {"key": "properties.restorePointCollectionId", "type": "str"}, - "restore_points": {"key": "properties.restorePoints", "type": "[RestorePoint]"}, + "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source: Optional["_models.RestorePointCollectionSourceProperties"] = None, + publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, + safety_profile: Optional["_models.GalleryApplicationVersionSafetyProfile"] = None, **kwargs: Any ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword source: The properties of the source resource that this restore point collection is - created from. - :paramtype source: - ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionSourceProperties + :keyword publishing_profile: The publishing profile of a gallery image version. + :paramtype publishing_profile: + ~azure.mgmt.compute.models.GalleryApplicationVersionPublishingProfile + :keyword safety_profile: The safety profile of the Gallery Application Version. + :paramtype safety_profile: ~azure.mgmt.compute.models.GalleryApplicationVersionSafetyProfile """ super().__init__(tags=tags, **kwargs) - self.source = source - self.provisioning_state: Optional[str] = None - self.restore_point_collection_id: Optional[str] = None - self.restore_points: Optional[List["_models.RestorePoint"]] = None + self.publishing_profile = publishing_profile + self.safety_profile = safety_profile + self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None + self.replication_status: Optional["_models.ReplicationStatus"] = None -class RestorePointEncryption(_serialization.Model): - """Encryption at rest settings for disk restore point. It is an optional property that can be - specified in the input while creating a restore point. +class GalleryArtifactSource(_serialization.Model): + """The source image from which the Image Version is going to be created. - :ivar disk_encryption_set: Describes the parameter of customer managed disk encryption set - resource id that can be specified for disk. **Note:** The disk encryption set resource id can - only be specified for managed disk. Please refer https://aka.ms/mdssewithcmkoverview for more - details. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSetParameters - :ivar type: The type of key used to encrypt the data of the disk restore point. Known values - are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and - "EncryptionAtRestWithPlatformAndCustomerKeys". - :vartype type: str or ~azure.mgmt.compute.v2024_11_01.models.RestorePointEncryptionType + 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.models.ManagedArtifact """ + _validation = { + "managed_image": {"required": True}, + } + _attribute_map = { - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - "type": {"key": "type", "type": "str"}, + "managed_image": {"key": "managedImage", "type": "ManagedArtifact"}, } - def __init__( - self, - *, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - type: Optional[Union[str, "_models.RestorePointEncryptionType"]] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, managed_image: "_models.ManagedArtifact", **kwargs: Any) -> None: """ - :keyword disk_encryption_set: Describes the parameter of customer managed disk encryption set - resource id that can be specified for disk. **Note:** The disk encryption set resource id can - only be specified for managed disk. Please refer https://aka.ms/mdssewithcmkoverview for more - details. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSetParameters - :keyword type: The type of key used to encrypt the data of the disk restore point. Known values - are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and - "EncryptionAtRestWithPlatformAndCustomerKeys". - :paramtype type: str or ~azure.mgmt.compute.v2024_11_01.models.RestorePointEncryptionType + :keyword managed_image: The managed artifact. Required. + :paramtype managed_image: ~azure.mgmt.compute.models.ManagedArtifact """ super().__init__(**kwargs) - self.disk_encryption_set = disk_encryption_set - self.type = type + self.managed_image = managed_image -class RestorePointInstanceView(_serialization.Model): - """The instance view of a restore point. +class GalleryArtifactVersionSource(_serialization.Model): + """The gallery artifact version source. - :ivar disk_restore_points: The disk restore points information. - :vartype disk_restore_points: - list[~azure.mgmt.compute.v2024_11_01.models.DiskRestorePointInstanceView] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :ivar id: The id of the gallery artifact version source. + :vartype id: str """ _attribute_map = { - "disk_restore_points": {"key": "diskRestorePoints", "type": "[DiskRestorePointInstanceView]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - disk_restore_points: Optional[List["_models.DiskRestorePointInstanceView"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin """ - :keyword disk_restore_points: The disk restore points information. - :paramtype disk_restore_points: - list[~azure.mgmt.compute.v2024_11_01.models.DiskRestorePointInstanceView] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :keyword id: The id of the gallery artifact version source. + :paramtype id: str """ super().__init__(**kwargs) - self.disk_restore_points = disk_restore_points - self.statuses = statuses + self.id = id -class RestorePointSourceMetadata(_serialization.Model): - """Describes the properties of the Virtual Machine for which the restore point was created. The - properties provided are a subset and the snapshot of the overall Virtual Machine properties - captured at the time of the restore point creation. +class GalleryArtifactVersionFullSource(GalleryArtifactVersionSource): + """The source of the gallery artifact version. - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar hardware_profile: Gets the hardware profile. - :vartype hardware_profile: ~azure.mgmt.compute.v2024_11_01.models.HardwareProfile - :ivar storage_profile: Gets the storage profile. - :vartype storage_profile: - ~azure.mgmt.compute.v2024_11_01.models.RestorePointSourceVMStorageProfile - :ivar os_profile: Gets the OS profile. - :vartype os_profile: ~azure.mgmt.compute.v2024_11_01.models.OSProfile - :ivar diagnostics_profile: Gets the diagnostics profile. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2024_11_01.models.DiagnosticsProfile - :ivar license_type: Gets the license type, which is for bring your own license scenario. - :vartype license_type: str - :ivar vm_id: Gets the virtual machine unique id. - :vartype vm_id: str - :ivar security_profile: Gets the security profile. - :vartype security_profile: ~azure.mgmt.compute.v2024_11_01.models.SecurityProfile - :ivar location: Location of the VM from which the restore point was created. - :vartype location: str - :ivar user_data: UserData associated with the source VM for which restore point is captured, - which is a base-64 encoded value. - :vartype user_data: str - :ivar hyper_v_generation: HyperVGeneration of the source VM for which restore point is - captured. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or - ~azure.mgmt.compute.v2024_11_01.models.HyperVGenerationTypes + :ivar id: The id of the gallery artifact version source. + :vartype id: str + :ivar community_gallery_image_id: The resource Id of the source Community Gallery Image. Only + required when using Community Gallery Image as a source. + :vartype community_gallery_image_id: str + :ivar virtual_machine_id: The resource Id of the source virtual machine. Only required when + capturing a virtual machine to source this Gallery Image Version. + :vartype virtual_machine_id: str """ - _validation = { - "hardware_profile": {"readonly": True}, - "os_profile": {"readonly": True}, - "diagnostics_profile": {"readonly": True}, - "license_type": {"readonly": True}, - "vm_id": {"readonly": True}, - "security_profile": {"readonly": True}, - "location": {"readonly": True}, - "user_data": {"readonly": True}, - "hyper_v_generation": {"readonly": True}, - } - _attribute_map = { - "hardware_profile": {"key": "hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "storageProfile", "type": "RestorePointSourceVMStorageProfile"}, - "os_profile": {"key": "osProfile", "type": "OSProfile"}, - "diagnostics_profile": {"key": "diagnosticsProfile", "type": "DiagnosticsProfile"}, - "license_type": {"key": "licenseType", "type": "str"}, - "vm_id": {"key": "vmId", "type": "str"}, - "security_profile": {"key": "securityProfile", "type": "SecurityProfile"}, - "location": {"key": "location", "type": "str"}, - "user_data": {"key": "userData", "type": "str"}, - "hyper_v_generation": {"key": "hyperVGeneration", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "community_gallery_image_id": {"key": "communityGalleryImageId", "type": "str"}, + "virtual_machine_id": {"key": "virtualMachineId", "type": "str"}, } def __init__( - self, *, storage_profile: Optional["_models.RestorePointSourceVMStorageProfile"] = None, **kwargs: Any + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + community_gallery_image_id: Optional[str] = None, + virtual_machine_id: Optional[str] = None, + **kwargs: Any ) -> None: """ - :keyword storage_profile: Gets the storage profile. - :paramtype storage_profile: - ~azure.mgmt.compute.v2024_11_01.models.RestorePointSourceVMStorageProfile + :keyword id: The id of the gallery artifact version source. + :paramtype id: str + :keyword community_gallery_image_id: The resource Id of the source Community Gallery Image. + Only required when using Community Gallery Image as a source. + :paramtype community_gallery_image_id: str + :keyword virtual_machine_id: The resource Id of the source virtual machine. Only required when + capturing a virtual machine to source this Gallery Image Version. + :paramtype virtual_machine_id: str """ - super().__init__(**kwargs) - self.hardware_profile: Optional["_models.HardwareProfile"] = None - self.storage_profile = storage_profile - self.os_profile: Optional["_models.OSProfile"] = None - self.diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None - self.license_type: Optional[str] = None - self.vm_id: Optional[str] = None - self.security_profile: Optional["_models.SecurityProfile"] = None - self.location: Optional[str] = None - self.user_data: Optional[str] = None - self.hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None + super().__init__(id=id, **kwargs) + self.community_gallery_image_id = community_gallery_image_id + self.virtual_machine_id = virtual_machine_id -class RestorePointSourceVMDataDisk(_serialization.Model): - """Describes a data disk. +class GalleryDiskImage(_serialization.Model): + """This is the disk image base class. Variables are only populated by the server, and will be ignored when sending a request. - :ivar lun: Gets the logical unit number. - :vartype lun: int - :ivar name: Gets the disk name. - :vartype name: str - :ivar caching: Gets the caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes - :ivar disk_size_gb: Gets the initial disk size in GB for blank data disks, and the new desired - size for existing OS and Data disks. - :vartype disk_size_gb: int - :ivar managed_disk: Contains the managed disk details. - :vartype managed_disk: ~azure.mgmt.compute.v2024_11_01.models.ManagedDiskParameters - :ivar disk_restore_point: Contains Disk Restore Point properties. - :vartype disk_restore_point: ~azure.mgmt.compute.v2024_11_01.models.DiskRestorePointAttributes - :ivar write_accelerator_enabled: Shows true if the disk is write-accelerator enabled. - :vartype write_accelerator_enabled: bool + :ivar size_in_gb: This property indicates the size of the VHD to be created. + :vartype size_in_gb: int + :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and + 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". + :vartype host_caching: str or ~azure.mgmt.compute.models.HostCaching + :ivar source: The source for the disk image. + :vartype source: ~azure.mgmt.compute.models.GalleryDiskImageSource """ _validation = { - "lun": {"readonly": True}, - "name": {"readonly": True}, - "caching": {"readonly": True}, - "disk_size_gb": {"readonly": True}, - "write_accelerator_enabled": {"readonly": True}, + "size_in_gb": {"readonly": True}, } _attribute_map = { - "lun": {"key": "lun", "type": "int"}, - "name": {"key": "name", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, - "disk_restore_point": {"key": "diskRestorePoint", "type": "DiskRestorePointAttributes"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "host_caching": {"key": "hostCaching", "type": "str"}, + "source": {"key": "source", "type": "GalleryDiskImageSource"}, } def __init__( self, *, - managed_disk: Optional["_models.ManagedDiskParameters"] = None, - disk_restore_point: Optional["_models.DiskRestorePointAttributes"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryDiskImageSource"] = None, **kwargs: Any ) -> None: """ - :keyword managed_disk: Contains the managed disk details. - :paramtype managed_disk: ~azure.mgmt.compute.v2024_11_01.models.ManagedDiskParameters - :keyword disk_restore_point: Contains Disk Restore Point properties. - :paramtype disk_restore_point: - ~azure.mgmt.compute.v2024_11_01.models.DiskRestorePointAttributes + :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.models.HostCaching + :keyword source: The source for the disk image. + :paramtype source: ~azure.mgmt.compute.models.GalleryDiskImageSource """ super().__init__(**kwargs) - self.lun: Optional[int] = None - self.name: Optional[str] = None - self.caching: Optional[Union[str, "_models.CachingTypes"]] = None - self.disk_size_gb: Optional[int] = None - self.managed_disk = managed_disk - self.disk_restore_point = disk_restore_point - self.write_accelerator_enabled: Optional[bool] = None + self.size_in_gb: Optional[int] = None + self.host_caching = host_caching + self.source = source -class RestorePointSourceVMOSDisk(_serialization.Model): - """Describes an Operating System disk. +class GalleryDataDiskImage(GalleryDiskImage): + """This is the data disk image. Variables are only populated by the server, and will be ignored when sending a request. - :ivar os_type: Gets the Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2024_11_01.models.OperatingSystemType - :ivar encryption_settings: Gets the disk encryption settings. - :vartype encryption_settings: ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSettings - :ivar name: Gets the disk name. - :vartype name: str - :ivar caching: Gets the caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes - :ivar disk_size_gb: Gets the disk size in GB. - :vartype disk_size_gb: int - :ivar managed_disk: Gets the managed disk details. - :vartype managed_disk: ~azure.mgmt.compute.v2024_11_01.models.ManagedDiskParameters - :ivar disk_restore_point: Contains Disk Restore Point properties. - :vartype disk_restore_point: ~azure.mgmt.compute.v2024_11_01.models.DiskRestorePointAttributes - :ivar write_accelerator_enabled: Shows true if the disk is write-accelerator enabled. - :vartype write_accelerator_enabled: bool + All required parameters must be populated in order to send to server. + + :ivar size_in_gb: This property indicates the size of the VHD to be created. + :vartype size_in_gb: int + :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and + 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". + :vartype host_caching: str or ~azure.mgmt.compute.models.HostCaching + :ivar source: The source for the disk image. + :vartype source: ~azure.mgmt.compute.models.GalleryDiskImageSource + :ivar 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. + :vartype lun: int """ _validation = { - "os_type": {"readonly": True}, - "encryption_settings": {"readonly": True}, - "name": {"readonly": True}, - "caching": {"readonly": True}, - "disk_size_gb": {"readonly": True}, - "write_accelerator_enabled": {"readonly": True}, + "size_in_gb": {"readonly": True}, + "lun": {"required": True}, } _attribute_map = { - "os_type": {"key": "osType", "type": "str"}, - "encryption_settings": {"key": "encryptionSettings", "type": "DiskEncryptionSettings"}, - "name": {"key": "name", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, - "disk_restore_point": {"key": "diskRestorePoint", "type": "DiskRestorePointAttributes"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, + "size_in_gb": {"key": "sizeInGB", "type": "int"}, + "host_caching": {"key": "hostCaching", "type": "str"}, + "source": {"key": "source", "type": "GalleryDiskImageSource"}, + "lun": {"key": "lun", "type": "int"}, } def __init__( self, *, - managed_disk: Optional["_models.ManagedDiskParameters"] = None, - disk_restore_point: Optional["_models.DiskRestorePointAttributes"] = None, + lun: int, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryDiskImageSource"] = None, **kwargs: Any ) -> None: """ - :keyword managed_disk: Gets the managed disk details. - :paramtype managed_disk: ~azure.mgmt.compute.v2024_11_01.models.ManagedDiskParameters - :keyword disk_restore_point: Contains Disk Restore Point properties. - :paramtype disk_restore_point: - ~azure.mgmt.compute.v2024_11_01.models.DiskRestorePointAttributes + :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.models.HostCaching + :keyword source: The source for the disk image. + :paramtype source: ~azure.mgmt.compute.models.GalleryDiskImageSource + :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__(**kwargs) - self.os_type: Optional[Union[str, "_models.OperatingSystemType"]] = None - self.encryption_settings: Optional["_models.DiskEncryptionSettings"] = None - self.name: Optional[str] = None - self.caching: Optional[Union[str, "_models.CachingTypes"]] = None - self.disk_size_gb: Optional[int] = None - self.managed_disk = managed_disk - self.disk_restore_point = disk_restore_point - self.write_accelerator_enabled: Optional[bool] = None - + super().__init__(host_caching=host_caching, source=source, **kwargs) + self.lun = lun -class RestorePointSourceVMStorageProfile(_serialization.Model): - """Describes the storage profile. - Variables are only populated by the server, and will be ignored when sending a request. +class GalleryDiskImageSource(GalleryArtifactVersionSource): + """The source for the disk image. - :ivar os_disk: Gets the OS disk of the VM captured at the time of the restore point creation. - :vartype os_disk: ~azure.mgmt.compute.v2024_11_01.models.RestorePointSourceVMOSDisk - :ivar data_disks: Gets the data disks of the VM captured at the time of the restore point - creation. - :vartype data_disks: list[~azure.mgmt.compute.v2024_11_01.models.RestorePointSourceVMDataDisk] - :ivar disk_controller_type: Gets the disk controller type of the VM captured at the time of the - restore point creation. Known values are: "SCSI" and "NVMe". - :vartype disk_controller_type: str or - ~azure.mgmt.compute.v2024_11_01.models.DiskControllerTypes + :ivar id: The id of the gallery artifact version source. + :vartype id: str + :ivar uri: The uri of the gallery artifact version source. Currently used to specify vhd/blob + source. + :vartype uri: str + :ivar storage_account_id: The Storage Account Id that contains the vhd blob being used as a + source for this artifact version. + :vartype storage_account_id: str """ - _validation = { - "disk_controller_type": {"readonly": True}, + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "storage_account_id": {"key": "storageAccountId", "type": "str"}, } + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + uri: Optional[str] = None, + storage_account_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The id of the gallery artifact version source. + :paramtype id: str + :keyword uri: The uri of the gallery artifact version source. Currently used to specify + vhd/blob source. + :paramtype uri: str + :keyword storage_account_id: The Storage Account Id that contains the vhd blob being used as a + source for this artifact version. + :paramtype storage_account_id: str + """ + super().__init__(id=id, **kwargs) + self.uri = uri + self.storage_account_id = storage_account_id + + +class GalleryExtendedLocation(_serialization.Model): + """The name of the extended location. + + :ivar name: + :vartype name: str + :ivar type: It is type of the extended location. Known values are: "EdgeZone" and "Unknown". + :vartype type: str or ~azure.mgmt.compute.models.GalleryExtendedLocationType + """ + _attribute_map = { - "os_disk": {"key": "osDisk", "type": "RestorePointSourceVMOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[RestorePointSourceVMDataDisk]"}, - "disk_controller_type": {"key": "diskControllerType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( self, *, - os_disk: Optional["_models.RestorePointSourceVMOSDisk"] = None, - data_disks: Optional[List["_models.RestorePointSourceVMDataDisk"]] = None, + name: Optional[str] = None, + type: Optional[Union[str, "_models.GalleryExtendedLocationType"]] = None, **kwargs: Any ) -> None: """ - :keyword os_disk: Gets the OS disk of the VM captured at the time of the restore point - creation. - :paramtype os_disk: ~azure.mgmt.compute.v2024_11_01.models.RestorePointSourceVMOSDisk - :keyword data_disks: Gets the data disks of the VM captured at the time of the restore point - creation. - :paramtype data_disks: - list[~azure.mgmt.compute.v2024_11_01.models.RestorePointSourceVMDataDisk] + :keyword name: + :paramtype name: str + :keyword type: It is type of the extended location. Known values are: "EdgeZone" and "Unknown". + :paramtype type: str or ~azure.mgmt.compute.models.GalleryExtendedLocationType """ super().__init__(**kwargs) - self.os_disk = os_disk - self.data_disks = data_disks - self.disk_controller_type: Optional[Union[str, "_models.DiskControllerTypes"]] = None + self.name = name + self.type = type -class RetrieveBootDiagnosticsDataResult(_serialization.Model): - """The SAS URIs of the console screenshot and serial log blobs. +class GalleryIdentifier(_serialization.Model): + """Describes the gallery unique name. Variables are only populated by the server, and will be ignored when sending a request. - :ivar console_screenshot_blob_uri: The console screenshot blob URI. - :vartype console_screenshot_blob_uri: str - :ivar serial_console_log_blob_uri: The serial console log blob URI. - :vartype serial_console_log_blob_uri: str + :ivar unique_name: The unique name of the Shared Image Gallery. This name is generated + automatically by Azure. + :vartype unique_name: str """ _validation = { - "console_screenshot_blob_uri": {"readonly": True}, - "serial_console_log_blob_uri": {"readonly": True}, + "unique_name": {"readonly": True}, } _attribute_map = { - "console_screenshot_blob_uri": {"key": "consoleScreenshotBlobUri", "type": "str"}, - "serial_console_log_blob_uri": {"key": "serialConsoleLogBlobUri", "type": "str"}, + "unique_name": {"key": "uniqueName", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.console_screenshot_blob_uri: Optional[str] = None - self.serial_console_log_blob_uri: Optional[str] = None + self.unique_name: Optional[str] = None -class RollbackStatusInfo(_serialization.Model): - """Information about rollback on failed VM instances after a OS Upgrade operation. +class GalleryImage(ResourceAutoGenerated): + """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. - :ivar successfully_rolledback_instance_count: The number of instances which have been - successfully rolled back. - :vartype successfully_rolledback_instance_count: int - :ivar failed_rolledback_instance_count: The number of instances which failed to rollback. - :vartype failed_rolledback_instance_count: int - :ivar rollback_error: Error details if OS rollback failed. - :vartype rollback_error: ~azure.mgmt.compute.v2024_11_01.models.ApiError + 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] + :ivar description: The description of this gallery image definition resource. This property is + updatable. + :vartype description: str + :ivar eula: The Eula agreement for the gallery image definition. + :vartype eula: str + :ivar privacy_statement_uri: The privacy statement uri. + :vartype privacy_statement_uri: str + :ivar release_note_uri: The release note uri. + :vartype release_note_uri: str + :ivar 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". + :vartype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :ivar 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". + :vartype os_state: str or ~azure.mgmt.compute.models.OperatingSystemStateTypes + :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS + disks only. Known values are: "V1" and "V2". + :vartype hyper_v_generation: str or ~azure.mgmt.compute.models.HyperVGeneration + :ivar 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. + :vartype end_of_life_date: ~datetime.datetime + :ivar identifier: This is the gallery image definition identifier. + :vartype identifier: ~azure.mgmt.compute.models.GalleryImageIdentifier + :ivar recommended: The properties describe the recommended machine configuration for this Image + Definition. These properties are updatable. + :vartype recommended: ~azure.mgmt.compute.models.RecommendedMachineConfiguration + :ivar disallowed: Describes the disallowed disk types. + :vartype disallowed: ~azure.mgmt.compute.models.Disallowed + :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by + marketplace images. + :vartype purchase_plan: ~azure.mgmt.compute.models.ImagePurchasePlan + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". + :vartype provisioning_state: str or ~azure.mgmt.compute.models.GalleryProvisioningState + :ivar features: A list of gallery image features. + :vartype features: list[~azure.mgmt.compute.models.GalleryImageFeature] + :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values + are: "x64" and "Arm64". + :vartype architecture: str or ~azure.mgmt.compute.models.Architecture """ _validation = { - "successfully_rolledback_instance_count": {"readonly": True}, - "failed_rolledback_instance_count": {"readonly": True}, - "rollback_error": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - "successfully_rolledback_instance_count": {"key": "successfullyRolledbackInstanceCount", "type": "int"}, - "failed_rolledback_instance_count": {"key": "failedRolledbackInstanceCount", "type": "int"}, - "rollback_error": {"key": "rollbackError", "type": "ApiError"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.successfully_rolledback_instance_count: Optional[int] = None - self.failed_rolledback_instance_count: Optional[int] = None - self.rollback_error: Optional["_models.ApiError"] = None + "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}"}, + "description": {"key": "properties.description", "type": "str"}, + "eula": {"key": "properties.eula", "type": "str"}, + "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, + "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, + "os_type": {"key": "properties.osType", "type": "str"}, + "os_state": {"key": "properties.osState", "type": "str"}, + "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, + "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, + "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, + "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, + "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, + "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "features": {"key": "properties.features", "type": "[GalleryImageFeature]"}, + "architecture": {"key": "properties.architecture", "type": "str"}, + } + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + description: Optional[str] = None, + eula: Optional[str] = None, + privacy_statement_uri: Optional[str] = None, + release_note_uri: Optional[str] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + end_of_life_date: Optional[datetime.datetime] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, + features: Optional[List["_models.GalleryImageFeature"]] = None, + architecture: Optional[Union[str, "_models.Architecture"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword description: The description of this gallery image definition resource. This property + is updatable. + :paramtype description: str + :keyword eula: The Eula agreement for the gallery image definition. + :paramtype eula: str + :keyword privacy_statement_uri: The privacy statement uri. + :paramtype privacy_statement_uri: str + :keyword release_note_uri: The release note uri. + :paramtype release_note_uri: 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.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.models.OperatingSystemStateTypes + :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.models.HyperVGeneration + :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.models.GalleryImageIdentifier + :keyword recommended: The properties describe the recommended machine configuration for this + Image Definition. These properties are updatable. + :paramtype recommended: ~azure.mgmt.compute.models.RecommendedMachineConfiguration + :keyword disallowed: Describes the disallowed disk types. + :paramtype disallowed: ~azure.mgmt.compute.models.Disallowed + :keyword purchase_plan: Describes the gallery image definition purchase plan. This is used by + marketplace images. + :paramtype purchase_plan: ~azure.mgmt.compute.models.ImagePurchasePlan + :keyword features: A list of gallery image features. + :paramtype features: list[~azure.mgmt.compute.models.GalleryImageFeature] + :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.models.Architecture + """ + super().__init__(location=location, tags=tags, **kwargs) + self.description = description + self.eula = eula + self.privacy_statement_uri = privacy_statement_uri + self.release_note_uri = release_note_uri + self.os_type = os_type + self.os_state = os_state + self.hyper_v_generation = hyper_v_generation + self.end_of_life_date = end_of_life_date + self.identifier = identifier + self.recommended = recommended + self.disallowed = disallowed + self.purchase_plan = purchase_plan + self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None + self.features = features + self.architecture = architecture -class RollingUpgradePolicy(_serialization.Model): - """The configuration parameters used while performing a rolling upgrade. - :ivar max_batch_instance_percent: The maximum percent of total virtual machine instances that - will be upgraded simultaneously by the rolling upgrade in one batch. As this is a maximum, - unhealthy instances in previous or future batches can cause the percentage of instances in a - batch to decrease to ensure higher reliability. The default value for this parameter is 20%. - :vartype max_batch_instance_percent: int - :ivar max_unhealthy_instance_percent: The maximum percentage of the total virtual machine - instances in the scale set that can be simultaneously unhealthy, either as a result of being - upgraded, or by being found in an unhealthy state by the virtual machine health checks before - the rolling upgrade aborts. This constraint will be checked prior to starting any batch. The - default value for this parameter is 20%. - :vartype max_unhealthy_instance_percent: int - :ivar max_unhealthy_upgraded_instance_percent: The maximum percentage of upgraded virtual - machine instances that can be found to be in an unhealthy state. This check will happen after - each batch is upgraded. If this percentage is ever exceeded, the rolling update aborts. The - default value for this parameter is 20%. - :vartype max_unhealthy_upgraded_instance_percent: int - :ivar pause_time_between_batches: The wait time between completing the update for all virtual - machines in one batch and starting the next batch. The time duration should be specified in ISO - 8601 format. The default value is 0 seconds (PT0S). - :vartype pause_time_between_batches: str - :ivar enable_cross_zone_upgrade: Allow VMSS to ignore AZ boundaries when constructing upgrade - batches. Take into consideration the Update Domain and maxBatchInstancePercent to determine the - batch size. - :vartype enable_cross_zone_upgrade: bool - :ivar prioritize_unhealthy_instances: Upgrade all unhealthy instances in a scale set before any - healthy instances. - :vartype prioritize_unhealthy_instances: bool - :ivar rollback_failed_instances_on_policy_breach: Rollback failed instances to previous model - if the Rolling Upgrade policy is violated. - :vartype rollback_failed_instances_on_policy_breach: bool - :ivar max_surge: Create new virtual machines to upgrade the scale set, rather than updating the - existing virtual machines. Existing virtual machines will be deleted once the new virtual - machines are created for each batch. - :vartype max_surge: bool +class GalleryImageFeature(_serialization.Model): + """A feature for gallery image. + + :ivar name: The name of the gallery image feature. + :vartype name: str + :ivar value: The value of the gallery image feature. + :vartype value: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, value: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: The name of the gallery image feature. + :paramtype name: str + :keyword value: The value of the gallery image feature. + :paramtype value: str + """ + super().__init__(**kwargs) + self.name = name + self.value = value + + +class GalleryImageIdentifier(_serialization.Model): + """This is the gallery image definition identifier. + + All required parameters must be populated in order to send to server. + + :ivar publisher: The name of the gallery image definition publisher. Required. + :vartype publisher: str + :ivar offer: The name of the gallery image definition offer. Required. + :vartype offer: str + :ivar sku: The name of the gallery image definition SKU. Required. + :vartype sku: str """ _validation = { - "max_batch_instance_percent": {"maximum": 100, "minimum": 5}, - "max_unhealthy_instance_percent": {"maximum": 100, "minimum": 5}, - "max_unhealthy_upgraded_instance_percent": {"maximum": 100}, + "publisher": {"required": True}, + "offer": {"required": True}, + "sku": {"required": True}, } _attribute_map = { - "max_batch_instance_percent": {"key": "maxBatchInstancePercent", "type": "int"}, - "max_unhealthy_instance_percent": {"key": "maxUnhealthyInstancePercent", "type": "int"}, - "max_unhealthy_upgraded_instance_percent": {"key": "maxUnhealthyUpgradedInstancePercent", "type": "int"}, - "pause_time_between_batches": {"key": "pauseTimeBetweenBatches", "type": "str"}, - "enable_cross_zone_upgrade": {"key": "enableCrossZoneUpgrade", "type": "bool"}, - "prioritize_unhealthy_instances": {"key": "prioritizeUnhealthyInstances", "type": "bool"}, - "rollback_failed_instances_on_policy_breach": {"key": "rollbackFailedInstancesOnPolicyBreach", "type": "bool"}, - "max_surge": {"key": "maxSurge", "type": "bool"}, + "publisher": {"key": "publisher", "type": "str"}, + "offer": {"key": "offer", "type": "str"}, + "sku": {"key": "sku", "type": "str"}, } - def __init__( - self, - *, - max_batch_instance_percent: Optional[int] = None, - max_unhealthy_instance_percent: Optional[int] = None, - max_unhealthy_upgraded_instance_percent: Optional[int] = None, - pause_time_between_batches: Optional[str] = None, - enable_cross_zone_upgrade: Optional[bool] = None, - prioritize_unhealthy_instances: Optional[bool] = None, - rollback_failed_instances_on_policy_breach: Optional[bool] = None, - max_surge: Optional[bool] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, publisher: str, offer: str, sku: str, **kwargs: Any) -> None: """ - :keyword max_batch_instance_percent: The maximum percent of total virtual machine instances - that will be upgraded simultaneously by the rolling upgrade in one batch. As this is a maximum, - unhealthy instances in previous or future batches can cause the percentage of instances in a - batch to decrease to ensure higher reliability. The default value for this parameter is 20%. - :paramtype max_batch_instance_percent: int - :keyword max_unhealthy_instance_percent: The maximum percentage of the total virtual machine - instances in the scale set that can be simultaneously unhealthy, either as a result of being - upgraded, or by being found in an unhealthy state by the virtual machine health checks before - the rolling upgrade aborts. This constraint will be checked prior to starting any batch. The - default value for this parameter is 20%. - :paramtype max_unhealthy_instance_percent: int - :keyword max_unhealthy_upgraded_instance_percent: The maximum percentage of upgraded virtual - machine instances that can be found to be in an unhealthy state. This check will happen after - each batch is upgraded. If this percentage is ever exceeded, the rolling update aborts. The - default value for this parameter is 20%. - :paramtype max_unhealthy_upgraded_instance_percent: int - :keyword pause_time_between_batches: The wait time between completing the update for all - virtual machines in one batch and starting the next batch. The time duration should be - specified in ISO 8601 format. The default value is 0 seconds (PT0S). - :paramtype pause_time_between_batches: str - :keyword enable_cross_zone_upgrade: Allow VMSS to ignore AZ boundaries when constructing - upgrade batches. Take into consideration the Update Domain and maxBatchInstancePercent to - determine the batch size. - :paramtype enable_cross_zone_upgrade: bool - :keyword prioritize_unhealthy_instances: Upgrade all unhealthy instances in a scale set before - any healthy instances. - :paramtype prioritize_unhealthy_instances: bool - :keyword rollback_failed_instances_on_policy_breach: Rollback failed instances to previous - model if the Rolling Upgrade policy is violated. - :paramtype rollback_failed_instances_on_policy_breach: bool - :keyword max_surge: Create new virtual machines to upgrade the scale set, rather than updating - the existing virtual machines. Existing virtual machines will be deleted once the new virtual - machines are created for each batch. - :paramtype max_surge: bool + :keyword publisher: The name of the gallery image definition publisher. Required. + :paramtype publisher: str + :keyword offer: The name of the gallery image definition offer. Required. + :paramtype offer: str + :keyword sku: The name of the gallery image definition SKU. Required. + :paramtype sku: str """ super().__init__(**kwargs) - self.max_batch_instance_percent = max_batch_instance_percent - self.max_unhealthy_instance_percent = max_unhealthy_instance_percent - self.max_unhealthy_upgraded_instance_percent = max_unhealthy_upgraded_instance_percent - self.pause_time_between_batches = pause_time_between_batches - self.enable_cross_zone_upgrade = enable_cross_zone_upgrade - self.prioritize_unhealthy_instances = prioritize_unhealthy_instances - self.rollback_failed_instances_on_policy_breach = rollback_failed_instances_on_policy_breach - self.max_surge = max_surge + self.publisher = publisher + self.offer = offer + self.sku = sku -class RollingUpgradeProgressInfo(_serialization.Model): - """Information about the number of virtual machine instances in each upgrade state. +class GalleryImageList(_serialization.Model): + """The List Gallery Images operation response. - 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 successful_instance_count: The number of instances that have been successfully upgraded. - :vartype successful_instance_count: int - :ivar failed_instance_count: The number of instances that have failed to be upgraded - successfully. - :vartype failed_instance_count: int - :ivar in_progress_instance_count: The number of instances that are currently being upgraded. - :vartype in_progress_instance_count: int - :ivar pending_instance_count: The number of instances that have not yet begun to be upgraded. - :vartype pending_instance_count: int + :ivar value: A list of Shared Image Gallery images. Required. + :vartype value: list[~azure.mgmt.compute.models.GalleryImage] + :ivar next_link: The uri to fetch the next page of Image Definitions in the Shared Image + Gallery. Call ListNext() with this to fetch the next page of gallery image definitions. + :vartype next_link: str """ _validation = { - "successful_instance_count": {"readonly": True}, - "failed_instance_count": {"readonly": True}, - "in_progress_instance_count": {"readonly": True}, - "pending_instance_count": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { - "successful_instance_count": {"key": "successfulInstanceCount", "type": "int"}, - "failed_instance_count": {"key": "failedInstanceCount", "type": "int"}, - "in_progress_instance_count": {"key": "inProgressInstanceCount", "type": "int"}, - "pending_instance_count": {"key": "pendingInstanceCount", "type": "int"}, + "value": {"key": "value", "type": "[GalleryImage]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, value: List["_models.GalleryImage"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of Shared Image Gallery images. Required. + :paramtype value: list[~azure.mgmt.compute.models.GalleryImage] + :keyword next_link: The uri to fetch the next page of Image Definitions in the Shared Image + Gallery. Call ListNext() with this to fetch the next page of gallery image definitions. + :paramtype next_link: str + """ super().__init__(**kwargs) - self.successful_instance_count: Optional[int] = None - self.failed_instance_count: Optional[int] = None - self.in_progress_instance_count: Optional[int] = None - self.pending_instance_count: Optional[int] = None + self.value = value + self.next_link = next_link -class RollingUpgradeRunningStatus(_serialization.Model): - """Information about the current running state of the overall upgrade. +class GalleryImageUpdate(UpdateResourceDefinition): + """Specifies information about the gallery image definition that you want to update. Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Known values are: - "RollingForward", "Cancelled", "Completed", and "Faulted". - :vartype code: str or ~azure.mgmt.compute.v2024_11_01.models.RollingUpgradeStatusCode - :ivar start_time: Start time of the upgrade. - :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start" - and "Cancel". - :vartype last_action: str or ~azure.mgmt.compute.v2024_11_01.models.RollingUpgradeActionType - :ivar last_action_time: Last action time of the upgrade. - :vartype last_action_time: ~datetime.datetime + :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] + :ivar description: The description of this gallery image definition resource. This property is + updatable. + :vartype description: str + :ivar eula: The Eula agreement for the gallery image definition. + :vartype eula: str + :ivar privacy_statement_uri: The privacy statement uri. + :vartype privacy_statement_uri: str + :ivar release_note_uri: The release note uri. + :vartype release_note_uri: str + :ivar 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". + :vartype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :ivar 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". + :vartype os_state: str or ~azure.mgmt.compute.models.OperatingSystemStateTypes + :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS + disks only. Known values are: "V1" and "V2". + :vartype hyper_v_generation: str or ~azure.mgmt.compute.models.HyperVGeneration + :ivar 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. + :vartype end_of_life_date: ~datetime.datetime + :ivar identifier: This is the gallery image definition identifier. + :vartype identifier: ~azure.mgmt.compute.models.GalleryImageIdentifier + :ivar recommended: The properties describe the recommended machine configuration for this Image + Definition. These properties are updatable. + :vartype recommended: ~azure.mgmt.compute.models.RecommendedMachineConfiguration + :ivar disallowed: Describes the disallowed disk types. + :vartype disallowed: ~azure.mgmt.compute.models.Disallowed + :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by + marketplace images. + :vartype purchase_plan: ~azure.mgmt.compute.models.ImagePurchasePlan + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". + :vartype provisioning_state: str or ~azure.mgmt.compute.models.GalleryProvisioningState + :ivar features: A list of gallery image features. + :vartype features: list[~azure.mgmt.compute.models.GalleryImageFeature] + :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values + are: "x64" and "Arm64". + :vartype architecture: str or ~azure.mgmt.compute.models.Architecture """ _validation = { - "code": {"readonly": True}, - "start_time": {"readonly": True}, - "last_action": {"readonly": True}, - "last_action_time": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - "code": {"key": "code", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "last_action": {"key": "lastAction", "type": "str"}, - "last_action_time": {"key": "lastActionTime", "type": "iso-8601"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "eula": {"key": "properties.eula", "type": "str"}, + "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, + "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, + "os_type": {"key": "properties.osType", "type": "str"}, + "os_state": {"key": "properties.osState", "type": "str"}, + "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, + "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, + "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, + "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, + "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, + "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "features": {"key": "properties.features", "type": "[GalleryImageFeature]"}, + "architecture": {"key": "properties.architecture", "type": "str"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + description: Optional[str] = None, + eula: Optional[str] = None, + privacy_statement_uri: Optional[str] = None, + release_note_uri: Optional[str] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + end_of_life_date: Optional[datetime.datetime] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, + features: Optional[List["_models.GalleryImageFeature"]] = None, + architecture: Optional[Union[str, "_models.Architecture"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword description: The description of this gallery image definition resource. This property + is updatable. + :paramtype description: str + :keyword eula: The Eula agreement for the gallery image definition. + :paramtype eula: str + :keyword privacy_statement_uri: The privacy statement uri. + :paramtype privacy_statement_uri: str + :keyword release_note_uri: The release note uri. + :paramtype release_note_uri: 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.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.models.OperatingSystemStateTypes + :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.models.HyperVGeneration + :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.models.GalleryImageIdentifier + :keyword recommended: The properties describe the recommended machine configuration for this + Image Definition. These properties are updatable. + :paramtype recommended: ~azure.mgmt.compute.models.RecommendedMachineConfiguration + :keyword disallowed: Describes the disallowed disk types. + :paramtype disallowed: ~azure.mgmt.compute.models.Disallowed + :keyword purchase_plan: Describes the gallery image definition purchase plan. This is used by + marketplace images. + :paramtype purchase_plan: ~azure.mgmt.compute.models.ImagePurchasePlan + :keyword features: A list of gallery image features. + :paramtype features: list[~azure.mgmt.compute.models.GalleryImageFeature] + :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.models.Architecture + """ + super().__init__(tags=tags, **kwargs) + self.description = description + self.eula = eula + self.privacy_statement_uri = privacy_statement_uri + self.release_note_uri = release_note_uri + self.os_type = os_type + self.os_state = os_state + self.hyper_v_generation = hyper_v_generation + self.end_of_life_date = end_of_life_date + self.identifier = identifier + self.recommended = recommended + self.disallowed = disallowed + self.purchase_plan = purchase_plan + self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None + self.features = features + self.architecture = architecture + + +class GalleryImageVersion(ResourceAutoGenerated): + """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. + :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] + :ivar publishing_profile: The publishing profile of a gallery image Version. + :vartype publishing_profile: ~azure.mgmt.compute.models.GalleryImageVersionPublishingProfile + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". + :vartype provisioning_state: str or ~azure.mgmt.compute.models.GalleryProvisioningState + :ivar storage_profile: This is the storage profile of a Gallery Image Version. + :vartype storage_profile: ~azure.mgmt.compute.models.GalleryImageVersionStorageProfile + :ivar safety_profile: This is the safety profile of the Gallery Image Version. + :vartype safety_profile: ~azure.mgmt.compute.models.GalleryImageVersionSafetyProfile + :ivar replication_status: This is the replication status of the gallery image version. + :vartype replication_status: ~azure.mgmt.compute.models.ReplicationStatus + :ivar security_profile: The security profile of a gallery image version. + :vartype security_profile: ~azure.mgmt.compute.models.ImageVersionSecurityProfile + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "replication_status": {"readonly": 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}"}, + "publishing_profile": {"key": "properties.publishingProfile", "type": "GalleryImageVersionPublishingProfile"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"}, + "safety_profile": {"key": "properties.safetyProfile", "type": "GalleryImageVersionSafetyProfile"}, + "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, + "security_profile": {"key": "properties.securityProfile", "type": "ImageVersionSecurityProfile"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, + storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, + safety_profile: Optional["_models.GalleryImageVersionSafetyProfile"] = None, + security_profile: Optional["_models.ImageVersionSecurityProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword publishing_profile: The publishing profile of a gallery image Version. + :paramtype publishing_profile: ~azure.mgmt.compute.models.GalleryImageVersionPublishingProfile + :keyword storage_profile: This is the storage profile of a Gallery Image Version. + :paramtype storage_profile: ~azure.mgmt.compute.models.GalleryImageVersionStorageProfile + :keyword safety_profile: This is the safety profile of the Gallery Image Version. + :paramtype safety_profile: ~azure.mgmt.compute.models.GalleryImageVersionSafetyProfile + :keyword security_profile: The security profile of a gallery image version. + :paramtype security_profile: ~azure.mgmt.compute.models.ImageVersionSecurityProfile + """ + super().__init__(location=location, tags=tags, **kwargs) + self.publishing_profile = publishing_profile + self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None + self.storage_profile = storage_profile + self.safety_profile = safety_profile + self.replication_status: Optional["_models.ReplicationStatus"] = None + self.security_profile = security_profile + + +class GalleryImageVersionList(_serialization.Model): + """The List Gallery Image version operation response. + + All required parameters must be populated in order to send to server. + + :ivar value: A list of gallery image versions. Required. + :vartype value: list[~azure.mgmt.compute.models.GalleryImageVersion] + :ivar next_link: The uri to fetch the next page of gallery image versions. Call ListNext() with + this to fetch the next page of gallery image versions. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[GalleryImageVersion]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.GalleryImageVersion"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: A list of gallery image versions. Required. + :paramtype value: list[~azure.mgmt.compute.models.GalleryImageVersion] + :keyword next_link: The uri to fetch the next page of gallery image versions. Call ListNext() + with this to fetch the next page of gallery image versions. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase): + """The publishing profile of a gallery image Version. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar target_regions: The target regions where the Image Version is going to be replicated to. + This property is updatable. + :vartype target_regions: list[~azure.mgmt.compute.models.TargetRegion] + :ivar replica_count: The number of replicas of the Image Version to be created per region. This + property would take effect for a region when regionalReplicaCount is not specified. This + property is updatable. + :vartype replica_count: int + :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of + the Image Definition won't use this Image Version. + :vartype exclude_from_latest: bool + :ivar published_date: The timestamp for when the gallery image version is published. + :vartype published_date: ~datetime.datetime + :ivar end_of_life_date: The end of life date of the gallery image version. This property can be + used for decommissioning purposes. This property is updatable. + :vartype end_of_life_date: ~datetime.datetime + :ivar storage_account_type: Specifies the storage account type to be used to store the image. + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and + "Premium_LRS". + :vartype storage_account_type: str or ~azure.mgmt.compute.models.StorageAccountType + :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. + This property is not updatable. Known values are: "Full" and "Shallow". + :vartype replication_mode: str or ~azure.mgmt.compute.models.ReplicationMode + :ivar target_extended_locations: The target extended locations where the Image Version is going + to be replicated to. This property is updatable. + :vartype target_extended_locations: + list[~azure.mgmt.compute.models.GalleryTargetExtendedLocation] + """ + + +class GalleryImageVersionSafetyProfile(GalleryArtifactSafetyProfileBase): + """This is the safety profile of the Gallery Image Version. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar allow_deletion_of_replicated_locations: Indicates whether or not removing this Gallery + Image Version from replicated regions is allowed. + :vartype allow_deletion_of_replicated_locations: bool + :ivar reported_for_policy_violation: Indicates whether this image has been reported as + violating Microsoft's policies. + :vartype reported_for_policy_violation: bool + :ivar policy_violations: A list of Policy Violations that have been reported for this Gallery + Image Version. + :vartype policy_violations: list[~azure.mgmt.compute.models.PolicyViolation] + """ + + _validation = { + "reported_for_policy_violation": {"readonly": True}, + "policy_violations": {"readonly": True}, + } + + _attribute_map = { + "allow_deletion_of_replicated_locations": {"key": "allowDeletionOfReplicatedLocations", "type": "bool"}, + "reported_for_policy_violation": {"key": "reportedForPolicyViolation", "type": "bool"}, + "policy_violations": {"key": "policyViolations", "type": "[PolicyViolation]"}, + } + + def __init__(self, *, allow_deletion_of_replicated_locations: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword allow_deletion_of_replicated_locations: Indicates whether or not removing this Gallery + Image Version from replicated regions is allowed. + :paramtype allow_deletion_of_replicated_locations: bool + """ + super().__init__(allow_deletion_of_replicated_locations=allow_deletion_of_replicated_locations, **kwargs) + self.reported_for_policy_violation: Optional[bool] = None + self.policy_violations: Optional[List["_models.PolicyViolation"]] = None + + +class GalleryImageVersionStorageProfile(_serialization.Model): + """This is the storage profile of a Gallery Image Version. + + :ivar source: The source of the gallery artifact version. + :vartype source: ~azure.mgmt.compute.models.GalleryArtifactVersionFullSource + :ivar os_disk_image: This is the OS disk image. + :vartype os_disk_image: ~azure.mgmt.compute.models.GalleryOSDiskImage + :ivar data_disk_images: A list of data disk images. + :vartype data_disk_images: list[~azure.mgmt.compute.models.GalleryDataDiskImage] + """ + + _attribute_map = { + "source": {"key": "source", "type": "GalleryArtifactVersionFullSource"}, + "os_disk_image": {"key": "osDiskImage", "type": "GalleryOSDiskImage"}, + "data_disk_images": {"key": "dataDiskImages", "type": "[GalleryDataDiskImage]"}, + } + + def __init__( + self, + *, + source: Optional["_models.GalleryArtifactVersionFullSource"] = None, + os_disk_image: Optional["_models.GalleryOSDiskImage"] = None, + data_disk_images: Optional[List["_models.GalleryDataDiskImage"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword source: The source of the gallery artifact version. + :paramtype source: ~azure.mgmt.compute.models.GalleryArtifactVersionFullSource + :keyword os_disk_image: This is the OS disk image. + :paramtype os_disk_image: ~azure.mgmt.compute.models.GalleryOSDiskImage + :keyword data_disk_images: A list of data disk images. + :paramtype data_disk_images: list[~azure.mgmt.compute.models.GalleryDataDiskImage] + """ + super().__init__(**kwargs) + self.source = source + self.os_disk_image = os_disk_image + self.data_disk_images = data_disk_images + + +class GalleryImageVersionUefiSettings(_serialization.Model): + """Contains UEFI settings for the image version. + + :ivar signature_template_names: The name of the template(s) that contains default UEFI key + signatures that will be added to the image. + :vartype signature_template_names: list[str or + ~azure.mgmt.compute.models.UefiSignatureTemplateName] + :ivar additional_signatures: Additional UEFI key signatures that will be added to the image in + addition to the signature templates. + :vartype additional_signatures: ~azure.mgmt.compute.models.UefiKeySignatures + """ + + _attribute_map = { + "signature_template_names": {"key": "signatureTemplateNames", "type": "[str]"}, + "additional_signatures": {"key": "additionalSignatures", "type": "UefiKeySignatures"}, + } + + def __init__( + self, + *, + signature_template_names: Optional[List[Union[str, "_models.UefiSignatureTemplateName"]]] = None, + additional_signatures: Optional["_models.UefiKeySignatures"] = None, + **kwargs: Any + ) -> None: + """ + :keyword signature_template_names: The name of the template(s) that contains default UEFI key + signatures that will be added to the image. + :paramtype signature_template_names: list[str or + ~azure.mgmt.compute.models.UefiSignatureTemplateName] + :keyword additional_signatures: Additional UEFI key signatures that will be added to the image + in addition to the signature templates. + :paramtype additional_signatures: ~azure.mgmt.compute.models.UefiKeySignatures + """ + super().__init__(**kwargs) + self.signature_template_names = signature_template_names + self.additional_signatures = additional_signatures + + +class GalleryImageVersionUpdate(UpdateResourceDefinition): + """Specifies information about the gallery image version that you want to update. + + Variables are only populated by the server, and will be ignored when sending a request. + + :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] + :ivar publishing_profile: The publishing profile of a gallery image Version. + :vartype publishing_profile: ~azure.mgmt.compute.models.GalleryImageVersionPublishingProfile + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". + :vartype provisioning_state: str or ~azure.mgmt.compute.models.GalleryProvisioningState + :ivar storage_profile: This is the storage profile of a Gallery Image Version. + :vartype storage_profile: ~azure.mgmt.compute.models.GalleryImageVersionStorageProfile + :ivar safety_profile: This is the safety profile of the Gallery Image Version. + :vartype safety_profile: ~azure.mgmt.compute.models.GalleryImageVersionSafetyProfile + :ivar replication_status: This is the replication status of the gallery image version. + :vartype replication_status: ~azure.mgmt.compute.models.ReplicationStatus + :ivar security_profile: The security profile of a gallery image version. + :vartype security_profile: ~azure.mgmt.compute.models.ImageVersionSecurityProfile + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "replication_status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "publishing_profile": {"key": "properties.publishingProfile", "type": "GalleryImageVersionPublishingProfile"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"}, + "safety_profile": {"key": "properties.safetyProfile", "type": "GalleryImageVersionSafetyProfile"}, + "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, + "security_profile": {"key": "properties.securityProfile", "type": "ImageVersionSecurityProfile"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, + storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, + safety_profile: Optional["_models.GalleryImageVersionSafetyProfile"] = None, + security_profile: Optional["_models.ImageVersionSecurityProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword publishing_profile: The publishing profile of a gallery image Version. + :paramtype publishing_profile: ~azure.mgmt.compute.models.GalleryImageVersionPublishingProfile + :keyword storage_profile: This is the storage profile of a Gallery Image Version. + :paramtype storage_profile: ~azure.mgmt.compute.models.GalleryImageVersionStorageProfile + :keyword safety_profile: This is the safety profile of the Gallery Image Version. + :paramtype safety_profile: ~azure.mgmt.compute.models.GalleryImageVersionSafetyProfile + :keyword security_profile: The security profile of a gallery image version. + :paramtype security_profile: ~azure.mgmt.compute.models.ImageVersionSecurityProfile + """ + super().__init__(tags=tags, **kwargs) + self.publishing_profile = publishing_profile + self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None + self.storage_profile = storage_profile + self.safety_profile = safety_profile + self.replication_status: Optional["_models.ReplicationStatus"] = None + self.security_profile = security_profile + + +class GalleryList(_serialization.Model): + """The List Galleries operation response. + + All required parameters must be populated in order to send to server. + + :ivar value: A list of galleries. Required. + :vartype value: list[~azure.mgmt.compute.models.Gallery] + :ivar next_link: The uri to fetch the next page of galleries. Call ListNext() with this to + fetch the next page of galleries. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Gallery]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.Gallery"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of galleries. Required. + :paramtype value: list[~azure.mgmt.compute.models.Gallery] + :keyword next_link: The uri to fetch the next page of galleries. Call ListNext() with this to + fetch the next page of galleries. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GalleryOSDiskImage(GalleryDiskImage): + """This is the OS disk image. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar size_in_gb: This property indicates the size of the VHD to be created. + :vartype size_in_gb: int + :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and + 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". + :vartype host_caching: str or ~azure.mgmt.compute.models.HostCaching + :ivar source: The source for the disk image. + :vartype source: ~azure.mgmt.compute.models.GalleryDiskImageSource + """ + + +class GalleryTargetExtendedLocation(_serialization.Model): + """GalleryTargetExtendedLocation. + + :ivar name: The name of the region. + :vartype name: str + :ivar extended_location: The name of the extended location. + :vartype extended_location: ~azure.mgmt.compute.models.GalleryExtendedLocation + :ivar extended_location_replica_count: The number of replicas of the Image Version to be + created per extended location. This property is updatable. + :vartype extended_location_replica_count: int + :ivar storage_account_type: Specifies the storage account type to be used to store the image. + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", + "StandardSSD_LRS", and "Premium_LRS". + :vartype storage_account_type: str or ~azure.mgmt.compute.models.EdgeZoneStorageAccountType + :ivar encryption: Optional. Allows users to provide customer managed keys for encrypting the OS + and data disks in the gallery artifact. + :vartype encryption: ~azure.mgmt.compute.models.EncryptionImages + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "GalleryExtendedLocation"}, + "extended_location_replica_count": {"key": "extendedLocationReplicaCount", "type": "int"}, + "storage_account_type": {"key": "storageAccountType", "type": "str"}, + "encryption": {"key": "encryption", "type": "EncryptionImages"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + extended_location: Optional["_models.GalleryExtendedLocation"] = None, + extended_location_replica_count: Optional[int] = None, + storage_account_type: Optional[Union[str, "_models.EdgeZoneStorageAccountType"]] = None, + encryption: Optional["_models.EncryptionImages"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the region. + :paramtype name: str + :keyword extended_location: The name of the extended location. + :paramtype extended_location: ~azure.mgmt.compute.models.GalleryExtendedLocation + :keyword extended_location_replica_count: The number of replicas of the Image Version to be + created per extended location. This property is updatable. + :paramtype extended_location_replica_count: int + :keyword storage_account_type: Specifies the storage account type to be used to store the + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", + "StandardSSD_LRS", and "Premium_LRS". + :paramtype storage_account_type: str or ~azure.mgmt.compute.models.EdgeZoneStorageAccountType + :keyword encryption: Optional. Allows users to provide customer managed keys for encrypting the + OS and data disks in the gallery artifact. + :paramtype encryption: ~azure.mgmt.compute.models.EncryptionImages + """ + super().__init__(**kwargs) + self.name = name + self.extended_location = extended_location + self.extended_location_replica_count = extended_location_replica_count + self.storage_account_type = storage_account_type + self.encryption = encryption + + +class GalleryUpdate(UpdateResourceDefinition): + """Specifies information about the Shared Image Gallery that you want to update. + + Variables are only populated by the server, and will be ignored when sending a request. + + :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] + :ivar description: The description of this Shared Image Gallery resource. This property is + updatable. + :vartype description: str + :ivar identifier: Describes the gallery unique name. + :vartype identifier: ~azure.mgmt.compute.models.GalleryIdentifier + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". + :vartype provisioning_state: str or ~azure.mgmt.compute.models.GalleryProvisioningState + :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. + :vartype sharing_profile: ~azure.mgmt.compute.models.SharingProfile + :ivar soft_delete_policy: Contains information about the soft deletion policy of the gallery. + :vartype soft_delete_policy: ~azure.mgmt.compute.models.SoftDeletePolicy + :ivar sharing_status: Sharing status of current gallery. + :vartype sharing_status: ~azure.mgmt.compute.models.SharingStatus + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "sharing_status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "identifier": {"key": "properties.identifier", "type": "GalleryIdentifier"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "sharing_profile": {"key": "properties.sharingProfile", "type": "SharingProfile"}, + "soft_delete_policy": {"key": "properties.softDeletePolicy", "type": "SoftDeletePolicy"}, + "sharing_status": {"key": "properties.sharingStatus", "type": "SharingStatus"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + description: Optional[str] = None, + identifier: Optional["_models.GalleryIdentifier"] = None, + sharing_profile: Optional["_models.SharingProfile"] = None, + soft_delete_policy: Optional["_models.SoftDeletePolicy"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword description: The description of this Shared Image Gallery resource. This property is + updatable. + :paramtype description: str + :keyword identifier: Describes the gallery unique name. + :paramtype identifier: ~azure.mgmt.compute.models.GalleryIdentifier + :keyword sharing_profile: Profile for gallery sharing to subscription or tenant. + :paramtype sharing_profile: ~azure.mgmt.compute.models.SharingProfile + :keyword soft_delete_policy: Contains information about the soft deletion policy of the + gallery. + :paramtype soft_delete_policy: ~azure.mgmt.compute.models.SoftDeletePolicy + """ + super().__init__(tags=tags, **kwargs) + self.description = description + self.identifier = identifier + self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None + self.sharing_profile = sharing_profile + self.soft_delete_policy = soft_delete_policy + self.sharing_status: Optional["_models.SharingStatus"] = None + + +class GrantAccessData(_serialization.Model): + """Data used for requesting a SAS. + + All required parameters must be populated in order to send to server. + + :ivar access: Required. Known values are: "None", "Read", and "Write". + :vartype access: str or ~azure.mgmt.compute.models.AccessLevel + :ivar duration_in_seconds: Time duration in seconds until the SAS access expires. Required. + :vartype duration_in_seconds: int + :ivar get_secure_vm_guest_state_sas: Set this flag to true to get additional SAS for VM guest + state. + :vartype get_secure_vm_guest_state_sas: bool + :ivar file_format: Used to specify the file format when making request for SAS on a VHDX file + format snapshot. Known values are: "VHD" and "VHDX". + :vartype file_format: str or ~azure.mgmt.compute.models.FileFormat + """ + + _validation = { + "access": {"required": True}, + "duration_in_seconds": {"required": True}, + } + + _attribute_map = { + "access": {"key": "access", "type": "str"}, + "duration_in_seconds": {"key": "durationInSeconds", "type": "int"}, + "get_secure_vm_guest_state_sas": {"key": "getSecureVMGuestStateSAS", "type": "bool"}, + "file_format": {"key": "fileFormat", "type": "str"}, + } + + def __init__( + self, + *, + access: Union[str, "_models.AccessLevel"], + duration_in_seconds: int, + get_secure_vm_guest_state_sas: Optional[bool] = None, + file_format: Optional[Union[str, "_models.FileFormat"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword access: Required. Known values are: "None", "Read", and "Write". + :paramtype access: str or ~azure.mgmt.compute.models.AccessLevel + :keyword duration_in_seconds: Time duration in seconds until the SAS access expires. Required. + :paramtype duration_in_seconds: int + :keyword get_secure_vm_guest_state_sas: Set this flag to true to get additional SAS for VM + guest state. + :paramtype get_secure_vm_guest_state_sas: bool + :keyword file_format: Used to specify the file format when making request for SAS on a VHDX + file format snapshot. Known values are: "VHD" and "VHDX". + :paramtype file_format: str or ~azure.mgmt.compute.models.FileFormat + """ + super().__init__(**kwargs) + self.access = access + self.duration_in_seconds = duration_in_seconds + self.get_secure_vm_guest_state_sas = get_secure_vm_guest_state_sas + self.file_format = file_format + + +class HardwareProfile(_serialization.Model): + """Specifies the hardware settings for the virtual machine. + + :ivar vm_size: Specifies the size of the virtual machine. The enum data type is currently + deprecated and will be removed by December 23rd 2023. The recommended way to get the list of + available sizes is using these APIs: `List all available virtual machine sizes in an + availability set + `_\\ , `List + all available virtual machine sizes in a region + `_\\ , `List all available + virtual machine sizes for resizing + `_. For more + information about virtual machine sizes, see `Sizes for virtual machines + `_. The available VM sizes depend on + region and availability set. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", + "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", + "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", + "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", + "Standard_A2m_v2", "Standard_A4m_v2", "Standard_A8m_v2", "Standard_B1s", "Standard_B1ms", + "Standard_B2s", "Standard_B2ms", "Standard_B4ms", "Standard_B8ms", "Standard_D1", + "Standard_D2", "Standard_D3", "Standard_D4", "Standard_D11", "Standard_D12", "Standard_D13", + "Standard_D14", "Standard_D1_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", + "Standard_D5_v2", "Standard_D2_v3", "Standard_D4_v3", "Standard_D8_v3", "Standard_D16_v3", + "Standard_D32_v3", "Standard_D64_v3", "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", + "Standard_D16s_v3", "Standard_D32s_v3", "Standard_D64s_v3", "Standard_D11_v2", + "Standard_D12_v2", "Standard_D13_v2", "Standard_D14_v2", "Standard_D15_v2", "Standard_DS1", + "Standard_DS2", "Standard_DS3", "Standard_DS4", "Standard_DS11", "Standard_DS12", + "Standard_DS13", "Standard_DS14", "Standard_DS1_v2", "Standard_DS2_v2", "Standard_DS3_v2", + "Standard_DS4_v2", "Standard_DS5_v2", "Standard_DS11_v2", "Standard_DS12_v2", + "Standard_DS13_v2", "Standard_DS14_v2", "Standard_DS15_v2", "Standard_DS13-4_v2", + "Standard_DS13-2_v2", "Standard_DS14-8_v2", "Standard_DS14-4_v2", "Standard_E2_v3", + "Standard_E4_v3", "Standard_E8_v3", "Standard_E16_v3", "Standard_E32_v3", "Standard_E64_v3", + "Standard_E2s_v3", "Standard_E4s_v3", "Standard_E8s_v3", "Standard_E16s_v3", + "Standard_E32s_v3", "Standard_E64s_v3", "Standard_E32-16_v3", "Standard_E32-8s_v3", + "Standard_E64-32s_v3", "Standard_E64-16s_v3", "Standard_F1", "Standard_F2", "Standard_F4", + "Standard_F8", "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", + "Standard_F16s", "Standard_F2s_v2", "Standard_F4s_v2", "Standard_F8s_v2", "Standard_F16s_v2", + "Standard_F32s_v2", "Standard_F64s_v2", "Standard_F72s_v2", "Standard_G1", "Standard_G2", + "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", "Standard_GS3", + "Standard_GS4", "Standard_GS5", "Standard_GS4-8", "Standard_GS4-4", "Standard_GS5-16", + "Standard_GS5-8", "Standard_H8", "Standard_H16", "Standard_H8m", "Standard_H16m", + "Standard_H16r", "Standard_H16mr", "Standard_L4s", "Standard_L8s", "Standard_L16s", + "Standard_L32s", "Standard_M64s", "Standard_M64ms", "Standard_M128s", "Standard_M128ms", + "Standard_M64-32ms", "Standard_M64-16ms", "Standard_M128-64ms", "Standard_M128-32ms", + "Standard_NC6", "Standard_NC12", "Standard_NC24", "Standard_NC24r", "Standard_NC6s_v2", + "Standard_NC12s_v2", "Standard_NC24s_v2", "Standard_NC24rs_v2", "Standard_NC6s_v3", + "Standard_NC12s_v3", "Standard_NC24s_v3", "Standard_NC24rs_v3", "Standard_ND6s", + "Standard_ND12s", "Standard_ND24s", "Standard_ND24rs", "Standard_NV6", "Standard_NV12", and + "Standard_NV24". + :vartype vm_size: str or ~azure.mgmt.compute.models.VirtualMachineSizeTypes + :ivar vm_size_properties: Specifies the properties for customizing the size of the virtual + machine. Minimum api-version: 2021-07-01. This feature is still in preview mode and is not + supported for VirtualMachineScaleSet. Please follow the instructions in `VM Customization + `_ for more details. + :vartype vm_size_properties: ~azure.mgmt.compute.models.VMSizeProperties + """ + + _attribute_map = { + "vm_size": {"key": "vmSize", "type": "str"}, + "vm_size_properties": {"key": "vmSizeProperties", "type": "VMSizeProperties"}, + } + + def __init__( + self, + *, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, + vm_size_properties: Optional["_models.VMSizeProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword vm_size: Specifies the size of the virtual machine. The enum data type is currently + deprecated and will be removed by December 23rd 2023. The recommended way to get the list of + available sizes is using these APIs: `List all available virtual machine sizes in an + availability set + `_\\ , `List + all available virtual machine sizes in a region + `_\\ , `List all available + virtual machine sizes for resizing + `_. For more + information about virtual machine sizes, see `Sizes for virtual machines + `_. The available VM sizes depend on + region and availability set. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", + "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", + "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", + "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", + "Standard_A2m_v2", "Standard_A4m_v2", "Standard_A8m_v2", "Standard_B1s", "Standard_B1ms", + "Standard_B2s", "Standard_B2ms", "Standard_B4ms", "Standard_B8ms", "Standard_D1", + "Standard_D2", "Standard_D3", "Standard_D4", "Standard_D11", "Standard_D12", "Standard_D13", + "Standard_D14", "Standard_D1_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", + "Standard_D5_v2", "Standard_D2_v3", "Standard_D4_v3", "Standard_D8_v3", "Standard_D16_v3", + "Standard_D32_v3", "Standard_D64_v3", "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", + "Standard_D16s_v3", "Standard_D32s_v3", "Standard_D64s_v3", "Standard_D11_v2", + "Standard_D12_v2", "Standard_D13_v2", "Standard_D14_v2", "Standard_D15_v2", "Standard_DS1", + "Standard_DS2", "Standard_DS3", "Standard_DS4", "Standard_DS11", "Standard_DS12", + "Standard_DS13", "Standard_DS14", "Standard_DS1_v2", "Standard_DS2_v2", "Standard_DS3_v2", + "Standard_DS4_v2", "Standard_DS5_v2", "Standard_DS11_v2", "Standard_DS12_v2", + "Standard_DS13_v2", "Standard_DS14_v2", "Standard_DS15_v2", "Standard_DS13-4_v2", + "Standard_DS13-2_v2", "Standard_DS14-8_v2", "Standard_DS14-4_v2", "Standard_E2_v3", + "Standard_E4_v3", "Standard_E8_v3", "Standard_E16_v3", "Standard_E32_v3", "Standard_E64_v3", + "Standard_E2s_v3", "Standard_E4s_v3", "Standard_E8s_v3", "Standard_E16s_v3", + "Standard_E32s_v3", "Standard_E64s_v3", "Standard_E32-16_v3", "Standard_E32-8s_v3", + "Standard_E64-32s_v3", "Standard_E64-16s_v3", "Standard_F1", "Standard_F2", "Standard_F4", + "Standard_F8", "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", + "Standard_F16s", "Standard_F2s_v2", "Standard_F4s_v2", "Standard_F8s_v2", "Standard_F16s_v2", + "Standard_F32s_v2", "Standard_F64s_v2", "Standard_F72s_v2", "Standard_G1", "Standard_G2", + "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", "Standard_GS3", + "Standard_GS4", "Standard_GS5", "Standard_GS4-8", "Standard_GS4-4", "Standard_GS5-16", + "Standard_GS5-8", "Standard_H8", "Standard_H16", "Standard_H8m", "Standard_H16m", + "Standard_H16r", "Standard_H16mr", "Standard_L4s", "Standard_L8s", "Standard_L16s", + "Standard_L32s", "Standard_M64s", "Standard_M64ms", "Standard_M128s", "Standard_M128ms", + "Standard_M64-32ms", "Standard_M64-16ms", "Standard_M128-64ms", "Standard_M128-32ms", + "Standard_NC6", "Standard_NC12", "Standard_NC24", "Standard_NC24r", "Standard_NC6s_v2", + "Standard_NC12s_v2", "Standard_NC24s_v2", "Standard_NC24rs_v2", "Standard_NC6s_v3", + "Standard_NC12s_v3", "Standard_NC24s_v3", "Standard_NC24rs_v3", "Standard_ND6s", + "Standard_ND12s", "Standard_ND24s", "Standard_ND24rs", "Standard_NV6", "Standard_NV12", and + "Standard_NV24". + :paramtype vm_size: str or ~azure.mgmt.compute.models.VirtualMachineSizeTypes + :keyword vm_size_properties: Specifies the properties for customizing the size of the virtual + machine. Minimum api-version: 2021-07-01. This feature is still in preview mode and is not + supported for VirtualMachineScaleSet. Please follow the instructions in `VM Customization + `_ for more details. + :paramtype vm_size_properties: ~azure.mgmt.compute.models.VMSizeProperties + """ + super().__init__(**kwargs) + self.vm_size = vm_size + self.vm_size_properties = vm_size_properties + + +class HostEndpointSettings(_serialization.Model): + """Specifies particular host endpoint settings. + + :ivar mode: Specifies the execution mode. In Audit mode, the system acts as if it is enforcing + the access control policy, including emitting access denial entries in the logs but it does not + actually deny any requests to host endpoints. In Enforce mode, the system will enforce the + access control and it is the recommended mode of operation. Known values are: "Audit", + "Enforce", and "Disabled". + :vartype mode: str or ~azure.mgmt.compute.models.Modes + :ivar in_vm_access_control_profile_reference_id: Specifies the InVMAccessControlProfileVersion + resource id in the format of + /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/inVMAccessControlProfiles/{profile}/versions/{version}. + :vartype in_vm_access_control_profile_reference_id: str + """ + + _attribute_map = { + "mode": {"key": "mode", "type": "str"}, + "in_vm_access_control_profile_reference_id": {"key": "inVMAccessControlProfileReferenceId", "type": "str"}, + } + + def __init__( + self, + *, + mode: Optional[Union[str, "_models.Modes"]] = None, + in_vm_access_control_profile_reference_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword mode: Specifies the execution mode. In Audit mode, the system acts as if it is + enforcing the access control policy, including emitting access denial entries in the logs but + it does not actually deny any requests to host endpoints. In Enforce mode, the system will + enforce the access control and it is the recommended mode of operation. Known values are: + "Audit", "Enforce", and "Disabled". + :paramtype mode: str or ~azure.mgmt.compute.models.Modes + :keyword in_vm_access_control_profile_reference_id: Specifies the + InVMAccessControlProfileVersion resource id in the format of + /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/inVMAccessControlProfiles/{profile}/versions/{version}. + :paramtype in_vm_access_control_profile_reference_id: str + """ + super().__init__(**kwargs) + self.mode = mode + self.in_vm_access_control_profile_reference_id = in_vm_access_control_profile_reference_id + + +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. + + 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: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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.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.models.ExtendedLocation + :ivar source_virtual_machine: The source virtual machine from which Image is created. + :vartype source_virtual_machine: ~azure.mgmt.compute.models.SubResource + :ivar storage_profile: Specifies the storage settings for the virtual machine disks. + :vartype storage_profile: ~azure.mgmt.compute.models.ImageStorageProfile + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str + :ivar hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created from + the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to + specify the value, if the source is managed resource like disk or snapshot, we may require the + user to specify the property if we cannot deduce it from the source managed resource. Known + values are: "V1" and "V2". + :vartype hyper_v_generation: str or ~azure.mgmt.compute.models.HyperVGenerationTypes + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"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"}, + "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"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, + **kwargs: Any + ) -> None: + """ + :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.models.ExtendedLocation + :keyword source_virtual_machine: The source virtual machine from which Image is created. + :paramtype source_virtual_machine: ~azure.mgmt.compute.models.SubResource + :keyword storage_profile: Specifies the storage settings for the virtual machine disks. + :paramtype storage_profile: ~azure.mgmt.compute.models.ImageStorageProfile + :keyword hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created + from the image. From API Version 2019-03-01 if the image source is a blob, then we need the + user to specify the value, if the source is managed resource like disk or snapshot, we may + require the user to specify the property if we cannot deduce it from the source managed + resource. Known values are: "V1" and "V2". + :paramtype hyper_v_generation: str or ~azure.mgmt.compute.models.HyperVGenerationTypes + """ + super().__init__(tags=tags, location=location, **kwargs) + self.extended_location = extended_location + self.source_virtual_machine = source_virtual_machine + self.storage_profile = storage_profile + self.provisioning_state: Optional[str] = None + self.hyper_v_generation = hyper_v_generation + + +class ImageDisk(_serialization.Model): + """Describes a image disk. + + :ivar snapshot: The snapshot. + :vartype snapshot: ~azure.mgmt.compute.models.SubResource + :ivar managed_disk: The managedDisk. + :vartype managed_disk: ~azure.mgmt.compute.models.SubResource + :ivar blob_uri: The Virtual Hard Disk. + :vartype blob_uri: str + :ivar caching: Specifies the caching requirements. Possible values are: **None,** **ReadOnly,** + **ReadWrite.** The default values are: **None for Standard storage. ReadOnly for Premium + storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". + :vartype caching: str or ~azure.mgmt.compute.models.CachingTypes + :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be + used to overwrite the name of the disk in a virtual machine image. This value cannot be larger + than 1023 GB. + :vartype disk_size_gb: int + :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + "StandardSSD_ZRS", and "PremiumV2_LRS". + :vartype storage_account_type: str or ~azure.mgmt.compute.models.StorageAccountTypes + :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for + the managed image disk. + :vartype disk_encryption_set: ~azure.mgmt.compute.models.DiskEncryptionSetParameters + """ + + _attribute_map = { + "snapshot": {"key": "snapshot", "type": "SubResource"}, + "managed_disk": {"key": "managedDisk", "type": "SubResource"}, + "blob_uri": {"key": "blobUri", "type": "str"}, + "caching": {"key": "caching", "type": "str"}, + "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, + "storage_account_type": {"key": "storageAccountType", "type": "str"}, + "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, + } + + def __init__( + self, + *, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, + blob_uri: Optional[str] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, + disk_size_gb: Optional[int] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, + **kwargs: Any + ) -> None: + """ + :keyword snapshot: The snapshot. + :paramtype snapshot: ~azure.mgmt.compute.models.SubResource + :keyword managed_disk: The managedDisk. + :paramtype managed_disk: ~azure.mgmt.compute.models.SubResource + :keyword blob_uri: The Virtual Hard Disk. + :paramtype blob_uri: str + :keyword caching: Specifies the caching requirements. Possible values are: **None,** + **ReadOnly,** **ReadWrite.** The default values are: **None for Standard storage. ReadOnly for + Premium storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". + :paramtype caching: str or ~azure.mgmt.compute.models.CachingTypes + :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be + used to overwrite the name of the disk in a virtual machine image. This value cannot be larger + than 1023 GB. + :paramtype disk_size_gb: int + :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + "StandardSSD_ZRS", and "PremiumV2_LRS". + :paramtype storage_account_type: str or ~azure.mgmt.compute.models.StorageAccountTypes + :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id + for the managed image disk. + :paramtype disk_encryption_set: ~azure.mgmt.compute.models.DiskEncryptionSetParameters + """ + super().__init__(**kwargs) + self.snapshot = snapshot + self.managed_disk = managed_disk + self.blob_uri = blob_uri + self.caching = caching + self.disk_size_gb = disk_size_gb + self.storage_account_type = storage_account_type + self.disk_encryption_set = disk_encryption_set + + +class ImageDataDisk(ImageDisk): + """Describes a data disk. + + All required parameters must be populated in order to send to server. + + :ivar snapshot: The snapshot. + :vartype snapshot: ~azure.mgmt.compute.models.SubResource + :ivar managed_disk: The managedDisk. + :vartype managed_disk: ~azure.mgmt.compute.models.SubResource + :ivar blob_uri: The Virtual Hard Disk. + :vartype blob_uri: str + :ivar caching: Specifies the caching requirements. Possible values are: **None,** **ReadOnly,** + **ReadWrite.** The default values are: **None for Standard storage. ReadOnly for Premium + storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". + :vartype caching: str or ~azure.mgmt.compute.models.CachingTypes + :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be + used to overwrite the name of the disk in a virtual machine image. This value cannot be larger + than 1023 GB. + :vartype disk_size_gb: int + :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + "StandardSSD_ZRS", and "PremiumV2_LRS". + :vartype storage_account_type: str or ~azure.mgmt.compute.models.StorageAccountTypes + :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for + the managed image disk. + :vartype disk_encryption_set: ~azure.mgmt.compute.models.DiskEncryptionSetParameters + :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify + data disks within the VM and therefore must be unique for each data disk attached to a VM. + Required. + :vartype lun: int + """ + + _validation = { + "lun": {"required": True}, + } + + _attribute_map = { + "snapshot": {"key": "snapshot", "type": "SubResource"}, + "managed_disk": {"key": "managedDisk", "type": "SubResource"}, + "blob_uri": {"key": "blobUri", "type": "str"}, + "caching": {"key": "caching", "type": "str"}, + "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, + "storage_account_type": {"key": "storageAccountType", "type": "str"}, + "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, + "lun": {"key": "lun", "type": "int"}, + } + + def __init__( + self, + *, + lun: int, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, + blob_uri: Optional[str] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, + disk_size_gb: Optional[int] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, + **kwargs: Any + ) -> None: + """ + :keyword snapshot: The snapshot. + :paramtype snapshot: ~azure.mgmt.compute.models.SubResource + :keyword managed_disk: The managedDisk. + :paramtype managed_disk: ~azure.mgmt.compute.models.SubResource + :keyword blob_uri: The Virtual Hard Disk. + :paramtype blob_uri: str + :keyword caching: Specifies the caching requirements. Possible values are: **None,** + **ReadOnly,** **ReadWrite.** The default values are: **None for Standard storage. ReadOnly for + Premium storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". + :paramtype caching: str or ~azure.mgmt.compute.models.CachingTypes + :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be + used to overwrite the name of the disk in a virtual machine image. This value cannot be larger + than 1023 GB. + :paramtype disk_size_gb: int + :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + "StandardSSD_ZRS", and "PremiumV2_LRS". + :paramtype storage_account_type: str or ~azure.mgmt.compute.models.StorageAccountTypes + :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id + for the managed image disk. + :paramtype disk_encryption_set: ~azure.mgmt.compute.models.DiskEncryptionSetParameters + :keyword lun: Specifies the logical unit number of the data disk. This value is used to + identify data disks within the VM and therefore must be unique for each data disk attached to a + VM. Required. + :paramtype lun: int + """ + super().__init__( + snapshot=snapshot, + managed_disk=managed_disk, + blob_uri=blob_uri, + caching=caching, + disk_size_gb=disk_size_gb, + storage_account_type=storage_account_type, + disk_encryption_set=disk_encryption_set, + **kwargs + ) + self.lun = lun + + +class ImageDeprecationStatus(_serialization.Model): + """Describes image deprecation status properties on the image. + + :ivar image_state: Describes the state of the image. Known values are: "Active", + "ScheduledForDeprecation", and "Deprecated". + :vartype image_state: str or ~azure.mgmt.compute.models.ImageState + :ivar scheduled_deprecation_time: The time, in future, at which this image will be marked as + deprecated. This scheduled time is chosen by the Publisher. + :vartype scheduled_deprecation_time: ~datetime.datetime + :ivar alternative_option: Describes the alternative option specified by the Publisher for this + image when this image is deprecated. + :vartype alternative_option: ~azure.mgmt.compute.models.AlternativeOption + """ + + _attribute_map = { + "image_state": {"key": "imageState", "type": "str"}, + "scheduled_deprecation_time": {"key": "scheduledDeprecationTime", "type": "iso-8601"}, + "alternative_option": {"key": "alternativeOption", "type": "AlternativeOption"}, + } + + def __init__( + self, + *, + image_state: Optional[Union[str, "_models.ImageState"]] = None, + scheduled_deprecation_time: Optional[datetime.datetime] = None, + alternative_option: Optional["_models.AlternativeOption"] = None, + **kwargs: Any + ) -> None: + """ + :keyword image_state: Describes the state of the image. Known values are: "Active", + "ScheduledForDeprecation", and "Deprecated". + :paramtype image_state: str or ~azure.mgmt.compute.models.ImageState + :keyword scheduled_deprecation_time: The time, in future, at which this image will be marked as + deprecated. This scheduled time is chosen by the Publisher. + :paramtype scheduled_deprecation_time: ~datetime.datetime + :keyword alternative_option: Describes the alternative option specified by the Publisher for + this image when this image is deprecated. + :paramtype alternative_option: ~azure.mgmt.compute.models.AlternativeOption + """ + super().__init__(**kwargs) + self.image_state = image_state + self.scheduled_deprecation_time = scheduled_deprecation_time + self.alternative_option = alternative_option + + +class ImageDiskReference(_serialization.Model): + """The source image used for creating the disk. + + :ivar id: A relative uri containing either a Platform Image Repository, user image, or Azure + Compute Gallery image reference. + :vartype id: str + :ivar shared_gallery_image_id: A relative uri containing a direct shared Azure Compute Gallery + image reference. + :vartype shared_gallery_image_id: str + :ivar community_gallery_image_id: A relative uri containing a community Azure Compute Gallery + image reference. + :vartype community_gallery_image_id: str + :ivar lun: If the disk is created from an image's data disk, this is an index that indicates + which of the data disks in the image to use. For OS disks, this field is null. + :vartype lun: int + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "shared_gallery_image_id": {"key": "sharedGalleryImageId", "type": "str"}, + "community_gallery_image_id": {"key": "communityGalleryImageId", "type": "str"}, + "lun": {"key": "lun", "type": "int"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + shared_gallery_image_id: Optional[str] = None, + community_gallery_image_id: Optional[str] = None, + lun: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: A relative uri containing either a Platform Image Repository, user image, or Azure + Compute Gallery image reference. + :paramtype id: str + :keyword shared_gallery_image_id: A relative uri containing a direct shared Azure Compute + Gallery image reference. + :paramtype shared_gallery_image_id: str + :keyword community_gallery_image_id: A relative uri containing a community Azure Compute + Gallery image reference. + :paramtype community_gallery_image_id: str + :keyword lun: If the disk is created from an image's data disk, this is an index that indicates + which of the data disks in the image to use. For OS disks, this field is null. + :paramtype lun: int + """ + super().__init__(**kwargs) + self.id = id + self.shared_gallery_image_id = shared_gallery_image_id + self.community_gallery_image_id = community_gallery_image_id + self.lun = lun + + +class ImageListResult(_serialization.Model): + """The List Image operation response. + + All required parameters must be populated in order to send to server. + + :ivar value: The list of Images. Required. + :vartype value: list[~azure.mgmt.compute.models.Image] + :ivar next_link: The uri to fetch the next page of Images. Call ListNext() with this to fetch + the next page of Images. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Image]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.Image"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of Images. Required. + :paramtype value: list[~azure.mgmt.compute.models.Image] + :keyword next_link: The uri to fetch the next page of Images. Call ListNext() with this to + fetch the next page of Images. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ImageOSDisk(ImageDisk): + """Describes an Operating System disk. + + All required parameters must be populated in order to send to server. + + :ivar snapshot: The snapshot. + :vartype snapshot: ~azure.mgmt.compute.models.SubResource + :ivar managed_disk: The managedDisk. + :vartype managed_disk: ~azure.mgmt.compute.models.SubResource + :ivar blob_uri: The Virtual Hard Disk. + :vartype blob_uri: str + :ivar caching: Specifies the caching requirements. Possible values are: **None,** **ReadOnly,** + **ReadWrite.** The default values are: **None for Standard storage. ReadOnly for Premium + storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". + :vartype caching: str or ~azure.mgmt.compute.models.CachingTypes + :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be + used to overwrite the name of the disk in a virtual machine image. This value cannot be larger + than 1023 GB. + :vartype disk_size_gb: int + :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + "StandardSSD_ZRS", and "PremiumV2_LRS". + :vartype storage_account_type: str or ~azure.mgmt.compute.models.StorageAccountTypes + :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for + the managed image disk. + :vartype disk_encryption_set: ~azure.mgmt.compute.models.DiskEncryptionSetParameters + :ivar os_type: This property allows you to specify the type of the OS that is included in the + disk if creating a VM from a custom image. Possible values are: **Windows,** **Linux.**. + Required. Known values are: "Windows" and "Linux". + :vartype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :ivar os_state: The OS State. For managed images, use Generalized. Required. Known values are: + "Generalized" and "Specialized". + :vartype os_state: str or ~azure.mgmt.compute.models.OperatingSystemStateTypes + """ + + _validation = { + "os_type": {"required": True}, + "os_state": {"required": True}, + } + + _attribute_map = { + "snapshot": {"key": "snapshot", "type": "SubResource"}, + "managed_disk": {"key": "managedDisk", "type": "SubResource"}, + "blob_uri": {"key": "blobUri", "type": "str"}, + "caching": {"key": "caching", "type": "str"}, + "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, + "storage_account_type": {"key": "storageAccountType", "type": "str"}, + "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, + "os_type": {"key": "osType", "type": "str"}, + "os_state": {"key": "osState", "type": "str"}, + } + + def __init__( + self, + *, + os_type: Union[str, "_models.OperatingSystemTypes"], + os_state: Union[str, "_models.OperatingSystemStateTypes"], + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, + blob_uri: Optional[str] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, + disk_size_gb: Optional[int] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, + **kwargs: Any + ) -> None: + """ + :keyword snapshot: The snapshot. + :paramtype snapshot: ~azure.mgmt.compute.models.SubResource + :keyword managed_disk: The managedDisk. + :paramtype managed_disk: ~azure.mgmt.compute.models.SubResource + :keyword blob_uri: The Virtual Hard Disk. + :paramtype blob_uri: str + :keyword caching: Specifies the caching requirements. Possible values are: **None,** + **ReadOnly,** **ReadWrite.** The default values are: **None for Standard storage. ReadOnly for + Premium storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". + :paramtype caching: str or ~azure.mgmt.compute.models.CachingTypes + :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be + used to overwrite the name of the disk in a virtual machine image. This value cannot be larger + than 1023 GB. + :paramtype disk_size_gb: int + :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + "StandardSSD_ZRS", and "PremiumV2_LRS". + :paramtype storage_account_type: str or ~azure.mgmt.compute.models.StorageAccountTypes + :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id + for the managed image disk. + :paramtype disk_encryption_set: ~azure.mgmt.compute.models.DiskEncryptionSetParameters + :keyword os_type: This property allows you to specify the type of the OS that is included in + the disk if creating a VM from a custom image. Possible values are: **Windows,** **Linux.**. + Required. Known values are: "Windows" and "Linux". + :paramtype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :keyword os_state: The OS State. For managed images, use Generalized. Required. Known values + are: "Generalized" and "Specialized". + :paramtype os_state: str or ~azure.mgmt.compute.models.OperatingSystemStateTypes + """ + super().__init__( + snapshot=snapshot, + managed_disk=managed_disk, + blob_uri=blob_uri, + caching=caching, + disk_size_gb=disk_size_gb, + storage_account_type=storage_account_type, + disk_encryption_set=disk_encryption_set, + **kwargs + ) + self.os_type = os_type + self.os_state = os_state + + +class ImagePurchasePlan(_serialization.Model): + """Describes the gallery image definition purchase plan. This is used by marketplace images. + + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The product ID. + :vartype product: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The product ID. + :paramtype product: str + """ + super().__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + + +class ImageReference(SubResource): + """Specifies information about the image to use. You can specify information about platform + images, marketplace images, or virtual machine images. This element is required when you want + to use a platform image, marketplace image, or virtual machine image, but is not used in other + creation operations. NOTE: Image reference publisher and offer can only be set when you create + the scale set. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar publisher: The image publisher. + :vartype publisher: str + :ivar offer: Specifies the offer of the platform image or marketplace image used to create the + virtual machine. + :vartype offer: str + :ivar sku: The image SKU. + :vartype sku: str + :ivar version: Specifies the version of the platform image or marketplace image used to create + the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and + Build are decimal numbers. Specify 'latest' to use the latest version of an image available at + deploy time. Even if you use 'latest', the VM image will not automatically update after deploy + time even if a new version becomes available. Please do not use field 'version' for gallery + image deployment, gallery image should always use 'id' field for deployment, to use 'latest' + version of gallery image, just set + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageName}' + in the 'id' field without version input. + :vartype version: str + :ivar exact_version: Specifies in decimal numbers, the version of platform image or marketplace + image used to create the virtual machine. This readonly field differs from 'version', only if + the value specified in 'version' field is 'latest'. + :vartype exact_version: str + :ivar shared_gallery_image_id: Specified the shared gallery image unique id for vm deployment. + This can be fetched from shared gallery image GET call. + :vartype shared_gallery_image_id: str + :ivar community_gallery_image_id: Specified the community gallery image unique id for vm + deployment. This can be fetched from community gallery image GET call. + :vartype community_gallery_image_id: str + """ + + _validation = { + "exact_version": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "offer": {"key": "offer", "type": "str"}, + "sku": {"key": "sku", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "exact_version": {"key": "exactVersion", "type": "str"}, + "shared_gallery_image_id": {"key": "sharedGalleryImageId", "type": "str"}, + "community_gallery_image_id": {"key": "communityGalleryImageId", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + publisher: Optional[str] = None, + offer: Optional[str] = None, + sku: Optional[str] = None, + version: Optional[str] = None, + shared_gallery_image_id: Optional[str] = None, + community_gallery_image_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Resource Id. + :paramtype id: str + :keyword publisher: The image publisher. + :paramtype publisher: str + :keyword offer: Specifies the offer of the platform image or marketplace image used to create + the virtual machine. + :paramtype offer: str + :keyword sku: The image SKU. + :paramtype sku: str + :keyword version: Specifies the version of the platform image or marketplace image used to + create the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, + Minor, and Build are decimal numbers. Specify 'latest' to use the latest version of an image + available at deploy time. Even if you use 'latest', the VM image will not automatically update + after deploy time even if a new version becomes available. Please do not use field 'version' + for gallery image deployment, gallery image should always use 'id' field for deployment, to use + 'latest' version of gallery image, just set + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageName}' + in the 'id' field without version input. + :paramtype version: str + :keyword shared_gallery_image_id: Specified the shared gallery image unique id for vm + deployment. This can be fetched from shared gallery image GET call. + :paramtype shared_gallery_image_id: str + :keyword community_gallery_image_id: Specified the community gallery image unique id for vm + deployment. This can be fetched from community gallery image GET call. + :paramtype community_gallery_image_id: str + """ + super().__init__(id=id, **kwargs) + self.publisher = publisher + self.offer = offer + self.sku = sku + self.version = version + self.exact_version: Optional[str] = None + self.shared_gallery_image_id = shared_gallery_image_id + self.community_gallery_image_id = community_gallery_image_id + + +class ImageStorageProfile(_serialization.Model): + """Describes a storage profile. + + :ivar os_disk: Specifies information about the operating system disk used by the virtual + machine. :code:`
`\\ :code:`
` For more information about disks, see `About disks and + VHDs for Azure virtual machines + `_. + :vartype os_disk: ~azure.mgmt.compute.models.ImageOSDisk + :ivar data_disks: Specifies the parameters that are used to add a data disk to a virtual + machine. :code:`
`\\ :code:`
` For more information about disks, see `About disks and + VHDs for Azure virtual machines + `_. + :vartype data_disks: list[~azure.mgmt.compute.models.ImageDataDisk] + :ivar zone_resilient: Specifies whether an image is zone resilient or not. Default is false. + Zone resilient images can be created only in regions that provide Zone Redundant Storage (ZRS). + :vartype zone_resilient: bool + """ + + _attribute_map = { + "os_disk": {"key": "osDisk", "type": "ImageOSDisk"}, + "data_disks": {"key": "dataDisks", "type": "[ImageDataDisk]"}, + "zone_resilient": {"key": "zoneResilient", "type": "bool"}, + } + + def __init__( + self, + *, + os_disk: Optional["_models.ImageOSDisk"] = None, + data_disks: Optional[List["_models.ImageDataDisk"]] = None, + zone_resilient: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword os_disk: Specifies information about the operating system disk used by the virtual + machine. :code:`
`\\ :code:`
` For more information about disks, see `About disks and + VHDs for Azure virtual machines + `_. + :paramtype os_disk: ~azure.mgmt.compute.models.ImageOSDisk + :keyword data_disks: Specifies the parameters that are used to add a data disk to a virtual + machine. :code:`
`\\ :code:`
` For more information about disks, see `About disks and + VHDs for Azure virtual machines + `_. + :paramtype data_disks: list[~azure.mgmt.compute.models.ImageDataDisk] + :keyword zone_resilient: Specifies whether an image is zone resilient or not. Default is false. + Zone resilient images can be created only in regions that provide Zone Redundant Storage (ZRS). + :paramtype zone_resilient: bool + """ + super().__init__(**kwargs) + self.os_disk = os_disk + self.data_disks = data_disks + self.zone_resilient = zone_resilient + + +class ImageUpdate(UpdateResource): + """The source user image virtual hard disk. Only tags may be updated. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar source_virtual_machine: The source virtual machine from which Image is created. + :vartype source_virtual_machine: ~azure.mgmt.compute.models.SubResource + :ivar storage_profile: Specifies the storage settings for the virtual machine disks. + :vartype storage_profile: ~azure.mgmt.compute.models.ImageStorageProfile + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str + :ivar hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created from + the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to + specify the value, if the source is managed resource like disk or snapshot, we may require the + user to specify the property if we cannot deduce it from the source managed resource. Known + values are: "V1" and "V2". + :vartype hyper_v_generation: str or ~azure.mgmt.compute.models.HyperVGenerationTypes + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "source_virtual_machine": {"key": "properties.sourceVirtualMachine", "type": "SubResource"}, + "storage_profile": {"key": "properties.storageProfile", "type": "ImageStorageProfile"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword source_virtual_machine: The source virtual machine from which Image is created. + :paramtype source_virtual_machine: ~azure.mgmt.compute.models.SubResource + :keyword storage_profile: Specifies the storage settings for the virtual machine disks. + :paramtype storage_profile: ~azure.mgmt.compute.models.ImageStorageProfile + :keyword hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created + from the image. From API Version 2019-03-01 if the image source is a blob, then we need the + user to specify the value, if the source is managed resource like disk or snapshot, we may + require the user to specify the property if we cannot deduce it from the source managed + resource. Known values are: "V1" and "V2". + :paramtype hyper_v_generation: str or ~azure.mgmt.compute.models.HyperVGenerationTypes + """ + super().__init__(tags=tags, **kwargs) + self.source_virtual_machine = source_virtual_machine + self.storage_profile = storage_profile + self.provisioning_state: Optional[str] = None + self.hyper_v_generation = hyper_v_generation + + +class ImageVersionSecurityProfile(_serialization.Model): + """The security profile of a gallery image version. + + :ivar uefi_settings: Contains UEFI settings for the image version. + :vartype uefi_settings: ~azure.mgmt.compute.models.GalleryImageVersionUefiSettings + """ + + _attribute_map = { + "uefi_settings": {"key": "uefiSettings", "type": "GalleryImageVersionUefiSettings"}, + } + + def __init__( + self, *, uefi_settings: Optional["_models.GalleryImageVersionUefiSettings"] = None, **kwargs: Any + ) -> None: + """ + :keyword uefi_settings: Contains UEFI settings for the image version. + :paramtype uefi_settings: ~azure.mgmt.compute.models.GalleryImageVersionUefiSettings + """ + super().__init__(**kwargs) + self.uefi_settings = uefi_settings + + +class InnerError(_serialization.Model): + """Inner error details. + + :ivar exceptiontype: The exception type. + :vartype exceptiontype: str + :ivar errordetail: The internal error message or exception dump. + :vartype errordetail: str + """ + + _attribute_map = { + "exceptiontype": {"key": "exceptiontype", "type": "str"}, + "errordetail": {"key": "errordetail", "type": "str"}, + } + + def __init__( + self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword exceptiontype: The exception type. + :paramtype exceptiontype: str + :keyword errordetail: The internal error message or exception dump. + :paramtype errordetail: str + """ + super().__init__(**kwargs) + self.exceptiontype = exceptiontype + self.errordetail = errordetail + + +class InstanceSku(_serialization.Model): + """The role instance SKU. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The sku name. + :vartype name: str + :ivar tier: The tier of the cloud service role instance. + :vartype tier: str + """ + + _validation = { + "name": {"readonly": True}, + "tier": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name: Optional[str] = None + self.tier: Optional[str] = None + + +class InstanceViewStatus(_serialization.Model): + """Instance view status. + + :ivar code: The status code. + :vartype code: str + :ivar level: The level code. Known values are: "Info", "Warning", and "Error". + :vartype level: str or ~azure.mgmt.compute.models.StatusLevelTypes + :ivar display_status: The short localizable label for the status. + :vartype display_status: str + :ivar message: The detailed status message, including for alerts and error messages. + :vartype message: str + :ivar time: The time of the status. + :vartype time: ~datetime.datetime + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "display_status": {"key": "displayStatus", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "time": {"key": "time", "type": "iso-8601"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, + display_status: Optional[str] = None, + message: Optional[str] = None, + time: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: The status code. + :paramtype code: str + :keyword level: The level code. Known values are: "Info", "Warning", and "Error". + :paramtype level: str or ~azure.mgmt.compute.models.StatusLevelTypes + :keyword display_status: The short localizable label for the status. + :paramtype display_status: str + :keyword message: The detailed status message, including for alerts and error messages. + :paramtype message: str + :keyword time: The time of the status. + :paramtype time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.code = code + self.level = level + self.display_status = display_status + self.message = message + self.time = time + + +class InstanceViewStatusesSummary(_serialization.Model): + """Instance view statuses. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar statuses_summary: The summary. + :vartype statuses_summary: list[~azure.mgmt.compute.models.StatusCodeCount] + """ + + _validation = { + "statuses_summary": {"readonly": True}, + } + + _attribute_map = { + "statuses_summary": {"key": "statusesSummary", "type": "[StatusCodeCount]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.statuses_summary: Optional[List["_models.StatusCodeCount"]] = None + + +class KeyForDiskEncryptionSet(_serialization.Model): + """Key Vault Key Url to be used for server side encryption of Managed Disks and Snapshots. + + All required parameters must be populated in order to send to server. + + :ivar source_vault: Resource id of the KeyVault containing the key or secret. This property is + optional and cannot be used if the KeyVault subscription is not the same as the Disk Encryption + Set subscription. + :vartype source_vault: ~azure.mgmt.compute.models.SourceVault + :ivar key_url: Fully versioned Key Url pointing to a key in KeyVault. Version segment of the + Url is required regardless of rotationToLatestKeyVersionEnabled value. Required. + :vartype key_url: str + """ + + _validation = { + "key_url": {"required": True}, + } + + _attribute_map = { + "source_vault": {"key": "sourceVault", "type": "SourceVault"}, + "key_url": {"key": "keyUrl", "type": "str"}, + } + + def __init__(self, *, key_url: str, source_vault: Optional["_models.SourceVault"] = None, **kwargs: Any) -> None: + """ + :keyword source_vault: Resource id of the KeyVault containing the key or secret. This property + is optional and cannot be used if the KeyVault subscription is not the same as the Disk + Encryption Set subscription. + :paramtype source_vault: ~azure.mgmt.compute.models.SourceVault + :keyword key_url: Fully versioned Key Url pointing to a key in KeyVault. Version segment of the + Url is required regardless of rotationToLatestKeyVersionEnabled value. Required. + :paramtype key_url: str + """ + super().__init__(**kwargs) + self.source_vault = source_vault + self.key_url = key_url + + +class KeyVaultAndKeyReference(_serialization.Model): + """Key Vault Key Url and vault id of KeK, KeK is optional and when provided is used to unwrap the + encryptionKey. + + All required parameters must be populated in order to send to server. + + :ivar source_vault: Resource id of the KeyVault containing the key or secret. Required. + :vartype source_vault: ~azure.mgmt.compute.models.SourceVault + :ivar key_url: Url pointing to a key or secret in KeyVault. Required. + :vartype key_url: str + """ + + _validation = { + "source_vault": {"required": True}, + "key_url": {"required": True}, + } + + _attribute_map = { + "source_vault": {"key": "sourceVault", "type": "SourceVault"}, + "key_url": {"key": "keyUrl", "type": "str"}, + } + + def __init__(self, *, source_vault: "_models.SourceVault", key_url: str, **kwargs: Any) -> None: + """ + :keyword source_vault: Resource id of the KeyVault containing the key or secret. Required. + :paramtype source_vault: ~azure.mgmt.compute.models.SourceVault + :keyword key_url: Url pointing to a key or secret in KeyVault. Required. + :paramtype key_url: str + """ + super().__init__(**kwargs) + self.source_vault = source_vault + self.key_url = key_url + + +class KeyVaultAndSecretReference(_serialization.Model): + """Key Vault Secret Url and vault id of the encryption key. + + All required parameters must be populated in order to send to server. + + :ivar source_vault: Resource id of the KeyVault containing the key or secret. Required. + :vartype source_vault: ~azure.mgmt.compute.models.SourceVault + :ivar secret_url: Url pointing to a key or secret in KeyVault. Required. + :vartype secret_url: str + """ + + _validation = { + "source_vault": {"required": True}, + "secret_url": {"required": True}, + } + + _attribute_map = { + "source_vault": {"key": "sourceVault", "type": "SourceVault"}, + "secret_url": {"key": "secretUrl", "type": "str"}, + } + + def __init__(self, *, source_vault: "_models.SourceVault", secret_url: str, **kwargs: Any) -> None: + """ + :keyword source_vault: Resource id of the KeyVault containing the key or secret. Required. + :paramtype source_vault: ~azure.mgmt.compute.models.SourceVault + :keyword secret_url: Url pointing to a key or secret in KeyVault. Required. + :paramtype secret_url: str + """ + super().__init__(**kwargs) + self.source_vault = source_vault + self.secret_url = secret_url + + +class KeyVaultKeyReference(_serialization.Model): + """Describes a reference to Key Vault Key. + + All required parameters must be populated in order to send to server. + + :ivar key_url: The URL referencing a key encryption key in Key Vault. Required. + :vartype key_url: str + :ivar source_vault: The relative URL of the Key Vault containing the key. Required. + :vartype source_vault: ~azure.mgmt.compute.models.SubResource + """ + + _validation = { + "key_url": {"required": True}, + "source_vault": {"required": True}, + } + + _attribute_map = { + "key_url": {"key": "keyUrl", "type": "str"}, + "source_vault": {"key": "sourceVault", "type": "SubResource"}, + } + + def __init__(self, *, key_url: str, source_vault: "_models.SubResource", **kwargs: Any) -> None: + """ + :keyword key_url: The URL referencing a key encryption key in Key Vault. Required. + :paramtype key_url: str + :keyword source_vault: The relative URL of the Key Vault containing the key. Required. + :paramtype source_vault: ~azure.mgmt.compute.models.SubResource + """ + super().__init__(**kwargs) + self.key_url = key_url + self.source_vault = source_vault + + +class KeyVaultSecretReference(_serialization.Model): + """Describes a reference to Key Vault Secret. + + All required parameters must be populated in order to send to server. + + :ivar secret_url: The URL referencing a secret in a Key Vault. Required. + :vartype secret_url: str + :ivar source_vault: The relative URL of the Key Vault containing the secret. Required. + :vartype source_vault: ~azure.mgmt.compute.models.SubResource + """ + + _validation = { + "secret_url": {"required": True}, + "source_vault": {"required": True}, + } + + _attribute_map = { + "secret_url": {"key": "secretUrl", "type": "str"}, + "source_vault": {"key": "sourceVault", "type": "SubResource"}, + } + + def __init__(self, *, secret_url: str, source_vault: "_models.SubResource", **kwargs: Any) -> None: + """ + :keyword secret_url: The URL referencing a secret in a Key Vault. Required. + :paramtype secret_url: str + :keyword source_vault: The relative URL of the Key Vault containing the secret. Required. + :paramtype source_vault: ~azure.mgmt.compute.models.SubResource + """ + super().__init__(**kwargs) + self.secret_url = secret_url + self.source_vault = source_vault + + +class LastPatchInstallationSummary(_serialization.Model): + """Describes the properties of the last installed patch summary. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The overall success or failure status of the operation. It remains "InProgress" + until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + and "CompletedWithWarnings". + :vartype status: str or ~azure.mgmt.compute.models.PatchOperationStatus + :ivar installation_activity_id: The activity ID of the operation that produced this result. It + is used to correlate across CRP and extension logs. + :vartype installation_activity_id: str + :ivar maintenance_window_exceeded: Describes whether the operation ran out of time before it + completed all its intended actions. + :vartype maintenance_window_exceeded: bool + :ivar not_selected_patch_count: The number of all available patches but not going to be + installed because it didn't match a classification or inclusion list entry. + :vartype not_selected_patch_count: int + :ivar excluded_patch_count: The number of all available patches but excluded explicitly by a + customer-specified exclusion list match. + :vartype excluded_patch_count: int + :ivar pending_patch_count: The number of all available patches expected to be installed over + the course of the patch installation operation. + :vartype pending_patch_count: int + :ivar installed_patch_count: The count of patches that successfully installed. + :vartype installed_patch_count: int + :ivar failed_patch_count: The count of patches that failed installation. + :vartype failed_patch_count: int + :ivar start_time: The UTC timestamp when the operation began. + :vartype start_time: ~datetime.datetime + :ivar last_modified_time: The UTC timestamp when the operation began. + :vartype last_modified_time: ~datetime.datetime + :ivar error: The errors that were encountered during execution of the operation. The details + array contains the list of them. + :vartype error: ~azure.mgmt.compute.models.ApiError + """ + + _validation = { + "status": {"readonly": True}, + "installation_activity_id": {"readonly": True}, + "maintenance_window_exceeded": {"readonly": True}, + "not_selected_patch_count": {"readonly": True}, + "excluded_patch_count": {"readonly": True}, + "pending_patch_count": {"readonly": True}, + "installed_patch_count": {"readonly": True}, + "failed_patch_count": {"readonly": True}, + "start_time": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "error": {"readonly": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "installation_activity_id": {"key": "installationActivityId", "type": "str"}, + "maintenance_window_exceeded": {"key": "maintenanceWindowExceeded", "type": "bool"}, + "not_selected_patch_count": {"key": "notSelectedPatchCount", "type": "int"}, + "excluded_patch_count": {"key": "excludedPatchCount", "type": "int"}, + "pending_patch_count": {"key": "pendingPatchCount", "type": "int"}, + "installed_patch_count": {"key": "installedPatchCount", "type": "int"}, + "failed_patch_count": {"key": "failedPatchCount", "type": "int"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "last_modified_time": {"key": "lastModifiedTime", "type": "iso-8601"}, + "error": {"key": "error", "type": "ApiError"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.status: Optional[Union[str, "_models.PatchOperationStatus"]] = None + self.installation_activity_id: Optional[str] = None + self.maintenance_window_exceeded: Optional[bool] = None + self.not_selected_patch_count: Optional[int] = None + self.excluded_patch_count: Optional[int] = None + self.pending_patch_count: Optional[int] = None + self.installed_patch_count: Optional[int] = None + self.failed_patch_count: Optional[int] = None + self.start_time: Optional[datetime.datetime] = None + self.last_modified_time: Optional[datetime.datetime] = None + self.error: Optional["_models.ApiError"] = None + + +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 LinuxConfiguration(_serialization.Model): + """Specifies the Linux operating system settings on the virtual machine. For a list of supported + Linux distributions, see `Linux on Azure-Endorsed Distributions + `_. + + :ivar disable_password_authentication: Specifies whether password authentication should be + disabled. + :vartype disable_password_authentication: bool + :ivar ssh: Specifies the ssh key configuration for a Linux OS. + :vartype ssh: ~azure.mgmt.compute.models.SshConfiguration + :ivar provision_vm_agent: Indicates whether virtual machine agent should be provisioned on the + virtual machine. When this property is not specified in the request body, default behavior is + to set it to true. This will ensure that VM Agent is installed on the VM so that extensions can + be added to the VM later. + :vartype provision_vm_agent: bool + :ivar patch_settings: [Preview Feature] Specifies settings related to VM Guest Patching on + Linux. + :vartype patch_settings: ~azure.mgmt.compute.models.LinuxPatchSettings + :ivar enable_vm_agent_platform_updates: Indicates whether VMAgent Platform Updates is enabled + for the Linux virtual machine. Default value is false. + :vartype enable_vm_agent_platform_updates: bool + """ + + _attribute_map = { + "disable_password_authentication": {"key": "disablePasswordAuthentication", "type": "bool"}, + "ssh": {"key": "ssh", "type": "SshConfiguration"}, + "provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"}, + "patch_settings": {"key": "patchSettings", "type": "LinuxPatchSettings"}, + "enable_vm_agent_platform_updates": {"key": "enableVMAgentPlatformUpdates", "type": "bool"}, + } + + def __init__( + self, + *, + disable_password_authentication: Optional[bool] = None, + ssh: Optional["_models.SshConfiguration"] = None, + provision_vm_agent: Optional[bool] = None, + patch_settings: Optional["_models.LinuxPatchSettings"] = None, + enable_vm_agent_platform_updates: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword disable_password_authentication: Specifies whether password authentication should be + disabled. + :paramtype disable_password_authentication: bool + :keyword ssh: Specifies the ssh key configuration for a Linux OS. + :paramtype ssh: ~azure.mgmt.compute.models.SshConfiguration + :keyword provision_vm_agent: Indicates whether virtual machine agent should be provisioned on + the virtual machine. When this property is not specified in the request body, default behavior + is to set it to true. This will ensure that VM Agent is installed on the VM so that extensions + can be added to the VM later. + :paramtype provision_vm_agent: bool + :keyword patch_settings: [Preview Feature] Specifies settings related to VM Guest Patching on + Linux. + :paramtype patch_settings: ~azure.mgmt.compute.models.LinuxPatchSettings + :keyword enable_vm_agent_platform_updates: Indicates whether VMAgent Platform Updates is + enabled for the Linux virtual machine. Default value is false. + :paramtype enable_vm_agent_platform_updates: bool + """ + super().__init__(**kwargs) + self.disable_password_authentication = disable_password_authentication + self.ssh = ssh + self.provision_vm_agent = provision_vm_agent + self.patch_settings = patch_settings + self.enable_vm_agent_platform_updates = enable_vm_agent_platform_updates + + +class LinuxParameters(_serialization.Model): + """Input for InstallPatches on a Linux VM, as directly received by the API. + + :ivar classifications_to_include: The update classifications to select when installing patches + for Linux. + :vartype classifications_to_include: list[str or + ~azure.mgmt.compute.models.VMGuestPatchClassificationLinux] + :ivar package_name_masks_to_include: packages to include in the patch operation. Format: + packageName_packageVersion. + :vartype package_name_masks_to_include: list[str] + :ivar package_name_masks_to_exclude: packages to exclude in the patch operation. Format: + packageName_packageVersion. + :vartype package_name_masks_to_exclude: list[str] + :ivar maintenance_run_id: This is used as a maintenance run identifier for Auto VM Guest + Patching in Linux. + :vartype maintenance_run_id: str + """ + + _attribute_map = { + "classifications_to_include": {"key": "classificationsToInclude", "type": "[str]"}, + "package_name_masks_to_include": {"key": "packageNameMasksToInclude", "type": "[str]"}, + "package_name_masks_to_exclude": {"key": "packageNameMasksToExclude", "type": "[str]"}, + "maintenance_run_id": {"key": "maintenanceRunId", "type": "str"}, + } + + def __init__( + self, + *, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationLinux"]]] = None, + package_name_masks_to_include: Optional[List[str]] = None, + package_name_masks_to_exclude: Optional[List[str]] = None, + maintenance_run_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword classifications_to_include: The update classifications to select when installing + patches for Linux. + :paramtype classifications_to_include: list[str or + ~azure.mgmt.compute.models.VMGuestPatchClassificationLinux] + :keyword package_name_masks_to_include: packages to include in the patch operation. Format: + packageName_packageVersion. + :paramtype package_name_masks_to_include: list[str] + :keyword package_name_masks_to_exclude: packages to exclude in the patch operation. Format: + packageName_packageVersion. + :paramtype package_name_masks_to_exclude: list[str] + :keyword maintenance_run_id: This is used as a maintenance run identifier for Auto VM Guest + Patching in Linux. + :paramtype maintenance_run_id: str + """ + super().__init__(**kwargs) + self.classifications_to_include = classifications_to_include + self.package_name_masks_to_include = package_name_masks_to_include + self.package_name_masks_to_exclude = package_name_masks_to_exclude + self.maintenance_run_id = maintenance_run_id + + +class LinuxPatchSettings(_serialization.Model): + """Specifies settings related to VM Guest Patching on Linux. + + :ivar patch_mode: Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual + machines associated to virtual machine scale set with OrchestrationMode as Flexible.\\ + :code:`
`\\ :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` + **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
`\\ :code:`
` **AutomaticByPlatform** - The virtual machine will be automatically + updated by the platform. The property provisionVMAgent must be true. Known values are: + "ImageDefault" and "AutomaticByPlatform". + :vartype patch_mode: str or ~azure.mgmt.compute.models.LinuxVMGuestPatchMode + :ivar assessment_mode: Specifies the mode of VM Guest Patch Assessment for the IaaS virtual + machine.\\ :code:`
`\\ :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. + :code:`
`\\ :code:`
` **AutomaticByPlatform** - The platform will trigger periodic + patch assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault" + and "AutomaticByPlatform". + :vartype assessment_mode: str or ~azure.mgmt.compute.models.LinuxPatchAssessmentMode + :ivar automatic_by_platform_settings: Specifies additional settings for patch mode + AutomaticByPlatform in VM Guest Patching on Linux. + :vartype automatic_by_platform_settings: + ~azure.mgmt.compute.models.LinuxVMGuestPatchAutomaticByPlatformSettings + """ + + _attribute_map = { + "patch_mode": {"key": "patchMode", "type": "str"}, + "assessment_mode": {"key": "assessmentMode", "type": "str"}, + "automatic_by_platform_settings": { + "key": "automaticByPlatformSettings", + "type": "LinuxVMGuestPatchAutomaticByPlatformSettings", + }, + } + + def __init__( + self, + *, + patch_mode: Optional[Union[str, "_models.LinuxVMGuestPatchMode"]] = None, + assessment_mode: Optional[Union[str, "_models.LinuxPatchAssessmentMode"]] = None, + automatic_by_platform_settings: Optional["_models.LinuxVMGuestPatchAutomaticByPlatformSettings"] = None, + **kwargs: Any + ) -> None: + """ + :keyword patch_mode: Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual + machines associated to virtual machine scale set with OrchestrationMode as Flexible.\\ + :code:`
`\\ :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` + **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
`\\ :code:`
` **AutomaticByPlatform** - The virtual machine will be automatically + updated by the platform. The property provisionVMAgent must be true. Known values are: + "ImageDefault" and "AutomaticByPlatform". + :paramtype patch_mode: str or ~azure.mgmt.compute.models.LinuxVMGuestPatchMode + :keyword assessment_mode: Specifies the mode of VM Guest Patch Assessment for the IaaS virtual + machine.\\ :code:`
`\\ :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. + :code:`
`\\ :code:`
` **AutomaticByPlatform** - The platform will trigger periodic + patch assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault" + and "AutomaticByPlatform". + :paramtype assessment_mode: str or ~azure.mgmt.compute.models.LinuxPatchAssessmentMode + :keyword automatic_by_platform_settings: Specifies additional settings for patch mode + AutomaticByPlatform in VM Guest Patching on Linux. + :paramtype automatic_by_platform_settings: + ~azure.mgmt.compute.models.LinuxVMGuestPatchAutomaticByPlatformSettings + """ + super().__init__(**kwargs) + self.patch_mode = patch_mode + self.assessment_mode = assessment_mode + self.automatic_by_platform_settings = automatic_by_platform_settings + + +class LinuxVMGuestPatchAutomaticByPlatformSettings(_serialization.Model): # pylint: disable=name-too-long + """Specifies additional settings to be applied when patch mode AutomaticByPlatform is selected in + Linux patch settings. + + :ivar reboot_setting: Specifies the reboot setting for all AutomaticByPlatform patch + installation operations. Known values are: "Unknown", "IfRequired", "Never", and "Always". + :vartype reboot_setting: str or + ~azure.mgmt.compute.models.LinuxVMGuestPatchAutomaticByPlatformRebootSetting + :ivar bypass_platform_safety_checks_on_user_schedule: Enables customer to schedule patching + without accidental upgrades. + :vartype bypass_platform_safety_checks_on_user_schedule: bool + """ + + _attribute_map = { + "reboot_setting": {"key": "rebootSetting", "type": "str"}, + "bypass_platform_safety_checks_on_user_schedule": { + "key": "bypassPlatformSafetyChecksOnUserSchedule", + "type": "bool", + }, + } + + def __init__( + self, + *, + reboot_setting: Optional[Union[str, "_models.LinuxVMGuestPatchAutomaticByPlatformRebootSetting"]] = None, + bypass_platform_safety_checks_on_user_schedule: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword reboot_setting: Specifies the reboot setting for all AutomaticByPlatform patch + installation operations. Known values are: "Unknown", "IfRequired", "Never", and "Always". + :paramtype reboot_setting: str or + ~azure.mgmt.compute.models.LinuxVMGuestPatchAutomaticByPlatformRebootSetting + :keyword bypass_platform_safety_checks_on_user_schedule: Enables customer to schedule patching + without accidental upgrades. + :paramtype bypass_platform_safety_checks_on_user_schedule: bool + """ + super().__init__(**kwargs) + self.reboot_setting = reboot_setting + self.bypass_platform_safety_checks_on_user_schedule = bypass_platform_safety_checks_on_user_schedule + + +class ListUsagesResult(_serialization.Model): + """The List Usages operation response. + + All required parameters must be populated in order to send to server. + + :ivar value: The list of compute resource usages. Required. + :vartype value: list[~azure.mgmt.compute.models.Usage] + :ivar next_link: The URI to fetch the next page of compute resource usage information. Call + ListNext() with this to fetch the next page of compute resource usage information. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Usage]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of compute resource usages. Required. + :paramtype value: list[~azure.mgmt.compute.models.Usage] + :keyword next_link: The URI to fetch the next page of compute resource usage information. Call + ListNext() with this to fetch the next page of compute resource usage information. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class LoadBalancerConfiguration(_serialization.Model): + """Describes the load balancer configuration. + + All required parameters must be populated in order to send to server. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: The name of the Load balancer. Required. + :vartype name: str + :ivar properties: Properties of the load balancer configuration. Required. + :vartype properties: ~azure.mgmt.compute.models.LoadBalancerConfigurationProperties + """ + + _validation = { + "name": {"required": True}, + "properties": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "LoadBalancerConfigurationProperties"}, + } + + def __init__( + self, + *, + name: str, + properties: "_models.LoadBalancerConfigurationProperties", + id: Optional[str] = None, # pylint: disable=redefined-builtin + **kwargs: Any + ) -> None: + """ + :keyword id: Resource Id. + :paramtype id: str + :keyword name: The name of the Load balancer. Required. + :paramtype name: str + :keyword properties: Properties of the load balancer configuration. Required. + :paramtype properties: ~azure.mgmt.compute.models.LoadBalancerConfigurationProperties + """ + super().__init__(**kwargs) + self.id = id + self.name = name + self.properties = properties + + +class LoadBalancerConfigurationProperties(_serialization.Model): + """Describes the properties of the load balancer configuration. + + All required parameters must be populated in order to send to server. + + :ivar frontend_ip_configurations: Specifies the frontend IP to be used for the load balancer. + Only IPv4 frontend IP address is supported. Each load balancer configuration must have exactly + one frontend IP configuration. Required. + :vartype frontend_ip_configurations: + list[~azure.mgmt.compute.models.LoadBalancerFrontendIpConfiguration] + """ + + _validation = { + "frontend_ip_configurations": {"required": True}, + } + + _attribute_map = { + "frontend_ip_configurations": { + "key": "frontendIpConfigurations", + "type": "[LoadBalancerFrontendIpConfiguration]", + }, + } + + def __init__( + self, *, frontend_ip_configurations: List["_models.LoadBalancerFrontendIpConfiguration"], **kwargs: Any + ) -> None: + """ + :keyword frontend_ip_configurations: Specifies the frontend IP to be used for the load + balancer. Only IPv4 frontend IP address is supported. Each load balancer configuration must + have exactly one frontend IP configuration. Required. + :paramtype frontend_ip_configurations: + list[~azure.mgmt.compute.models.LoadBalancerFrontendIpConfiguration] + """ + super().__init__(**kwargs) + self.frontend_ip_configurations = frontend_ip_configurations + + +class LoadBalancerFrontendIpConfiguration(_serialization.Model): + """Specifies the frontend IP to be used for the load balancer. Only IPv4 frontend IP address is + supported. Each load balancer configuration must have exactly one frontend IP configuration. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the resource that is unique within the set of frontend IP + configurations used by the load balancer. This name can be used to access the resource. + Required. + :vartype name: str + :ivar properties: Properties of load balancer frontend ip configuration. Required. + :vartype properties: ~azure.mgmt.compute.models.LoadBalancerFrontendIpConfigurationProperties + """ + + _validation = { + "name": {"required": True}, + "properties": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "LoadBalancerFrontendIpConfigurationProperties"}, + } + + def __init__( + self, *, name: str, properties: "_models.LoadBalancerFrontendIpConfigurationProperties", **kwargs: Any + ) -> None: + """ + :keyword name: The name of the resource that is unique within the set of frontend IP + configurations used by the load balancer. This name can be used to access the resource. + Required. + :paramtype name: str + :keyword properties: Properties of load balancer frontend ip configuration. Required. + :paramtype properties: ~azure.mgmt.compute.models.LoadBalancerFrontendIpConfigurationProperties + """ + super().__init__(**kwargs) + self.name = name + self.properties = properties + + +class LoadBalancerFrontendIpConfigurationProperties(_serialization.Model): # pylint: disable=name-too-long + """Describes a cloud service IP Configuration. + + :ivar public_ip_address: The reference to the public ip address resource. + :vartype public_ip_address: ~azure.mgmt.compute.models.SubResource + :ivar subnet: The reference to the virtual network subnet resource. + :vartype subnet: ~azure.mgmt.compute.models.SubResource + :ivar private_ip_address: The virtual network private IP address of the IP configuration. + :vartype private_ip_address: str + """ + + _attribute_map = { + "public_ip_address": {"key": "publicIPAddress", "type": "SubResource"}, + "subnet": {"key": "subnet", "type": "SubResource"}, + "private_ip_address": {"key": "privateIPAddress", "type": "str"}, + } + + def __init__( + self, + *, + public_ip_address: Optional["_models.SubResource"] = None, + subnet: Optional["_models.SubResource"] = None, + private_ip_address: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword public_ip_address: The reference to the public ip address resource. + :paramtype public_ip_address: ~azure.mgmt.compute.models.SubResource + :keyword subnet: The reference to the virtual network subnet resource. + :paramtype subnet: ~azure.mgmt.compute.models.SubResource + :keyword private_ip_address: The virtual network private IP address of the IP configuration. + :paramtype private_ip_address: str + """ + super().__init__(**kwargs) + self.public_ip_address = public_ip_address + self.subnet = subnet + self.private_ip_address = private_ip_address + + +class LogAnalyticsInputBase(_serialization.Model): + """Api input base class for LogAnalytics Api. + + All required parameters must be populated in order to send to server. + + :ivar blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api + writes output logs to. Required. + :vartype blob_container_sas_uri: str + :ivar from_time: From time of the query. Required. + :vartype from_time: ~datetime.datetime + :ivar to_time: To time of the query. Required. + :vartype to_time: ~datetime.datetime + :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. + :vartype group_by_throttle_policy: bool + :ivar group_by_operation_name: Group query result by Operation Name. + :vartype group_by_operation_name: bool + :ivar group_by_resource_name: Group query result by Resource Name. + :vartype group_by_resource_name: bool + :ivar group_by_client_application_id: Group query result by Client Application ID. + :vartype group_by_client_application_id: bool + :ivar group_by_user_agent: Group query result by User Agent. + :vartype group_by_user_agent: bool + """ + + _validation = { + "blob_container_sas_uri": {"required": True}, + "from_time": {"required": True}, + "to_time": {"required": True}, + } + + _attribute_map = { + "blob_container_sas_uri": {"key": "blobContainerSasUri", "type": "str"}, + "from_time": {"key": "fromTime", "type": "iso-8601"}, + "to_time": {"key": "toTime", "type": "iso-8601"}, + "group_by_throttle_policy": {"key": "groupByThrottlePolicy", "type": "bool"}, + "group_by_operation_name": {"key": "groupByOperationName", "type": "bool"}, + "group_by_resource_name": {"key": "groupByResourceName", "type": "bool"}, + "group_by_client_application_id": {"key": "groupByClientApplicationId", "type": "bool"}, + "group_by_user_agent": {"key": "groupByUserAgent", "type": "bool"}, + } + + def __init__( + self, + *, + blob_container_sas_uri: str, + from_time: datetime.datetime, + to_time: datetime.datetime, + group_by_throttle_policy: Optional[bool] = None, + group_by_operation_name: Optional[bool] = None, + group_by_resource_name: Optional[bool] = None, + group_by_client_application_id: Optional[bool] = None, + group_by_user_agent: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics + Api writes output logs to. Required. + :paramtype blob_container_sas_uri: str + :keyword from_time: From time of the query. Required. + :paramtype from_time: ~datetime.datetime + :keyword to_time: To time of the query. Required. + :paramtype to_time: ~datetime.datetime + :keyword group_by_throttle_policy: Group query result by Throttle Policy applied. + :paramtype group_by_throttle_policy: bool + :keyword group_by_operation_name: Group query result by Operation Name. + :paramtype group_by_operation_name: bool + :keyword group_by_resource_name: Group query result by Resource Name. + :paramtype group_by_resource_name: bool + :keyword group_by_client_application_id: Group query result by Client Application ID. + :paramtype group_by_client_application_id: bool + :keyword group_by_user_agent: Group query result by User Agent. + :paramtype group_by_user_agent: bool + """ + super().__init__(**kwargs) + self.blob_container_sas_uri = blob_container_sas_uri + self.from_time = from_time + self.to_time = to_time + self.group_by_throttle_policy = group_by_throttle_policy + self.group_by_operation_name = group_by_operation_name + self.group_by_resource_name = group_by_resource_name + self.group_by_client_application_id = group_by_client_application_id + self.group_by_user_agent = group_by_user_agent + + +class LogAnalyticsOperationResult(_serialization.Model): + """LogAnalytics operation status response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar properties: LogAnalyticsOutput. + :vartype properties: ~azure.mgmt.compute.models.LogAnalyticsOutput + """ + + _validation = { + "properties": {"readonly": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "LogAnalyticsOutput"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.properties: Optional["_models.LogAnalyticsOutput"] = None + + +class LogAnalyticsOutput(_serialization.Model): + """LogAnalytics output properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar output: Output file Uri path to blob container. + :vartype output: str + """ + + _validation = { + "output": {"readonly": True}, + } + + _attribute_map = { + "output": {"key": "output", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.output: Optional[str] = None + + +class MaintenanceRedeployStatus(_serialization.Model): + """Maintenance Operation Status. + + :ivar is_customer_initiated_maintenance_allowed: True, if customer is allowed to perform + Maintenance. + :vartype is_customer_initiated_maintenance_allowed: bool + :ivar pre_maintenance_window_start_time: Start Time for the Pre Maintenance Window. + :vartype pre_maintenance_window_start_time: ~datetime.datetime + :ivar pre_maintenance_window_end_time: End Time for the Pre Maintenance Window. + :vartype pre_maintenance_window_end_time: ~datetime.datetime + :ivar maintenance_window_start_time: Start Time for the Maintenance Window. + :vartype maintenance_window_start_time: ~datetime.datetime + :ivar maintenance_window_end_time: End Time for the Maintenance Window. + :vartype maintenance_window_end_time: ~datetime.datetime + :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: + "None", "RetryLater", "MaintenanceAborted", and "MaintenanceCompleted". + :vartype last_operation_result_code: str or + ~azure.mgmt.compute.models.MaintenanceOperationResultCodeTypes + :ivar last_operation_message: Message returned for the last Maintenance Operation. + :vartype last_operation_message: str + """ + + _attribute_map = { + "is_customer_initiated_maintenance_allowed": {"key": "isCustomerInitiatedMaintenanceAllowed", "type": "bool"}, + "pre_maintenance_window_start_time": {"key": "preMaintenanceWindowStartTime", "type": "iso-8601"}, + "pre_maintenance_window_end_time": {"key": "preMaintenanceWindowEndTime", "type": "iso-8601"}, + "maintenance_window_start_time": {"key": "maintenanceWindowStartTime", "type": "iso-8601"}, + "maintenance_window_end_time": {"key": "maintenanceWindowEndTime", "type": "iso-8601"}, + "last_operation_result_code": {"key": "lastOperationResultCode", "type": "str"}, + "last_operation_message": {"key": "lastOperationMessage", "type": "str"}, + } + + def __init__( + self, + *, + is_customer_initiated_maintenance_allowed: Optional[bool] = None, + pre_maintenance_window_start_time: Optional[datetime.datetime] = None, + pre_maintenance_window_end_time: Optional[datetime.datetime] = None, + maintenance_window_start_time: Optional[datetime.datetime] = None, + maintenance_window_end_time: Optional[datetime.datetime] = None, + last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, + last_operation_message: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword is_customer_initiated_maintenance_allowed: True, if customer is allowed to perform + Maintenance. + :paramtype is_customer_initiated_maintenance_allowed: bool + :keyword pre_maintenance_window_start_time: Start Time for the Pre Maintenance Window. + :paramtype pre_maintenance_window_start_time: ~datetime.datetime + :keyword pre_maintenance_window_end_time: End Time for the Pre Maintenance Window. + :paramtype pre_maintenance_window_end_time: ~datetime.datetime + :keyword maintenance_window_start_time: Start Time for the Maintenance Window. + :paramtype maintenance_window_start_time: ~datetime.datetime + :keyword maintenance_window_end_time: End Time for the Maintenance Window. + :paramtype maintenance_window_end_time: ~datetime.datetime + :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values + are: "None", "RetryLater", "MaintenanceAborted", and "MaintenanceCompleted". + :paramtype last_operation_result_code: str or + ~azure.mgmt.compute.models.MaintenanceOperationResultCodeTypes + :keyword last_operation_message: Message returned for the last Maintenance Operation. + :paramtype last_operation_message: str + """ + super().__init__(**kwargs) + self.is_customer_initiated_maintenance_allowed = is_customer_initiated_maintenance_allowed + self.pre_maintenance_window_start_time = pre_maintenance_window_start_time + self.pre_maintenance_window_end_time = pre_maintenance_window_end_time + self.maintenance_window_start_time = maintenance_window_start_time + self.maintenance_window_end_time = maintenance_window_end_time + self.last_operation_result_code = last_operation_result_code + self.last_operation_message = last_operation_message + + +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 ManagedDiskParameters(SubResource): + """The parameters of a managed disk. + + :ivar id: Resource Id. + :vartype id: str + :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + "StandardSSD_ZRS", and "PremiumV2_LRS". + :vartype storage_account_type: str or ~azure.mgmt.compute.models.StorageAccountTypes + :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for + the managed disk. + :vartype disk_encryption_set: ~azure.mgmt.compute.models.DiskEncryptionSetParameters + :ivar security_profile: Specifies the security profile for the managed disk. + :vartype security_profile: ~azure.mgmt.compute.models.VMDiskSecurityProfile + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "storage_account_type": {"key": "storageAccountType", "type": "str"}, + "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, + "security_profile": {"key": "securityProfile", "type": "VMDiskSecurityProfile"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, + security_profile: Optional["_models.VMDiskSecurityProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Resource Id. + :paramtype id: str + :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + "StandardSSD_ZRS", and "PremiumV2_LRS". + :paramtype storage_account_type: str or ~azure.mgmt.compute.models.StorageAccountTypes + :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id + for the managed disk. + :paramtype disk_encryption_set: ~azure.mgmt.compute.models.DiskEncryptionSetParameters + :keyword security_profile: Specifies the security profile for the managed disk. + :paramtype security_profile: ~azure.mgmt.compute.models.VMDiskSecurityProfile + """ + super().__init__(id=id, **kwargs) + self.storage_account_type = storage_account_type + self.disk_encryption_set = disk_encryption_set + self.security_profile = security_profile + + +class MigrateToVirtualMachineScaleSetInput(_serialization.Model): + """Describes the Virtual Machine Scale Set to migrate from Availability Set. + + All required parameters must be populated in order to send to server. + + :ivar virtual_machine_scale_set_flexible: Specifies information about the Virtual Machine Scale + Set that the Availability Set should be migrated to. Minimum api‐version: 2024‐11‐01. Required. + :vartype virtual_machine_scale_set_flexible: ~azure.mgmt.compute.models.SubResource + """ + + _validation = { + "virtual_machine_scale_set_flexible": {"required": True}, + } + + _attribute_map = { + "virtual_machine_scale_set_flexible": {"key": "virtualMachineScaleSetFlexible", "type": "SubResource"}, + } + + def __init__(self, *, virtual_machine_scale_set_flexible: "_models.SubResource", **kwargs: Any) -> None: + """ + :keyword virtual_machine_scale_set_flexible: Specifies information about the Virtual Machine + Scale Set that the Availability Set should be migrated to. Minimum api‐version: 2024‐11‐01. + Required. + :paramtype virtual_machine_scale_set_flexible: ~azure.mgmt.compute.models.SubResource + """ + super().__init__(**kwargs) + self.virtual_machine_scale_set_flexible = virtual_machine_scale_set_flexible + + +class MigrateVMToVirtualMachineScaleSetInput(_serialization.Model): + """The input of virtual machine migration from Availability Set to Flexible Virtual Machine Scale + Set. + + :ivar target_zone: The target zone of VM migration to Flexible Virtual Machine Scale Set. + :vartype target_zone: str + :ivar target_fault_domain: The target compute fault domain of VM migration to Flexible Virtual + Machine Scale Set. + :vartype target_fault_domain: int + :ivar target_vm_size: The target Virtual Machine size of VM migration to Flexible Virtual + Machine Scale Set. + :vartype target_vm_size: str + """ + + _attribute_map = { + "target_zone": {"key": "targetZone", "type": "str"}, + "target_fault_domain": {"key": "targetFaultDomain", "type": "int"}, + "target_vm_size": {"key": "targetVMSize", "type": "str"}, + } + + def __init__( + self, + *, + target_zone: Optional[str] = None, + target_fault_domain: Optional[int] = None, + target_vm_size: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword target_zone: The target zone of VM migration to Flexible Virtual Machine Scale Set. + :paramtype target_zone: str + :keyword target_fault_domain: The target compute fault domain of VM migration to Flexible + Virtual Machine Scale Set. + :paramtype target_fault_domain: int + :keyword target_vm_size: The target Virtual Machine size of VM migration to Flexible Virtual + Machine Scale Set. + :paramtype target_vm_size: str + """ + super().__init__(**kwargs) + self.target_zone = target_zone + self.target_fault_domain = target_fault_domain + self.target_vm_size = target_vm_size + + +class NetworkInterfaceReference(SubResource): + """Describes a network interface reference. + + :ivar id: Resource Id. + :vartype id: str + :ivar primary: Specifies the primary network interface in case the virtual machine has more + than 1 network interface. + :vartype primary: bool + :ivar delete_option: Specify what happens to the network interface when the VM is deleted. + Known values are: "Delete" and "Detach". + :vartype delete_option: str or ~azure.mgmt.compute.models.DeleteOptions + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "primary": {"key": "properties.primary", "type": "bool"}, + "delete_option": {"key": "properties.deleteOption", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + primary: Optional[bool] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Resource Id. + :paramtype id: str + :keyword primary: Specifies the primary network interface in case the virtual machine has more + than 1 network interface. + :paramtype primary: bool + :keyword delete_option: Specify what happens to the network interface when the VM is deleted. + Known values are: "Delete" and "Detach". + :paramtype delete_option: str or ~azure.mgmt.compute.models.DeleteOptions + """ + super().__init__(id=id, **kwargs) + self.primary = primary + self.delete_option = delete_option + + +class NetworkProfile(_serialization.Model): + """Specifies the network interfaces or the networking configuration of the virtual machine. + + :ivar network_interfaces: Specifies the list of resource Ids for the network interfaces + associated with the virtual machine. + :vartype network_interfaces: list[~azure.mgmt.compute.models.NetworkInterfaceReference] + :ivar network_api_version: specifies the Microsoft.Network API version used when creating + networking resources in the Network Interface Configurations. Known values are: "2020-11-01" + and "2022-11-01". + :vartype network_api_version: str or ~azure.mgmt.compute.models.NetworkApiVersion + :ivar network_interface_configurations: Specifies the networking configurations that will be + used to create the virtual machine networking resources. + :vartype network_interface_configurations: + list[~azure.mgmt.compute.models.VirtualMachineNetworkInterfaceConfiguration] + """ + + _attribute_map = { + "network_interfaces": {"key": "networkInterfaces", "type": "[NetworkInterfaceReference]"}, + "network_api_version": {"key": "networkApiVersion", "type": "str"}, + "network_interface_configurations": { + "key": "networkInterfaceConfigurations", + "type": "[VirtualMachineNetworkInterfaceConfiguration]", + }, + } + + def __init__( + self, + *, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, + network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineNetworkInterfaceConfiguration"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword network_interfaces: Specifies the list of resource Ids for the network interfaces + associated with the virtual machine. + :paramtype network_interfaces: list[~azure.mgmt.compute.models.NetworkInterfaceReference] + :keyword network_api_version: specifies the Microsoft.Network API version used when creating + networking resources in the Network Interface Configurations. Known values are: "2020-11-01" + and "2022-11-01". + :paramtype network_api_version: str or ~azure.mgmt.compute.models.NetworkApiVersion + :keyword network_interface_configurations: Specifies the networking configurations that will be + used to create the virtual machine networking resources. + :paramtype network_interface_configurations: + list[~azure.mgmt.compute.models.VirtualMachineNetworkInterfaceConfiguration] + """ + super().__init__(**kwargs) + self.network_interfaces = network_interfaces + self.network_api_version = network_api_version + 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.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.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.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.models.OperationDisplay + """ + super().__init__(**kwargs) + self.name: Optional[str] = None + self.is_data_action: Optional[bool] = None + self.display = display + self.origin: Optional[Union[str, "_models.Origin"]] = None + self.action_type: Optional[Union[str, "_models.ActionType"]] = 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: Optional[str] = None + self.resource: Optional[str] = None + self.operation: Optional[str] = None + self.description: Optional[str] = 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.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: Optional[List["_models.Operation"]] = None + self.next_link: Optional[str] = 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. "AutomaticRepairs" + :vartype service_name: str or ~azure.mgmt.compute.models.OrchestrationServiceNames + :ivar action: The action to be performed. Required. Known values are: "Resume" and "Suspend". + :vartype action: str or ~azure.mgmt.compute.models.OrchestrationServiceStateAction + """ + + _validation = { + "service_name": {"required": True}, + "action": {"required": True}, + } + + _attribute_map = { + "service_name": {"key": "serviceName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + } + + def __init__( + self, + *, + service_name: Union[str, "_models.OrchestrationServiceNames"], + action: Union[str, "_models.OrchestrationServiceStateAction"], + **kwargs: Any + ) -> None: + """ + :keyword service_name: The name of the service. Required. "AutomaticRepairs" + :paramtype service_name: str or ~azure.mgmt.compute.models.OrchestrationServiceNames + :keyword action: The action to be performed. Required. Known values are: "Resume" and + "Suspend". + :paramtype action: str or ~azure.mgmt.compute.models.OrchestrationServiceStateAction + """ + super().__init__(**kwargs) + self.service_name = service_name + self.action = action + + +class OrchestrationServiceSummary(_serialization.Model): + """Summary for an orchestration service of a virtual machine scale set. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar service_name: The name of the service. "AutomaticRepairs" + :vartype service_name: str or ~azure.mgmt.compute.models.OrchestrationServiceNames + :ivar service_state: The current state of the service. Known values are: "NotRunning", + "Running", and "Suspended". + :vartype service_state: str or ~azure.mgmt.compute.models.OrchestrationServiceState + """ + + _validation = { + "service_name": {"readonly": True}, + "service_state": {"readonly": True}, + } + + _attribute_map = { + "service_name": {"key": "serviceName", "type": "str"}, + "service_state": {"key": "serviceState", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.service_name: Optional[Union[str, "_models.OrchestrationServiceNames"]] = None + self.service_state: Optional[Union[str, "_models.OrchestrationServiceState"]] = None + + +class OSDisk(_serialization.Model): + """Specifies information about the operating system disk used by the virtual machine. For more + information about disks, see `About disks and VHDs for Azure virtual machines + `_. + + All required parameters must be populated in order to send to server. + + :ivar os_type: This property allows you to specify the type of the OS that is included in the + disk if creating a VM from user-image or a specialized VHD. Possible values are: **Windows,** + **Linux.**. Known values are: "Windows" and "Linux". + :vartype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :ivar encryption_settings: Specifies the encryption settings for the OS Disk. Minimum + api-version: 2015-06-15. + :vartype encryption_settings: ~azure.mgmt.compute.models.DiskEncryptionSettings + :ivar name: The disk name. + :vartype name: str + :ivar vhd: The virtual hard disk. + :vartype vhd: ~azure.mgmt.compute.models.VirtualHardDisk + :ivar image: 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. + :vartype image: ~azure.mgmt.compute.models.VirtualHardDisk + :ivar caching: Specifies the caching requirements. Possible values are: **None,** **ReadOnly,** + **ReadWrite.** The defaulting behavior is: **None for Standard storage. ReadOnly for Premium + storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". + :vartype caching: str or ~azure.mgmt.compute.models.CachingTypes + :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or + disabled on the disk. + :vartype write_accelerator_enabled: bool + :ivar diff_disk_settings: Specifies the ephemeral Disk Settings for the operating system disk + used by the virtual machine. + :vartype diff_disk_settings: ~azure.mgmt.compute.models.DiffDiskSettings + :ivar create_option: Specifies how the virtual machine disk should be created. Possible values + are **Attach:** This value is used when you are using a specialized disk to create the virtual + machine. **FromImage:** This value is used when you are using an image to create the virtual + machine. If you are using a platform image, you should also use the imageReference element + described above. If you are using a marketplace image, you should also use the plan element + previously described. Required. Known values are: "FromImage", "Empty", "Attach", "Copy", and + "Restore". + :vartype create_option: str or ~azure.mgmt.compute.models.DiskCreateOptionTypes + :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be + used to overwrite the size of the disk in a virtual machine image. The property 'diskSizeGB' is + the number of bytes x 1024^3 for the disk and the value cannot be larger than 1023. + :vartype disk_size_gb: int + :ivar managed_disk: The managed disk parameters. + :vartype managed_disk: ~azure.mgmt.compute.models.ManagedDiskParameters + :ivar delete_option: Specifies whether OS Disk should be deleted or detached upon VM deletion. + Possible values are: **Delete.** If this value is used, the OS disk is deleted when VM is + deleted. **Detach.** If this value is used, the os disk is retained after VM is deleted. The + default value is set to **Detach**. For an ephemeral OS Disk, the default value is set to + **Delete**. The user cannot change the delete option for an ephemeral OS Disk. Known values + are: "Delete" and "Detach". + :vartype delete_option: str or ~azure.mgmt.compute.models.DiskDeleteOptionTypes + """ + + _validation = { + "create_option": {"required": True}, + } + + _attribute_map = { + "os_type": {"key": "osType", "type": "str"}, + "encryption_settings": {"key": "encryptionSettings", "type": "DiskEncryptionSettings"}, + "name": {"key": "name", "type": "str"}, + "vhd": {"key": "vhd", "type": "VirtualHardDisk"}, + "image": {"key": "image", "type": "VirtualHardDisk"}, + "caching": {"key": "caching", "type": "str"}, + "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, + "diff_disk_settings": {"key": "diffDiskSettings", "type": "DiffDiskSettings"}, + "create_option": {"key": "createOption", "type": "str"}, + "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, + "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, + "delete_option": {"key": "deleteOption", "type": "str"}, + } + + def __init__( + self, + *, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, + name: Optional[str] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, + write_accelerator_enabled: Optional[bool] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, + disk_size_gb: Optional[int] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword os_type: This property allows you to specify the type of the OS that is included in + the disk if creating a VM from user-image or a specialized VHD. Possible values are: + **Windows,** **Linux.**. Known values are: "Windows" and "Linux". + :paramtype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :keyword encryption_settings: Specifies the encryption settings for the OS Disk. Minimum + api-version: 2015-06-15. + :paramtype encryption_settings: ~azure.mgmt.compute.models.DiskEncryptionSettings + :keyword name: The disk name. + :paramtype name: str + :keyword vhd: The virtual hard disk. + :paramtype vhd: ~azure.mgmt.compute.models.VirtualHardDisk + :keyword image: 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. + :paramtype image: ~azure.mgmt.compute.models.VirtualHardDisk + :keyword caching: Specifies the caching requirements. Possible values are: **None,** + **ReadOnly,** **ReadWrite.** The defaulting behavior is: **None for Standard storage. ReadOnly + for Premium storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". + :paramtype caching: str or ~azure.mgmt.compute.models.CachingTypes + :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or + disabled on the disk. + :paramtype write_accelerator_enabled: bool + :keyword diff_disk_settings: Specifies the ephemeral Disk Settings for the operating system + disk used by the virtual machine. + :paramtype diff_disk_settings: ~azure.mgmt.compute.models.DiffDiskSettings + :keyword create_option: Specifies how the virtual machine disk should be created. Possible + values are **Attach:** This value is used when you are using a specialized disk to create the + virtual machine. **FromImage:** This value is used when you are using an image to create the + virtual machine. If you are using a platform image, you should also use the imageReference + element described above. If you are using a marketplace image, you should also use the plan + element previously described. Required. Known values are: "FromImage", "Empty", "Attach", + "Copy", and "Restore". + :paramtype create_option: str or ~azure.mgmt.compute.models.DiskCreateOptionTypes + :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can + be used to overwrite the size of the disk in a virtual machine image. The property 'diskSizeGB' + is the number of bytes x 1024^3 for the disk and the value cannot be larger than 1023. + :paramtype disk_size_gb: int + :keyword managed_disk: The managed disk parameters. + :paramtype managed_disk: ~azure.mgmt.compute.models.ManagedDiskParameters + :keyword delete_option: Specifies whether OS Disk should be deleted or detached upon VM + deletion. Possible values are: **Delete.** If this value is used, the OS disk is deleted when + VM is deleted. **Detach.** If this value is used, the os disk is retained after VM is deleted. + The default value is set to **Detach**. For an ephemeral OS Disk, the default value is set to + **Delete**. The user cannot change the delete option for an ephemeral OS Disk. Known values + are: "Delete" and "Detach". + :paramtype delete_option: str or ~azure.mgmt.compute.models.DiskDeleteOptionTypes + """ + super().__init__(**kwargs) + self.os_type = os_type + self.encryption_settings = encryption_settings + self.name = name + self.vhd = vhd + self.image = image + self.caching = caching + self.write_accelerator_enabled = write_accelerator_enabled + self.diff_disk_settings = diff_disk_settings + self.create_option = create_option + self.disk_size_gb = disk_size_gb + self.managed_disk = managed_disk + self.delete_option = delete_option + + +class OSDiskImage(_serialization.Model): + """Contains the os disk image information. + + All required parameters must be populated in order to send to server. + + :ivar operating_system: The operating system of the osDiskImage. Required. Known values are: + "Windows" and "Linux". + :vartype operating_system: str or ~azure.mgmt.compute.models.OperatingSystemTypes + """ + + _validation = { + "operating_system": {"required": True}, + } + + _attribute_map = { + "operating_system": {"key": "operatingSystem", "type": "str"}, + } + + def __init__(self, *, operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs: Any) -> None: + """ + :keyword operating_system: The operating system of the osDiskImage. Required. Known values are: + "Windows" and "Linux". + :paramtype operating_system: str or ~azure.mgmt.compute.models.OperatingSystemTypes + """ + super().__init__(**kwargs) + self.operating_system = operating_system + + +class OSDiskImageEncryption(DiskImageEncryption): + """Contains encryption settings for an OS disk image. + + :ivar disk_encryption_set_id: A relative URI containing the resource ID of the disk encryption + set. + :vartype disk_encryption_set_id: str + :ivar security_profile: This property specifies the security profile of an OS disk image. + :vartype security_profile: ~azure.mgmt.compute.models.OSDiskImageSecurityProfile + """ + + _attribute_map = { + "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, + "security_profile": {"key": "securityProfile", "type": "OSDiskImageSecurityProfile"}, + } + + def __init__( + self, + *, + disk_encryption_set_id: Optional[str] = None, + security_profile: Optional["_models.OSDiskImageSecurityProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword disk_encryption_set_id: A relative URI containing the resource ID of the disk + encryption set. + :paramtype disk_encryption_set_id: str + :keyword security_profile: This property specifies the security profile of an OS disk image. + :paramtype security_profile: ~azure.mgmt.compute.models.OSDiskImageSecurityProfile + """ + super().__init__(disk_encryption_set_id=disk_encryption_set_id, **kwargs) + self.security_profile = security_profile + + +class OSDiskImageSecurityProfile(_serialization.Model): + """Contains security profile for an OS disk image. + + :ivar confidential_vm_encryption_type: confidential VM encryption types. Known values are: + "EncryptedVMGuestStateOnlyWithPmk", "EncryptedWithPmk", "EncryptedWithCmk", and + "NonPersistedTPM". + :vartype confidential_vm_encryption_type: str or + ~azure.mgmt.compute.models.ConfidentialVMEncryptionType + :ivar secure_vm_disk_encryption_set_id: secure VM disk encryption set id. + :vartype secure_vm_disk_encryption_set_id: str + """ + + _attribute_map = { + "confidential_vm_encryption_type": {"key": "confidentialVMEncryptionType", "type": "str"}, + "secure_vm_disk_encryption_set_id": {"key": "secureVMDiskEncryptionSetId", "type": "str"}, + } + + def __init__( + self, + *, + confidential_vm_encryption_type: Optional[Union[str, "_models.ConfidentialVMEncryptionType"]] = None, + secure_vm_disk_encryption_set_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword confidential_vm_encryption_type: confidential VM encryption types. Known values are: + "EncryptedVMGuestStateOnlyWithPmk", "EncryptedWithPmk", "EncryptedWithCmk", and + "NonPersistedTPM". + :paramtype confidential_vm_encryption_type: str or + ~azure.mgmt.compute.models.ConfidentialVMEncryptionType + :keyword secure_vm_disk_encryption_set_id: secure VM disk encryption set id. + :paramtype secure_vm_disk_encryption_set_id: str + """ + super().__init__(**kwargs) + self.confidential_vm_encryption_type = confidential_vm_encryption_type + self.secure_vm_disk_encryption_set_id = secure_vm_disk_encryption_set_id + + +class OSFamily(_serialization.Model): + """Describes a cloud service OS family. + + Variables are only populated by the server, and will be ignored when sending a request. + + :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. + :vartype location: str + :ivar properties: OS family properties. + :vartype properties: ~azure.mgmt.compute.models.OSFamilyProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "OSFamilyProperties"}, + } + + def __init__(self, *, properties: Optional["_models.OSFamilyProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: OS family properties. + :paramtype properties: ~azure.mgmt.compute.models.OSFamilyProperties + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.location: Optional[str] = None + self.properties = properties + + +class OSFamilyListResult(_serialization.Model): + """The list operation result. + + All required parameters must be populated in order to send to server. + + :ivar value: The list of resources. Required. + :vartype value: list[~azure.mgmt.compute.models.OSFamily] + :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of + resources. Do this till nextLink is null to fetch all the resources. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[OSFamily]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.OSFamily"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of resources. Required. + :paramtype value: list[~azure.mgmt.compute.models.OSFamily] + :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page + of resources. Do this till nextLink is null to fetch all the resources. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OSFamilyProperties(_serialization.Model): + """OS family properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The OS family name. + :vartype name: str + :ivar label: The OS family label. + :vartype label: str + :ivar versions: List of OS versions belonging to this family. + :vartype versions: list[~azure.mgmt.compute.models.OSVersionPropertiesBase] + """ + + _validation = { + "name": {"readonly": True}, + "label": {"readonly": True}, + "versions": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "versions": {"key": "versions", "type": "[OSVersionPropertiesBase]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name: Optional[str] = None + self.label: Optional[str] = None + self.versions: Optional[List["_models.OSVersionPropertiesBase"]] = None + + +class OSImageNotificationProfile(_serialization.Model): + """OSImageNotificationProfile. + + :ivar not_before_timeout: Length of time a Virtual Machine being reimaged or having its OS + upgraded will have to potentially approve the OS Image Scheduled Event before the event is auto + approved (timed out). The configuration is specified in ISO 8601 format, and the value must be + 15 minutes (PT15M). + :vartype not_before_timeout: str + :ivar enable: Specifies whether the OS Image Scheduled event is enabled or disabled. + :vartype enable: bool + """ + + _attribute_map = { + "not_before_timeout": {"key": "notBeforeTimeout", "type": "str"}, + "enable": {"key": "enable", "type": "bool"}, + } + + def __init__( + self, *, not_before_timeout: Optional[str] = None, enable: Optional[bool] = None, **kwargs: Any + ) -> None: + """ + :keyword not_before_timeout: Length of time a Virtual Machine being reimaged or having its OS + upgraded will have to potentially approve the OS Image Scheduled Event before the event is auto + approved (timed out). The configuration is specified in ISO 8601 format, and the value must be + 15 minutes (PT15M). + :paramtype not_before_timeout: str + :keyword enable: Specifies whether the OS Image Scheduled event is enabled or disabled. + :paramtype enable: bool + """ + super().__init__(**kwargs) + self.not_before_timeout = not_before_timeout + self.enable = enable + + +class OSProfile(_serialization.Model): + """Specifies the operating system settings for the virtual machine. Some of the settings cannot be + changed once VM is provisioned. + + :ivar computer_name: Specifies the host OS name of the virtual machine. This name cannot be + updated after the VM is created. **Max-length (Windows):** 15 characters. **Max-length + (Linux):** 64 characters. For naming conventions and restrictions see `Azure infrastructure + services implementation guidelines + `_. + :vartype computer_name: str + :ivar admin_username: Specifies the name of the administrator account. :code:`
`\\ + :code:`
` This property cannot be updated after the VM is created. :code:`
`\\ + :code:`
` **Windows-only restriction:** Cannot end in "." :code:`
`\\ :code:`
` + **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", + "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", + "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", + "sys", "test2", "test3", "user4", "user5". :code:`
`\\ :code:`
` **Minimum-length + (Linux):** 1 character :code:`
`\\ :code:`
` **Max-length (Linux):** 64 characters + :code:`
`\\ :code:`
` **Max-length (Windows):** 20 characters. + :vartype admin_username: str + :ivar admin_password: Specifies the password of the administrator account. :code:`
`\\ + :code:`
` **Minimum-length (Windows):** 8 characters :code:`
`\\ :code:`
` + **Minimum-length (Linux):** 6 characters :code:`
`\\ :code:`
` **Max-length (Windows):** + 123 characters :code:`
`\\ :code:`
` **Max-length (Linux):** 72 characters :code:`
`\\ + :code:`
` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled + :code:`
` Has lower characters :code:`
`Has upper characters :code:`
` Has a digit + :code:`
` Has a special character (Regex match [\\W_]) :code:`
`\\ :code:`
` + **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", + "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
`\\ :code:`
` + For resetting the password, see `How to reset the Remote Desktop service or its login password + in a Windows VM `_ + :code:`
`\\ :code:`
` For resetting root password, see `Manage users, SSH, and check or + repair disks on Azure Linux VMs using the VMAccess Extension + `_. + :vartype admin_password: str + :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded + string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum + length of the binary array is 65535 bytes. **Note: Do not pass any secrets or passwords in + customData property.** This property cannot be updated after the VM is created. The property + 'customData' is passed to the VM to be saved as a file, for more information see `Custom Data + on Azure VMs `_. + For using cloud-init for your Linux VM, see `Using cloud-init to customize a Linux VM during + creation `_. + :vartype custom_data: str + :ivar windows_configuration: Specifies Windows operating system settings on the virtual + machine. + :vartype windows_configuration: ~azure.mgmt.compute.models.WindowsConfiguration + :ivar linux_configuration: Specifies the Linux operating system settings on the virtual + machine. For a list of supported Linux distributions, see `Linux on Azure-Endorsed + Distributions `_. + :vartype linux_configuration: ~azure.mgmt.compute.models.LinuxConfiguration + :ivar secrets: Specifies set of certificates that should be installed onto the virtual machine. + To install certificates on a virtual machine it is recommended to use the `Azure Key Vault + virtual machine extension for Linux + `_ or the `Azure + Key Vault virtual machine extension for Windows + `_. + :vartype secrets: list[~azure.mgmt.compute.models.VaultSecretGroup] + :ivar allow_extension_operations: Specifies whether extension operations should be allowed on + the virtual machine. This may only be set to False when no extensions are present on the + virtual machine. + :vartype allow_extension_operations: bool + :ivar require_guest_provision_signal: Optional property which must either be set to True or + omitted. + :vartype require_guest_provision_signal: bool + """ + + _attribute_map = { + "computer_name": {"key": "computerName", "type": "str"}, + "admin_username": {"key": "adminUsername", "type": "str"}, + "admin_password": {"key": "adminPassword", "type": "str"}, + "custom_data": {"key": "customData", "type": "str"}, + "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, + "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, + "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, + "allow_extension_operations": {"key": "allowExtensionOperations", "type": "bool"}, + "require_guest_provision_signal": {"key": "requireGuestProvisionSignal", "type": "bool"}, + } + + def __init__( + self, + *, + computer_name: Optional[str] = None, + admin_username: Optional[str] = None, + admin_password: Optional[str] = None, + custom_data: Optional[str] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, + allow_extension_operations: Optional[bool] = None, + require_guest_provision_signal: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword computer_name: Specifies the host OS name of the virtual machine. This name cannot be + updated after the VM is created. **Max-length (Windows):** 15 characters. **Max-length + (Linux):** 64 characters. For naming conventions and restrictions see `Azure infrastructure + services implementation guidelines + `_. + :paramtype computer_name: str + :keyword admin_username: Specifies the name of the administrator account. :code:`
`\\ + :code:`
` This property cannot be updated after the VM is created. :code:`
`\\ + :code:`
` **Windows-only restriction:** Cannot end in "." :code:`
`\\ :code:`
` + **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", + "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", + "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", + "sys", "test2", "test3", "user4", "user5". :code:`
`\\ :code:`
` **Minimum-length + (Linux):** 1 character :code:`
`\\ :code:`
` **Max-length (Linux):** 64 characters + :code:`
`\\ :code:`
` **Max-length (Windows):** 20 characters. + :paramtype admin_username: str + :keyword admin_password: Specifies the password of the administrator account. :code:`
`\\ + :code:`
` **Minimum-length (Windows):** 8 characters :code:`
`\\ :code:`
` + **Minimum-length (Linux):** 6 characters :code:`
`\\ :code:`
` **Max-length (Windows):** + 123 characters :code:`
`\\ :code:`
` **Max-length (Linux):** 72 characters :code:`
`\\ + :code:`
` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled + :code:`
` Has lower characters :code:`
`Has upper characters :code:`
` Has a digit + :code:`
` Has a special character (Regex match [\\W_]) :code:`
`\\ :code:`
` + **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", + "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
`\\ :code:`
` + For resetting the password, see `How to reset the Remote Desktop service or its login password + in a Windows VM `_ + :code:`
`\\ :code:`
` For resetting root password, see `Manage users, SSH, and check or + repair disks on Azure Linux VMs using the VMAccess Extension + `_. + :paramtype admin_password: str + :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded + string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum + length of the binary array is 65535 bytes. **Note: Do not pass any secrets or passwords in + customData property.** This property cannot be updated after the VM is created. The property + 'customData' is passed to the VM to be saved as a file, for more information see `Custom Data + on Azure VMs `_. + For using cloud-init for your Linux VM, see `Using cloud-init to customize a Linux VM during + creation `_. + :paramtype custom_data: str + :keyword windows_configuration: Specifies Windows operating system settings on the virtual + machine. + :paramtype windows_configuration: ~azure.mgmt.compute.models.WindowsConfiguration + :keyword linux_configuration: Specifies the Linux operating system settings on the virtual + machine. For a list of supported Linux distributions, see `Linux on Azure-Endorsed + Distributions `_. + :paramtype linux_configuration: ~azure.mgmt.compute.models.LinuxConfiguration + :keyword secrets: Specifies set of certificates that should be installed onto the virtual + machine. To install certificates on a virtual machine it is recommended to use the `Azure Key + Vault virtual machine extension for Linux + `_ or the `Azure + Key Vault virtual machine extension for Windows + `_. + :paramtype secrets: list[~azure.mgmt.compute.models.VaultSecretGroup] + :keyword allow_extension_operations: Specifies whether extension operations should be allowed + on the virtual machine. This may only be set to False when no extensions are present on the + virtual machine. + :paramtype allow_extension_operations: bool + :keyword require_guest_provision_signal: Optional property which must either be set to True or + omitted. + :paramtype require_guest_provision_signal: bool + """ + super().__init__(**kwargs) + self.computer_name = computer_name + self.admin_username = admin_username + self.admin_password = admin_password + self.custom_data = custom_data + self.windows_configuration = windows_configuration + self.linux_configuration = linux_configuration + self.secrets = secrets + self.allow_extension_operations = allow_extension_operations + self.require_guest_provision_signal = require_guest_provision_signal + + +class OSProfileProvisioningData(_serialization.Model): + """Additional parameters for Reimaging Non-Ephemeral Virtual Machine. + + :ivar admin_password: Specifies the password of the administrator account. :code:`
`\\ + :code:`
` **Minimum-length (Windows):** 8 characters :code:`
`\\ :code:`
` + **Minimum-length (Linux):** 6 characters :code:`
`\\ :code:`
` **Max-length (Windows):** + 123 characters :code:`
`\\ :code:`
` **Max-length (Linux):** 72 characters :code:`
`\\ + :code:`
` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled + :code:`
` Has lower characters :code:`
`Has upper characters :code:`
` Has a digit + :code:`
` Has a special character (Regex match [\\W_]) :code:`
`\\ :code:`
` + **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", + "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
`\\ :code:`
` + For resetting the password, see `How to reset the Remote Desktop service or its login password + in a Windows VM `_ + :code:`
`\\ :code:`
` For resetting root password, see `Manage users, SSH, and check or + repair disks on Azure Linux VMs using the VMAccess Extension + `_. + :vartype admin_password: str + :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded + string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum + length of the binary array is 65535 bytes. **Note: Do not pass any secrets or passwords in + customData property.** This property cannot be updated after the VM is created. The property + customData is passed to the VM to be saved as a file, for more information see `Custom Data on + Azure VMs `_. If + using cloud-init for your Linux VM, see `Using cloud-init to customize a Linux VM during + creation `_. + :vartype custom_data: str + """ + + _attribute_map = { + "admin_password": {"key": "adminPassword", "type": "str"}, + "custom_data": {"key": "customData", "type": "str"}, + } + + def __init__( + self, *, admin_password: Optional[str] = None, custom_data: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword admin_password: Specifies the password of the administrator account. :code:`
`\\ + :code:`
` **Minimum-length (Windows):** 8 characters :code:`
`\\ :code:`
` + **Minimum-length (Linux):** 6 characters :code:`
`\\ :code:`
` **Max-length (Windows):** + 123 characters :code:`
`\\ :code:`
` **Max-length (Linux):** 72 characters :code:`
`\\ + :code:`
` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled + :code:`
` Has lower characters :code:`
`Has upper characters :code:`
` Has a digit + :code:`
` Has a special character (Regex match [\\W_]) :code:`
`\\ :code:`
` + **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", + "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
`\\ :code:`
` + For resetting the password, see `How to reset the Remote Desktop service or its login password + in a Windows VM `_ + :code:`
`\\ :code:`
` For resetting root password, see `Manage users, SSH, and check or + repair disks on Azure Linux VMs using the VMAccess Extension + `_. + :paramtype admin_password: str + :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded + string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum + length of the binary array is 65535 bytes. **Note: Do not pass any secrets or passwords in + customData property.** This property cannot be updated after the VM is created. The property + customData is passed to the VM to be saved as a file, for more information see `Custom Data on + Azure VMs `_. If + using cloud-init for your Linux VM, see `Using cloud-init to customize a Linux VM during + creation `_. + :paramtype custom_data: str + """ + super().__init__(**kwargs) + self.admin_password = admin_password + self.custom_data = custom_data + + +class OSVersion(_serialization.Model): + """Describes a cloud service OS version. + + Variables are only populated by the server, and will be ignored when sending a request. + + :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. + :vartype location: str + :ivar properties: OS version properties. + :vartype properties: ~azure.mgmt.compute.models.OSVersionProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "OSVersionProperties"}, + } + + def __init__(self, *, properties: Optional["_models.OSVersionProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: OS version properties. + :paramtype properties: ~azure.mgmt.compute.models.OSVersionProperties + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.location: Optional[str] = None + self.properties = properties + + +class OSVersionListResult(_serialization.Model): + """The list operation result. + + All required parameters must be populated in order to send to server. + + :ivar value: The list of resources. Required. + :vartype value: list[~azure.mgmt.compute.models.OSVersion] + :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of + resources. Do this till nextLink is null to fetch all the resources. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[OSVersion]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.OSVersion"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of resources. Required. + :paramtype value: list[~azure.mgmt.compute.models.OSVersion] + :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page + of resources. Do this till nextLink is null to fetch all the resources. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OSVersionProperties(_serialization.Model): + """OS version properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar family: The family of this OS version. + :vartype family: str + :ivar family_label: The family label of this OS version. + :vartype family_label: str + :ivar version: The OS version. + :vartype version: str + :ivar label: The OS version label. + :vartype label: str + :ivar is_default: Specifies whether this is the default OS version for its family. + :vartype is_default: bool + :ivar is_active: Specifies whether this OS version is active. + :vartype is_active: bool + """ + + _validation = { + "family": {"readonly": True}, + "family_label": {"readonly": True}, + "version": {"readonly": True}, + "label": {"readonly": True}, + "is_default": {"readonly": True}, + "is_active": {"readonly": True}, + } + + _attribute_map = { + "family": {"key": "family", "type": "str"}, + "family_label": {"key": "familyLabel", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "is_default": {"key": "isDefault", "type": "bool"}, + "is_active": {"key": "isActive", "type": "bool"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.family: Optional[str] = None + self.family_label: Optional[str] = None + self.version: Optional[str] = None + self.label: Optional[str] = None + self.is_default: Optional[bool] = None + self.is_active: Optional[bool] = None + + +class OSVersionPropertiesBase(_serialization.Model): + """Configuration view of an OS version. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar version: The OS version. + :vartype version: str + :ivar label: The OS version label. + :vartype label: str + :ivar is_default: Specifies whether this is the default OS version for its family. + :vartype is_default: bool + :ivar is_active: Specifies whether this OS version is active. + :vartype is_active: bool + """ + + _validation = { + "version": {"readonly": True}, + "label": {"readonly": True}, + "is_default": {"readonly": True}, + "is_active": {"readonly": True}, + } + + _attribute_map = { + "version": {"key": "version", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "is_default": {"key": "isDefault", "type": "bool"}, + "is_active": {"key": "isActive", "type": "bool"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.version: Optional[str] = None + self.label: Optional[str] = None + self.is_default: Optional[bool] = None + self.is_active: Optional[bool] = None + + +class PatchInstallationDetail(_serialization.Model): + """Information about a specific patch that was encountered during an installation action. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar patch_id: A unique identifier for the patch. + :vartype patch_id: str + :ivar name: The friendly name of the patch. + :vartype name: str + :ivar version: The version string of the package. It may conform to Semantic Versioning. Only + applies to Linux. + :vartype version: str + :ivar kb_id: The KBID of the patch. Only applies to Windows patches. + :vartype kb_id: str + :ivar classifications: The classification(s) of the patch as provided by the patch publisher. + :vartype classifications: list[str] + :ivar installation_state: The state of the patch after the installation operation completed. + Known values are: "Unknown", "Installed", "Failed", "Excluded", "NotSelected", and "Pending". + :vartype installation_state: str or ~azure.mgmt.compute.models.PatchInstallationState + """ + + _validation = { + "patch_id": {"readonly": True}, + "name": {"readonly": True}, + "version": {"readonly": True}, + "kb_id": {"readonly": True}, + "classifications": {"readonly": True}, + "installation_state": {"readonly": True}, + } + + _attribute_map = { + "patch_id": {"key": "patchId", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "kb_id": {"key": "kbId", "type": "str"}, + "classifications": {"key": "classifications", "type": "[str]"}, + "installation_state": {"key": "installationState", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.patch_id: Optional[str] = None + self.name: Optional[str] = None + self.version: Optional[str] = None + self.kb_id: Optional[str] = None + self.classifications: Optional[List[str]] = None + self.installation_state: Optional[Union[str, "_models.PatchInstallationState"]] = None + + +class PatchSettings(_serialization.Model): + """Specifies settings related to VM Guest Patching on Windows. + + :ivar patch_mode: Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual + machines associated to virtual machine scale set with OrchestrationMode as Flexible.\\ + :code:`
`\\ :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` + **Manual** - You control the application of patches to a virtual machine. You do this by + applying patches manually inside the VM. In this mode, automatic updates are disabled; the + property WindowsConfiguration.enableAutomaticUpdates must be false\\ :code:`
`\\ + :code:`
` **AutomaticByOS** - The virtual machine will automatically be updated by the OS. + The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
`\\ + :code:`
` **AutomaticByPlatform** - the virtual machine will automatically updated by the + platform. The properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must + be true. Known values are: "Manual", "AutomaticByOS", and "AutomaticByPlatform". + :vartype patch_mode: str or ~azure.mgmt.compute.models.WindowsVMGuestPatchMode + :ivar enable_hotpatching: Enables customers to patch their Azure VMs without requiring a + reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must + be set to 'AutomaticByPlatform'. + :vartype enable_hotpatching: bool + :ivar assessment_mode: Specifies the mode of VM Guest patch assessment for the IaaS virtual + machine.\\ :code:`
`\\ :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.\\ + :code:`
`\\ :code:`
` **AutomaticByPlatform** - The platform will trigger periodic + patch assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault" + and "AutomaticByPlatform". + :vartype assessment_mode: str or ~azure.mgmt.compute.models.WindowsPatchAssessmentMode + :ivar automatic_by_platform_settings: Specifies additional settings for patch mode + AutomaticByPlatform in VM Guest Patching on Windows. + :vartype automatic_by_platform_settings: + ~azure.mgmt.compute.models.WindowsVMGuestPatchAutomaticByPlatformSettings + """ + + _attribute_map = { + "patch_mode": {"key": "patchMode", "type": "str"}, + "enable_hotpatching": {"key": "enableHotpatching", "type": "bool"}, + "assessment_mode": {"key": "assessmentMode", "type": "str"}, + "automatic_by_platform_settings": { + "key": "automaticByPlatformSettings", + "type": "WindowsVMGuestPatchAutomaticByPlatformSettings", + }, + } + + def __init__( + self, + *, + patch_mode: Optional[Union[str, "_models.WindowsVMGuestPatchMode"]] = None, + enable_hotpatching: Optional[bool] = None, + assessment_mode: Optional[Union[str, "_models.WindowsPatchAssessmentMode"]] = None, + automatic_by_platform_settings: Optional["_models.WindowsVMGuestPatchAutomaticByPlatformSettings"] = None, + **kwargs: Any + ) -> None: + """ + :keyword patch_mode: Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual + machines associated to virtual machine scale set with OrchestrationMode as Flexible.\\ + :code:`
`\\ :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` + **Manual** - You control the application of patches to a virtual machine. You do this by + applying patches manually inside the VM. In this mode, automatic updates are disabled; the + property WindowsConfiguration.enableAutomaticUpdates must be false\\ :code:`
`\\ + :code:`
` **AutomaticByOS** - The virtual machine will automatically be updated by the OS. + The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
`\\ + :code:`
` **AutomaticByPlatform** - the virtual machine will automatically updated by the + platform. The properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must + be true. Known values are: "Manual", "AutomaticByOS", and "AutomaticByPlatform". + :paramtype patch_mode: str or ~azure.mgmt.compute.models.WindowsVMGuestPatchMode + :keyword enable_hotpatching: Enables customers to patch their Azure VMs without requiring a + reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must + be set to 'AutomaticByPlatform'. + :paramtype enable_hotpatching: bool + :keyword assessment_mode: Specifies the mode of VM Guest patch assessment for the IaaS virtual + machine.\\ :code:`
`\\ :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.\\ + :code:`
`\\ :code:`
` **AutomaticByPlatform** - The platform will trigger periodic + patch assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault" + and "AutomaticByPlatform". + :paramtype assessment_mode: str or ~azure.mgmt.compute.models.WindowsPatchAssessmentMode + :keyword automatic_by_platform_settings: Specifies additional settings for patch mode + AutomaticByPlatform in VM Guest Patching on Windows. + :paramtype automatic_by_platform_settings: + ~azure.mgmt.compute.models.WindowsVMGuestPatchAutomaticByPlatformSettings + """ + super().__init__(**kwargs) + self.patch_mode = patch_mode + self.enable_hotpatching = enable_hotpatching + self.assessment_mode = assessment_mode + self.automatic_by_platform_settings = automatic_by_platform_settings + + +class PirResource(_serialization.Model): + """The Resource model definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Resource name. + :vartype name: str + :ivar location: Resource location. + :vartype location: str + """ + + _validation = { + "name": {"readonly": True}, + "location": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name: Optional[str] = None + self.location: Optional[str] = None + + +class PirSharedGalleryResource(PirResource): + """Base information about the shared gallery resource in pir. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Resource name. + :vartype name: str + :ivar location: Resource location. + :vartype location: str + :ivar unique_id: The unique id of this shared gallery. + :vartype unique_id: str + """ + + _validation = { + "name": {"readonly": True}, + "location": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "unique_id": {"key": "identifier.uniqueId", "type": "str"}, + } + + 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 + """ + super().__init__(**kwargs) + self.unique_id = unique_id + + +class Placement(_serialization.Model): + """Describes the user-defined constraints for virtual machine hardware placement. + + :ivar zone_placement_policy: Specifies the policy for virtual machine's placement in + availability zone. Possible values are: **Any** - An availability zone will be automatically + picked by system as part of virtual machine creation. "Any" + :vartype zone_placement_policy: str or ~azure.mgmt.compute.models.ZonePlacementPolicyType + :ivar include_zones: This property supplements the 'zonePlacementPolicy' property. If + 'zonePlacementPolicy' is set to 'Any', availability zone selected by the system must be present + in the list of availability zones passed with 'includeZones'. If 'includeZones' is not + provided, all availability zones in region will be considered for selection. + :vartype include_zones: list[str] + :ivar exclude_zones: This property supplements the 'zonePlacementPolicy' property. If + 'zonePlacementPolicy' is set to 'Any', availability zone selected by the system must not be + present in the list of availability zones passed with 'excludeZones'. If 'excludeZones' is not + provided, all availability zones in region will be considered for selection. + :vartype exclude_zones: list[str] + """ + + _attribute_map = { + "zone_placement_policy": {"key": "zonePlacementPolicy", "type": "str"}, + "include_zones": {"key": "includeZones", "type": "[str]"}, + "exclude_zones": {"key": "excludeZones", "type": "[str]"}, + } + + def __init__( + self, + *, + zone_placement_policy: Optional[Union[str, "_models.ZonePlacementPolicyType"]] = None, + include_zones: Optional[List[str]] = None, + exclude_zones: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword zone_placement_policy: Specifies the policy for virtual machine's placement in + availability zone. Possible values are: **Any** - An availability zone will be automatically + picked by system as part of virtual machine creation. "Any" + :paramtype zone_placement_policy: str or ~azure.mgmt.compute.models.ZonePlacementPolicyType + :keyword include_zones: This property supplements the 'zonePlacementPolicy' property. If + 'zonePlacementPolicy' is set to 'Any', availability zone selected by the system must be present + in the list of availability zones passed with 'includeZones'. If 'includeZones' is not + provided, all availability zones in region will be considered for selection. + :paramtype include_zones: list[str] + :keyword exclude_zones: This property supplements the 'zonePlacementPolicy' property. If + 'zonePlacementPolicy' is set to 'Any', availability zone selected by the system must not be + present in the list of availability zones passed with 'excludeZones'. If 'excludeZones' is not + provided, all availability zones in region will be considered for selection. + :paramtype exclude_zones: list[str] + """ + super().__init__(**kwargs) + self.zone_placement_policy = zone_placement_policy + self.include_zones = include_zones + self.exclude_zones = exclude_zones + + +class Plan(_serialization.Model): + """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 the marketplace + image that you want to use and then click **Want to deploy programmatically, Get Started ->**. + Enter any required information and then click **Save**. + + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :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. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :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. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + """ + super().__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + + +class PolicyViolation(_serialization.Model): + """A policy violation reported against a gallery artifact. + + :ivar category: Describes the nature of the policy violation. Known values are: "Other", + "ImageFlaggedUnsafe", "CopyrightValidation", and "IpTheft". + :vartype category: str or ~azure.mgmt.compute.models.PolicyViolationCategory + :ivar details: Describes specific details about why this policy violation was reported. + :vartype details: str + """ + + _attribute_map = { + "category": {"key": "category", "type": "str"}, + "details": {"key": "details", "type": "str"}, + } + + def __init__( + self, + *, + category: Optional[Union[str, "_models.PolicyViolationCategory"]] = None, + details: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword category: Describes the nature of the policy violation. Known values are: "Other", + "ImageFlaggedUnsafe", "CopyrightValidation", and "IpTheft". + :paramtype category: str or ~azure.mgmt.compute.models.PolicyViolationCategory + :keyword details: Describes specific details about why this policy violation was reported. + :paramtype details: str + """ + super().__init__(**kwargs) + self.category = category + self.details = details + + +class PriorityMixPolicy(_serialization.Model): + """Specifies the target splits for Spot and Regular priority VMs within a scale set with flexible + orchestration mode. With this property the customer is able to specify the base number of + regular priority VMs created as the VMSS flex instance scales out and the split between Spot + and Regular priority VMs after this base target has been reached. + + :ivar base_regular_priority_count: The base number of regular priority VMs that will be created + in this scale set as it scales out. + :vartype base_regular_priority_count: int + :ivar regular_priority_percentage_above_base: The percentage of VM instances, after the base + regular priority count has been reached, that are expected to use regular priority. + :vartype regular_priority_percentage_above_base: int + """ + + _validation = { + "regular_priority_percentage_above_base": {"maximum": 100}, + } + + _attribute_map = { + "base_regular_priority_count": {"key": "baseRegularPriorityCount", "type": "int"}, + "regular_priority_percentage_above_base": {"key": "regularPriorityPercentageAboveBase", "type": "int"}, + } + + def __init__( + self, + *, + base_regular_priority_count: Optional[int] = None, + regular_priority_percentage_above_base: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword base_regular_priority_count: The base number of regular priority VMs that will be + created in this scale set as it scales out. + :paramtype base_regular_priority_count: int + :keyword regular_priority_percentage_above_base: The percentage of VM instances, after the base + regular priority count has been reached, that are expected to use regular priority. + :paramtype regular_priority_percentage_above_base: int + """ + super().__init__(**kwargs) + self.base_regular_priority_count = base_regular_priority_count + self.regular_priority_percentage_above_base = regular_priority_percentage_above_base + + +class PrivateEndpoint(_serialization.Model): + """The Private Endpoint resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ARM identifier for Private Endpoint. + :vartype id: str + """ + + _validation = { + "id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id: Optional[str] = None + + +class PrivateEndpointConnection(_serialization.Model): + """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. + :vartype id: str + :ivar name: private endpoint connection name. + :vartype name: str + :ivar type: private endpoint connection type. + :vartype type: str + :ivar private_endpoint: The resource of private end point. + :vartype private_endpoint: ~azure.mgmt.compute.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between DiskAccess and Virtual Network. + :vartype private_link_service_connection_state: + ~azure.mgmt.compute.models.PrivateLinkServiceConnectionState + :ivar provisioning_state: The provisioning state of the private endpoint connection resource. + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.compute.models.PrivateEndpointConnectionProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "private_endpoint": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, + **kwargs: Any + ) -> None: + """ + :keyword private_link_service_connection_state: A collection of information about the state of + the connection between DiskAccess and Virtual Network. + :paramtype private_link_service_connection_state: + ~azure.mgmt.compute.models.PrivateLinkServiceConnectionState + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.private_endpoint: Optional["_models.PrivateEndpoint"] = None + self.private_link_service_connection_state = private_link_service_connection_state + self.provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = None + + +class PrivateEndpointConnectionListResult(_serialization.Model): + """A list of private link resources. + + :ivar value: Array of private endpoint connections. + :vartype value: list[~azure.mgmt.compute.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. + :vartype next_link: str + """ + + _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 + ) -> None: + """ + :keyword value: Array of private endpoint connections. + :paramtype value: list[~azure.mgmt.compute.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. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PrivateLinkResource(_serialization.Model): + """A private link resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: private link resource Id. + :vartype id: str + :ivar name: private link resource name. + :vartype name: str + :ivar type: private link resource type. + :vartype type: str + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + :ivar required_zone_names: The private link resource DNS zone name. + :vartype required_zone_names: list[str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, + } + + def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs: Any) -> None: + """ + :keyword required_zone_names: The private link resource DNS zone name. + :paramtype required_zone_names: list[str] + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.group_id: Optional[str] = None + self.required_members: Optional[List[str]] = None + self.required_zone_names = required_zone_names + + +class PrivateLinkResourceListResult(_serialization.Model): + """A list of private link resources. + + :ivar value: Array of private link resources. + :vartype value: list[~azure.mgmt.compute.models.PrivateLinkResource] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + } + + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Array of private link resources. + :paramtype value: list[~azure.mgmt.compute.models.PrivateLinkResource] + """ + super().__init__(**kwargs) + self.value = value + + +class PrivateLinkServiceConnectionState(_serialization.Model): + """A collection of information about the state of the connection between service consumer and + provider. + + :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + of the service. Known values are: "Pending", "Approved", and "Rejected". + :vartype status: str or ~azure.mgmt.compute.models.PrivateEndpointServiceConnectionStatus + :ivar description: The reason for approval/rejection of the connection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :vartype actions_required: str + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, + description: Optional[str] = None, + actions_required: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the + owner of the service. Known values are: "Pending", "Approved", and "Rejected". + :paramtype status: str or ~azure.mgmt.compute.models.PrivateEndpointServiceConnectionStatus + :keyword description: The reason for approval/rejection of the connection. + :paramtype description: str + :keyword actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :paramtype actions_required: str + """ + super().__init__(**kwargs) + self.status = status + self.description = description + self.actions_required = actions_required + + +class PropertyUpdatesInProgress(_serialization.Model): + """Properties of the disk for which update is pending. + + :ivar target_tier: The target performance tier of the disk if a tier change operation is in + progress. + :vartype target_tier: str + """ + + _attribute_map = { + "target_tier": {"key": "targetTier", "type": "str"}, + } + + def __init__(self, *, target_tier: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword target_tier: The target performance tier of the disk if a tier change operation is in + progress. + :paramtype target_tier: str + """ + super().__init__(**kwargs) + self.target_tier = target_tier + + +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: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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.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: The availability zones. + :vartype zones: list[str] + :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. + Possible values are: **Standard** : Co-locate resources within an Azure region or Availability + Zone. **Ultra** : For future use. Known values are: "Standard" and "Ultra". + :vartype proximity_placement_group_type: str or + ~azure.mgmt.compute.models.ProximityPlacementGroupType + :ivar virtual_machines: A list of references to all virtual machines in the proximity placement + group. + :vartype virtual_machines: list[~azure.mgmt.compute.models.SubResourceWithColocationStatus] + :ivar virtual_machine_scale_sets: A list of references to all virtual machine scale sets in the + proximity placement group. + :vartype virtual_machine_scale_sets: + list[~azure.mgmt.compute.models.SubResourceWithColocationStatus] + :ivar availability_sets: A list of references to all availability sets in the proximity + placement group. + :vartype availability_sets: list[~azure.mgmt.compute.models.SubResourceWithColocationStatus] + :ivar colocation_status: Describes colocation status of the Proximity Placement Group. + :vartype colocation_status: ~azure.mgmt.compute.models.InstanceViewStatus + :ivar intent: Specifies the user intent of the proximity placement group. + :vartype intent: ~azure.mgmt.compute.models.ProximityPlacementGroupPropertiesIntent + """ + + _validation = { + "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}, + "availability_sets": {"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"}, + "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]"}, + "virtual_machine_scale_sets": { + "key": "properties.virtualMachineScaleSets", + "type": "[SubResourceWithColocationStatus]", + }, + "availability_sets": {"key": "properties.availabilitySets", "type": "[SubResourceWithColocationStatus]"}, + "colocation_status": {"key": "properties.colocationStatus", "type": "InstanceViewStatus"}, + "intent": {"key": "properties.intent", "type": "ProximityPlacementGroupPropertiesIntent"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + zones: Optional[List[str]] = None, + proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, + intent: Optional["_models.ProximityPlacementGroupPropertiesIntent"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword zones: The availability zones. + :paramtype zones: list[str] + :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. + Possible values are: **Standard** : Co-locate resources within an Azure region or Availability + Zone. **Ultra** : For future use. Known values are: "Standard" and "Ultra". + :paramtype proximity_placement_group_type: str or + ~azure.mgmt.compute.models.ProximityPlacementGroupType + :keyword colocation_status: Describes colocation status of the Proximity Placement Group. + :paramtype colocation_status: ~azure.mgmt.compute.models.InstanceViewStatus + :keyword intent: Specifies the user intent of the proximity placement group. + :paramtype intent: ~azure.mgmt.compute.models.ProximityPlacementGroupPropertiesIntent + """ + super().__init__(tags=tags, location=location, **kwargs) + self.zones = zones + self.proximity_placement_group_type = proximity_placement_group_type + self.virtual_machines: Optional[List["_models.SubResourceWithColocationStatus"]] = None + self.virtual_machine_scale_sets: Optional[List["_models.SubResourceWithColocationStatus"]] = None + self.availability_sets: Optional[List["_models.SubResourceWithColocationStatus"]] = None + self.colocation_status = colocation_status + self.intent = intent + + +class ProximityPlacementGroupListResult(_serialization.Model): + """The List Proximity Placement Group operation response. + + All required parameters must be populated in order to send to server. + + :ivar value: The list of proximity placement groups. Required. + :vartype value: list[~azure.mgmt.compute.models.ProximityPlacementGroup] + :ivar next_link: The URI to fetch the next page of proximity placement groups. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ProximityPlacementGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The list of proximity placement groups. Required. + :paramtype value: list[~azure.mgmt.compute.models.ProximityPlacementGroup] + :keyword next_link: The URI to fetch the next page of proximity placement groups. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ProximityPlacementGroupPropertiesIntent(_serialization.Model): + """Specifies the user intent of the proximity placement group. + + :ivar vm_sizes: Specifies possible sizes of virtual machines that can be created in the + proximity placement group. + :vartype vm_sizes: list[str] + """ + + _attribute_map = { + "vm_sizes": {"key": "vmSizes", "type": "[str]"}, + } + + def __init__(self, *, vm_sizes: Optional[List[str]] = None, **kwargs: Any) -> None: + """ + :keyword vm_sizes: Specifies possible sizes of virtual machines that can be created in the + proximity placement group. + :paramtype vm_sizes: list[str] + """ + super().__init__(**kwargs) + self.vm_sizes = vm_sizes + + +class ProximityPlacementGroupUpdate(UpdateResource): + """Specifies information about the proximity placement group. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + +class ProxyAgentSettings(_serialization.Model): + """Specifies ProxyAgent settings for the virtual machine or virtual machine scale set. Minimum + api-version: 2023-09-01. + + :ivar enabled: Specifies whether ProxyAgent feature should be enabled on the virtual machine or + virtual machine scale set. + :vartype enabled: bool + :ivar mode: Specifies the mode that ProxyAgent will execute on. Warning: this property has been + deprecated, please specify 'mode' under particular hostendpoint setting. Known values are: + "Audit" and "Enforce". + :vartype mode: str or ~azure.mgmt.compute.models.Mode + :ivar key_incarnation_id: Increase the value of this property allows users to reset the key + used for securing communication channel between guest and host. + :vartype key_incarnation_id: int + :ivar wire_server: Specifies the Wire Server endpoint settings while creating the virtual + machine or virtual machine scale set. Minimum api-version: 2024-03-01. + :vartype wire_server: ~azure.mgmt.compute.models.HostEndpointSettings + :ivar imds: Specifies the IMDS endpoint settings while creating the virtual machine or virtual + machine scale set. Minimum api-version: 2024-03-01. + :vartype imds: ~azure.mgmt.compute.models.HostEndpointSettings + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "mode": {"key": "mode", "type": "str"}, + "key_incarnation_id": {"key": "keyIncarnationId", "type": "int"}, + "wire_server": {"key": "wireServer", "type": "HostEndpointSettings"}, + "imds": {"key": "imds", "type": "HostEndpointSettings"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + mode: Optional[Union[str, "_models.Mode"]] = None, + key_incarnation_id: Optional[int] = None, + wire_server: Optional["_models.HostEndpointSettings"] = None, + imds: Optional["_models.HostEndpointSettings"] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Specifies whether ProxyAgent feature should be enabled on the virtual machine + or virtual machine scale set. + :paramtype enabled: bool + :keyword mode: Specifies the mode that ProxyAgent will execute on. Warning: this property has + been deprecated, please specify 'mode' under particular hostendpoint setting. Known values are: + "Audit" and "Enforce". + :paramtype mode: str or ~azure.mgmt.compute.models.Mode + :keyword key_incarnation_id: Increase the value of this property allows users to reset the key + used for securing communication channel between guest and host. + :paramtype key_incarnation_id: int + :keyword wire_server: Specifies the Wire Server endpoint settings while creating the virtual + machine or virtual machine scale set. Minimum api-version: 2024-03-01. + :paramtype wire_server: ~azure.mgmt.compute.models.HostEndpointSettings + :keyword imds: Specifies the IMDS endpoint settings while creating the virtual machine or + virtual machine scale set. Minimum api-version: 2024-03-01. + :paramtype imds: ~azure.mgmt.compute.models.HostEndpointSettings + """ + super().__init__(**kwargs) + self.enabled = enabled + self.mode = mode + self.key_incarnation_id = key_incarnation_id + self.wire_server = wire_server + self.imds = imds + + +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: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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.models.SystemData + """ + + +class PublicIPAddressSku(_serialization.Model): + """Describes the public IP Sku. It can only be set with OrchestrationMode as Flexible. + + :ivar name: Specify public IP sku name. Known values are: "Basic" and "Standard". + :vartype name: str or ~azure.mgmt.compute.models.PublicIPAddressSkuName + :ivar tier: Specify public IP sku tier. Known values are: "Regional", "Global", and "Global". + :vartype tier: str or ~azure.mgmt.compute.models.PublicIPAddressSkuTier + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[Union[str, "_models.PublicIPAddressSkuName"]] = None, + tier: Optional[Union[str, "_models.PublicIPAddressSkuTier"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Specify public IP sku name. Known values are: "Basic" and "Standard". + :paramtype name: str or ~azure.mgmt.compute.models.PublicIPAddressSkuName + :keyword tier: Specify public IP sku tier. Known values are: "Regional", "Global", and + "Global". + :paramtype tier: str or ~azure.mgmt.compute.models.PublicIPAddressSkuTier + """ + super().__init__(**kwargs) + self.name = name + self.tier = tier + + +class PurchasePlan(_serialization.Model): + """Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. + + All required parameters must be populated in order to send to server. + + :ivar publisher: The publisher ID. Required. + :vartype publisher: str + :ivar name: The plan ID. Required. + :vartype name: 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 + """ + + _validation = { + "publisher": {"required": True}, + "name": {"required": True}, + "product": {"required": True}, + } + + _attribute_map = { + "publisher": {"key": "publisher", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "product": {"key": "product", "type": "str"}, + } + + def __init__(self, *, publisher: str, name: str, product: str, **kwargs: Any) -> None: + """ + :keyword publisher: The publisher ID. Required. + :paramtype publisher: str + :keyword name: The plan ID. Required. + :paramtype name: 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 + """ + super().__init__(**kwargs) + self.publisher = publisher + self.name = name + self.product = product + + +class PurchasePlanAutoGenerated(_serialization.Model): + """Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. + + All required parameters must be populated in order to send to server. + + :ivar name: The plan ID. Required. + :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 + """ + + _validation = { + "name": {"required": True}, + "publisher": {"required": True}, + "product": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + } + + 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.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + + +class RecommendedMachineConfiguration(_serialization.Model): + """The properties describe the recommended machine configuration for this Image Definition. These + properties are updatable. + + :ivar v_cp_us: Describes the resource range. + :vartype v_cp_us: ~azure.mgmt.compute.models.ResourceRange + :ivar memory: Describes the resource range. + :vartype memory: ~azure.mgmt.compute.models.ResourceRange + """ + + _attribute_map = { + "v_cp_us": {"key": "vCPUs", "type": "ResourceRange"}, + "memory": {"key": "memory", "type": "ResourceRange"}, + } + + def __init__( + self, + *, + v_cp_us: Optional["_models.ResourceRange"] = None, + memory: Optional["_models.ResourceRange"] = None, + **kwargs: Any + ) -> None: + """ + :keyword v_cp_us: Describes the resource range. + :paramtype v_cp_us: ~azure.mgmt.compute.models.ResourceRange + :keyword memory: Describes the resource range. + :paramtype memory: ~azure.mgmt.compute.models.ResourceRange + """ + super().__init__(**kwargs) + self.v_cp_us = v_cp_us + self.memory = memory + + +class RecoveryWalkResponse(_serialization.Model): + """Response after calling a manual recovery walk. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar walk_performed: Whether the recovery walk was performed. + :vartype walk_performed: bool + :ivar next_platform_update_domain: The next update domain that needs to be walked. Null means + walk spanning all update domains has been completed. + :vartype next_platform_update_domain: int + """ + + _validation = { + "walk_performed": {"readonly": True}, + "next_platform_update_domain": {"readonly": True}, + } + + _attribute_map = { + "walk_performed": {"key": "walkPerformed", "type": "bool"}, + "next_platform_update_domain": {"key": "nextPlatformUpdateDomain", "type": "int"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.walk_performed: Optional[bool] = None + self.next_platform_update_domain: Optional[int] = None + + +class RegionalReplicationStatus(_serialization.Model): + """This is the regional replication status. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar region: The region to which the gallery image version is being replicated to. + :vartype region: str + :ivar state: This is the regional replication state. Known values are: "Unknown", + "Replicating", "Completed", and "Failed". + :vartype state: str or ~azure.mgmt.compute.models.ReplicationState + :ivar details: The details of the replication status. + :vartype details: str + :ivar progress: It indicates progress of the replication job. + :vartype progress: int + """ + + _validation = { + "region": {"readonly": True}, + "state": {"readonly": True}, + "details": {"readonly": True}, + "progress": {"readonly": True}, + } + + _attribute_map = { + "region": {"key": "region", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "details": {"key": "details", "type": "str"}, + "progress": {"key": "progress", "type": "int"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.region: Optional[str] = None + self.state: Optional[Union[str, "_models.ReplicationState"]] = None + self.details: Optional[str] = None + self.progress: Optional[int] = None + + +class RegionalSharingStatus(_serialization.Model): + """Gallery regional sharing status. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar region: Region name. + :vartype region: str + :ivar state: Gallery sharing state in current region. Known values are: "Succeeded", + "InProgress", "Failed", and "Unknown". + :vartype state: str or ~azure.mgmt.compute.models.SharingState + :ivar details: Details of gallery regional sharing failure. + :vartype details: str + """ + + _validation = { + "state": {"readonly": True}, + } + + _attribute_map = { + "region": {"key": "region", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "details": {"key": "details", "type": "str"}, + } + + def __init__(self, *, region: Optional[str] = None, details: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword region: Region name. + :paramtype region: str + :keyword details: Details of gallery regional sharing failure. + :paramtype details: str + """ + super().__init__(**kwargs) + self.region = region + self.state: Optional[Union[str, "_models.SharingState"]] = None + self.details = details + + +class ReplicationStatus(_serialization.Model): + """This is the replication status of the gallery image version. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar aggregated_state: This is the aggregated replication status based on all the regional + replication status flags. Known values are: "Unknown", "InProgress", "Completed", and "Failed". + :vartype aggregated_state: str or ~azure.mgmt.compute.models.AggregatedReplicationState + :ivar summary: This is a summary of replication status for each region. + :vartype summary: list[~azure.mgmt.compute.models.RegionalReplicationStatus] + """ + + _validation = { + "aggregated_state": {"readonly": True}, + "summary": {"readonly": True}, + } + + _attribute_map = { + "aggregated_state": {"key": "aggregatedState", "type": "str"}, + "summary": {"key": "summary", "type": "[RegionalReplicationStatus]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.aggregated_state: Optional[Union[str, "_models.AggregatedReplicationState"]] = None + self.summary: Optional[List["_models.RegionalReplicationStatus"]] = None + + +class RequestRateByIntervalInput(LogAnalyticsInputBase): + """Api request input for LogAnalytics getRequestRateByInterval Api. + + All required parameters must be populated in order to send to server. + + :ivar blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api + writes output logs to. Required. + :vartype blob_container_sas_uri: str + :ivar from_time: From time of the query. Required. + :vartype from_time: ~datetime.datetime + :ivar to_time: To time of the query. Required. + :vartype to_time: ~datetime.datetime + :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. + :vartype group_by_throttle_policy: bool + :ivar group_by_operation_name: Group query result by Operation Name. + :vartype group_by_operation_name: bool + :ivar group_by_resource_name: Group query result by Resource Name. + :vartype group_by_resource_name: bool + :ivar group_by_client_application_id: Group query result by Client Application ID. + :vartype group_by_client_application_id: bool + :ivar group_by_user_agent: Group query result by User Agent. + :vartype group_by_user_agent: bool + :ivar interval_length: Interval value in minutes used to create LogAnalytics call rate logs. + Required. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", and "SixtyMins". + :vartype interval_length: str or ~azure.mgmt.compute.models.IntervalInMins + """ + + _validation = { + "blob_container_sas_uri": {"required": True}, + "from_time": {"required": True}, + "to_time": {"required": True}, + "interval_length": {"required": True}, + } + + _attribute_map = { + "blob_container_sas_uri": {"key": "blobContainerSasUri", "type": "str"}, + "from_time": {"key": "fromTime", "type": "iso-8601"}, + "to_time": {"key": "toTime", "type": "iso-8601"}, + "group_by_throttle_policy": {"key": "groupByThrottlePolicy", "type": "bool"}, + "group_by_operation_name": {"key": "groupByOperationName", "type": "bool"}, + "group_by_resource_name": {"key": "groupByResourceName", "type": "bool"}, + "group_by_client_application_id": {"key": "groupByClientApplicationId", "type": "bool"}, + "group_by_user_agent": {"key": "groupByUserAgent", "type": "bool"}, + "interval_length": {"key": "intervalLength", "type": "str"}, + } + + def __init__( + self, + *, + blob_container_sas_uri: str, + from_time: datetime.datetime, + to_time: datetime.datetime, + interval_length: Union[str, "_models.IntervalInMins"], + group_by_throttle_policy: Optional[bool] = None, + group_by_operation_name: Optional[bool] = None, + group_by_resource_name: Optional[bool] = None, + group_by_client_application_id: Optional[bool] = None, + group_by_user_agent: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics + Api writes output logs to. Required. + :paramtype blob_container_sas_uri: str + :keyword from_time: From time of the query. Required. + :paramtype from_time: ~datetime.datetime + :keyword to_time: To time of the query. Required. + :paramtype to_time: ~datetime.datetime + :keyword group_by_throttle_policy: Group query result by Throttle Policy applied. + :paramtype group_by_throttle_policy: bool + :keyword group_by_operation_name: Group query result by Operation Name. + :paramtype group_by_operation_name: bool + :keyword group_by_resource_name: Group query result by Resource Name. + :paramtype group_by_resource_name: bool + :keyword group_by_client_application_id: Group query result by Client Application ID. + :paramtype group_by_client_application_id: bool + :keyword group_by_user_agent: Group query result by User Agent. + :paramtype group_by_user_agent: bool + :keyword interval_length: Interval value in minutes used to create LogAnalytics call rate logs. + Required. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", and "SixtyMins". + :paramtype interval_length: str or ~azure.mgmt.compute.models.IntervalInMins + """ + super().__init__( + blob_container_sas_uri=blob_container_sas_uri, + from_time=from_time, + to_time=to_time, + group_by_throttle_policy=group_by_throttle_policy, + group_by_operation_name=group_by_operation_name, + group_by_resource_name=group_by_resource_name, + group_by_client_application_id=group_by_client_application_id, + group_by_user_agent=group_by_user_agent, + **kwargs + ) + self.interval_length = interval_length + + +class ResiliencyPolicy(_serialization.Model): + """Describes an resiliency policy - AutomaticZoneRebalancingPolicy, ResilientVMCreationPolicy + and/or ResilientVMDeletionPolicy. + + :ivar resilient_vm_creation_policy: The configuration parameters used while performing + resilient VM creation. + :vartype resilient_vm_creation_policy: ~azure.mgmt.compute.models.ResilientVMCreationPolicy + :ivar resilient_vm_deletion_policy: The configuration parameters used while performing + resilient VM deletion. + :vartype resilient_vm_deletion_policy: ~azure.mgmt.compute.models.ResilientVMDeletionPolicy + :ivar automatic_zone_rebalancing_policy: The configuration parameters used while performing + automatic AZ balancing. + :vartype automatic_zone_rebalancing_policy: + ~azure.mgmt.compute.models.AutomaticZoneRebalancingPolicy + """ + + _attribute_map = { + "resilient_vm_creation_policy": {"key": "resilientVMCreationPolicy", "type": "ResilientVMCreationPolicy"}, + "resilient_vm_deletion_policy": {"key": "resilientVMDeletionPolicy", "type": "ResilientVMDeletionPolicy"}, + "automatic_zone_rebalancing_policy": { + "key": "automaticZoneRebalancingPolicy", + "type": "AutomaticZoneRebalancingPolicy", + }, + } + + def __init__( + self, + *, + resilient_vm_creation_policy: Optional["_models.ResilientVMCreationPolicy"] = None, + resilient_vm_deletion_policy: Optional["_models.ResilientVMDeletionPolicy"] = None, + automatic_zone_rebalancing_policy: Optional["_models.AutomaticZoneRebalancingPolicy"] = None, + **kwargs: Any + ) -> None: + """ + :keyword resilient_vm_creation_policy: The configuration parameters used while performing + resilient VM creation. + :paramtype resilient_vm_creation_policy: ~azure.mgmt.compute.models.ResilientVMCreationPolicy + :keyword resilient_vm_deletion_policy: The configuration parameters used while performing + resilient VM deletion. + :paramtype resilient_vm_deletion_policy: ~azure.mgmt.compute.models.ResilientVMDeletionPolicy + :keyword automatic_zone_rebalancing_policy: The configuration parameters used while performing + automatic AZ balancing. + :paramtype automatic_zone_rebalancing_policy: + ~azure.mgmt.compute.models.AutomaticZoneRebalancingPolicy + """ + super().__init__(**kwargs) + self.resilient_vm_creation_policy = resilient_vm_creation_policy + self.resilient_vm_deletion_policy = resilient_vm_deletion_policy + self.automatic_zone_rebalancing_policy = automatic_zone_rebalancing_policy + + +class ResilientVMCreationPolicy(_serialization.Model): + """The configuration parameters used while performing resilient VM creation. + + :ivar enabled: Specifies whether resilient VM creation should be enabled on the virtual machine + scale set. The default value is false. + :vartype enabled: bool + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Specifies whether resilient VM creation should be enabled on the virtual + machine scale set. The default value is false. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.enabled = enabled + + +class ResilientVMDeletionPolicy(_serialization.Model): + """The configuration parameters used while performing resilient VM deletion. + + :ivar enabled: Specifies whether resilient VM deletion should be enabled on the virtual machine + scale set. The default value is false. + :vartype enabled: bool + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + } + + 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 ResourceInstanceViewStatus(_serialization.Model): + """Instance view status. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The status code. + :vartype code: str + :ivar display_status: The short localizable label for the status. + :vartype display_status: str + :ivar message: The detailed status message, including for alerts and error messages. + :vartype message: str + :ivar time: The time of the status. + :vartype time: ~datetime.datetime + :ivar level: The level code. Known values are: "Info", "Warning", and "Error". + :vartype level: str or ~azure.mgmt.compute.models.StatusLevelTypes + """ + + _validation = { + "code": {"readonly": True}, + "display_status": {"readonly": True}, + "message": {"readonly": True}, + "time": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "display_status": {"key": "displayStatus", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "time": {"key": "time", "type": "iso-8601"}, + "level": {"key": "level", "type": "str"}, + } + + def __init__(self, *, level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, **kwargs: Any) -> None: + """ + :keyword level: The level code. Known values are: "Info", "Warning", and "Error". + :paramtype level: str or ~azure.mgmt.compute.models.StatusLevelTypes + """ + super().__init__(**kwargs) + self.code: Optional[str] = None + self.display_status: Optional[str] = None + self.message: Optional[str] = None + self.time: Optional[datetime.datetime] = None + self.level = level + + +class ResourceRange(_serialization.Model): + """Describes the resource range. + + :ivar min: The minimum number of the resource. + :vartype min: int + :ivar max: The maximum number of the resource. + :vartype max: int + """ + + _attribute_map = { + "min": {"key": "min", "type": "int"}, + "max": {"key": "max", "type": "int"}, + } + + def __init__( + self, + *, + min: Optional[int] = None, # pylint: disable=redefined-builtin + max: Optional[int] = None, # pylint: disable=redefined-builtin + **kwargs: Any + ) -> None: + """ + :keyword min: The minimum number of the resource. + :paramtype min: int + :keyword max: The maximum number of the resource. + :paramtype max: int + """ + super().__init__(**kwargs) + self.min = min + self.max = max + + +class ResourceSharingProfile(_serialization.Model): + """ResourceSharingProfile. + + :ivar subscription_ids: Specifies an array of subscription resource IDs that capacity + reservation group is shared with. **Note:** Minimum api-version: 2023-09-01. Please refer to + https://aka.ms/computereservationsharing for more details. + :vartype subscription_ids: list[~azure.mgmt.compute.models.SubResource] + """ + + _attribute_map = { + "subscription_ids": {"key": "subscriptionIds", "type": "[SubResource]"}, + } + + def __init__(self, *, subscription_ids: Optional[List["_models.SubResource"]] = None, **kwargs: Any) -> None: + """ + :keyword subscription_ids: Specifies an array of subscription resource IDs that capacity + reservation group is shared with. **Note:** Minimum api-version: 2023-09-01. Please refer to + https://aka.ms/computereservationsharing for more details. + :paramtype subscription_ids: list[~azure.mgmt.compute.models.SubResource] + """ + super().__init__(**kwargs) + self.subscription_ids = subscription_ids + + +class ResourceSku(_serialization.Model): + """Describes an available Compute SKU. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar resource_type: The type of resource the SKU applies to. + :vartype resource_type: str + :ivar name: The name of SKU. + :vartype name: str + :ivar tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
`\\ + :code:`
` Possible Values:\\ :code:`
`\\ :code:`
` **Standard**\\ :code:`
`\\ :code:`
` **Basic**. + :vartype tier: str + :ivar size: The Size of the SKU. + :vartype size: str + :ivar family: The Family of this particular SKU. + :vartype family: str + :ivar kind: The Kind of resources that are supported in this SKU. + :vartype kind: str + :ivar capacity: Specifies the number of virtual machines in the scale set. + :vartype capacity: ~azure.mgmt.compute.models.ResourceSkuCapacity + :ivar locations: The set of locations that the SKU is available. + :vartype locations: list[str] + :ivar location_info: A list of locations and availability zones in those locations where the + SKU is available. + :vartype location_info: list[~azure.mgmt.compute.models.ResourceSkuLocationInfo] + :ivar api_versions: The api versions that support this SKU. + :vartype api_versions: list[str] + :ivar costs: Metadata for retrieving price info. + :vartype costs: list[~azure.mgmt.compute.models.ResourceSkuCosts] + :ivar capabilities: A name value pair to describe the capability. + :vartype capabilities: list[~azure.mgmt.compute.models.ResourceSkuCapabilities] + :ivar restrictions: The restrictions because of which SKU cannot be used. This is empty if + there are no restrictions. + :vartype restrictions: list[~azure.mgmt.compute.models.ResourceSkuRestrictions] + """ + + _validation = { + "resource_type": {"readonly": True}, + "name": {"readonly": True}, + "tier": {"readonly": True}, + "size": {"readonly": True}, + "family": {"readonly": True}, + "kind": {"readonly": True}, + "capacity": {"readonly": True}, + "locations": {"readonly": True}, + "location_info": {"readonly": True}, + "api_versions": {"readonly": True}, + "costs": {"readonly": True}, + "capabilities": {"readonly": True}, + "restrictions": {"readonly": True}, + } + + _attribute_map = { + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "capacity": {"key": "capacity", "type": "ResourceSkuCapacity"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[ResourceSkuLocationInfo]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "costs": {"key": "costs", "type": "[ResourceSkuCosts]"}, + "capabilities": {"key": "capabilities", "type": "[ResourceSkuCapabilities]"}, + "restrictions": {"key": "restrictions", "type": "[ResourceSkuRestrictions]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.resource_type: Optional[str] = None + self.name: Optional[str] = None + self.tier: Optional[str] = None + self.size: Optional[str] = None + self.family: Optional[str] = None + self.kind: Optional[str] = None + self.capacity: Optional["_models.ResourceSkuCapacity"] = None + self.locations: Optional[List[str]] = None + self.location_info: Optional[List["_models.ResourceSkuLocationInfo"]] = None + self.api_versions: Optional[List[str]] = None + self.costs: Optional[List["_models.ResourceSkuCosts"]] = None + self.capabilities: Optional[List["_models.ResourceSkuCapabilities"]] = None + self.restrictions: Optional[List["_models.ResourceSkuRestrictions"]] = None + + +class ResourceSkuCapabilities(_serialization.Model): + """Describes The SKU capabilities object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: An invariant to describe the feature. + :vartype name: str + :ivar value: An invariant if the feature is measured by quantity. + :vartype value: str + """ + + _validation = { + "name": {"readonly": True}, + "value": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name: Optional[str] = None + self.value: Optional[str] = None + + +class ResourceSkuCapacity(_serialization.Model): + """Describes scaling information of a SKU. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar minimum: The minimum capacity. + :vartype minimum: int + :ivar maximum: The maximum capacity that can be set. + :vartype maximum: int + :ivar default: The default capacity. + :vartype default: int + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", + "Manual", and "None". + :vartype scale_type: str or ~azure.mgmt.compute.models.ResourceSkuCapacityScaleType + """ + + _validation = { + "minimum": {"readonly": True}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "scale_type": {"readonly": True}, + } + + _attribute_map = { + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.minimum: Optional[int] = None + self.maximum: Optional[int] = None + self.default: Optional[int] = None + self.scale_type: Optional[Union[str, "_models.ResourceSkuCapacityScaleType"]] = None + + +class ResourceSkuCosts(_serialization.Model): + """Describes metadata for retrieving price info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar meter_id: Used for querying price from commerce. + :vartype meter_id: str + :ivar quantity: The multiplier is needed to extend the base metered cost. + :vartype quantity: int + :ivar extended_unit: An invariant to show the extended unit. + :vartype extended_unit: str + """ + + _validation = { + "meter_id": {"readonly": True}, + "quantity": {"readonly": True}, + "extended_unit": {"readonly": True}, + } + + _attribute_map = { + "meter_id": {"key": "meterID", "type": "str"}, + "quantity": {"key": "quantity", "type": "int"}, + "extended_unit": {"key": "extendedUnit", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.meter_id: Optional[str] = None + self.quantity: Optional[int] = None + self.extended_unit: Optional[str] = None + + +class ResourceSkuLocationInfo(_serialization.Model): + """Describes an available Compute SKU Location Information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location: Location of the SKU. + :vartype location: str + :ivar zones: List of availability zones where the SKU is supported. + :vartype zones: list[str] + :ivar zone_details: Details of capabilities available to a SKU in specific zones. + :vartype zone_details: list[~azure.mgmt.compute.models.ResourceSkuZoneDetails] + :ivar extended_locations: The names of extended locations. + :vartype extended_locations: list[str] + :ivar type: The type of the extended location. "EdgeZone" + :vartype type: str or ~azure.mgmt.compute.models.ExtendedLocationType + """ + + _validation = { + "location": {"readonly": True}, + "zones": {"readonly": True}, + "zone_details": {"readonly": True}, + "extended_locations": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "zone_details": {"key": "zoneDetails", "type": "[ResourceSkuZoneDetails]"}, + "extended_locations": {"key": "extendedLocations", "type": "[str]"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.location: Optional[str] = None + self.zones: Optional[List[str]] = None + self.zone_details: Optional[List["_models.ResourceSkuZoneDetails"]] = None + self.extended_locations: Optional[List[str]] = None + self.type: Optional[Union[str, "_models.ExtendedLocationType"]] = None + + +class ResourceSkuRestrictionInfo(_serialization.Model): + """Describes an available Compute SKU Restriction Information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar locations: Locations where the SKU is restricted. + :vartype locations: list[str] + :ivar zones: List of availability zones where the SKU is restricted. + :vartype zones: list[str] + """ + + _validation = { + "locations": {"readonly": True}, + "zones": {"readonly": True}, + } + + _attribute_map = { + "locations": {"key": "locations", "type": "[str]"}, + "zones": {"key": "zones", "type": "[str]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.locations: Optional[List[str]] = None + self.zones: Optional[List[str]] = None + + +class ResourceSkuRestrictions(_serialization.Model): + """Describes scaling information of a SKU. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The type of restrictions. Known values are: "Location" and "Zone". + :vartype type: str or ~azure.mgmt.compute.models.ResourceSkuRestrictionsType + :ivar values: The value of restrictions. If the restriction type is set to location. This would + be different locations where the SKU is restricted. + :vartype values: list[str] + :ivar restriction_info: The information about the restriction where the SKU cannot be used. + :vartype restriction_info: ~azure.mgmt.compute.models.ResourceSkuRestrictionInfo + :ivar reason_code: The reason for restriction. Known values are: "QuotaId" and + "NotAvailableForSubscription". + :vartype reason_code: str or ~azure.mgmt.compute.models.ResourceSkuRestrictionsReasonCode + """ + + _validation = { + "type": {"readonly": True}, + "values": {"readonly": True}, + "restriction_info": {"readonly": True}, + "reason_code": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "restriction_info": {"key": "restrictionInfo", "type": "ResourceSkuRestrictionInfo"}, + "reason_code": {"key": "reasonCode", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type: Optional[Union[str, "_models.ResourceSkuRestrictionsType"]] = None + self.values: Optional[List[str]] = None + self.restriction_info: Optional["_models.ResourceSkuRestrictionInfo"] = None + self.reason_code: Optional[Union[str, "_models.ResourceSkuRestrictionsReasonCode"]] = None + + +class ResourceSkusResult(_serialization.Model): + """The List Resource Skus operation response. + + All required parameters must be populated in order to send to server. + + :ivar value: The ResourceSku items on this page. Required. + :vartype value: list[~azure.mgmt.compute.models.ResourceSku] + :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": "[ResourceSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.ResourceSku"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: The ResourceSku items on this page. Required. + :paramtype value: list[~azure.mgmt.compute.models.ResourceSku] + :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 ResourceSkuZoneDetails(_serialization.Model): + """Describes The zonal capabilities of a SKU. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The set of zones that the SKU is available in with the specified capabilities. + :vartype name: list[str] + :ivar capabilities: A list of capabilities that are available for the SKU in the specified list + of zones. + :vartype capabilities: list[~azure.mgmt.compute.models.ResourceSkuCapabilities] + """ + + _validation = { + "name": {"readonly": True}, + "capabilities": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[ResourceSkuCapabilities]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name: Optional[List[str]] = None + self.capabilities: Optional[List["_models.ResourceSkuCapabilities"]] = None + + +class ResourceUriList(_serialization.Model): + """The List resources which are encrypted with the disk encryption set. + + All required parameters must be populated in order to send to server. + + :ivar value: A list of IDs or Owner IDs of resources which are encrypted with the disk + encryption set. Required. + :vartype value: list[str] + :ivar next_link: The uri to fetch the next page of encrypted resources. Call ListNext() with + this to fetch the next page of encrypted resources. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[str]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List[str], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of IDs or Owner IDs of resources which are encrypted with the disk + encryption set. Required. + :paramtype value: list[str] + :keyword next_link: The uri to fetch the next page of encrypted resources. Call ListNext() with + this to fetch the next page of encrypted resources. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ResourceWithOptionalLocation(_serialization.Model): + """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: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.tags = tags + + +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: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = 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}. + :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.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.models.ApiEntityReference] + :ivar source_metadata: Gets the details of the VM captured at the time of the restore point + creation. + :vartype source_metadata: ~azure.mgmt.compute.models.RestorePointSourceMetadata + :ivar provisioning_state: Gets the provisioning state of the restore point. + :vartype provisioning_state: str + :ivar consistency_mode: ConsistencyMode of the RestorePoint. Can be specified in the input + while creating a restore point. For now, only CrashConsistent is accepted as a valid input. + Please refer to https://aka.ms/RestorePoints for more details. Known values are: + "CrashConsistent", "FileSystemConsistent", and "ApplicationConsistent". + :vartype consistency_mode: str or ~azure.mgmt.compute.models.ConsistencyModeTypes + :ivar time_created: Gets the creation time of the restore point. + :vartype time_created: ~datetime.datetime + :ivar source_restore_point: Resource Id of the source restore point from which a copy needs to + be created. + :vartype source_restore_point: ~azure.mgmt.compute.models.ApiEntityReference + :ivar instance_view: The restore point instance view. + :vartype instance_view: ~azure.mgmt.compute.models.RestorePointInstanceView + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "instance_view": {"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"}, + "exclude_disks": {"key": "properties.excludeDisks", "type": "[ApiEntityReference]"}, + "source_metadata": {"key": "properties.sourceMetadata", "type": "RestorePointSourceMetadata"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "consistency_mode": {"key": "properties.consistencyMode", "type": "str"}, + "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, + "source_restore_point": {"key": "properties.sourceRestorePoint", "type": "ApiEntityReference"}, + "instance_view": {"key": "properties.instanceView", "type": "RestorePointInstanceView"}, + } + + def __init__( + self, + *, + exclude_disks: Optional[List["_models.ApiEntityReference"]] = None, + source_metadata: Optional["_models.RestorePointSourceMetadata"] = None, + consistency_mode: Optional[Union[str, "_models.ConsistencyModeTypes"]] = None, + time_created: Optional[datetime.datetime] = None, + source_restore_point: Optional["_models.ApiEntityReference"] = None, + **kwargs: Any + ) -> None: + """ + :keyword 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. + :paramtype exclude_disks: list[~azure.mgmt.compute.models.ApiEntityReference] + :keyword source_metadata: Gets the details of the VM captured at the time of the restore point + creation. + :paramtype source_metadata: ~azure.mgmt.compute.models.RestorePointSourceMetadata + :keyword consistency_mode: ConsistencyMode of the RestorePoint. Can be specified in the input + while creating a restore point. For now, only CrashConsistent is accepted as a valid input. + Please refer to https://aka.ms/RestorePoints for more details. Known values are: + "CrashConsistent", "FileSystemConsistent", and "ApplicationConsistent". + :paramtype consistency_mode: str or ~azure.mgmt.compute.models.ConsistencyModeTypes + :keyword time_created: Gets the creation time of the restore point. + :paramtype time_created: ~datetime.datetime + :keyword source_restore_point: Resource Id of the source restore point from which a copy needs + to be created. + :paramtype source_restore_point: ~azure.mgmt.compute.models.ApiEntityReference + """ + super().__init__(**kwargs) + self.exclude_disks = exclude_disks + self.source_metadata = source_metadata + self.provisioning_state: Optional[str] = None + self.consistency_mode = consistency_mode + self.time_created = time_created + self.source_restore_point = source_restore_point + self.instance_view: Optional["_models.RestorePointInstanceView"] = None + + +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: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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.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.models.RestorePointCollectionSourceProperties + :ivar provisioning_state: The provisioning state of the restore point collection. + :vartype provisioning_state: str + :ivar restore_point_collection_id: The unique id of the restore point collection. + :vartype restore_point_collection_id: str + :ivar restore_points: A list containing all restore points created under this restore point + collection. + :vartype restore_points: list[~azure.mgmt.compute.models.RestorePoint] + """ + + _validation = { + "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}, + "restore_points": {"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"}, + "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"}, + "restore_points": {"key": "properties.restorePoints", "type": "[RestorePoint]"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + source: Optional["_models.RestorePointCollectionSourceProperties"] = None, + **kwargs: Any + ) -> None: + """ + :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.models.RestorePointCollectionSourceProperties + """ + super().__init__(tags=tags, location=location, **kwargs) + self.source = source + self.provisioning_state: Optional[str] = None + self.restore_point_collection_id: Optional[str] = None + self.restore_points: Optional[List["_models.RestorePoint"]] = None + + +class RestorePointCollectionListResult(_serialization.Model): + """The List restore point collection operation response. + + 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.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: List["_models.RestorePointCollection"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: Gets the list of restore point collections. Required. + :paramtype value: list[~azure.mgmt.compute.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. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RestorePointCollectionSourceProperties(_serialization.Model): + """The properties of the source resource that this restore point collection is created from. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location: Location of the source resource used to create this restore point collection. + :vartype location: str + :ivar id: Resource Id of the source resource used to create this restore point collection. + :vartype id: str + """ + + _validation = { + "location": {"readonly": True}, + } + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: Resource Id of the source resource used to create this restore point collection. + :paramtype id: str + """ + super().__init__(**kwargs) + self.location: Optional[str] = None + self.id = id + + +class RestorePointCollectionUpdate(UpdateResource): + """Update Restore Point collection parameters. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar source: The properties of the source resource that this restore point collection is + created from. + :vartype source: ~azure.mgmt.compute.models.RestorePointCollectionSourceProperties + :ivar provisioning_state: The provisioning state of the restore point collection. + :vartype provisioning_state: str + :ivar restore_point_collection_id: The unique id of the restore point collection. + :vartype restore_point_collection_id: str + :ivar restore_points: A list containing all restore points created under this restore point + collection. + :vartype restore_points: list[~azure.mgmt.compute.models.RestorePoint] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "restore_point_collection_id": {"readonly": True}, + "restore_points": {"readonly": True}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "source": {"key": "properties.source", "type": "RestorePointCollectionSourceProperties"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "restore_point_collection_id": {"key": "properties.restorePointCollectionId", "type": "str"}, + "restore_points": {"key": "properties.restorePoints", "type": "[RestorePoint]"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + source: Optional["_models.RestorePointCollectionSourceProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword source: The properties of the source resource that this restore point collection is + created from. + :paramtype source: ~azure.mgmt.compute.models.RestorePointCollectionSourceProperties + """ + super().__init__(tags=tags, **kwargs) + self.source = source + self.provisioning_state: Optional[str] = None + self.restore_point_collection_id: Optional[str] = None + self.restore_points: Optional[List["_models.RestorePoint"]] = None + + +class RestorePointEncryption(_serialization.Model): + """Encryption at rest settings for disk restore point. It is an optional property that can be + specified in the input while creating a restore point. + + :ivar disk_encryption_set: Describes the parameter of customer managed disk encryption set + resource id that can be specified for disk. **Note:** The disk encryption set resource id can + only be specified for managed disk. Please refer https://aka.ms/mdssewithcmkoverview for more + details. + :vartype disk_encryption_set: ~azure.mgmt.compute.models.DiskEncryptionSetParameters + :ivar type: The type of key used to encrypt the data of the disk restore point. Known values + are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and + "EncryptionAtRestWithPlatformAndCustomerKeys". + :vartype type: str or ~azure.mgmt.compute.models.RestorePointEncryptionType + """ + + _attribute_map = { + "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, + type: Optional[Union[str, "_models.RestorePointEncryptionType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword disk_encryption_set: Describes the parameter of customer managed disk encryption set + resource id that can be specified for disk. **Note:** The disk encryption set resource id can + only be specified for managed disk. Please refer https://aka.ms/mdssewithcmkoverview for more + details. + :paramtype disk_encryption_set: ~azure.mgmt.compute.models.DiskEncryptionSetParameters + :keyword type: The type of key used to encrypt the data of the disk restore point. Known values + are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and + "EncryptionAtRestWithPlatformAndCustomerKeys". + :paramtype type: str or ~azure.mgmt.compute.models.RestorePointEncryptionType + """ + super().__init__(**kwargs) + self.disk_encryption_set = disk_encryption_set + self.type = type + + +class RestorePointInstanceView(_serialization.Model): + """The instance view of a restore point. + + :ivar disk_restore_points: The disk restore points information. + :vartype disk_restore_points: list[~azure.mgmt.compute.models.DiskRestorePointInstanceView] + :ivar statuses: The resource status information. + :vartype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] + """ + + _attribute_map = { + "disk_restore_points": {"key": "diskRestorePoints", "type": "[DiskRestorePointInstanceView]"}, + "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, + } + + def __init__( + self, + *, + disk_restore_points: Optional[List["_models.DiskRestorePointInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword disk_restore_points: The disk restore points information. + :paramtype disk_restore_points: list[~azure.mgmt.compute.models.DiskRestorePointInstanceView] + :keyword statuses: The resource status information. + :paramtype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] + """ + super().__init__(**kwargs) + self.disk_restore_points = disk_restore_points + self.statuses = statuses + + +class RestorePointSourceMetadata(_serialization.Model): + """Describes the properties of the Virtual Machine for which the restore point was created. The + properties provided are a subset and the snapshot of the overall Virtual Machine properties + captured at the time of the restore point creation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar hardware_profile: Gets the hardware profile. + :vartype hardware_profile: ~azure.mgmt.compute.models.HardwareProfile + :ivar storage_profile: Gets the storage profile. + :vartype storage_profile: ~azure.mgmt.compute.models.RestorePointSourceVMStorageProfile + :ivar os_profile: Gets the OS profile. + :vartype os_profile: ~azure.mgmt.compute.models.OSProfile + :ivar diagnostics_profile: Gets the diagnostics profile. + :vartype diagnostics_profile: ~azure.mgmt.compute.models.DiagnosticsProfile + :ivar license_type: Gets the license type, which is for bring your own license scenario. + :vartype license_type: str + :ivar vm_id: Gets the virtual machine unique id. + :vartype vm_id: str + :ivar security_profile: Gets the security profile. + :vartype security_profile: ~azure.mgmt.compute.models.SecurityProfile + :ivar location: Location of the VM from which the restore point was created. + :vartype location: str + :ivar user_data: UserData associated with the source VM for which restore point is captured, + which is a base-64 encoded value. + :vartype user_data: str + :ivar hyper_v_generation: HyperVGeneration of the source VM for which restore point is + captured. Known values are: "V1" and "V2". + :vartype hyper_v_generation: str or ~azure.mgmt.compute.models.HyperVGenerationTypes + """ + + _validation = { + "hardware_profile": {"readonly": True}, + "os_profile": {"readonly": True}, + "diagnostics_profile": {"readonly": True}, + "license_type": {"readonly": True}, + "vm_id": {"readonly": True}, + "security_profile": {"readonly": True}, + "location": {"readonly": True}, + "user_data": {"readonly": True}, + "hyper_v_generation": {"readonly": True}, + } + + _attribute_map = { + "hardware_profile": {"key": "hardwareProfile", "type": "HardwareProfile"}, + "storage_profile": {"key": "storageProfile", "type": "RestorePointSourceVMStorageProfile"}, + "os_profile": {"key": "osProfile", "type": "OSProfile"}, + "diagnostics_profile": {"key": "diagnosticsProfile", "type": "DiagnosticsProfile"}, + "license_type": {"key": "licenseType", "type": "str"}, + "vm_id": {"key": "vmId", "type": "str"}, + "security_profile": {"key": "securityProfile", "type": "SecurityProfile"}, + "location": {"key": "location", "type": "str"}, + "user_data": {"key": "userData", "type": "str"}, + "hyper_v_generation": {"key": "hyperVGeneration", "type": "str"}, + } + + def __init__( + self, *, storage_profile: Optional["_models.RestorePointSourceVMStorageProfile"] = None, **kwargs: Any + ) -> None: + """ + :keyword storage_profile: Gets the storage profile. + :paramtype storage_profile: ~azure.mgmt.compute.models.RestorePointSourceVMStorageProfile + """ + super().__init__(**kwargs) + self.hardware_profile: Optional["_models.HardwareProfile"] = None + self.storage_profile = storage_profile + self.os_profile: Optional["_models.OSProfile"] = None + self.diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None + self.license_type: Optional[str] = None + self.vm_id: Optional[str] = None + self.security_profile: Optional["_models.SecurityProfile"] = None + self.location: Optional[str] = None + self.user_data: Optional[str] = None + self.hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None + + +class RestorePointSourceVMDataDisk(_serialization.Model): + """Describes a data disk. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar lun: Gets the logical unit number. + :vartype lun: int + :ivar name: Gets the disk name. + :vartype name: str + :ivar caching: Gets the caching type. Known values are: "None", "ReadOnly", and "ReadWrite". + :vartype caching: str or ~azure.mgmt.compute.models.CachingTypes + :ivar disk_size_gb: Gets the initial disk size in GB for blank data disks, and the new desired + size for existing OS and Data disks. + :vartype disk_size_gb: int + :ivar managed_disk: Contains the managed disk details. + :vartype managed_disk: ~azure.mgmt.compute.models.ManagedDiskParameters + :ivar disk_restore_point: Contains Disk Restore Point properties. + :vartype disk_restore_point: ~azure.mgmt.compute.models.DiskRestorePointAttributes + :ivar write_accelerator_enabled: Shows true if the disk is write-accelerator enabled. + :vartype write_accelerator_enabled: bool + """ + + _validation = { + "lun": {"readonly": True}, + "name": {"readonly": True}, + "caching": {"readonly": True}, + "disk_size_gb": {"readonly": True}, + "write_accelerator_enabled": {"readonly": True}, + } + + _attribute_map = { + "lun": {"key": "lun", "type": "int"}, + "name": {"key": "name", "type": "str"}, + "caching": {"key": "caching", "type": "str"}, + "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, + "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, + "disk_restore_point": {"key": "diskRestorePoint", "type": "DiskRestorePointAttributes"}, + "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, + } + + def __init__( + self, + *, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + disk_restore_point: Optional["_models.DiskRestorePointAttributes"] = None, + **kwargs: Any + ) -> None: + """ + :keyword managed_disk: Contains the managed disk details. + :paramtype managed_disk: ~azure.mgmt.compute.models.ManagedDiskParameters + :keyword disk_restore_point: Contains Disk Restore Point properties. + :paramtype disk_restore_point: ~azure.mgmt.compute.models.DiskRestorePointAttributes + """ + super().__init__(**kwargs) + self.lun: Optional[int] = None + self.name: Optional[str] = None + self.caching: Optional[Union[str, "_models.CachingTypes"]] = None + self.disk_size_gb: Optional[int] = None + self.managed_disk = managed_disk + self.disk_restore_point = disk_restore_point + self.write_accelerator_enabled: Optional[bool] = None + + +class RestorePointSourceVMOSDisk(_serialization.Model): + """Describes an Operating System disk. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar os_type: Gets the Operating System type. Known values are: "Windows" and "Linux". + :vartype os_type: str or ~azure.mgmt.compute.models.OperatingSystemType + :ivar encryption_settings: Gets the disk encryption settings. + :vartype encryption_settings: ~azure.mgmt.compute.models.DiskEncryptionSettings + :ivar name: Gets the disk name. + :vartype name: str + :ivar caching: Gets the caching type. Known values are: "None", "ReadOnly", and "ReadWrite". + :vartype caching: str or ~azure.mgmt.compute.models.CachingTypes + :ivar disk_size_gb: Gets the disk size in GB. + :vartype disk_size_gb: int + :ivar managed_disk: Gets the managed disk details. + :vartype managed_disk: ~azure.mgmt.compute.models.ManagedDiskParameters + :ivar disk_restore_point: Contains Disk Restore Point properties. + :vartype disk_restore_point: ~azure.mgmt.compute.models.DiskRestorePointAttributes + :ivar write_accelerator_enabled: Shows true if the disk is write-accelerator enabled. + :vartype write_accelerator_enabled: bool + """ + + _validation = { + "os_type": {"readonly": True}, + "encryption_settings": {"readonly": True}, + "name": {"readonly": True}, + "caching": {"readonly": True}, + "disk_size_gb": {"readonly": True}, + "write_accelerator_enabled": {"readonly": True}, + } + + _attribute_map = { + "os_type": {"key": "osType", "type": "str"}, + "encryption_settings": {"key": "encryptionSettings", "type": "DiskEncryptionSettings"}, + "name": {"key": "name", "type": "str"}, + "caching": {"key": "caching", "type": "str"}, + "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, + "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, + "disk_restore_point": {"key": "diskRestorePoint", "type": "DiskRestorePointAttributes"}, + "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, + } + + def __init__( + self, + *, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + disk_restore_point: Optional["_models.DiskRestorePointAttributes"] = None, + **kwargs: Any + ) -> None: + """ + :keyword managed_disk: Gets the managed disk details. + :paramtype managed_disk: ~azure.mgmt.compute.models.ManagedDiskParameters + :keyword disk_restore_point: Contains Disk Restore Point properties. + :paramtype disk_restore_point: ~azure.mgmt.compute.models.DiskRestorePointAttributes + """ + super().__init__(**kwargs) + self.os_type: Optional[Union[str, "_models.OperatingSystemType"]] = None + self.encryption_settings: Optional["_models.DiskEncryptionSettings"] = None + self.name: Optional[str] = None + self.caching: Optional[Union[str, "_models.CachingTypes"]] = None + self.disk_size_gb: Optional[int] = None + self.managed_disk = managed_disk + self.disk_restore_point = disk_restore_point + self.write_accelerator_enabled: Optional[bool] = None + + +class RestorePointSourceVMStorageProfile(_serialization.Model): + """Describes the storage profile. + + 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.models.RestorePointSourceVMOSDisk + :ivar data_disks: Gets the data disks of the VM captured at the time of the restore point + creation. + :vartype data_disks: list[~azure.mgmt.compute.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 ~azure.mgmt.compute.models.DiskControllerTypes + """ + + _validation = { + "disk_controller_type": {"readonly": True}, + } + + _attribute_map = { + "os_disk": {"key": "osDisk", "type": "RestorePointSourceVMOSDisk"}, + "data_disks": {"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, + **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.models.RestorePointSourceVMOSDisk + :keyword data_disks: Gets the data disks of the VM captured at the time of the restore point + creation. + :paramtype data_disks: list[~azure.mgmt.compute.models.RestorePointSourceVMDataDisk] + """ + super().__init__(**kwargs) + self.os_disk = os_disk + self.data_disks = data_disks + self.disk_controller_type: Optional[Union[str, "_models.DiskControllerTypes"]] = None + + +class RetrieveBootDiagnosticsDataResult(_serialization.Model): + """The SAS URIs of the console screenshot and serial log blobs. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar console_screenshot_blob_uri: The console screenshot blob URI. + :vartype console_screenshot_blob_uri: str + :ivar serial_console_log_blob_uri: The serial console log blob URI. + :vartype serial_console_log_blob_uri: str + """ + + _validation = { + "console_screenshot_blob_uri": {"readonly": True}, + "serial_console_log_blob_uri": {"readonly": True}, + } + + _attribute_map = { + "console_screenshot_blob_uri": {"key": "consoleScreenshotBlobUri", "type": "str"}, + "serial_console_log_blob_uri": {"key": "serialConsoleLogBlobUri", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.console_screenshot_blob_uri: Optional[str] = None + self.serial_console_log_blob_uri: Optional[str] = None + + +class RoleInstance(_serialization.Model): + """Describes the cloud service role instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :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. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar sku: The role instance SKU. + :vartype sku: ~azure.mgmt.compute.models.InstanceSku + :ivar properties: Role instance properties. + :vartype properties: ~azure.mgmt.compute.models.RoleInstanceProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "tags": {"readonly": 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}"}, + "sku": {"key": "sku", "type": "InstanceSku"}, + "properties": {"key": "properties", "type": "RoleInstanceProperties"}, + } + + def __init__( + self, + *, + sku: Optional["_models.InstanceSku"] = None, + properties: Optional["_models.RoleInstanceProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword sku: The role instance SKU. + :paramtype sku: ~azure.mgmt.compute.models.InstanceSku + :keyword properties: Role instance properties. + :paramtype properties: ~azure.mgmt.compute.models.RoleInstanceProperties + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.location: Optional[str] = None + self.tags: Optional[Dict[str, str]] = None + self.sku = sku + self.properties = properties + + +class RoleInstanceListResult(_serialization.Model): + """The list operation result. + + All required parameters must be populated in order to send to server. + + :ivar value: The list of resources. Required. + :vartype value: list[~azure.mgmt.compute.models.RoleInstance] + :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of + resources. Do this till nextLink is null to fetch all the resources. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[RoleInstance]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.RoleInstance"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of resources. Required. + :paramtype value: list[~azure.mgmt.compute.models.RoleInstance] + :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page + of resources. Do this till nextLink is null to fetch all the resources. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleInstanceNetworkProfile(_serialization.Model): + """Describes the network profile for the role instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar network_interfaces: Specifies the list of resource Ids for the network interfaces + associated with the role instance. + :vartype network_interfaces: list[~azure.mgmt.compute.models.SubResource] + """ + + _validation = { + "network_interfaces": {"readonly": True}, + } + + _attribute_map = { + "network_interfaces": {"key": "networkInterfaces", "type": "[SubResource]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.network_interfaces: Optional[List["_models.SubResource"]] = None + + +class RoleInstanceProperties(_serialization.Model): + """Role instance properties. + + :ivar network_profile: Describes the network profile for the role instance. + :vartype network_profile: ~azure.mgmt.compute.models.RoleInstanceNetworkProfile + :ivar instance_view: The instance view of the role instance. + :vartype instance_view: ~azure.mgmt.compute.models.RoleInstanceView + """ + + _attribute_map = { + "network_profile": {"key": "networkProfile", "type": "RoleInstanceNetworkProfile"}, + "instance_view": {"key": "instanceView", "type": "RoleInstanceView"}, + } + + def __init__( + self, + *, + network_profile: Optional["_models.RoleInstanceNetworkProfile"] = None, + instance_view: Optional["_models.RoleInstanceView"] = None, + **kwargs: Any + ) -> None: + """ + :keyword network_profile: Describes the network profile for the role instance. + :paramtype network_profile: ~azure.mgmt.compute.models.RoleInstanceNetworkProfile + :keyword instance_view: The instance view of the role instance. + :paramtype instance_view: ~azure.mgmt.compute.models.RoleInstanceView + """ + super().__init__(**kwargs) + self.network_profile = network_profile + self.instance_view = instance_view + + +class RoleInstances(_serialization.Model): + """Specifies a list of role instances from the cloud service. + + All required parameters must be populated in order to send to server. + + :ivar role_instances: List of cloud service role instance names. Value of '*' will signify all + role instances of the cloud service. Required. + :vartype role_instances: list[str] + """ + + _validation = { + "role_instances": {"required": True}, + } + + _attribute_map = { + "role_instances": {"key": "roleInstances", "type": "[str]"}, + } + + def __init__(self, *, role_instances: List[str], **kwargs: Any) -> None: + """ + :keyword role_instances: List of cloud service role instance names. Value of '*' will signify + all role instances of the cloud service. Required. + :paramtype role_instances: list[str] + """ + super().__init__(**kwargs) + self.role_instances = role_instances + + +class RoleInstanceView(_serialization.Model): + """The instance view of the role instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar platform_update_domain: The Update Domain. + :vartype platform_update_domain: int + :ivar platform_fault_domain: The Fault Domain. + :vartype platform_fault_domain: int + :ivar private_id: Specifies a unique identifier generated internally for the cloud service + associated with this role instance. :code:`
`\\ :code:`
` NOTE: If you are using + Azure Diagnostics extension, this property can be used as 'DeploymentId' for querying details. + :vartype private_id: str + :ivar statuses: + :vartype statuses: list[~azure.mgmt.compute.models.ResourceInstanceViewStatus] + """ + + _validation = { + "platform_update_domain": {"readonly": True}, + "platform_fault_domain": {"readonly": True}, + "private_id": {"readonly": True}, + "statuses": {"readonly": True}, + } + + _attribute_map = { + "platform_update_domain": {"key": "platformUpdateDomain", "type": "int"}, + "platform_fault_domain": {"key": "platformFaultDomain", "type": "int"}, + "private_id": {"key": "privateId", "type": "str"}, + "statuses": {"key": "statuses", "type": "[ResourceInstanceViewStatus]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.platform_update_domain: Optional[int] = None + self.platform_fault_domain: Optional[int] = None + self.private_id: Optional[str] = None + self.statuses: Optional[List["_models.ResourceInstanceViewStatus"]] = None + + +class RollbackStatusInfo(_serialization.Model): + """Information about rollback on failed VM instances after a OS Upgrade operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar successfully_rolledback_instance_count: The number of instances which have been + successfully rolled back. + :vartype successfully_rolledback_instance_count: int + :ivar failed_rolledback_instance_count: The number of instances which failed to rollback. + :vartype failed_rolledback_instance_count: int + :ivar rollback_error: Error details if OS rollback failed. + :vartype rollback_error: ~azure.mgmt.compute.models.ApiError + """ + + _validation = { + "successfully_rolledback_instance_count": {"readonly": True}, + "failed_rolledback_instance_count": {"readonly": True}, + "rollback_error": {"readonly": True}, + } + + _attribute_map = { + "successfully_rolledback_instance_count": {"key": "successfullyRolledbackInstanceCount", "type": "int"}, + "failed_rolledback_instance_count": {"key": "failedRolledbackInstanceCount", "type": "int"}, + "rollback_error": {"key": "rollbackError", "type": "ApiError"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.successfully_rolledback_instance_count: Optional[int] = None + self.failed_rolledback_instance_count: Optional[int] = None + self.rollback_error: Optional["_models.ApiError"] = None + + +class RollingUpgradePolicy(_serialization.Model): + """The configuration parameters used while performing a rolling upgrade. + + :ivar max_batch_instance_percent: The maximum percent of total virtual machine instances that + will be upgraded simultaneously by the rolling upgrade in one batch. As this is a maximum, + unhealthy instances in previous or future batches can cause the percentage of instances in a + batch to decrease to ensure higher reliability. The default value for this parameter is 20%. + :vartype max_batch_instance_percent: int + :ivar max_unhealthy_instance_percent: The maximum percentage of the total virtual machine + instances in the scale set that can be simultaneously unhealthy, either as a result of being + upgraded, or by being found in an unhealthy state by the virtual machine health checks before + the rolling upgrade aborts. This constraint will be checked prior to starting any batch. The + default value for this parameter is 20%. + :vartype max_unhealthy_instance_percent: int + :ivar max_unhealthy_upgraded_instance_percent: The maximum percentage of upgraded virtual + machine instances that can be found to be in an unhealthy state. This check will happen after + each batch is upgraded. If this percentage is ever exceeded, the rolling update aborts. The + default value for this parameter is 20%. + :vartype max_unhealthy_upgraded_instance_percent: int + :ivar pause_time_between_batches: The wait time between completing the update for all virtual + machines in one batch and starting the next batch. The time duration should be specified in ISO + 8601 format. The default value is 0 seconds (PT0S). + :vartype pause_time_between_batches: str + :ivar enable_cross_zone_upgrade: Allow VMSS to ignore AZ boundaries when constructing upgrade + batches. Take into consideration the Update Domain and maxBatchInstancePercent to determine the + batch size. + :vartype enable_cross_zone_upgrade: bool + :ivar prioritize_unhealthy_instances: Upgrade all unhealthy instances in a scale set before any + healthy instances. + :vartype prioritize_unhealthy_instances: bool + :ivar rollback_failed_instances_on_policy_breach: Rollback failed instances to previous model + if the Rolling Upgrade policy is violated. + :vartype rollback_failed_instances_on_policy_breach: bool + :ivar max_surge: Create new virtual machines to upgrade the scale set, rather than updating the + existing virtual machines. Existing virtual machines will be deleted once the new virtual + machines are created for each batch. + :vartype max_surge: bool + """ + + _validation = { + "max_batch_instance_percent": {"maximum": 100, "minimum": 5}, + "max_unhealthy_instance_percent": {"maximum": 100, "minimum": 5}, + "max_unhealthy_upgraded_instance_percent": {"maximum": 100}, + } + + _attribute_map = { + "max_batch_instance_percent": {"key": "maxBatchInstancePercent", "type": "int"}, + "max_unhealthy_instance_percent": {"key": "maxUnhealthyInstancePercent", "type": "int"}, + "max_unhealthy_upgraded_instance_percent": {"key": "maxUnhealthyUpgradedInstancePercent", "type": "int"}, + "pause_time_between_batches": {"key": "pauseTimeBetweenBatches", "type": "str"}, + "enable_cross_zone_upgrade": {"key": "enableCrossZoneUpgrade", "type": "bool"}, + "prioritize_unhealthy_instances": {"key": "prioritizeUnhealthyInstances", "type": "bool"}, + "rollback_failed_instances_on_policy_breach": {"key": "rollbackFailedInstancesOnPolicyBreach", "type": "bool"}, + "max_surge": {"key": "maxSurge", "type": "bool"}, + } + + def __init__( + self, + *, + max_batch_instance_percent: Optional[int] = None, + max_unhealthy_instance_percent: Optional[int] = None, + max_unhealthy_upgraded_instance_percent: Optional[int] = None, + pause_time_between_batches: Optional[str] = None, + enable_cross_zone_upgrade: Optional[bool] = None, + prioritize_unhealthy_instances: Optional[bool] = None, + rollback_failed_instances_on_policy_breach: Optional[bool] = None, + max_surge: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword max_batch_instance_percent: The maximum percent of total virtual machine instances + that will be upgraded simultaneously by the rolling upgrade in one batch. As this is a maximum, + unhealthy instances in previous or future batches can cause the percentage of instances in a + batch to decrease to ensure higher reliability. The default value for this parameter is 20%. + :paramtype max_batch_instance_percent: int + :keyword max_unhealthy_instance_percent: The maximum percentage of the total virtual machine + instances in the scale set that can be simultaneously unhealthy, either as a result of being + upgraded, or by being found in an unhealthy state by the virtual machine health checks before + the rolling upgrade aborts. This constraint will be checked prior to starting any batch. The + default value for this parameter is 20%. + :paramtype max_unhealthy_instance_percent: int + :keyword max_unhealthy_upgraded_instance_percent: The maximum percentage of upgraded virtual + machine instances that can be found to be in an unhealthy state. This check will happen after + each batch is upgraded. If this percentage is ever exceeded, the rolling update aborts. The + default value for this parameter is 20%. + :paramtype max_unhealthy_upgraded_instance_percent: int + :keyword pause_time_between_batches: The wait time between completing the update for all + virtual machines in one batch and starting the next batch. The time duration should be + specified in ISO 8601 format. The default value is 0 seconds (PT0S). + :paramtype pause_time_between_batches: str + :keyword enable_cross_zone_upgrade: Allow VMSS to ignore AZ boundaries when constructing + upgrade batches. Take into consideration the Update Domain and maxBatchInstancePercent to + determine the batch size. + :paramtype enable_cross_zone_upgrade: bool + :keyword prioritize_unhealthy_instances: Upgrade all unhealthy instances in a scale set before + any healthy instances. + :paramtype prioritize_unhealthy_instances: bool + :keyword rollback_failed_instances_on_policy_breach: Rollback failed instances to previous + model if the Rolling Upgrade policy is violated. + :paramtype rollback_failed_instances_on_policy_breach: bool + :keyword max_surge: Create new virtual machines to upgrade the scale set, rather than updating + the existing virtual machines. Existing virtual machines will be deleted once the new virtual + machines are created for each batch. + :paramtype max_surge: bool + """ + super().__init__(**kwargs) + self.max_batch_instance_percent = max_batch_instance_percent + self.max_unhealthy_instance_percent = max_unhealthy_instance_percent + self.max_unhealthy_upgraded_instance_percent = max_unhealthy_upgraded_instance_percent + self.pause_time_between_batches = pause_time_between_batches + self.enable_cross_zone_upgrade = enable_cross_zone_upgrade + self.prioritize_unhealthy_instances = prioritize_unhealthy_instances + self.rollback_failed_instances_on_policy_breach = rollback_failed_instances_on_policy_breach + self.max_surge = max_surge + + +class RollingUpgradeProgressInfo(_serialization.Model): + """Information about the number of virtual machine instances in each upgrade state. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar successful_instance_count: The number of instances that have been successfully upgraded. + :vartype successful_instance_count: int + :ivar failed_instance_count: The number of instances that have failed to be upgraded + successfully. + :vartype failed_instance_count: int + :ivar in_progress_instance_count: The number of instances that are currently being upgraded. + :vartype in_progress_instance_count: int + :ivar pending_instance_count: The number of instances that have not yet begun to be upgraded. + :vartype pending_instance_count: int + """ + + _validation = { + "successful_instance_count": {"readonly": True}, + "failed_instance_count": {"readonly": True}, + "in_progress_instance_count": {"readonly": True}, + "pending_instance_count": {"readonly": True}, + } + + _attribute_map = { + "successful_instance_count": {"key": "successfulInstanceCount", "type": "int"}, + "failed_instance_count": {"key": "failedInstanceCount", "type": "int"}, + "in_progress_instance_count": {"key": "inProgressInstanceCount", "type": "int"}, + "pending_instance_count": {"key": "pendingInstanceCount", "type": "int"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.successful_instance_count: Optional[int] = None + self.failed_instance_count: Optional[int] = None + self.in_progress_instance_count: Optional[int] = None + self.pending_instance_count: Optional[int] = None + + +class RollingUpgradeRunningStatus(_serialization.Model): + """Information about the current running state of the overall upgrade. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Code indicating the current status of the upgrade. Known values are: + "RollingForward", "Cancelled", "Completed", and "Faulted". + :vartype code: str or ~azure.mgmt.compute.models.RollingUpgradeStatusCode + :ivar start_time: Start time of the upgrade. + :vartype start_time: ~datetime.datetime + :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start" + and "Cancel". + :vartype last_action: str or ~azure.mgmt.compute.models.RollingUpgradeActionType + :ivar last_action_time: Last action time of the upgrade. + :vartype last_action_time: ~datetime.datetime + """ + + _validation = { + "code": {"readonly": True}, + "start_time": {"readonly": True}, + "last_action": {"readonly": True}, + "last_action_time": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "last_action": {"key": "lastAction", "type": "str"}, + "last_action_time": {"key": "lastActionTime", "type": "iso-8601"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code: Optional[Union[str, "_models.RollingUpgradeStatusCode"]] = None + self.start_time: Optional[datetime.datetime] = None + self.last_action: Optional[Union[str, "_models.RollingUpgradeActionType"]] = None + self.last_action_time: Optional[datetime.datetime] = None + + +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: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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.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.models.RollingUpgradePolicy + :ivar running_status: Information about the current running state of the overall upgrade. + :vartype running_status: ~azure.mgmt.compute.models.RollingUpgradeRunningStatus + :ivar progress: Information about the number of virtual machine instances in each upgrade + state. + :vartype progress: ~azure.mgmt.compute.models.RollingUpgradeProgressInfo + :ivar error: Error details for this upgrade, if there are any. + :vartype error: ~azure.mgmt.compute.models.ApiError + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "policy": {"readonly": True}, + "running_status": {"readonly": True}, + "progress": {"readonly": True}, + "error": {"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"}, + "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"}, + "error": {"key": "properties.error", "type": "ApiError"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(tags=tags, location=location, **kwargs) + self.policy: Optional["_models.RollingUpgradePolicy"] = None + self.running_status: Optional["_models.RollingUpgradeRunningStatus"] = None + self.progress: Optional["_models.RollingUpgradeProgressInfo"] = None + self.error: Optional["_models.ApiError"] = None + + +class RunCommandDocumentBase(_serialization.Model): + """Describes the properties of a Run Command metadata. + + All required parameters must be populated in order to send to server. + + :ivar schema: The VM run command schema. Required. + :vartype schema: str + :ivar id: The VM run command id. Required. + :vartype id: str + :ivar os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". + :vartype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :ivar label: The VM run command label. Required. + :vartype label: str + :ivar description: The VM run command description. Required. + :vartype description: str + """ + + _validation = { + "schema": {"required": True}, + "id": {"required": True}, + "os_type": {"required": True}, + "label": {"required": True}, + "description": {"required": True}, + } + + _attribute_map = { + "schema": {"key": "$schema", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "os_type": {"key": "osType", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__( + self, + *, + schema: str, + id: str, # pylint: disable=redefined-builtin + os_type: Union[str, "_models.OperatingSystemTypes"], + label: str, + description: str, + **kwargs: Any + ) -> None: + """ + :keyword schema: The VM run command schema. Required. + :paramtype schema: str + :keyword id: The VM run command id. Required. + :paramtype id: str + :keyword os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". + :paramtype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :keyword label: The VM run command label. Required. + :paramtype label: str + :keyword description: The VM run command description. Required. + :paramtype description: str + """ + super().__init__(**kwargs) + self.schema = schema + self.id = id + self.os_type = os_type + self.label = label + self.description = description + + +class RunCommandDocument(RunCommandDocumentBase): + """Describes the properties of a Run Command. + + All required parameters must be populated in order to send to server. + + :ivar schema: The VM run command schema. Required. + :vartype schema: str + :ivar id: The VM run command id. Required. + :vartype id: str + :ivar os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". + :vartype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :ivar label: The VM run command label. Required. + :vartype label: str + :ivar description: The VM run command description. Required. + :vartype description: str + :ivar script: The script to be executed. Required. + :vartype script: list[str] + :ivar parameters: The parameters used by the script. + :vartype parameters: list[~azure.mgmt.compute.models.RunCommandParameterDefinition] + """ + + _validation = { + "schema": {"required": True}, + "id": {"required": True}, + "os_type": {"required": True}, + "label": {"required": True}, + "description": {"required": True}, + "script": {"required": True}, + } + + _attribute_map = { + "schema": {"key": "$schema", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "os_type": {"key": "osType", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "script": {"key": "script", "type": "[str]"}, + "parameters": {"key": "parameters", "type": "[RunCommandParameterDefinition]"}, + } + + def __init__( + self, + *, + schema: str, + id: str, # pylint: disable=redefined-builtin + os_type: Union[str, "_models.OperatingSystemTypes"], + label: str, + description: str, + script: List[str], + parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword schema: The VM run command schema. Required. + :paramtype schema: str + :keyword id: The VM run command id. Required. + :paramtype id: str + :keyword os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". + :paramtype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :keyword label: The VM run command label. Required. + :paramtype label: str + :keyword description: The VM run command description. Required. + :paramtype description: str + :keyword script: The script to be executed. Required. + :paramtype script: list[str] + :keyword parameters: The parameters used by the script. + :paramtype parameters: list[~azure.mgmt.compute.models.RunCommandParameterDefinition] + """ + super().__init__(schema=schema, id=id, os_type=os_type, label=label, description=description, **kwargs) + self.script = script + self.parameters = parameters + + +class RunCommandInput(_serialization.Model): + """Capture Virtual Machine parameters. + + All required parameters must be populated in order to send to server. + + :ivar command_id: The run command id. Required. + :vartype command_id: str + :ivar script: Optional. The script to be executed. When this value is given, the given script + will override the default script of the command. + :vartype script: list[str] + :ivar parameters: The run command parameters. + :vartype parameters: list[~azure.mgmt.compute.models.RunCommandInputParameter] + """ + + _validation = { + "command_id": {"required": True}, + } + + _attribute_map = { + "command_id": {"key": "commandId", "type": "str"}, + "script": {"key": "script", "type": "[str]"}, + "parameters": {"key": "parameters", "type": "[RunCommandInputParameter]"}, + } + + def __init__( + self, + *, + command_id: str, + script: Optional[List[str]] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword command_id: The run command id. Required. + :paramtype command_id: str + :keyword script: Optional. The script to be executed. When this value is given, the given + script will override the default script of the command. + :paramtype script: list[str] + :keyword parameters: The run command parameters. + :paramtype parameters: list[~azure.mgmt.compute.models.RunCommandInputParameter] + """ + super().__init__(**kwargs) + self.command_id = command_id + self.script = script + self.parameters = parameters + + +class RunCommandInputParameter(_serialization.Model): + """Describes the properties of a run command parameter. + + All required parameters must be populated in order to send to server. + + :ivar name: The run command parameter name. Required. + :vartype name: str + :ivar value: The run command parameter value. Required. + :vartype value: str + """ + + _validation = { + "name": {"required": True}, + "value": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: + """ + :keyword name: The run command parameter name. Required. + :paramtype name: str + :keyword value: The run command parameter value. Required. + :paramtype value: str + """ + super().__init__(**kwargs) + self.name = name + self.value = value + + +class RunCommandListResult(_serialization.Model): + """The List Virtual Machine operation response. + + All required parameters must be populated in order to send to server. + + :ivar value: The list of virtual machine run commands. Required. + :vartype value: list[~azure.mgmt.compute.models.RunCommandDocumentBase] + :ivar next_link: The uri to fetch the next page of run commands. Call ListNext() with this to + fetch the next page of run commands. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[RunCommandDocumentBase]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The list of virtual machine run commands. Required. + :paramtype value: list[~azure.mgmt.compute.models.RunCommandDocumentBase] + :keyword next_link: The uri to fetch the next page of run commands. Call ListNext() with this + to fetch the next page of run commands. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RunCommandManagedIdentity(_serialization.Model): + """Contains clientId or objectId (use only one, not both) of a user-assigned managed identity that + has access to storage blob used in Run Command. Use an empty RunCommandManagedIdentity object + in case of system-assigned identity. Make sure the Azure storage blob exists in case of + scriptUri, and managed identity has been given access to blob's container with 'Storage Blob + Data Reader' role assignment with scriptUri blob and 'Storage Blob Data Contributor' for Append + blobs(outputBlobUri, errorBlobUri). In case of user assigned identity, make sure you add it + under VM's identity. For more info on managed identity and Run Command, refer + https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged. + + :ivar client_id: Client Id (GUID value) of the user-assigned managed identity. ObjectId should + not be used if this is provided. + :vartype client_id: str + :ivar object_id: Object Id (GUID value) of the user-assigned managed identity. ClientId should + not be used if this is provided. + :vartype object_id: str + """ + + _attribute_map = { + "client_id": {"key": "clientId", "type": "str"}, + "object_id": {"key": "objectId", "type": "str"}, + } + + def __init__(self, *, client_id: Optional[str] = None, object_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword client_id: Client Id (GUID value) of the user-assigned managed identity. ObjectId + should not be used if this is provided. + :paramtype client_id: str + :keyword object_id: Object Id (GUID value) of the user-assigned managed identity. ClientId + should not be used if this is provided. + :paramtype object_id: str + """ + super().__init__(**kwargs) + self.client_id = client_id + self.object_id = object_id + + +class RunCommandParameterDefinition(_serialization.Model): + """Describes the properties of a run command parameter. + + All required parameters must be populated in order to send to server. + + :ivar name: The run command parameter name. Required. + :vartype name: str + :ivar type: The run command parameter type. Required. + :vartype type: str + :ivar default_value: The run command parameter default value. + :vartype default_value: str + :ivar required: The run command parameter required. + :vartype required: bool + """ + + _validation = { + "name": {"required": True}, + "type": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "default_value": {"key": "defaultValue", "type": "str"}, + "required": {"key": "required", "type": "bool"}, + } + + def __init__( + 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. + :paramtype name: str + :keyword type: The run command parameter type. Required. + :paramtype type: str + :keyword default_value: The run command parameter default value. + :paramtype default_value: str + :keyword required: The run command parameter required. + :paramtype required: bool + """ + super().__init__(**kwargs) + self.name = name + self.type = type + self.default_value = default_value + self.required = required + + +class RunCommandResult(_serialization.Model): + """RunCommandResult. + + :ivar value: Run command operation response. + :vartype value: list[~azure.mgmt.compute.models.InstanceViewStatus] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[InstanceViewStatus]"}, + } + + def __init__(self, *, value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Run command operation response. + :paramtype value: list[~azure.mgmt.compute.models.InstanceViewStatus] + """ + super().__init__(**kwargs) + self.value = value + + +class ScaleInPolicy(_serialization.Model): + """Describes a scale-in policy for a virtual machine scale set. + + :ivar rules: The rules to be followed when scaling-in a virtual machine scale set. + :code:`
`\\ :code:`
` Possible values are: :code:`
`\\ :code:`
` **Default** When a + virtual machine scale set is scaled in, the scale set will first be balanced across zones if it + is a zonal scale set. Then, it will be balanced across Fault Domains as far as possible. Within + each Fault Domain, the virtual machines chosen for removal will be the newest ones that are not + protected from scale-in. :code:`
`\\ :code:`
` **OldestVM** When a virtual machine scale + set is being scaled-in, the oldest virtual machines that are not protected from scale-in will + be chosen for removal. For zonal virtual machine scale sets, the scale set will first be + balanced across zones. Within each zone, the oldest virtual machines that are not protected + will be chosen for removal. :code:`
`\\ :code:`
` **NewestVM** When a virtual machine + scale set is being scaled-in, the newest virtual machines that are not protected from scale-in + will be chosen for removal. For zonal virtual machine scale sets, the scale set will first be + balanced across zones. Within each zone, the newest virtual machines that are not protected + will be chosen for removal. :code:`
`\\ :code:`
`. + :vartype rules: list[str or ~azure.mgmt.compute.models.VirtualMachineScaleSetScaleInRules] + :ivar force_deletion: This property allows you to specify if virtual machines chosen for + removal have to be force deleted when a virtual machine scale set is being scaled-in.(Feature + in Preview). + :vartype force_deletion: bool + :ivar prioritize_unhealthy_v_ms: This property allows you to prioritize the deletion of + unhealthy and inactive VMs when a virtual machine scale set is being scaled-in.(Feature in + Preview). + :vartype prioritize_unhealthy_v_ms: bool + """ + + _attribute_map = { + "rules": {"key": "rules", "type": "[str]"}, + "force_deletion": {"key": "forceDeletion", "type": "bool"}, + "prioritize_unhealthy_v_ms": {"key": "prioritizeUnhealthyVMs", "type": "bool"}, + } + + def __init__( + self, + *, + rules: Optional[List[Union[str, "_models.VirtualMachineScaleSetScaleInRules"]]] = None, + force_deletion: Optional[bool] = None, + prioritize_unhealthy_v_ms: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword rules: The rules to be followed when scaling-in a virtual machine scale set. + :code:`
`\\ :code:`
` Possible values are: :code:`
`\\ :code:`
` **Default** When a + virtual machine scale set is scaled in, the scale set will first be balanced across zones if it + is a zonal scale set. Then, it will be balanced across Fault Domains as far as possible. Within + each Fault Domain, the virtual machines chosen for removal will be the newest ones that are not + protected from scale-in. :code:`
`\\ :code:`
` **OldestVM** When a virtual machine scale + set is being scaled-in, the oldest virtual machines that are not protected from scale-in will + be chosen for removal. For zonal virtual machine scale sets, the scale set will first be + balanced across zones. Within each zone, the oldest virtual machines that are not protected + will be chosen for removal. :code:`
`\\ :code:`
` **NewestVM** When a virtual machine + scale set is being scaled-in, the newest virtual machines that are not protected from scale-in + will be chosen for removal. For zonal virtual machine scale sets, the scale set will first be + balanced across zones. Within each zone, the newest virtual machines that are not protected + will be chosen for removal. :code:`
`\\ :code:`
`. + :paramtype rules: list[str or ~azure.mgmt.compute.models.VirtualMachineScaleSetScaleInRules] + :keyword force_deletion: This property allows you to specify if virtual machines chosen for + removal have to be force deleted when a virtual machine scale set is being scaled-in.(Feature + in Preview). + :paramtype force_deletion: bool + :keyword prioritize_unhealthy_v_ms: This property allows you to prioritize the deletion of + unhealthy and inactive VMs when a virtual machine scale set is being scaled-in.(Feature in + Preview). + :paramtype prioritize_unhealthy_v_ms: bool + """ + super().__init__(**kwargs) + self.rules = rules + self.force_deletion = force_deletion + self.prioritize_unhealthy_v_ms = prioritize_unhealthy_v_ms + + +class ScheduledEventsAdditionalPublishingTargets(_serialization.Model): # pylint: disable=name-too-long + """ScheduledEventsAdditionalPublishingTargets. + + :ivar event_grid_and_resource_graph: The configuration parameters used while creating + eventGridAndResourceGraph Scheduled Event setting. + :vartype event_grid_and_resource_graph: ~azure.mgmt.compute.models.EventGridAndResourceGraph + """ + + _attribute_map = { + "event_grid_and_resource_graph": {"key": "eventGridAndResourceGraph", "type": "EventGridAndResourceGraph"}, + } + + def __init__( + self, *, event_grid_and_resource_graph: Optional["_models.EventGridAndResourceGraph"] = None, **kwargs: Any + ) -> None: + """ + :keyword event_grid_and_resource_graph: The configuration parameters used while creating + eventGridAndResourceGraph Scheduled Event setting. + :paramtype event_grid_and_resource_graph: ~azure.mgmt.compute.models.EventGridAndResourceGraph + """ + super().__init__(**kwargs) + self.event_grid_and_resource_graph = event_grid_and_resource_graph + + +class ScheduledEventsPolicy(_serialization.Model): + """Specifies Redeploy, Reboot and ScheduledEventsAdditionalPublishingTargets Scheduled Event + related configurations. + + :ivar user_initiated_redeploy: The configuration parameters used while creating + userInitiatedRedeploy scheduled event setting creation. + :vartype user_initiated_redeploy: ~azure.mgmt.compute.models.UserInitiatedRedeploy + :ivar user_initiated_reboot: The configuration parameters used while creating + userInitiatedReboot scheduled event setting creation. + :vartype user_initiated_reboot: ~azure.mgmt.compute.models.UserInitiatedReboot + :ivar scheduled_events_additional_publishing_targets: The configuration parameters used while + publishing scheduledEventsAdditionalPublishingTargets. + :vartype scheduled_events_additional_publishing_targets: + ~azure.mgmt.compute.models.ScheduledEventsAdditionalPublishingTargets + """ + + _attribute_map = { + "user_initiated_redeploy": {"key": "userInitiatedRedeploy", "type": "UserInitiatedRedeploy"}, + "user_initiated_reboot": {"key": "userInitiatedReboot", "type": "UserInitiatedReboot"}, + "scheduled_events_additional_publishing_targets": { + "key": "scheduledEventsAdditionalPublishingTargets", + "type": "ScheduledEventsAdditionalPublishingTargets", + }, + } + + def __init__( + self, + *, + user_initiated_redeploy: Optional["_models.UserInitiatedRedeploy"] = None, + user_initiated_reboot: Optional["_models.UserInitiatedReboot"] = None, + scheduled_events_additional_publishing_targets: Optional[ + "_models.ScheduledEventsAdditionalPublishingTargets" + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword user_initiated_redeploy: The configuration parameters used while creating + userInitiatedRedeploy scheduled event setting creation. + :paramtype user_initiated_redeploy: ~azure.mgmt.compute.models.UserInitiatedRedeploy + :keyword user_initiated_reboot: The configuration parameters used while creating + userInitiatedReboot scheduled event setting creation. + :paramtype user_initiated_reboot: ~azure.mgmt.compute.models.UserInitiatedReboot + :keyword scheduled_events_additional_publishing_targets: The configuration parameters used + while publishing scheduledEventsAdditionalPublishingTargets. + :paramtype scheduled_events_additional_publishing_targets: + ~azure.mgmt.compute.models.ScheduledEventsAdditionalPublishingTargets + """ + super().__init__(**kwargs) + self.user_initiated_redeploy = user_initiated_redeploy + self.user_initiated_reboot = user_initiated_reboot + self.scheduled_events_additional_publishing_targets = scheduled_events_additional_publishing_targets + + +class ScheduledEventsProfile(_serialization.Model): + """ScheduledEventsProfile. + + :ivar terminate_notification_profile: Specifies Terminate Scheduled Event related + configurations. + :vartype terminate_notification_profile: + ~azure.mgmt.compute.models.TerminateNotificationProfile + :ivar os_image_notification_profile: Specifies OS Image Scheduled Event related configurations. + :vartype os_image_notification_profile: ~azure.mgmt.compute.models.OSImageNotificationProfile + """ + + _attribute_map = { + "terminate_notification_profile": { + "key": "terminateNotificationProfile", + "type": "TerminateNotificationProfile", + }, + "os_image_notification_profile": {"key": "osImageNotificationProfile", "type": "OSImageNotificationProfile"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, + *, + terminate_notification_profile: Optional["_models.TerminateNotificationProfile"] = None, + os_image_notification_profile: Optional["_models.OSImageNotificationProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword terminate_notification_profile: Specifies Terminate Scheduled Event related + configurations. + :paramtype terminate_notification_profile: + ~azure.mgmt.compute.models.TerminateNotificationProfile + :keyword os_image_notification_profile: Specifies OS Image Scheduled Event related + configurations. + :paramtype os_image_notification_profile: ~azure.mgmt.compute.models.OSImageNotificationProfile + """ super().__init__(**kwargs) - self.code: Optional[Union[str, "_models.RollingUpgradeStatusCode"]] = None - self.start_time: Optional[datetime.datetime] = None - self.last_action: Optional[Union[str, "_models.RollingUpgradeActionType"]] = None - self.last_action_time: Optional[datetime.datetime] = None - + self.terminate_notification_profile = terminate_notification_profile + self.os_image_notification_profile = os_image_notification_profile -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. +class SecurityPostureReference(_serialization.Model): + """Specifies the security posture to be used in the scale set. Minimum api-version: 2023-03-01. 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}. + :ivar id: The security posture reference id in the form of + /CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|latest. + Required. :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar policy: The rolling upgrade policies applied for this upgrade. - :vartype policy: ~azure.mgmt.compute.v2024_11_01.models.RollingUpgradePolicy - :ivar running_status: Information about the current running state of the overall upgrade. - :vartype running_status: ~azure.mgmt.compute.v2024_11_01.models.RollingUpgradeRunningStatus - :ivar progress: Information about the number of virtual machine instances in each upgrade - state. - :vartype progress: ~azure.mgmt.compute.v2024_11_01.models.RollingUpgradeProgressInfo - :ivar error: Error details for this upgrade, if there are any. - :vartype error: ~azure.mgmt.compute.v2024_11_01.models.ApiError + :ivar exclude_extensions: The list of virtual machine extension names to exclude when applying + the security posture. + :vartype exclude_extensions: list[str] + :ivar is_overridable: Whether the security posture can be overridden by the user. + :vartype is_overridable: bool """ _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - "policy": {"readonly": True}, - "running_status": {"readonly": True}, - "progress": {"readonly": True}, - "error": {"readonly": True}, + "id": {"required": True}, } _attribute_map = { "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"}, - "policy": {"key": "properties.policy", "type": "RollingUpgradePolicy"}, - "running_status": {"key": "properties.runningStatus", "type": "RollingUpgradeRunningStatus"}, - "progress": {"key": "properties.progress", "type": "RollingUpgradeProgressInfo"}, - "error": {"key": "properties.error", "type": "ApiError"}, + "exclude_extensions": {"key": "excludeExtensions", "type": "[str]"}, + "is_overridable": {"key": "isOverridable", "type": "bool"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + exclude_extensions: Optional[List[str]] = None, + is_overridable: Optional[bool] = None, + **kwargs: Any + ) -> None: """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str + :keyword id: The security posture reference id in the form of + /CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|latest. + Required. + :paramtype id: str + :keyword exclude_extensions: The list of virtual machine extension names to exclude when + applying the security posture. + :paramtype exclude_extensions: list[str] + :keyword is_overridable: Whether the security posture can be overridden by the user. + :paramtype is_overridable: bool """ - super().__init__(tags=tags, location=location, **kwargs) - self.policy: Optional["_models.RollingUpgradePolicy"] = None - self.running_status: Optional["_models.RollingUpgradeRunningStatus"] = None - self.progress: Optional["_models.RollingUpgradeProgressInfo"] = None - self.error: Optional["_models.ApiError"] = None - + super().__init__(**kwargs) + self.id = id + self.exclude_extensions = exclude_extensions + self.is_overridable = is_overridable -class RunCommandDocumentBase(_serialization.Model): - """Describes the properties of a Run Command metadata. - All required parameters must be populated in order to send to server. +class SecurityPostureReferenceUpdate(_serialization.Model): + """Specifies the security posture to be used in the scale set. Minimum api-version: 2023-03-01. - :ivar schema: The VM run command schema. Required. - :vartype schema: str - :ivar id: The VM run command id. Required. + :ivar id: The security posture reference id in the form of + /CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|latest. :vartype id: str - :ivar os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2024_11_01.models.OperatingSystemTypes - :ivar label: The VM run command label. Required. - :vartype label: str - :ivar description: The VM run command description. Required. - :vartype description: str + :ivar exclude_extensions: The list of virtual machine extension names to exclude when applying + the security posture. + :vartype exclude_extensions: list[str] + :ivar is_overridable: Whether the security posture can be overridden by the user. + :vartype is_overridable: bool """ - _validation = { - "schema": {"required": True}, - "id": {"required": True}, - "os_type": {"required": True}, - "label": {"required": True}, - "description": {"required": True}, - } - _attribute_map = { - "schema": {"key": "$schema", "type": "str"}, "id": {"key": "id", "type": "str"}, - "os_type": {"key": "osType", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "description": {"key": "description", "type": "str"}, + "exclude_extensions": {"key": "excludeExtensions", "type": "[str]"}, + "is_overridable": {"key": "isOverridable", "type": "bool"}, } def __init__( self, *, - schema: str, - id: str, # pylint: disable=redefined-builtin - os_type: Union[str, "_models.OperatingSystemTypes"], - label: str, - description: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + exclude_extensions: Optional[List[str]] = None, + is_overridable: Optional[bool] = None, **kwargs: Any ) -> None: """ - :keyword schema: The VM run command schema. Required. - :paramtype schema: str - :keyword id: The VM run command id. Required. + :keyword id: The security posture reference id in the form of + /CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|latest. :paramtype id: str - :keyword os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2024_11_01.models.OperatingSystemTypes - :keyword label: The VM run command label. Required. - :paramtype label: str - :keyword description: The VM run command description. Required. - :paramtype description: str + :keyword exclude_extensions: The list of virtual machine extension names to exclude when + applying the security posture. + :paramtype exclude_extensions: list[str] + :keyword is_overridable: Whether the security posture can be overridden by the user. + :paramtype is_overridable: bool """ super().__init__(**kwargs) - self.schema = schema self.id = id - self.os_type = os_type - self.label = label - self.description = description - + self.exclude_extensions = exclude_extensions + self.is_overridable = is_overridable -class RunCommandDocument(RunCommandDocumentBase): - """Describes the properties of a Run Command. - All required parameters must be populated in order to send to server. +class SecurityProfile(_serialization.Model): + """Specifies the Security profile settings for the virtual machine or virtual machine scale set. - :ivar schema: The VM run command schema. Required. - :vartype schema: str - :ivar id: The VM run command id. Required. - :vartype id: str - :ivar os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2024_11_01.models.OperatingSystemTypes - :ivar label: The VM run command label. Required. - :vartype label: str - :ivar description: The VM run command description. Required. - :vartype description: str - :ivar script: The script to be executed. Required. - :vartype script: list[str] - :ivar parameters: The parameters used by the script. - :vartype parameters: list[~azure.mgmt.compute.v2024_11_01.models.RunCommandParameterDefinition] + :ivar uefi_settings: Specifies the security settings like secure boot and vTPM used while + creating the virtual machine. Minimum api-version: 2020-12-01. + :vartype uefi_settings: ~azure.mgmt.compute.models.UefiSettings + :ivar encryption_at_host: This property can be used by user in the request to enable or disable + the Host Encryption for the virtual machine or virtual machine scale set. This will enable the + encryption for all the disks including Resource/Temp disk at host itself. The default behavior + is: The Encryption at host will be disabled unless this property is set to true for the + resource. + :vartype encryption_at_host: bool + :ivar security_type: Specifies the SecurityType of the virtual machine. It has to be set to any + specified value to enable UefiSettings. The default behavior is: UefiSettings will not be + enabled unless this property is set. Known values are: "TrustedLaunch" and "ConfidentialVM". + :vartype security_type: str or ~azure.mgmt.compute.models.SecurityTypes + :ivar encryption_identity: Specifies the Managed Identity used by ADE to get access token for + keyvault operations. + :vartype encryption_identity: ~azure.mgmt.compute.models.EncryptionIdentity + :ivar proxy_agent_settings: Specifies ProxyAgent settings while creating the virtual machine. + Minimum api-version: 2023-09-01. + :vartype proxy_agent_settings: ~azure.mgmt.compute.models.ProxyAgentSettings """ - _validation = { - "schema": {"required": True}, - "id": {"required": True}, - "os_type": {"required": True}, - "label": {"required": True}, - "description": {"required": True}, - "script": {"required": True}, - } - _attribute_map = { - "schema": {"key": "$schema", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "os_type": {"key": "osType", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "script": {"key": "script", "type": "[str]"}, - "parameters": {"key": "parameters", "type": "[RunCommandParameterDefinition]"}, + "uefi_settings": {"key": "uefiSettings", "type": "UefiSettings"}, + "encryption_at_host": {"key": "encryptionAtHost", "type": "bool"}, + "security_type": {"key": "securityType", "type": "str"}, + "encryption_identity": {"key": "encryptionIdentity", "type": "EncryptionIdentity"}, + "proxy_agent_settings": {"key": "proxyAgentSettings", "type": "ProxyAgentSettings"}, } def __init__( self, *, - schema: str, - id: str, # pylint: disable=redefined-builtin - os_type: Union[str, "_models.OperatingSystemTypes"], - label: str, - description: str, - script: List[str], - parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, + uefi_settings: Optional["_models.UefiSettings"] = None, + encryption_at_host: Optional[bool] = None, + security_type: Optional[Union[str, "_models.SecurityTypes"]] = None, + encryption_identity: Optional["_models.EncryptionIdentity"] = None, + proxy_agent_settings: Optional["_models.ProxyAgentSettings"] = None, **kwargs: Any ) -> None: """ - :keyword schema: The VM run command schema. Required. - :paramtype schema: str - :keyword id: The VM run command id. Required. - :paramtype id: str - :keyword os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2024_11_01.models.OperatingSystemTypes - :keyword label: The VM run command label. Required. - :paramtype label: str - :keyword description: The VM run command description. Required. - :paramtype description: str - :keyword script: The script to be executed. Required. - :paramtype script: list[str] - :keyword parameters: The parameters used by the script. - :paramtype parameters: - list[~azure.mgmt.compute.v2024_11_01.models.RunCommandParameterDefinition] + :keyword uefi_settings: Specifies the security settings like secure boot and vTPM used while + creating the virtual machine. Minimum api-version: 2020-12-01. + :paramtype uefi_settings: ~azure.mgmt.compute.models.UefiSettings + :keyword encryption_at_host: This property can be used by user in the request to enable or + disable the Host Encryption for the virtual machine or virtual machine scale set. This will + enable the encryption for all the disks including Resource/Temp disk at host itself. The + default behavior is: The Encryption at host will be disabled unless this property is set to + true for the resource. + :paramtype encryption_at_host: bool + :keyword security_type: Specifies the SecurityType of the virtual machine. It has to be set to + any specified value to enable UefiSettings. The default behavior is: UefiSettings will not be + enabled unless this property is set. Known values are: "TrustedLaunch" and "ConfidentialVM". + :paramtype security_type: str or ~azure.mgmt.compute.models.SecurityTypes + :keyword encryption_identity: Specifies the Managed Identity used by ADE to get access token + for keyvault operations. + :paramtype encryption_identity: ~azure.mgmt.compute.models.EncryptionIdentity + :keyword proxy_agent_settings: Specifies ProxyAgent settings while creating the virtual + machine. Minimum api-version: 2023-09-01. + :paramtype proxy_agent_settings: ~azure.mgmt.compute.models.ProxyAgentSettings """ - super().__init__(schema=schema, id=id, os_type=os_type, label=label, description=description, **kwargs) - self.script = script - self.parameters = parameters - + super().__init__(**kwargs) + self.uefi_settings = uefi_settings + self.encryption_at_host = encryption_at_host + self.security_type = security_type + self.encryption_identity = encryption_identity + self.proxy_agent_settings = proxy_agent_settings -class RunCommandInput(_serialization.Model): - """Capture Virtual Machine parameters. - All required parameters must be populated in order to send to server. +class ServiceArtifactReference(_serialization.Model): + """Specifies the service artifact reference id used to set same image version for all virtual + machines in the scale set when using 'latest' image version. Minimum api-version: 2022-11-01. - :ivar command_id: The run command id. Required. - :vartype command_id: str - :ivar script: Optional. The script to be executed. When this value is given, the given script - will override the default script of the command. - :vartype script: list[str] - :ivar parameters: The run command parameters. - :vartype parameters: list[~azure.mgmt.compute.v2024_11_01.models.RunCommandInputParameter] + :ivar id: The service artifact reference id in the form of + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/serviceArtifacts/{serviceArtifactName}/vmArtifactsProfiles/{vmArtifactsProfilesName}. + :vartype id: str """ - _validation = { - "command_id": {"required": True}, - } - _attribute_map = { - "command_id": {"key": "commandId", "type": "str"}, - "script": {"key": "script", "type": "[str]"}, - "parameters": {"key": "parameters", "type": "[RunCommandInputParameter]"}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - command_id: str, - script: Optional[List[str]] = None, - parameters: Optional[List["_models.RunCommandInputParameter"]] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin """ - :keyword command_id: The run command id. Required. - :paramtype command_id: str - :keyword script: Optional. The script to be executed. When this value is given, the given - script will override the default script of the command. - :paramtype script: list[str] - :keyword parameters: The run command parameters. - :paramtype parameters: list[~azure.mgmt.compute.v2024_11_01.models.RunCommandInputParameter] + :keyword id: The service artifact reference id in the form of + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/serviceArtifacts/{serviceArtifactName}/vmArtifactsProfiles/{vmArtifactsProfilesName}. + :paramtype id: str """ super().__init__(**kwargs) - self.command_id = command_id - self.script = script - self.parameters = parameters + self.id = id -class RunCommandInputParameter(_serialization.Model): - """Describes the properties of a run command parameter. +class SharedGallery(PirSharedGalleryResource): + """Specifies information about the Shared Gallery that you want to create or update. - All required parameters must be populated in order to send to server. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The run command parameter name. Required. + :ivar name: Resource name. :vartype name: str - :ivar value: The run command parameter value. Required. - :vartype value: str + :ivar location: Resource location. + :vartype location: str + :ivar unique_id: The unique id of this shared gallery. + :vartype unique_id: str + :ivar artifact_tags: The artifact tags of a shared gallery resource. + :vartype artifact_tags: dict[str, str] """ _validation = { - "name": {"required": True}, - "value": {"required": True}, + "name": {"readonly": True}, + "location": {"readonly": True}, + "artifact_tags": {"readonly": True}, } _attribute_map = { "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "unique_id": {"key": "identifier.uniqueId", "type": "str"}, + "artifact_tags": {"key": "properties.artifactTags", "type": "{str}"}, } - def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: + def __init__(self, *, unique_id: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword name: The run command parameter name. Required. - :paramtype name: str - :keyword value: The run command parameter value. Required. - :paramtype value: str + :keyword unique_id: The unique id of this shared gallery. + :paramtype unique_id: str """ - super().__init__(**kwargs) - self.name = name - self.value = value + super().__init__(unique_id=unique_id, **kwargs) + self.artifact_tags: Optional[Dict[str, str]] = None -class RunCommandListResult(_serialization.Model): - """The List Virtual Machine operation response. +class SharedGalleryDiskImage(_serialization.Model): + """This is the disk image base class. - All required parameters must be populated in order to send to server. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: The list of virtual machine run commands. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.RunCommandDocumentBase] - :ivar next_link: The uri to fetch the next page of run commands. Call ListNext() with this to - fetch the next page of run commands. - :vartype next_link: str + :ivar disk_size_gb: This property indicates the size of the VHD to be created. + :vartype disk_size_gb: int + :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and + 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". + :vartype host_caching: str or ~azure.mgmt.compute.models.SharedGalleryHostCaching """ _validation = { - "value": {"required": True}, + "disk_size_gb": {"readonly": True}, } _attribute_map = { - "value": {"key": "value", "type": "[RunCommandDocumentBase]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, + "host_caching": {"key": "hostCaching", "type": "str"}, } def __init__( - self, *, value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs: Any + self, *, host_caching: Optional[Union[str, "_models.SharedGalleryHostCaching"]] = None, **kwargs: Any ) -> None: """ - :keyword value: The list of virtual machine run commands. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.RunCommandDocumentBase] - :keyword next_link: The uri to fetch the next page of run commands. Call ListNext() with this - to fetch the next page of run commands. - :paramtype next_link: str + :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.models.SharedGalleryHostCaching """ super().__init__(**kwargs) - self.value = value - self.next_link = next_link + self.disk_size_gb: Optional[int] = None + self.host_caching = host_caching -class RunCommandManagedIdentity(_serialization.Model): - """Contains clientId or objectId (use only one, not both) of a user-assigned managed identity that - has access to storage blob used in Run Command. Use an empty RunCommandManagedIdentity object - in case of system-assigned identity. Make sure the Azure storage blob exists in case of - scriptUri, and managed identity has been given access to blob's container with 'Storage Blob - Data Reader' role assignment with scriptUri blob and 'Storage Blob Data Contributor' for Append - blobs(outputBlobUri, errorBlobUri). In case of user assigned identity, make sure you add it - under VM's identity. For more info on managed identity and Run Command, refer - https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged. +class SharedGalleryDataDiskImage(SharedGalleryDiskImage): + """This is the data disk image. - :ivar client_id: Client Id (GUID value) of the user-assigned managed identity. ObjectId should - not be used if this is provided. - :vartype client_id: str - :ivar object_id: Object Id (GUID value) of the user-assigned managed identity. ClientId should - not be used if this is provided. - :vartype object_id: str + 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 disk_size_gb: This property indicates the size of the VHD to be created. + :vartype disk_size_gb: int + :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and + 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". + :vartype host_caching: str or ~azure.mgmt.compute.models.SharedGalleryHostCaching + :ivar 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. + :vartype lun: int """ + _validation = { + "disk_size_gb": {"readonly": True}, + "lun": {"required": True}, + } + _attribute_map = { - "client_id": {"key": "clientId", "type": "str"}, - "object_id": {"key": "objectId", "type": "str"}, + "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, + "host_caching": {"key": "hostCaching", "type": "str"}, + "lun": {"key": "lun", "type": "int"}, } - def __init__(self, *, client_id: Optional[str] = None, object_id: Optional[str] = None, **kwargs: Any) -> None: + def __init__( + self, *, lun: int, host_caching: Optional[Union[str, "_models.SharedGalleryHostCaching"]] = None, **kwargs: Any + ) -> None: """ - :keyword client_id: Client Id (GUID value) of the user-assigned managed identity. ObjectId - should not be used if this is provided. - :paramtype client_id: str - :keyword object_id: Object Id (GUID value) of the user-assigned managed identity. ClientId - should not be used if this is provided. - :paramtype object_id: str + :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.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__(**kwargs) - self.client_id = client_id - self.object_id = object_id + super().__init__(host_caching=host_caching, **kwargs) + self.lun = lun -class RunCommandParameterDefinition(_serialization.Model): - """Describes the properties of a run command parameter. +class SharedGalleryImage(PirSharedGalleryResource): + """Specifies information about the gallery image definition that you want to create or update. - All required parameters must be populated in order to send to server. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The run command parameter name. Required. + :ivar name: Resource name. :vartype name: str - :ivar type: The run command parameter type. Required. - :vartype type: str - :ivar default_value: The run command parameter default value. - :vartype default_value: str - :ivar required: The run command parameter required. - :vartype required: bool + :ivar location: Resource location. + :vartype location: str + :ivar unique_id: The unique id of this shared gallery. + :vartype unique_id: str + :ivar 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". + :vartype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :ivar 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". + :vartype os_state: str or ~azure.mgmt.compute.models.OperatingSystemStateTypes + :ivar 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. + :vartype end_of_life_date: ~datetime.datetime + :ivar identifier: This is the gallery image definition identifier. + :vartype identifier: ~azure.mgmt.compute.models.GalleryImageIdentifier + :ivar recommended: The properties describe the recommended machine configuration for this Image + Definition. These properties are updatable. + :vartype recommended: ~azure.mgmt.compute.models.RecommendedMachineConfiguration + :ivar disallowed: Describes the disallowed disk types. + :vartype disallowed: ~azure.mgmt.compute.models.Disallowed + :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS + disks only. Known values are: "V1" and "V2". + :vartype hyper_v_generation: str or ~azure.mgmt.compute.models.HyperVGeneration + :ivar features: A list of gallery image features. + :vartype features: list[~azure.mgmt.compute.models.GalleryImageFeature] + :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by + marketplace images. + :vartype purchase_plan: ~azure.mgmt.compute.models.ImagePurchasePlan + :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values + are: "x64" and "Arm64". + :vartype architecture: str or ~azure.mgmt.compute.models.Architecture + :ivar privacy_statement_uri: Privacy statement uri for the current community gallery image. + :vartype privacy_statement_uri: str + :ivar eula: End-user license agreement for the current community gallery image. + :vartype eula: str + :ivar artifact_tags: The artifact tags of a shared gallery resource. + :vartype artifact_tags: dict[str, str] """ _validation = { - "name": {"required": True}, - "type": {"required": True}, + "name": {"readonly": True}, + "location": {"readonly": True}, } _attribute_map = { "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "default_value": {"key": "defaultValue", "type": "str"}, - "required": {"key": "required", "type": "bool"}, + "location": {"key": "location", "type": "str"}, + "unique_id": {"key": "identifier.uniqueId", "type": "str"}, + "os_type": {"key": "properties.osType", "type": "str"}, + "os_state": {"key": "properties.osState", "type": "str"}, + "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, + "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, + "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, + "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, + "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, + "features": {"key": "properties.features", "type": "[GalleryImageFeature]"}, + "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, + "architecture": {"key": "properties.architecture", "type": "str"}, + "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, + "eula": {"key": "properties.eula", "type": "str"}, + "artifact_tags": {"key": "properties.artifactTags", "type": "{str}"}, } def __init__( self, *, - name: str, - type: str, - default_value: Optional[str] = None, - required: Optional[bool] = None, + 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 ) -> None: """ - :keyword name: The run command parameter name. Required. - :paramtype name: str - :keyword type: The run command parameter type. Required. - :paramtype type: str - :keyword default_value: The run command parameter default value. - :paramtype default_value: str - :keyword required: The run command parameter required. - :paramtype required: bool - """ - super().__init__(**kwargs) - self.name = name - self.type = type - self.default_value = default_value - self.required = required + :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.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.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.models.GalleryImageIdentifier + :keyword recommended: The properties describe the recommended machine configuration for this + Image Definition. These properties are updatable. + :paramtype recommended: ~azure.mgmt.compute.models.RecommendedMachineConfiguration + :keyword disallowed: Describes the disallowed disk types. + :paramtype disallowed: ~azure.mgmt.compute.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.models.HyperVGeneration + :keyword features: A list of gallery image features. + :paramtype features: list[~azure.mgmt.compute.models.GalleryImageFeature] + :keyword purchase_plan: Describes the gallery image definition purchase plan. This is used by + marketplace images. + :paramtype purchase_plan: ~azure.mgmt.compute.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.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.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 -class RunCommandResult(_serialization.Model): - """RunCommandResult. +class SharedGalleryImageList(_serialization.Model): + """The List Shared Gallery Images operation response. - :ivar value: Run command operation response. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + All required parameters must be populated in order to send to server. + + :ivar value: A list of shared gallery images. Required. + :vartype value: list[~azure.mgmt.compute.models.SharedGalleryImage] + :ivar next_link: The uri to fetch the next page of shared gallery images. Call ListNext() with + this to fetch the next page of shared gallery images. + :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { - "value": {"key": "value", "type": "[InstanceViewStatus]"}, + "value": {"key": "value", "type": "[SharedGalleryImage]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Run command operation response. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + def __init__( + self, *, value: List["_models.SharedGalleryImage"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ - super().__init__(**kwargs) - self.value = value - - -class ScaleInPolicy(_serialization.Model): - """Describes a scale-in policy for a virtual machine scale set. - - :ivar rules: The rules to be followed when scaling-in a virtual machine scale set. - :code:`
`\\ :code:`
` Possible values are: :code:`
`\\ :code:`
` **Default** When a - virtual machine scale set is scaled in, the scale set will first be balanced across zones if it - is a zonal scale set. Then, it will be balanced across Fault Domains as far as possible. Within - each Fault Domain, the virtual machines chosen for removal will be the newest ones that are not - protected from scale-in. :code:`
`\\ :code:`
` **OldestVM** When a virtual machine scale - set is being scaled-in, the oldest virtual machines that are not protected from scale-in will - be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the oldest virtual machines that are not protected - will be chosen for removal. :code:`
`\\ :code:`
` **NewestVM** When a virtual machine - scale set is being scaled-in, the newest virtual machines that are not protected from scale-in - will be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the newest virtual machines that are not protected - will be chosen for removal. :code:`
`\\ :code:`
`. - :vartype rules: list[str or - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetScaleInRules] - :ivar force_deletion: This property allows you to specify if virtual machines chosen for - removal have to be force deleted when a virtual machine scale set is being scaled-in.(Feature - in Preview). - :vartype force_deletion: bool - :ivar prioritize_unhealthy_v_ms: This property allows you to prioritize the deletion of - unhealthy and inactive VMs when a virtual machine scale set is being scaled-in.(Feature in - Preview). - :vartype prioritize_unhealthy_v_ms: bool + :keyword value: A list of shared gallery images. Required. + :paramtype value: list[~azure.mgmt.compute.models.SharedGalleryImage] + :keyword next_link: The uri to fetch the next page of shared gallery images. Call ListNext() + with this to fetch the next page of shared gallery images. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SharedGalleryImageVersion(PirSharedGalleryResource): + """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. + + :ivar name: Resource name. + :vartype name: str + :ivar location: Resource location. + :vartype location: str + :ivar unique_id: The unique id of this shared gallery. + :vartype unique_id: str + :ivar published_date: The published date of the gallery image version Definition. This property + can be used for decommissioning purposes. This property is updatable. + :vartype published_date: ~datetime.datetime + :ivar 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. + :vartype end_of_life_date: ~datetime.datetime + :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of + the Image Definition won't use this Image Version. + :vartype exclude_from_latest: bool + :ivar storage_profile: Describes the storage profile of the image version. + :vartype storage_profile: ~azure.mgmt.compute.models.SharedGalleryImageVersionStorageProfile + :ivar artifact_tags: The artifact tags of a shared gallery resource. + :vartype artifact_tags: dict[str, str] """ + _validation = { + "name": {"readonly": True}, + "location": {"readonly": True}, + } + _attribute_map = { - "rules": {"key": "rules", "type": "[str]"}, - "force_deletion": {"key": "forceDeletion", "type": "bool"}, - "prioritize_unhealthy_v_ms": {"key": "prioritizeUnhealthyVMs", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "unique_id": {"key": "identifier.uniqueId", "type": "str"}, + "published_date": {"key": "properties.publishedDate", "type": "iso-8601"}, + "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, + "exclude_from_latest": {"key": "properties.excludeFromLatest", "type": "bool"}, + "storage_profile": {"key": "properties.storageProfile", "type": "SharedGalleryImageVersionStorageProfile"}, + "artifact_tags": {"key": "properties.artifactTags", "type": "{str}"}, } def __init__( self, *, - rules: Optional[List[Union[str, "_models.VirtualMachineScaleSetScaleInRules"]]] = None, - force_deletion: Optional[bool] = None, - prioritize_unhealthy_v_ms: Optional[bool] = None, + 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: """ - :keyword rules: The rules to be followed when scaling-in a virtual machine scale set. - :code:`
`\\ :code:`
` Possible values are: :code:`
`\\ :code:`
` **Default** When a - virtual machine scale set is scaled in, the scale set will first be balanced across zones if it - is a zonal scale set. Then, it will be balanced across Fault Domains as far as possible. Within - each Fault Domain, the virtual machines chosen for removal will be the newest ones that are not - protected from scale-in. :code:`
`\\ :code:`
` **OldestVM** When a virtual machine scale - set is being scaled-in, the oldest virtual machines that are not protected from scale-in will - be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the oldest virtual machines that are not protected - will be chosen for removal. :code:`
`\\ :code:`
` **NewestVM** When a virtual machine - scale set is being scaled-in, the newest virtual machines that are not protected from scale-in - will be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the newest virtual machines that are not protected - will be chosen for removal. :code:`
`\\ :code:`
`. - :paramtype rules: list[str or - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetScaleInRules] - :keyword force_deletion: This property allows you to specify if virtual machines chosen for - removal have to be force deleted when a virtual machine scale set is being scaled-in.(Feature - in Preview). - :paramtype force_deletion: bool - :keyword prioritize_unhealthy_v_ms: This property allows you to prioritize the deletion of - unhealthy and inactive VMs when a virtual machine scale set is being scaled-in.(Feature in - Preview). - :paramtype prioritize_unhealthy_v_ms: bool - """ - super().__init__(**kwargs) - self.rules = rules - self.force_deletion = force_deletion - self.prioritize_unhealthy_v_ms = prioritize_unhealthy_v_ms + :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.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 -class ScheduledEventsAdditionalPublishingTargets(_serialization.Model): # pylint: disable=name-too-long - """ScheduledEventsAdditionalPublishingTargets. +class SharedGalleryImageVersionList(_serialization.Model): + """The List Shared Gallery Image versions operation response. - :ivar event_grid_and_resource_graph: The configuration parameters used while creating - eventGridAndResourceGraph Scheduled Event setting. - :vartype event_grid_and_resource_graph: - ~azure.mgmt.compute.v2024_11_01.models.EventGridAndResourceGraph + All required parameters must be populated in order to send to server. + + :ivar value: A list of shared gallery images versions. Required. + :vartype value: list[~azure.mgmt.compute.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. + :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { - "event_grid_and_resource_graph": {"key": "eventGridAndResourceGraph", "type": "EventGridAndResourceGraph"}, + "value": {"key": "value", "type": "[SharedGalleryImageVersion]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, *, event_grid_and_resource_graph: Optional["_models.EventGridAndResourceGraph"] = None, **kwargs: Any + self, *, value: List["_models.SharedGalleryImageVersion"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword event_grid_and_resource_graph: The configuration parameters used while creating - eventGridAndResourceGraph Scheduled Event setting. - :paramtype event_grid_and_resource_graph: - ~azure.mgmt.compute.v2024_11_01.models.EventGridAndResourceGraph + :keyword value: A list of shared gallery images versions. Required. + :paramtype value: list[~azure.mgmt.compute.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. + :paramtype next_link: str """ super().__init__(**kwargs) - self.event_grid_and_resource_graph = event_grid_and_resource_graph + self.value = value + self.next_link = next_link -class ScheduledEventsPolicy(_serialization.Model): - """Specifies Redeploy, Reboot and ScheduledEventsAdditionalPublishingTargets Scheduled Event - related configurations. +class SharedGalleryImageVersionStorageProfile(_serialization.Model): + """This is the storage profile of a Gallery Image Version. - :ivar user_initiated_redeploy: The configuration parameters used while creating - userInitiatedRedeploy scheduled event setting creation. - :vartype user_initiated_redeploy: ~azure.mgmt.compute.v2024_11_01.models.UserInitiatedRedeploy - :ivar user_initiated_reboot: The configuration parameters used while creating - userInitiatedReboot scheduled event setting creation. - :vartype user_initiated_reboot: ~azure.mgmt.compute.v2024_11_01.models.UserInitiatedReboot - :ivar scheduled_events_additional_publishing_targets: The configuration parameters used while - publishing scheduledEventsAdditionalPublishingTargets. - :vartype scheduled_events_additional_publishing_targets: - ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsAdditionalPublishingTargets + :ivar os_disk_image: This is the OS disk image. + :vartype os_disk_image: ~azure.mgmt.compute.models.SharedGalleryOSDiskImage + :ivar data_disk_images: A list of data disk images. + :vartype data_disk_images: list[~azure.mgmt.compute.models.SharedGalleryDataDiskImage] """ _attribute_map = { - "user_initiated_redeploy": {"key": "userInitiatedRedeploy", "type": "UserInitiatedRedeploy"}, - "user_initiated_reboot": {"key": "userInitiatedReboot", "type": "UserInitiatedReboot"}, - "scheduled_events_additional_publishing_targets": { - "key": "scheduledEventsAdditionalPublishingTargets", - "type": "ScheduledEventsAdditionalPublishingTargets", - }, + "os_disk_image": {"key": "osDiskImage", "type": "SharedGalleryOSDiskImage"}, + "data_disk_images": {"key": "dataDiskImages", "type": "[SharedGalleryDataDiskImage]"}, } def __init__( self, *, - user_initiated_redeploy: Optional["_models.UserInitiatedRedeploy"] = None, - user_initiated_reboot: Optional["_models.UserInitiatedReboot"] = None, - scheduled_events_additional_publishing_targets: Optional[ - "_models.ScheduledEventsAdditionalPublishingTargets" - ] = None, + os_disk_image: Optional["_models.SharedGalleryOSDiskImage"] = None, + data_disk_images: Optional[List["_models.SharedGalleryDataDiskImage"]] = None, **kwargs: Any ) -> None: """ - :keyword user_initiated_redeploy: The configuration parameters used while creating - userInitiatedRedeploy scheduled event setting creation. - :paramtype user_initiated_redeploy: - ~azure.mgmt.compute.v2024_11_01.models.UserInitiatedRedeploy - :keyword user_initiated_reboot: The configuration parameters used while creating - userInitiatedReboot scheduled event setting creation. - :paramtype user_initiated_reboot: ~azure.mgmt.compute.v2024_11_01.models.UserInitiatedReboot - :keyword scheduled_events_additional_publishing_targets: The configuration parameters used - while publishing scheduledEventsAdditionalPublishingTargets. - :paramtype scheduled_events_additional_publishing_targets: - ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsAdditionalPublishingTargets + :keyword os_disk_image: This is the OS disk image. + :paramtype os_disk_image: ~azure.mgmt.compute.models.SharedGalleryOSDiskImage + :keyword data_disk_images: A list of data disk images. + :paramtype data_disk_images: list[~azure.mgmt.compute.models.SharedGalleryDataDiskImage] """ super().__init__(**kwargs) - self.user_initiated_redeploy = user_initiated_redeploy - self.user_initiated_reboot = user_initiated_reboot - self.scheduled_events_additional_publishing_targets = scheduled_events_additional_publishing_targets + self.os_disk_image = os_disk_image + self.data_disk_images = data_disk_images -class ScheduledEventsProfile(_serialization.Model): - """ScheduledEventsProfile. +class SharedGalleryList(_serialization.Model): + """The List Shared Galleries operation response. - :ivar terminate_notification_profile: Specifies Terminate Scheduled Event related - configurations. - :vartype terminate_notification_profile: - ~azure.mgmt.compute.v2024_11_01.models.TerminateNotificationProfile - :ivar os_image_notification_profile: Specifies OS Image Scheduled Event related configurations. - :vartype os_image_notification_profile: - ~azure.mgmt.compute.v2024_11_01.models.OSImageNotificationProfile + All required parameters must be populated in order to send to server. + + :ivar value: A list of shared galleries. Required. + :vartype value: list[~azure.mgmt.compute.models.SharedGallery] + :ivar next_link: The uri to fetch the next page of shared galleries. Call ListNext() with this + to fetch the next page of shared galleries. + :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { - "terminate_notification_profile": { - "key": "terminateNotificationProfile", - "type": "TerminateNotificationProfile", - }, - "os_image_notification_profile": {"key": "osImageNotificationProfile", "type": "OSImageNotificationProfile"}, + "value": {"key": "value", "type": "[SharedGallery]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - terminate_notification_profile: Optional["_models.TerminateNotificationProfile"] = None, - os_image_notification_profile: Optional["_models.OSImageNotificationProfile"] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, value: List["_models.SharedGallery"], next_link: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword terminate_notification_profile: Specifies Terminate Scheduled Event related - configurations. - :paramtype terminate_notification_profile: - ~azure.mgmt.compute.v2024_11_01.models.TerminateNotificationProfile - :keyword os_image_notification_profile: Specifies OS Image Scheduled Event related - configurations. - :paramtype os_image_notification_profile: - ~azure.mgmt.compute.v2024_11_01.models.OSImageNotificationProfile + :keyword value: A list of shared galleries. Required. + :paramtype value: list[~azure.mgmt.compute.models.SharedGallery] + :keyword next_link: The uri to fetch the next page of shared galleries. Call ListNext() with + this to fetch the next page of shared galleries. + :paramtype next_link: str """ super().__init__(**kwargs) - self.terminate_notification_profile = terminate_notification_profile - self.os_image_notification_profile = os_image_notification_profile + self.value = value + self.next_link = next_link -class SecurityPostureReference(_serialization.Model): - """Specifies the security posture to be used in the scale set. Minimum api-version: 2023-03-01. +class SharedGalleryOSDiskImage(SharedGalleryDiskImage): + """This is the OS disk image. - All required parameters must be populated in order to send to server. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The security posture reference id in the form of - /CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|latest. - Required. - :vartype id: str - :ivar exclude_extensions: The list of virtual machine extension names to exclude when applying - the security posture. - :vartype exclude_extensions: list[str] - :ivar is_overridable: Whether the security posture can be overridden by the user. - :vartype is_overridable: bool + :ivar disk_size_gb: This property indicates the size of the VHD to be created. + :vartype disk_size_gb: int + :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and + 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". + :vartype host_caching: str or ~azure.mgmt.compute.models.SharedGalleryHostCaching + """ + + +class ShareInfoElement(_serialization.Model): + """ShareInfoElement. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar vm_uri: A relative URI containing the ID of the VM that has the disk attached. + :vartype vm_uri: str """ _validation = { - "id": {"required": True}, + "vm_uri": {"readonly": True}, } _attribute_map = { - "id": {"key": "id", "type": "str"}, - "exclude_extensions": {"key": "excludeExtensions", "type": "[str]"}, - "is_overridable": {"key": "isOverridable", "type": "bool"}, + "vm_uri": {"key": "vmUri", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.vm_uri: Optional[str] = None + + +class SharingProfile(_serialization.Model): + """Profile for gallery sharing to subscription or tenant. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar permissions: This property allows you to specify the permission of sharing gallery. + Possible values are: **Private,** **Groups,** **Community.**. Known values are: "Private", + "Groups", and "Community". + :vartype permissions: str or ~azure.mgmt.compute.models.GallerySharingPermissionTypes + :ivar groups: A list of sharing profile groups. + :vartype groups: list[~azure.mgmt.compute.models.SharingProfileGroup] + :ivar community_gallery_info: Information of community gallery if current gallery is shared to + community. + :vartype community_gallery_info: ~azure.mgmt.compute.models.CommunityGalleryInfo + """ + + _validation = { + "groups": {"readonly": True}, + } + + _attribute_map = { + "permissions": {"key": "permissions", "type": "str"}, + "groups": {"key": "groups", "type": "[SharingProfileGroup]"}, + "community_gallery_info": {"key": "communityGalleryInfo", "type": "CommunityGalleryInfo"}, } def __init__( self, *, - id: str, # pylint: disable=redefined-builtin - exclude_extensions: Optional[List[str]] = None, - is_overridable: Optional[bool] = None, + permissions: Optional[Union[str, "_models.GallerySharingPermissionTypes"]] = None, + community_gallery_info: Optional["_models.CommunityGalleryInfo"] = None, **kwargs: Any ) -> None: """ - :keyword id: The security posture reference id in the form of - /CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|latest. - Required. - :paramtype id: str - :keyword exclude_extensions: The list of virtual machine extension names to exclude when - applying the security posture. - :paramtype exclude_extensions: list[str] - :keyword is_overridable: Whether the security posture can be overridden by the user. - :paramtype is_overridable: bool + :keyword permissions: This property allows you to specify the permission of sharing gallery. + Possible values are: **Private,** **Groups,** **Community.**. Known values are: "Private", + "Groups", and "Community". + :paramtype permissions: str or ~azure.mgmt.compute.models.GallerySharingPermissionTypes + :keyword community_gallery_info: Information of community gallery if current gallery is shared + to community. + :paramtype community_gallery_info: ~azure.mgmt.compute.models.CommunityGalleryInfo """ super().__init__(**kwargs) - self.id = id - self.exclude_extensions = exclude_extensions - self.is_overridable = is_overridable + self.permissions = permissions + self.groups: Optional[List["_models.SharingProfileGroup"]] = None + self.community_gallery_info = community_gallery_info -class SecurityPostureReferenceUpdate(_serialization.Model): - """Specifies the security posture to be used in the scale set. Minimum api-version: 2023-03-01. +class SharingProfileGroup(_serialization.Model): + """Group of the gallery sharing profile. - :ivar id: The security posture reference id in the form of - /CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|latest. - :vartype id: str - :ivar exclude_extensions: The list of virtual machine extension names to exclude when applying - the security posture. - :vartype exclude_extensions: list[str] - :ivar is_overridable: Whether the security posture can be overridden by the user. - :vartype is_overridable: bool + :ivar type: This property allows you to specify the type of sharing group. Possible values are: + **Subscriptions,** **AADTenants.**. Known values are: "Subscriptions" and "AADTenants". + :vartype type: str or ~azure.mgmt.compute.models.SharingProfileGroupTypes + :ivar ids: A list of subscription/tenant ids the gallery is aimed to be shared to. + :vartype ids: list[str] """ _attribute_map = { - "id": {"key": "id", "type": "str"}, - "exclude_extensions": {"key": "excludeExtensions", "type": "[str]"}, - "is_overridable": {"key": "isOverridable", "type": "bool"}, + "type": {"key": "type", "type": "str"}, + "ids": {"key": "ids", "type": "[str]"}, } def __init__( self, *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - exclude_extensions: Optional[List[str]] = None, - is_overridable: Optional[bool] = None, + type: Optional[Union[str, "_models.SharingProfileGroupTypes"]] = None, + ids: Optional[List[str]] = None, **kwargs: Any ) -> None: """ - :keyword id: The security posture reference id in the form of - /CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|latest. - :paramtype id: str - :keyword exclude_extensions: The list of virtual machine extension names to exclude when - applying the security posture. - :paramtype exclude_extensions: list[str] - :keyword is_overridable: Whether the security posture can be overridden by the user. - :paramtype is_overridable: bool + :keyword type: This property allows you to specify the type of sharing group. Possible values + are: **Subscriptions,** **AADTenants.**. Known values are: "Subscriptions" and "AADTenants". + :paramtype type: str or ~azure.mgmt.compute.models.SharingProfileGroupTypes + :keyword ids: A list of subscription/tenant ids the gallery is aimed to be shared to. + :paramtype ids: list[str] """ super().__init__(**kwargs) - self.id = id - self.exclude_extensions = exclude_extensions - self.is_overridable = is_overridable + self.type = type + self.ids = ids -class SecurityProfile(_serialization.Model): - """Specifies the Security profile settings for the virtual machine or virtual machine scale set. +class SharingStatus(_serialization.Model): + """Sharing status of current gallery. - :ivar uefi_settings: Specifies the security settings like secure boot and vTPM used while - creating the virtual machine. Minimum api-version: 2020-12-01. - :vartype uefi_settings: ~azure.mgmt.compute.v2024_11_01.models.UefiSettings - :ivar encryption_at_host: This property can be used by user in the request to enable or disable - the Host Encryption for the virtual machine or virtual machine scale set. This will enable the - encryption for all the disks including Resource/Temp disk at host itself. The default behavior - is: The Encryption at host will be disabled unless this property is set to true for the - resource. - :vartype encryption_at_host: bool - :ivar security_type: Specifies the SecurityType of the virtual machine. It has to be set to any - specified value to enable UefiSettings. The default behavior is: UefiSettings will not be - enabled unless this property is set. Known values are: "TrustedLaunch" and "ConfidentialVM". - :vartype security_type: str or ~azure.mgmt.compute.v2024_11_01.models.SecurityTypes - :ivar encryption_identity: Specifies the Managed Identity used by ADE to get access token for - keyvault operations. - :vartype encryption_identity: ~azure.mgmt.compute.v2024_11_01.models.EncryptionIdentity - :ivar proxy_agent_settings: Specifies ProxyAgent settings while creating the virtual machine. - Minimum api-version: 2023-09-01. - :vartype proxy_agent_settings: ~azure.mgmt.compute.v2024_11_01.models.ProxyAgentSettings + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar aggregated_state: Aggregated sharing state of current gallery. Known values are: + "Succeeded", "InProgress", "Failed", and "Unknown". + :vartype aggregated_state: str or ~azure.mgmt.compute.models.SharingState + :ivar summary: Summary of all regional sharing status. + :vartype summary: list[~azure.mgmt.compute.models.RegionalSharingStatus] """ + _validation = { + "aggregated_state": {"readonly": True}, + } + _attribute_map = { - "uefi_settings": {"key": "uefiSettings", "type": "UefiSettings"}, - "encryption_at_host": {"key": "encryptionAtHost", "type": "bool"}, - "security_type": {"key": "securityType", "type": "str"}, - "encryption_identity": {"key": "encryptionIdentity", "type": "EncryptionIdentity"}, - "proxy_agent_settings": {"key": "proxyAgentSettings", "type": "ProxyAgentSettings"}, + "aggregated_state": {"key": "aggregatedState", "type": "str"}, + "summary": {"key": "summary", "type": "[RegionalSharingStatus]"}, } - def __init__( - self, - *, - uefi_settings: Optional["_models.UefiSettings"] = None, - encryption_at_host: Optional[bool] = None, - security_type: Optional[Union[str, "_models.SecurityTypes"]] = None, - encryption_identity: Optional["_models.EncryptionIdentity"] = None, - proxy_agent_settings: Optional["_models.ProxyAgentSettings"] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, summary: Optional[List["_models.RegionalSharingStatus"]] = None, **kwargs: Any) -> None: """ - :keyword uefi_settings: Specifies the security settings like secure boot and vTPM used while - creating the virtual machine. Minimum api-version: 2020-12-01. - :paramtype uefi_settings: ~azure.mgmt.compute.v2024_11_01.models.UefiSettings - :keyword encryption_at_host: This property can be used by user in the request to enable or - disable the Host Encryption for the virtual machine or virtual machine scale set. This will - enable the encryption for all the disks including Resource/Temp disk at host itself. The - default behavior is: The Encryption at host will be disabled unless this property is set to - true for the resource. - :paramtype encryption_at_host: bool - :keyword security_type: Specifies the SecurityType of the virtual machine. It has to be set to - any specified value to enable UefiSettings. The default behavior is: UefiSettings will not be - enabled unless this property is set. Known values are: "TrustedLaunch" and "ConfidentialVM". - :paramtype security_type: str or ~azure.mgmt.compute.v2024_11_01.models.SecurityTypes - :keyword encryption_identity: Specifies the Managed Identity used by ADE to get access token - for keyvault operations. - :paramtype encryption_identity: ~azure.mgmt.compute.v2024_11_01.models.EncryptionIdentity - :keyword proxy_agent_settings: Specifies ProxyAgent settings while creating the virtual - machine. Minimum api-version: 2023-09-01. - :paramtype proxy_agent_settings: ~azure.mgmt.compute.v2024_11_01.models.ProxyAgentSettings + :keyword summary: Summary of all regional sharing status. + :paramtype summary: list[~azure.mgmt.compute.models.RegionalSharingStatus] """ super().__init__(**kwargs) - self.uefi_settings = uefi_settings - self.encryption_at_host = encryption_at_host - self.security_type = security_type - self.encryption_identity = encryption_identity - self.proxy_agent_settings = proxy_agent_settings + self.aggregated_state: Optional[Union[str, "_models.SharingState"]] = None + self.summary = summary -class ServiceArtifactReference(_serialization.Model): - """Specifies the service artifact reference id used to set same image version for all virtual - machines in the scale set when using 'latest' image version. Minimum api-version: 2022-11-01. +class SharingUpdate(_serialization.Model): + """Specifies information about the gallery sharing profile update. - :ivar id: The service artifact reference id in the form of - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/serviceArtifacts/{serviceArtifactName}/vmArtifactsProfiles/{vmArtifactsProfilesName}. - :vartype id: str + All required parameters must be populated in order to send to server. + + :ivar operation_type: This property allows you to specify the operation type of gallery sharing + update. Possible values are: **Add,** **Remove,** **Reset.**. Required. Known values are: + "Add", "Remove", "Reset", and "EnableCommunity". + :vartype operation_type: str or ~azure.mgmt.compute.models.SharingUpdateOperationTypes + :ivar groups: A list of sharing profile groups. + :vartype groups: list[~azure.mgmt.compute.models.SharingProfileGroup] """ + _validation = { + "operation_type": {"required": True}, + } + _attribute_map = { - "id": {"key": "id", "type": "str"}, + "operation_type": {"key": "operationType", "type": "str"}, + "groups": {"key": "groups", "type": "[SharingProfileGroup]"}, } - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + def __init__( + self, + *, + operation_type: Union[str, "_models.SharingUpdateOperationTypes"], + groups: Optional[List["_models.SharingProfileGroup"]] = None, + **kwargs: Any + ) -> None: """ - :keyword id: The service artifact reference id in the form of - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/serviceArtifacts/{serviceArtifactName}/vmArtifactsProfiles/{vmArtifactsProfilesName}. - :paramtype id: str + :keyword operation_type: This property allows you to specify the operation type of gallery + sharing update. Possible values are: **Add,** **Remove,** **Reset.**. Required. Known values + are: "Add", "Remove", "Reset", and "EnableCommunity". + :paramtype operation_type: str or ~azure.mgmt.compute.models.SharingUpdateOperationTypes + :keyword groups: A list of sharing profile groups. + :paramtype groups: list[~azure.mgmt.compute.models.SharingProfileGroup] """ super().__init__(**kwargs) - self.id = id + self.operation_type = operation_type + self.groups = groups class Sku(_serialization.Model): @@ -8482,11 +16801,11 @@ class SkuProfile(_serialization.Model): able to specify a list of VM sizes and an allocation strategy. :ivar vm_sizes: Specifies the VM sizes for the virtual machine scale set. - :vartype vm_sizes: list[~azure.mgmt.compute.v2024_11_01.models.SkuProfileVMSize] + :vartype vm_sizes: list[~azure.mgmt.compute.models.SkuProfileVMSize] :ivar allocation_strategy: Specifies the allocation strategy for the virtual machine scale set based on which the VMs will be allocated. Known values are: "LowestPrice", "CapacityOptimized", and "Prioritized". - :vartype allocation_strategy: str or ~azure.mgmt.compute.v2024_11_01.models.AllocationStrategy + :vartype allocation_strategy: str or ~azure.mgmt.compute.models.AllocationStrategy """ _attribute_map = { @@ -8494,51 +16813,555 @@ class SkuProfile(_serialization.Model): "allocation_strategy": {"key": "allocationStrategy", "type": "str"}, } - def __init__( - self, - *, - vm_sizes: Optional[List["_models.SkuProfileVMSize"]] = None, - allocation_strategy: Optional[Union[str, "_models.AllocationStrategy"]] = None, - **kwargs: Any - ) -> None: + def __init__( + self, + *, + vm_sizes: Optional[List["_models.SkuProfileVMSize"]] = None, + allocation_strategy: Optional[Union[str, "_models.AllocationStrategy"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword vm_sizes: Specifies the VM sizes for the virtual machine scale set. + :paramtype vm_sizes: list[~azure.mgmt.compute.models.SkuProfileVMSize] + :keyword allocation_strategy: Specifies the allocation strategy for the virtual machine scale + set based on which the VMs will be allocated. Known values are: "LowestPrice", + "CapacityOptimized", and "Prioritized". + :paramtype allocation_strategy: str or ~azure.mgmt.compute.models.AllocationStrategy + """ + super().__init__(**kwargs) + self.vm_sizes = vm_sizes + self.allocation_strategy = allocation_strategy + + +class SkuProfileVMSize(_serialization.Model): + """Specifies the VM Size. + + :ivar name: Specifies the name of the VM Size. + :vartype name: str + :ivar rank: Specifies the rank (a.k.a priority) associated with the VM Size. + :vartype rank: int + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "rank": {"key": "rank", "type": "int"}, + } + + def __init__(self, *, name: Optional[str] = None, rank: Optional[int] = None, **kwargs: Any) -> None: + """ + :keyword name: Specifies the name of the VM Size. + :paramtype name: str + :keyword rank: Specifies the rank (a.k.a priority) associated with the VM Size. + :paramtype rank: int + """ + super().__init__(**kwargs) + self.name = name + self.rank = rank + + +class Snapshot(ResourceAutoGenerated): + """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. + :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] + :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 + an optional parameter for incremental snapshot and the default behavior is the SKU will be set + to the same sku as the previous snapshot. + :vartype sku: ~azure.mgmt.compute.models.SnapshotSku + :ivar extended_location: The extended location where the snapshot will be created. Extended + location cannot be changed. + :vartype extended_location: ~azure.mgmt.compute.models.ExtendedLocation + :ivar time_created: The time when the snapshot was created. + :vartype time_created: ~datetime.datetime + :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". + :vartype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS + disks only. Known values are: "V1" and "V2". + :vartype hyper_v_generation: str or ~azure.mgmt.compute.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.models.PurchasePlanAutoGenerated + :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.models.SupportedCapabilities + :ivar creation_data: Disk source information. CreationData information cannot be changed after + the disk has been created. + :vartype creation_data: ~azure.mgmt.compute.models.CreationData + :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it + indicates the size of the disk to create. If this field is present for updates or creation with + other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a + running VM, and can only increase the disk's size. + :vartype disk_size_gb: int + :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. + :vartype disk_size_bytes: int + :ivar disk_state: The state of the snapshot. Known values are: "Unattached", "Attached", + "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", and "ActiveUpload". + :vartype disk_state: str or ~azure.mgmt.compute.models.DiskState + :ivar unique_id: Unique Guid identifying the resource. + :vartype unique_id: str + :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk + Encryption, can contain multiple encryption settings per disk or snapshot. + :vartype encryption_settings_collection: + ~azure.mgmt.compute.models.EncryptionSettingsCollection + :ivar provisioning_state: The disk provisioning state. + :vartype provisioning_state: str + :ivar incremental: Whether a snapshot is incremental. Incremental snapshots on the same disk + occupy less space than full snapshots and can be diffed. + :vartype incremental: bool + :ivar incremental_snapshot_family_id: Incremental snapshots for a disk share an incremental + snapshot family id. The Get Page Range Diff API can only be called on incremental snapshots + with the same family id. + :vartype incremental_snapshot_family_id: str + :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed + keys or platform managed keys. + :vartype encryption: ~azure.mgmt.compute.models.Encryption + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", and "DenyAll". + :vartype network_access_policy: str or ~azure.mgmt.compute.models.NetworkAccessPolicy + :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. + :vartype disk_access_id: str + :ivar security_profile: Contains the security related information for the resource. + :vartype security_profile: ~azure.mgmt.compute.models.DiskSecurityProfile + :ivar supports_hibernation: Indicates the OS on a snapshot supports hibernation. + :vartype supports_hibernation: bool + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled" and "Disabled". + :vartype public_network_access: str or ~azure.mgmt.compute.models.PublicNetworkAccess + :ivar completion_percent: Percentage complete for the background copy when a resource is + created via the CopyStart operation. + :vartype completion_percent: float + :ivar copy_completion_error: Indicates the error details if the background copy of a resource + created via the CopyStart operation fails. + :vartype copy_completion_error: ~azure.mgmt.compute.models.CopyCompletionError + :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading + to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". + :vartype data_access_auth_mode: str or ~azure.mgmt.compute.models.DataAccessAuthMode + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "managed_by": {"readonly": True}, + "time_created": {"readonly": True}, + "disk_size_bytes": {"readonly": True}, + "disk_state": {"readonly": True}, + "unique_id": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "incremental_snapshot_family_id": {"readonly": 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}"}, + "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": "PurchasePlanAutoGenerated"}, + "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, + "creation_data": {"key": "properties.creationData", "type": "CreationData"}, + "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, + "disk_size_bytes": {"key": "properties.diskSizeBytes", "type": "int"}, + "disk_state": {"key": "properties.diskState", "type": "str"}, + "unique_id": {"key": "properties.uniqueId", "type": "str"}, + "encryption_settings_collection": { + "key": "properties.encryptionSettingsCollection", + "type": "EncryptionSettingsCollection", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "incremental": {"key": "properties.incremental", "type": "bool"}, + "incremental_snapshot_family_id": {"key": "properties.incrementalSnapshotFamilyId", "type": "str"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, + "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, + "security_profile": {"key": "properties.securityProfile", "type": "DiskSecurityProfile"}, + "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "completion_percent": {"key": "properties.completionPercent", "type": "float"}, + "copy_completion_error": {"key": "properties.copyCompletionError", "type": "CopyCompletionError"}, + "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + sku: Optional["_models.SnapshotSku"] = None, + 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.PurchasePlanAutoGenerated"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, + creation_data: Optional["_models.CreationData"] = None, + disk_size_gb: Optional[int] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, + incremental: Optional[bool] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, + disk_access_id: Optional[str] = None, + security_profile: Optional["_models.DiskSecurityProfile"] = None, + supports_hibernation: Optional[bool] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + completion_percent: Optional[float] = None, + copy_completion_error: Optional["_models.CopyCompletionError"] = None, + data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, 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. + :paramtype sku: ~azure.mgmt.compute.models.SnapshotSku + :keyword extended_location: The extended location where the snapshot will be created. Extended + location cannot be changed. + :paramtype extended_location: ~azure.mgmt.compute.models.ExtendedLocation + :keyword os_type: The Operating System type. Known values are: "Windows" and "Linux". + :paramtype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :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.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.models.PurchasePlanAutoGenerated + :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.models.SupportedCapabilities + :keyword creation_data: Disk source information. CreationData information cannot be changed + after the disk has been created. + :paramtype creation_data: ~azure.mgmt.compute.models.CreationData + :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it + indicates the size of the disk to create. If this field is present for updates or creation with + other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a + running VM, and can only increase the disk's size. + :paramtype disk_size_gb: int + :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk + Encryption, can contain multiple encryption settings per disk or snapshot. + :paramtype encryption_settings_collection: + ~azure.mgmt.compute.models.EncryptionSettingsCollection + :keyword incremental: Whether a snapshot is incremental. Incremental snapshots on the same disk + occupy less space than full snapshots and can be diffed. + :paramtype incremental: bool + :keyword encryption: Encryption property can be used to encrypt data at rest with customer + managed keys or platform managed keys. + :paramtype encryption: ~azure.mgmt.compute.models.Encryption + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", and "DenyAll". + :paramtype network_access_policy: str or ~azure.mgmt.compute.models.NetworkAccessPolicy + :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on + disks. + :paramtype disk_access_id: str + :keyword security_profile: Contains the security related information for the resource. + :paramtype security_profile: ~azure.mgmt.compute.models.DiskSecurityProfile + :keyword supports_hibernation: Indicates the OS on a snapshot supports hibernation. + :paramtype supports_hibernation: bool + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled" and "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.compute.models.PublicNetworkAccess + :keyword completion_percent: Percentage complete for the background copy when a resource is + created via the CopyStart operation. + :paramtype completion_percent: float + :keyword copy_completion_error: Indicates the error details if the background copy of a + resource created via the CopyStart operation fails. + :paramtype copy_completion_error: ~azure.mgmt.compute.models.CopyCompletionError + :keyword data_access_auth_mode: Additional authentication requirements when exporting or + uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". + :paramtype data_access_auth_mode: str or ~azure.mgmt.compute.models.DataAccessAuthMode + """ + super().__init__(location=location, tags=tags, **kwargs) + self.managed_by: Optional[str] = None + self.sku = sku + self.extended_location = extended_location + self.time_created: Optional[datetime.datetime] = None + self.os_type = os_type + self.hyper_v_generation = hyper_v_generation + self.purchase_plan = purchase_plan + self.supported_capabilities = supported_capabilities + self.creation_data = creation_data + self.disk_size_gb = disk_size_gb + self.disk_size_bytes: Optional[int] = None + self.disk_state: Optional[Union[str, "_models.DiskState"]] = None + self.unique_id: Optional[str] = None + self.encryption_settings_collection = encryption_settings_collection + self.provisioning_state: Optional[str] = None + self.incremental = incremental + self.incremental_snapshot_family_id: Optional[str] = None + self.encryption = encryption + self.network_access_policy = network_access_policy + self.disk_access_id = disk_access_id + self.security_profile = security_profile + self.supports_hibernation = supports_hibernation + self.public_network_access = public_network_access + self.completion_percent = completion_percent + self.copy_completion_error = copy_completion_error + self.data_access_auth_mode = data_access_auth_mode + + +class SnapshotList(_serialization.Model): + """The List Snapshots operation response. + + All required parameters must be populated in order to send to server. + + :ivar value: A list of snapshots. Required. + :vartype value: list[~azure.mgmt.compute.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. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Snapshot]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of snapshots. Required. + :paramtype value: list[~azure.mgmt.compute.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. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SnapshotSku(_serialization.Model): + """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. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", and "Standard_ZRS". + :vartype name: str or ~azure.mgmt.compute.models.SnapshotStorageAccountTypes + :ivar tier: The sku tier. + :vartype tier: str + """ + + _validation = { + "tier": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + } + + def __init__( + self, *, name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs: Any + ) -> None: + """ + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", and + "Standard_ZRS". + :paramtype name: str or ~azure.mgmt.compute.models.SnapshotStorageAccountTypes + """ + super().__init__(**kwargs) + self.name = name + self.tier: Optional[str] = None + + +class SnapshotUpdate(_serialization.Model): + """Snapshot update resource. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar 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. + :vartype sku: ~azure.mgmt.compute.models.SnapshotSku + :ivar os_type: the Operating System type. Known values are: "Windows" and "Linux". + :vartype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it + indicates the size of the disk to create. If this field is present for updates or creation with + other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a + running VM, and can only increase the disk's size. + :vartype disk_size_gb: int + :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk + Encryption, can contain multiple encryption settings per disk or snapshot. + :vartype encryption_settings_collection: + ~azure.mgmt.compute.models.EncryptionSettingsCollection + :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed + keys or platform managed keys. + :vartype encryption: ~azure.mgmt.compute.models.Encryption + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", and "DenyAll". + :vartype network_access_policy: str or ~azure.mgmt.compute.models.NetworkAccessPolicy + :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. + :vartype disk_access_id: str + :ivar supports_hibernation: Indicates the OS on a snapshot supports hibernation. + :vartype supports_hibernation: bool + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled" and "Disabled". + :vartype public_network_access: str or ~azure.mgmt.compute.models.PublicNetworkAccess + :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading + to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". + :vartype data_access_auth_mode: str or ~azure.mgmt.compute.models.DataAccessAuthMode + :ivar supported_capabilities: List of supported capabilities for the image from which the OS + disk was created. + :vartype supported_capabilities: ~azure.mgmt.compute.models.SupportedCapabilities + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "SnapshotSku"}, + "os_type": {"key": "properties.osType", "type": "str"}, + "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, + "encryption_settings_collection": { + "key": "properties.encryptionSettingsCollection", + "type": "EncryptionSettingsCollection", + }, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, + "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, + "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, + "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + disk_size_gb: Optional[int] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, + disk_access_id: Optional[str] = None, + supports_hibernation: Optional[bool] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, 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. + :paramtype sku: ~azure.mgmt.compute.models.SnapshotSku + :keyword os_type: the Operating System type. Known values are: "Windows" and "Linux". + :paramtype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes + :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it + indicates the size of the disk to create. If this field is present for updates or creation with + other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a + running VM, and can only increase the disk's size. + :paramtype disk_size_gb: int + :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk + Encryption, can contain multiple encryption settings per disk or snapshot. + :paramtype encryption_settings_collection: + ~azure.mgmt.compute.models.EncryptionSettingsCollection + :keyword encryption: Encryption property can be used to encrypt data at rest with customer + managed keys or platform managed keys. + :paramtype encryption: ~azure.mgmt.compute.models.Encryption + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", and "DenyAll". + :paramtype network_access_policy: str or ~azure.mgmt.compute.models.NetworkAccessPolicy + :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on + disks. + :paramtype disk_access_id: str + :keyword supports_hibernation: Indicates the OS on a snapshot supports hibernation. + :paramtype supports_hibernation: bool + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled" and "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.compute.models.PublicNetworkAccess + :keyword data_access_auth_mode: Additional authentication requirements when exporting or + uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". + :paramtype data_access_auth_mode: str or ~azure.mgmt.compute.models.DataAccessAuthMode + :keyword supported_capabilities: List of supported capabilities for the image from which the OS + disk was created. + :paramtype supported_capabilities: ~azure.mgmt.compute.models.SupportedCapabilities + """ + super().__init__(**kwargs) + self.tags = tags + self.sku = sku + self.os_type = os_type + self.disk_size_gb = disk_size_gb + self.encryption_settings_collection = encryption_settings_collection + self.encryption = encryption + self.network_access_policy = network_access_policy + self.disk_access_id = disk_access_id + self.supports_hibernation = supports_hibernation + self.public_network_access = public_network_access + self.data_access_auth_mode = data_access_auth_mode + self.supported_capabilities = supported_capabilities + + +class SoftDeletePolicy(_serialization.Model): + """Contains information about the soft deletion policy of the gallery. + + :ivar is_soft_delete_enabled: Enables soft-deletion for resources in this gallery, allowing + them to be recovered within retention time. + :vartype is_soft_delete_enabled: bool + """ + + _attribute_map = { + "is_soft_delete_enabled": {"key": "isSoftDeleteEnabled", "type": "bool"}, + } + + def __init__(self, *, is_soft_delete_enabled: Optional[bool] = None, **kwargs: Any) -> None: """ - :keyword vm_sizes: Specifies the VM sizes for the virtual machine scale set. - :paramtype vm_sizes: list[~azure.mgmt.compute.v2024_11_01.models.SkuProfileVMSize] - :keyword allocation_strategy: Specifies the allocation strategy for the virtual machine scale - set based on which the VMs will be allocated. Known values are: "LowestPrice", - "CapacityOptimized", and "Prioritized". - :paramtype allocation_strategy: str or - ~azure.mgmt.compute.v2024_11_01.models.AllocationStrategy + :keyword is_soft_delete_enabled: Enables soft-deletion for resources in this gallery, allowing + them to be recovered within retention time. + :paramtype is_soft_delete_enabled: bool """ super().__init__(**kwargs) - self.vm_sizes = vm_sizes - self.allocation_strategy = allocation_strategy + self.is_soft_delete_enabled = is_soft_delete_enabled -class SkuProfileVMSize(_serialization.Model): - """Specifies the VM Size. +class SourceVault(_serialization.Model): + """The vault id is an Azure Resource Manager Resource id in the form + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}. - :ivar name: Specifies the name of the VM Size. - :vartype name: str - :ivar rank: Specifies the rank (a.k.a priority) associated with the VM Size. - :vartype rank: int + :ivar id: Resource Id. + :vartype id: str """ _attribute_map = { - "name": {"key": "name", "type": "str"}, - "rank": {"key": "rank", "type": "int"}, + "id": {"key": "id", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, rank: Optional[int] = None, **kwargs: Any) -> None: + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin """ - :keyword name: Specifies the name of the VM Size. - :paramtype name: str - :keyword rank: Specifies the rank (a.k.a priority) associated with the VM Size. - :paramtype rank: int + :keyword id: Resource Id. + :paramtype id: str """ super().__init__(**kwargs) - self.name = name - self.rank = rank + self.id = id class SpotRestorePolicy(_serialization.Model): @@ -8578,7 +17401,7 @@ class SshConfiguration(_serialization.Model): """SSH configuration for Linux based VMs running on Azure. :ivar public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :vartype public_keys: list[~azure.mgmt.compute.v2024_11_01.models.SshPublicKey] + :vartype public_keys: list[~azure.mgmt.compute.models.SshPublicKey] """ _attribute_map = { @@ -8588,7 +17411,7 @@ class SshConfiguration(_serialization.Model): def __init__(self, *, public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs: Any) -> None: """ :keyword public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :paramtype public_keys: list[~azure.mgmt.compute.v2024_11_01.models.SshPublicKey] + :paramtype public_keys: list[~azure.mgmt.compute.models.SshPublicKey] """ super().__init__(**kwargs) self.public_keys = public_keys @@ -8600,7 +17423,7 @@ class SshGenerateKeyPairInputParameters(_serialization.Model): :ivar encryption_type: The encryption type of the SSH keys to be generated. See SshEncryptionTypes for possible set of values. If not provided, will default to RSA. Known values are: "RSA" and "Ed25519". - :vartype encryption_type: str or ~azure.mgmt.compute.v2024_11_01.models.SshEncryptionTypes + :vartype encryption_type: str or ~azure.mgmt.compute.models.SshEncryptionTypes """ _attribute_map = { @@ -8614,7 +17437,7 @@ def __init__( :keyword encryption_type: The encryption type of the SSH keys to be generated. See SshEncryptionTypes for possible set of values. If not provided, will default to RSA. Known values are: "RSA" and "Ed25519". - :paramtype encryption_type: str or ~azure.mgmt.compute.v2024_11_01.models.SshEncryptionTypes + :paramtype encryption_type: str or ~azure.mgmt.compute.models.SshEncryptionTypes """ super().__init__(**kwargs) self.encryption_type = encryption_type @@ -8726,7 +17549,7 @@ class SshPublicKeyResource(TrackedResource): :vartype type: str :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData + :vartype system_data: ~azure.mgmt.compute.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. @@ -8780,7 +17603,7 @@ class SshPublicKeysGroupListResult(_serialization.Model): All required parameters must be populated in order to send to server. :ivar value: The list of SSH public keys. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource] + :vartype value: list[~azure.mgmt.compute.models.SshPublicKeyResource] :ivar next_link: The URI to fetch the next page of SSH public keys. Call ListNext() with this URI to fetch the next page of SSH public keys. :vartype next_link: str @@ -8800,7 +17623,7 @@ def __init__( ) -> None: """ :keyword value: The list of SSH public keys. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource] + :paramtype value: list[~azure.mgmt.compute.models.SshPublicKeyResource] :keyword next_link: The URI to fetch the next page of SSH public keys. Call ListNext() with this URI to fetch the next page of SSH public keys. :paramtype next_link: str @@ -8843,6 +17666,34 @@ def __init__( self.public_key = public_key +class StatusCodeCount(_serialization.Model): + """The status code and count of the cloud service instance view statuses. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The instance view status code. + :vartype code: str + :ivar count: Number of instances having this status code. + :vartype count: int + """ + + _validation = { + "code": {"readonly": True}, + "count": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "count": {"key": "count", "type": "int"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code: Optional[str] = None + self.count: Optional[int] = None + + class StorageProfile(_serialization.Model): """Specifies the storage settings for the virtual machine disks. @@ -8850,15 +17701,15 @@ class StorageProfile(_serialization.Model): information about platform images, marketplace images, or virtual machine images. This element is required when you want to use a platform image, marketplace image, or virtual machine image, but is not used in other creation operations. - :vartype image_reference: ~azure.mgmt.compute.v2024_11_01.models.ImageReference + :vartype image_reference: ~azure.mgmt.compute.models.ImageReference :ivar os_disk: Specifies information about the operating system disk used by the virtual machine. For more information about disks, see `About disks and VHDs for Azure virtual machines `_. - :vartype os_disk: ~azure.mgmt.compute.v2024_11_01.models.OSDisk + :vartype os_disk: ~azure.mgmt.compute.models.OSDisk :ivar data_disks: Specifies the parameters that are used to add a data disk to a virtual machine. For more information about disks, see `About disks and VHDs for Azure virtual machines `_. - :vartype data_disks: list[~azure.mgmt.compute.v2024_11_01.models.DataDisk] + :vartype data_disks: list[~azure.mgmt.compute.models.DataDisk] :ivar disk_controller_type: Specifies the disk controller type configured for the VM. **Note:** This property will be set to the default disk controller type if not specified provided virtual machine is being created with 'hyperVGeneration' set to V2 based on the capabilities of the @@ -8866,8 +17717,7 @@ class StorageProfile(_serialization.Model): deallocate the VM before updating its disk controller type unless you are updating the VM size in the VM configuration which implicitly deallocates and reallocates the VM. Minimum api-version: 2022-08-01. Known values are: "SCSI" and "NVMe". - :vartype disk_controller_type: str or - ~azure.mgmt.compute.v2024_11_01.models.DiskControllerTypes + :vartype disk_controller_type: str or ~azure.mgmt.compute.models.DiskControllerTypes :ivar align_regional_disks_to_vm_zone: Specifies whether the regional disks should be aligned/moved to the VM zone. This is applicable only for VMs with placement property set. Please note that this change is irreversible. Minimum api-version: 2024-11-01. @@ -8897,15 +17747,15 @@ def __init__( information about platform images, marketplace images, or virtual machine images. This element is required when you want to use a platform image, marketplace image, or virtual machine image, but is not used in other creation operations. - :paramtype image_reference: ~azure.mgmt.compute.v2024_11_01.models.ImageReference + :paramtype image_reference: ~azure.mgmt.compute.models.ImageReference :keyword os_disk: Specifies information about the operating system disk used by the virtual machine. For more information about disks, see `About disks and VHDs for Azure virtual machines `_. - :paramtype os_disk: ~azure.mgmt.compute.v2024_11_01.models.OSDisk + :paramtype os_disk: ~azure.mgmt.compute.models.OSDisk :keyword data_disks: Specifies the parameters that are used to add a data disk to a virtual machine. For more information about disks, see `About disks and VHDs for Azure virtual machines `_. - :paramtype data_disks: list[~azure.mgmt.compute.v2024_11_01.models.DataDisk] + :paramtype data_disks: list[~azure.mgmt.compute.models.DataDisk] :keyword disk_controller_type: Specifies the disk controller type configured for the VM. **Note:** This property will be set to the default disk controller type if not specified provided virtual machine is being created with 'hyperVGeneration' set to V2 based on the @@ -8913,8 +17763,7 @@ def __init__( version. You need to deallocate the VM before updating its disk controller type unless you are updating the VM size in the VM configuration which implicitly deallocates and reallocates the VM. Minimum api-version: 2022-08-01. Known values are: "SCSI" and "NVMe". - :paramtype disk_controller_type: str or - ~azure.mgmt.compute.v2024_11_01.models.DiskControllerTypes + :paramtype disk_controller_type: str or ~azure.mgmt.compute.models.DiskControllerTypes :keyword align_regional_disks_to_vm_zone: Specifies whether the regional disks should be aligned/moved to the VM zone. This is applicable only for VMs with placement property set. Please note that this change is irreversible. Minimum api-version: 2024-11-01. @@ -8935,7 +17784,7 @@ class SubResourceWithColocationStatus(SubResource): :vartype id: str :ivar colocation_status: Describes colocation status of a resource in the Proximity Placement Group. - :vartype colocation_status: ~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus + :vartype colocation_status: ~azure.mgmt.compute.models.InstanceViewStatus """ _attribute_map = { @@ -8955,12 +17804,57 @@ def __init__( :paramtype id: str :keyword colocation_status: Describes colocation status of a resource in the Proximity Placement Group. - :paramtype colocation_status: ~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus + :paramtype colocation_status: ~azure.mgmt.compute.models.InstanceViewStatus """ super().__init__(id=id, **kwargs) self.colocation_status = colocation_status +class SupportedCapabilities(_serialization.Model): + """List of supported capabilities persisted on the disk resource for VM use. + + :ivar disk_controller_types: The disk controllers that an OS disk supports. If set it can be + SCSI or SCSI, NVME or NVME, SCSI. + :vartype disk_controller_types: str + :ivar accelerated_network: True if the image from which the OS disk is created supports + accelerated networking. + :vartype accelerated_network: bool + :ivar architecture: CPU architecture supported by an OS disk. Known values are: "x64" and + "Arm64". + :vartype architecture: str or ~azure.mgmt.compute.models.Architecture + """ + + _attribute_map = { + "disk_controller_types": {"key": "diskControllerTypes", "type": "str"}, + "accelerated_network": {"key": "acceleratedNetwork", "type": "bool"}, + "architecture": {"key": "architecture", "type": "str"}, + } + + def __init__( + self, + *, + disk_controller_types: Optional[str] = None, + accelerated_network: Optional[bool] = None, + architecture: Optional[Union[str, "_models.Architecture"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword disk_controller_types: The disk controllers that an OS disk supports. If set it can be + SCSI or SCSI, NVME or NVME, SCSI. + :paramtype disk_controller_types: str + :keyword accelerated_network: True if the image from which the OS disk is created supports + accelerated networking. + :paramtype accelerated_network: bool + :keyword architecture: CPU architecture supported by an OS disk. Known values are: "x64" and + "Arm64". + :paramtype architecture: str or ~azure.mgmt.compute.models.Architecture + """ + super().__init__(**kwargs) + self.disk_controller_types = disk_controller_types + self.accelerated_network = accelerated_network + self.architecture = architecture + + class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. @@ -8968,14 +17862,14 @@ class SystemData(_serialization.Model): :vartype created_by: str :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.compute.v2024_11_01.models.CreatedByType + :vartype created_by_type: str or ~azure.mgmt.compute.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str :ivar last_modified_by_type: The type of identity that last modified the resource. Known values are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or ~azure.mgmt.compute.v2024_11_01.models.CreatedByType + :vartype last_modified_by_type: str or ~azure.mgmt.compute.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime """ @@ -9005,14 +17899,14 @@ def __init__( :paramtype created_by: str :keyword created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.compute.v2024_11_01.models.CreatedByType + :paramtype created_by_type: str or ~azure.mgmt.compute.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str :keyword last_modified_by_type: The type of identity that last modified the resource. Known values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or ~azure.mgmt.compute.v2024_11_01.models.CreatedByType + :paramtype last_modified_by_type: str or ~azure.mgmt.compute.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ @@ -9055,6 +17949,75 @@ def __init__(self, **kwargs: Any) -> None: self.last_modified_at: Optional[datetime.datetime] = None +class TargetRegion(_serialization.Model): + """Describes the target region information. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the region. Required. + :vartype name: str + :ivar regional_replica_count: The number of replicas of the Image Version to be created per + region. This property is updatable. + :vartype regional_replica_count: int + :ivar storage_account_type: Specifies the storage account type to be used to store the image. + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and + "Premium_LRS". + :vartype storage_account_type: str or ~azure.mgmt.compute.models.StorageAccountType + :ivar encryption: Optional. Allows users to provide customer managed keys for encrypting the OS + and data disks in the gallery artifact. + :vartype encryption: ~azure.mgmt.compute.models.EncryptionImages + :ivar exclude_from_latest: Contains the flag setting to hide an image when users specify + version='latest'. + :vartype exclude_from_latest: bool + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "regional_replica_count": {"key": "regionalReplicaCount", "type": "int"}, + "storage_account_type": {"key": "storageAccountType", "type": "str"}, + "encryption": {"key": "encryption", "type": "EncryptionImages"}, + "exclude_from_latest": {"key": "excludeFromLatest", "type": "bool"}, + } + + def __init__( + self, + *, + name: str, + regional_replica_count: Optional[int] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + encryption: Optional["_models.EncryptionImages"] = None, + exclude_from_latest: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the region. Required. + :paramtype name: str + :keyword regional_replica_count: The number of replicas of the Image Version to be created per + region. This property is updatable. + :paramtype regional_replica_count: int + :keyword storage_account_type: Specifies the storage account type to be used to store the + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and + "Premium_LRS". + :paramtype storage_account_type: str or ~azure.mgmt.compute.models.StorageAccountType + :keyword encryption: Optional. Allows users to provide customer managed keys for encrypting the + OS and data disks in the gallery artifact. + :paramtype encryption: ~azure.mgmt.compute.models.EncryptionImages + :keyword exclude_from_latest: Contains the flag setting to hide an image when users specify + version='latest'. + :paramtype exclude_from_latest: bool + """ + super().__init__(**kwargs) + self.name = name + self.regional_replica_count = regional_replica_count + self.storage_account_type = storage_account_type + self.encryption = encryption + self.exclude_from_latest = exclude_from_latest + + class TerminateNotificationProfile(_serialization.Model): """TerminateNotificationProfile. @@ -9114,6 +18077,85 @@ class ThrottledRequestsInput(LogAnalyticsInputBase): """ +class UefiKey(_serialization.Model): + """A UEFI key signature. + + :ivar type: The type of key signature. Known values are: "sha256" and "x509". + :vartype type: str or ~azure.mgmt.compute.models.UefiKeyType + :ivar value: The value of the key signature. + :vartype value: list[str] + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "[str]"}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.UefiKeyType"]] = None, + value: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: The type of key signature. Known values are: "sha256" and "x509". + :paramtype type: str or ~azure.mgmt.compute.models.UefiKeyType + :keyword value: The value of the key signature. + :paramtype value: list[str] + """ + super().__init__(**kwargs) + self.type = type + self.value = value + + +class UefiKeySignatures(_serialization.Model): + """Additional UEFI key signatures that will be added to the image in addition to the signature + templates. + + :ivar pk: The Platform Key of this image version. + :vartype pk: ~azure.mgmt.compute.models.UefiKey + :ivar kek: The Key Encryption Keys of this image version. + :vartype kek: list[~azure.mgmt.compute.models.UefiKey] + :ivar db: The database of UEFI keys for this image version. + :vartype db: list[~azure.mgmt.compute.models.UefiKey] + :ivar dbx: The database of revoked UEFI keys for this image version. + :vartype dbx: list[~azure.mgmt.compute.models.UefiKey] + """ + + _attribute_map = { + "pk": {"key": "pk", "type": "UefiKey"}, + "kek": {"key": "kek", "type": "[UefiKey]"}, + "db": {"key": "db", "type": "[UefiKey]"}, + "dbx": {"key": "dbx", "type": "[UefiKey]"}, + } + + def __init__( + self, + *, + pk: Optional["_models.UefiKey"] = None, + kek: Optional[List["_models.UefiKey"]] = None, + db: Optional[List["_models.UefiKey"]] = None, + dbx: Optional[List["_models.UefiKey"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword pk: The Platform Key of this image version. + :paramtype pk: ~azure.mgmt.compute.models.UefiKey + :keyword kek: The Key Encryption Keys of this image version. + :paramtype kek: list[~azure.mgmt.compute.models.UefiKey] + :keyword db: The database of UEFI keys for this image version. + :paramtype db: list[~azure.mgmt.compute.models.UefiKey] + :keyword dbx: The database of revoked UEFI keys for this image version. + :paramtype dbx: list[~azure.mgmt.compute.models.UefiKey] + """ + super().__init__(**kwargs) + self.pk = pk + self.kek = kek + self.db = db + self.dbx = dbx + + class UefiSettings(_serialization.Model): """Specifies the security settings like secure boot and vTPM used while creating the virtual machine. Minimum api-version: 2020-12-01. @@ -9147,14 +18189,75 @@ def __init__( self.v_tpm_enabled = v_tpm_enabled +class UpdateDomain(_serialization.Model): + """Defines an update domain for the cloud service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource Name. + :vartype name: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + + +class UpdateDomainListResult(_serialization.Model): + """The list operation result. + + All required parameters must be populated in order to send to server. + + :ivar value: The list of resources. Required. + :vartype value: list[~azure.mgmt.compute.models.UpdateDomain] + :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of + resources. Do this till nextLink is null to fetch all the resources. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[UpdateDomain]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.UpdateDomain"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of resources. Required. + :paramtype value: list[~azure.mgmt.compute.models.UpdateDomain] + :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page + of resources. Do this till nextLink is null to fetch all the resources. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + class UpgradeOperationHistoricalStatusInfo(_serialization.Model): """Virtual Machine Scale Set OS Upgrade History operation response. Variables are only populated by the server, and will be ignored when sending a request. :ivar properties: Information about the properties of the upgrade operation. - :vartype properties: - ~azure.mgmt.compute.v2024_11_01.models.UpgradeOperationHistoricalStatusInfoProperties + :vartype properties: ~azure.mgmt.compute.models.UpgradeOperationHistoricalStatusInfoProperties :ivar type: Resource type. :vartype type: str :ivar location: Resource location. @@ -9187,18 +18290,18 @@ class UpgradeOperationHistoricalStatusInfoProperties(_serialization.Model): # p Variables are only populated by the server, and will be ignored when sending a request. :ivar running_status: Information about the overall status of the upgrade operation. - :vartype running_status: ~azure.mgmt.compute.v2024_11_01.models.UpgradeOperationHistoryStatus + :vartype running_status: ~azure.mgmt.compute.models.UpgradeOperationHistoryStatus :ivar progress: Counts of the VMs in each state. - :vartype progress: ~azure.mgmt.compute.v2024_11_01.models.RollingUpgradeProgressInfo + :vartype progress: ~azure.mgmt.compute.models.RollingUpgradeProgressInfo :ivar error: Error Details for this upgrade if there are any. - :vartype error: ~azure.mgmt.compute.v2024_11_01.models.ApiError + :vartype error: ~azure.mgmt.compute.models.ApiError :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", and "Platform". - :vartype started_by: str or ~azure.mgmt.compute.v2024_11_01.models.UpgradeOperationInvoker + :vartype started_by: str or ~azure.mgmt.compute.models.UpgradeOperationInvoker :ivar target_image_reference: Image Reference details. - :vartype target_image_reference: ~azure.mgmt.compute.v2024_11_01.models.ImageReference + :vartype target_image_reference: ~azure.mgmt.compute.models.ImageReference :ivar rollback_info: Information about OS rollback if performed. - :vartype rollback_info: ~azure.mgmt.compute.v2024_11_01.models.RollbackStatusInfo + :vartype rollback_info: ~azure.mgmt.compute.models.RollbackStatusInfo """ _validation = { @@ -9237,7 +18340,7 @@ class UpgradeOperationHistoryStatus(_serialization.Model): :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", and "Faulted". - :vartype code: str or ~azure.mgmt.compute.v2024_11_01.models.UpgradeState + :vartype code: str or ~azure.mgmt.compute.models.UpgradeState :ivar start_time: Start time of the upgrade. :vartype start_time: ~datetime.datetime :ivar end_time: End time of the upgrade. @@ -9273,14 +18376,13 @@ class UpgradePolicy(_serialization.Model): the manualUpgrade action.\\ :code:`
`\\ :code:`
` **Automatic** - All virtual machines in the scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", and "Rolling". - :vartype mode: str or ~azure.mgmt.compute.v2024_11_01.models.UpgradeMode + :vartype mode: str or ~azure.mgmt.compute.models.UpgradeMode :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. - :vartype rolling_upgrade_policy: ~azure.mgmt.compute.v2024_11_01.models.RollingUpgradePolicy + :vartype rolling_upgrade_policy: ~azure.mgmt.compute.models.RollingUpgradePolicy :ivar automatic_os_upgrade_policy: Configuration parameters used for performing automatic OS Upgrade. - :vartype automatic_os_upgrade_policy: - ~azure.mgmt.compute.v2024_11_01.models.AutomaticOSUpgradePolicy + :vartype automatic_os_upgrade_policy: ~azure.mgmt.compute.models.AutomaticOSUpgradePolicy """ _attribute_map = { @@ -9304,14 +18406,13 @@ def __init__( do this by using the manualUpgrade action.\\ :code:`
`\\ :code:`
` **Automatic** - All virtual machines in the scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", and "Rolling". - :paramtype mode: str or ~azure.mgmt.compute.v2024_11_01.models.UpgradeMode + :paramtype mode: str or ~azure.mgmt.compute.models.UpgradeMode :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. - :paramtype rolling_upgrade_policy: ~azure.mgmt.compute.v2024_11_01.models.RollingUpgradePolicy + :paramtype rolling_upgrade_policy: ~azure.mgmt.compute.models.RollingUpgradePolicy :keyword automatic_os_upgrade_policy: Configuration parameters used for performing automatic OS Upgrade. - :paramtype automatic_os_upgrade_policy: - ~azure.mgmt.compute.v2024_11_01.models.AutomaticOSUpgradePolicy + :paramtype automatic_os_upgrade_policy: ~azure.mgmt.compute.models.AutomaticOSUpgradePolicy """ super().__init__(**kwargs) self.mode = mode @@ -9334,7 +18435,7 @@ class Usage(_serialization.Model): :ivar limit: The maximum permitted usage of the resource. Required. :vartype limit: int :ivar name: The name of the type of usage. Required. - :vartype name: ~azure.mgmt.compute.v2024_11_01.models.UsageName + :vartype name: ~azure.mgmt.compute.models.UsageName """ _validation = { @@ -9360,7 +18461,7 @@ def __init__(self, *, current_value: int, limit: int, name: "_models.UsageName", :keyword limit: The maximum permitted usage of the resource. Required. :paramtype limit: int :keyword name: The name of the type of usage. Required. - :paramtype name: ~azure.mgmt.compute.v2024_11_01.models.UsageName + :paramtype name: ~azure.mgmt.compute.models.UsageName """ super().__init__(**kwargs) self.current_value = current_value @@ -9394,6 +18495,126 @@ def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str self.localized_value = localized_value +class UserArtifactManage(_serialization.Model): + """UserArtifactManage. + + All required parameters must be populated in order to send to server. + + :ivar install: Required. The path and arguments to install the gallery application. This is + limited to 4096 characters. Required. + :vartype install: str + :ivar remove: Required. The path and arguments to remove the gallery application. This is + limited to 4096 characters. Required. + :vartype remove: str + :ivar update: Optional. The path and arguments to update the gallery application. If not + present, then update operation will invoke remove command on the previous version and install + command on the current version of the gallery application. This is limited to 4096 characters. + :vartype update: str + """ + + _validation = { + "install": {"required": True}, + "remove": {"required": True}, + } + + _attribute_map = { + "install": {"key": "install", "type": "str"}, + "remove": {"key": "remove", "type": "str"}, + "update": {"key": "update", "type": "str"}, + } + + def __init__(self, *, install: str, remove: str, update: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword install: Required. The path and arguments to install the gallery application. This is + limited to 4096 characters. Required. + :paramtype install: str + :keyword remove: Required. The path and arguments to remove the gallery application. This is + limited to 4096 characters. Required. + :paramtype remove: str + :keyword update: Optional. The path and arguments to update the gallery application. If not + present, then update operation will invoke remove command on the previous version and install + command on the current version of the gallery application. This is limited to 4096 characters. + :paramtype update: str + """ + super().__init__(**kwargs) + self.install = install + self.remove = remove + self.update = update + + +class UserArtifactSettings(_serialization.Model): + """Additional settings for the VM app that contains the target package and config file name when + it is deployed to target VM or VM scale set. + + :ivar package_file_name: Optional. The name to assign the downloaded package file on the VM. + This is limited to 4096 characters. If not specified, the package file will be named the same + as the Gallery Application name. + :vartype package_file_name: str + :ivar config_file_name: Optional. The name to assign the downloaded config file on the VM. This + is limited to 4096 characters. If not specified, the config file will be named the Gallery + Application name appended with "_config". + :vartype config_file_name: str + """ + + _attribute_map = { + "package_file_name": {"key": "packageFileName", "type": "str"}, + "config_file_name": {"key": "configFileName", "type": "str"}, + } + + def __init__( + self, *, package_file_name: Optional[str] = None, config_file_name: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword package_file_name: Optional. The name to assign the downloaded package file on the VM. + This is limited to 4096 characters. If not specified, the package file will be named the same + as the Gallery Application name. + :paramtype package_file_name: str + :keyword config_file_name: Optional. The name to assign the downloaded config file on the VM. + This is limited to 4096 characters. If not specified, the config file will be named the Gallery + Application name appended with "_config". + :paramtype config_file_name: str + """ + super().__init__(**kwargs) + self.package_file_name = package_file_name + self.config_file_name = config_file_name + + +class UserArtifactSource(_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 media_link: Required. The mediaLink of the artifact, must be a readable storage page + blob. Required. + :vartype media_link: str + :ivar default_configuration_link: Optional. The defaultConfigurationLink of the artifact, must + be a readable storage page blob. + :vartype default_configuration_link: str + """ + + _validation = { + "media_link": {"required": True}, + } + + _attribute_map = { + "media_link": {"key": "mediaLink", "type": "str"}, + "default_configuration_link": {"key": "defaultConfigurationLink", "type": "str"}, + } + + def __init__(self, *, media_link: str, default_configuration_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword media_link: Required. The mediaLink of the artifact, must be a readable storage page + blob. Required. + :paramtype media_link: str + :keyword default_configuration_link: Optional. The defaultConfigurationLink of the artifact, + must be a readable storage page blob. + :paramtype default_configuration_link: str + """ + super().__init__(**kwargs) + self.media_link = media_link + self.default_configuration_link = default_configuration_link + + class UserAssignedIdentitiesValue(_serialization.Model): """UserAssignedIdentitiesValue. @@ -9556,10 +18777,10 @@ class VaultSecretGroup(_serialization.Model): :ivar source_vault: The relative URL of the Key Vault containing all of the certificates in VaultCertificates. - :vartype source_vault: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype source_vault: ~azure.mgmt.compute.models.SubResource :ivar vault_certificates: The list of key vault references in SourceVault which contain certificates. - :vartype vault_certificates: list[~azure.mgmt.compute.v2024_11_01.models.VaultCertificate] + :vartype vault_certificates: list[~azure.mgmt.compute.models.VaultCertificate] """ _attribute_map = { @@ -9577,10 +18798,10 @@ def __init__( """ :keyword source_vault: The relative URL of the Key Vault containing all of the certificates in VaultCertificates. - :paramtype source_vault: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype source_vault: ~azure.mgmt.compute.models.SubResource :keyword vault_certificates: The list of key vault references in SourceVault which contain certificates. - :paramtype vault_certificates: list[~azure.mgmt.compute.v2024_11_01.models.VaultCertificate] + :paramtype vault_certificates: list[~azure.mgmt.compute.models.VaultCertificate] """ super().__init__(**kwargs) self.source_vault = source_vault @@ -9624,7 +18845,7 @@ class VirtualMachine(TrackedResource): :vartype type: str :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData + :vartype system_data: ~azure.mgmt.compute.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. @@ -9634,15 +18855,15 @@ class VirtualMachine(TrackedResource): image from an API, you must enable the image for programmatic use. In the Azure portal, find the marketplace image that you want to use and then click **Want to deploy programmatically, Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2024_11_01.models.Plan + :vartype plan: ~azure.mgmt.compute.models.Plan :ivar resources: The virtual machine child extension resources. - :vartype resources: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] + :vartype resources: list[~azure.mgmt.compute.models.VirtualMachineExtension] :ivar identity: The identity of the virtual machine, if configured. - :vartype identity: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineIdentity + :vartype identity: ~azure.mgmt.compute.models.VirtualMachineIdentity :ivar zones: The availability zones. :vartype zones: list[str] :ivar extended_location: The extended location of the Virtual Machine. - :vartype extended_location: ~azure.mgmt.compute.v2024_11_01.models.ExtendedLocation + :vartype extended_location: ~azure.mgmt.compute.models.ExtendedLocation :ivar managed_by: ManagedBy is set to Virtual Machine Scale Set(VMSS) flex ARM resourceID, if the VM is part of the VMSS. This property is used by platform for internal resource group delete optimization. @@ -9653,29 +18874,29 @@ class VirtualMachine(TrackedResource): :ivar placement: Placement section specifies the user-defined constraints for virtual machine hardware placement. This property cannot be changed once VM is provisioned. Minimum api-version: 2024-11-01. - :vartype placement: ~azure.mgmt.compute.v2024_11_01.models.Placement + :vartype placement: ~azure.mgmt.compute.models.Placement :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2024_11_01.models.HardwareProfile + :vartype hardware_profile: ~azure.mgmt.compute.models.HardwareProfile :ivar scheduled_events_policy: Specifies Redeploy, Reboot and ScheduledEventsAdditionalPublishingTargets Scheduled Event related configurations for the virtual machine. - :vartype scheduled_events_policy: ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsPolicy + :vartype scheduled_events_policy: ~azure.mgmt.compute.models.ScheduledEventsPolicy :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2024_11_01.models.StorageProfile + :vartype storage_profile: ~azure.mgmt.compute.models.StorageProfile :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the virtual machine. - :vartype additional_capabilities: ~azure.mgmt.compute.v2024_11_01.models.AdditionalCapabilities + :vartype additional_capabilities: ~azure.mgmt.compute.models.AdditionalCapabilities :ivar os_profile: Specifies the operating system settings used while creating the virtual machine. Some of the settings cannot be changed once VM is provisioned. - :vartype os_profile: ~azure.mgmt.compute.v2024_11_01.models.OSProfile + :vartype os_profile: ~azure.mgmt.compute.models.OSProfile :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2024_11_01.models.NetworkProfile + :vartype network_profile: ~azure.mgmt.compute.models.NetworkProfile :ivar security_profile: Specifies the Security related profile settings for the virtual machine. - :vartype security_profile: ~azure.mgmt.compute.v2024_11_01.models.SecurityProfile + :vartype security_profile: ~azure.mgmt.compute.models.SecurityProfile :ivar diagnostics_profile: Specifies the boot diagnostic settings state. Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2024_11_01.models.DiagnosticsProfile + :vartype diagnostics_profile: ~azure.mgmt.compute.models.DiagnosticsProfile :ivar availability_set: 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 @@ -9687,41 +18908,40 @@ class VirtualMachine(TrackedResource): VM is being added should be under the same resource group as the availability set resource. An existing VM cannot be added to an availability set. This property cannot exist along with a non-null properties.virtualMachineScaleSet reference. - :vartype availability_set: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype availability_set: ~azure.mgmt.compute.models.SubResource :ivar virtual_machine_scale_set: Specifies information about the virtual machine scale set that the virtual machine should be assigned to. Virtual machines specified in the same virtual machine scale set are allocated to different nodes to maximize availability. Currently, a VM can only be added to virtual machine scale set at creation time. An existing VM cannot be added to a virtual machine scale set. This property cannot exist along with a non-null properties.availabilitySet reference. Minimum api‐version: 2019‐03‐01. - :vartype virtual_machine_scale_set: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype virtual_machine_scale_set: ~azure.mgmt.compute.models.SubResource :ivar proximity_placement_group: Specifies information about the proximity placement group that the virtual machine should be assigned to. Minimum api-version: 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype proximity_placement_group: ~azure.mgmt.compute.models.SubResource :ivar priority: Specifies the priority for the virtual machine. Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :vartype priority: str or ~azure.mgmt.compute.v2024_11_01.models.VirtualMachinePriorityTypes + :vartype priority: str or ~azure.mgmt.compute.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and "Delete". - :vartype eviction_policy: str or - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineEvictionPolicyTypes + :vartype eviction_policy: str or ~azure.mgmt.compute.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2024_11_01.models.BillingProfile + :vartype billing_profile: ~azure.mgmt.compute.models.BillingProfile :ivar host: Specifies information about the dedicated host that the virtual machine resides in. Minimum api-version: 2018-10-01. - :vartype host: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype host: ~azure.mgmt.compute.models.SubResource :ivar host_group: Specifies information about the dedicated host group that the virtual machine resides in. **Note:** User cannot specify both host and hostGroup properties. Minimum api-version: 2020-06-01. - :vartype host_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype host_group: ~azure.mgmt.compute.models.SubResource :ivar provisioning_state: The provisioning state, which only appears in the response. :vartype provisioning_state: str :ivar instance_view: The virtual machine instance view. - :vartype instance_view: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstanceView + :vartype instance_view: ~azure.mgmt.compute.models.VirtualMachineInstanceView :ivar license_type: Specifies that the image or disk that is being used was licensed on-premises. :code:`
`\\ :code:`
` Possible values for Windows Server operating system are: :code:`
`\\ :code:`
` Windows_Client :code:`
`\\ :code:`
` Windows_Server @@ -9750,18 +18970,16 @@ class VirtualMachine(TrackedResource): can be viewed in the Virtual Machine Instance View. Minimum api‐version: 2020‐12‐01. :vartype platform_fault_domain: int :ivar scheduled_events_profile: Specifies Scheduled Event related configurations. - :vartype scheduled_events_profile: - ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsProfile + :vartype scheduled_events_profile: ~azure.mgmt.compute.models.ScheduledEventsProfile :ivar user_data: UserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here. Minimum api-version: 2021-03-01. :vartype user_data: str :ivar capacity_reservation: Specifies information about the capacity reservation that is used to allocate virtual machine. Minimum api-version: 2021-04-01. - :vartype capacity_reservation: - ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationProfile + :vartype capacity_reservation: ~azure.mgmt.compute.models.CapacityReservationProfile :ivar application_profile: Specifies the gallery applications that should be made available to the VM/VMSS. - :vartype application_profile: ~azure.mgmt.compute.v2024_11_01.models.ApplicationProfile + :vartype application_profile: ~azure.mgmt.compute.models.ApplicationProfile :ivar time_created: Specifies the time at which the Virtual Machine resource was created. Minimum api-version: 2021-11-01. :vartype time_created: ~datetime.datetime @@ -9871,41 +19089,39 @@ def __init__( # pylint: disable=too-many-locals image from an API, you must enable the image for programmatic use. In the Azure portal, find the marketplace image that you want to use and then click **Want to deploy programmatically, Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2024_11_01.models.Plan + :paramtype plan: ~azure.mgmt.compute.models.Plan :keyword identity: The identity of the virtual machine, if configured. - :paramtype identity: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineIdentity + :paramtype identity: ~azure.mgmt.compute.models.VirtualMachineIdentity :keyword zones: The availability zones. :paramtype zones: list[str] :keyword extended_location: The extended location of the Virtual Machine. - :paramtype extended_location: ~azure.mgmt.compute.v2024_11_01.models.ExtendedLocation + :paramtype extended_location: ~azure.mgmt.compute.models.ExtendedLocation :keyword placement: Placement section specifies the user-defined constraints for virtual machine hardware placement. This property cannot be changed once VM is provisioned. Minimum api-version: 2024-11-01. - :paramtype placement: ~azure.mgmt.compute.v2024_11_01.models.Placement + :paramtype placement: ~azure.mgmt.compute.models.Placement :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2024_11_01.models.HardwareProfile + :paramtype hardware_profile: ~azure.mgmt.compute.models.HardwareProfile :keyword scheduled_events_policy: Specifies Redeploy, Reboot and ScheduledEventsAdditionalPublishingTargets Scheduled Event related configurations for the virtual machine. - :paramtype scheduled_events_policy: - ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsPolicy + :paramtype scheduled_events_policy: ~azure.mgmt.compute.models.ScheduledEventsPolicy :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2024_11_01.models.StorageProfile + :paramtype storage_profile: ~azure.mgmt.compute.models.StorageProfile :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the virtual machine. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2024_11_01.models.AdditionalCapabilities + :paramtype additional_capabilities: ~azure.mgmt.compute.models.AdditionalCapabilities :keyword os_profile: Specifies the operating system settings used while creating the virtual machine. Some of the settings cannot be changed once VM is provisioned. - :paramtype os_profile: ~azure.mgmt.compute.v2024_11_01.models.OSProfile + :paramtype os_profile: ~azure.mgmt.compute.models.OSProfile :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2024_11_01.models.NetworkProfile + :paramtype network_profile: ~azure.mgmt.compute.models.NetworkProfile :keyword security_profile: Specifies the Security related profile settings for the virtual machine. - :paramtype security_profile: ~azure.mgmt.compute.v2024_11_01.models.SecurityProfile + :paramtype security_profile: ~azure.mgmt.compute.models.SecurityProfile :keyword diagnostics_profile: Specifies the boot diagnostic settings state. Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2024_11_01.models.DiagnosticsProfile + :paramtype diagnostics_profile: ~azure.mgmt.compute.models.DiagnosticsProfile :keyword availability_set: 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 @@ -9917,37 +19133,36 @@ def __init__( # pylint: disable=too-many-locals VM is being added should be under the same resource group as the availability set resource. An existing VM cannot be added to an availability set. This property cannot exist along with a non-null properties.virtualMachineScaleSet reference. - :paramtype availability_set: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype availability_set: ~azure.mgmt.compute.models.SubResource :keyword virtual_machine_scale_set: Specifies information about the virtual machine scale set that the virtual machine should be assigned to. Virtual machines specified in the same virtual machine scale set are allocated to different nodes to maximize availability. Currently, a VM can only be added to virtual machine scale set at creation time. An existing VM cannot be added to a virtual machine scale set. This property cannot exist along with a non-null properties.availabilitySet reference. Minimum api‐version: 2019‐03‐01. - :paramtype virtual_machine_scale_set: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype virtual_machine_scale_set: ~azure.mgmt.compute.models.SubResource :keyword proximity_placement_group: Specifies information about the proximity placement group that the virtual machine should be assigned to. Minimum api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype proximity_placement_group: ~azure.mgmt.compute.models.SubResource :keyword priority: Specifies the priority for the virtual machine. Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :paramtype priority: str or ~azure.mgmt.compute.v2024_11_01.models.VirtualMachinePriorityTypes + :paramtype priority: str or ~azure.mgmt.compute.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and "Delete". - :paramtype eviction_policy: str or - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineEvictionPolicyTypes + :paramtype eviction_policy: str or ~azure.mgmt.compute.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual machine. Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2024_11_01.models.BillingProfile + :paramtype billing_profile: ~azure.mgmt.compute.models.BillingProfile :keyword host: Specifies information about the dedicated host that the virtual machine resides in. Minimum api-version: 2018-10-01. - :paramtype host: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype host: ~azure.mgmt.compute.models.SubResource :keyword host_group: Specifies information about the dedicated host group that the virtual machine resides in. **Note:** User cannot specify both host and hostGroup properties. Minimum api-version: 2020-06-01. - :paramtype host_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype host_group: ~azure.mgmt.compute.models.SubResource :keyword license_type: Specifies that the image or disk that is being used was licensed on-premises. :code:`
`\\ :code:`
` Possible values for Windows Server operating system are: :code:`
`\\ :code:`
` Windows_Client :code:`
`\\ :code:`
` Windows_Server @@ -9973,18 +19188,16 @@ def __init__( # pylint: disable=too-many-locals can be viewed in the Virtual Machine Instance View. Minimum api‐version: 2020‐12‐01. :paramtype platform_fault_domain: int :keyword scheduled_events_profile: Specifies Scheduled Event related configurations. - :paramtype scheduled_events_profile: - ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsProfile + :paramtype scheduled_events_profile: ~azure.mgmt.compute.models.ScheduledEventsProfile :keyword user_data: UserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here. Minimum api-version: 2021-03-01. :paramtype user_data: str :keyword capacity_reservation: Specifies information about the capacity reservation that is used to allocate virtual machine. Minimum api-version: 2021-04-01. - :paramtype capacity_reservation: - ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationProfile + :paramtype capacity_reservation: ~azure.mgmt.compute.models.CapacityReservationProfile :keyword application_profile: Specifies the gallery applications that should be made available to the VM/VMSS. - :paramtype application_profile: ~azure.mgmt.compute.v2024_11_01.models.ApplicationProfile + :paramtype application_profile: ~azure.mgmt.compute.models.ApplicationProfile """ super().__init__(tags=tags, location=location, **kwargs) self.plan = plan @@ -10031,9 +19244,9 @@ class VirtualMachineAgentInstanceView(_serialization.Model): :vartype vm_agent_version: str :ivar extension_handlers: The virtual machine extension handler instance view. :vartype extension_handlers: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionHandlerInstanceView] + list[~azure.mgmt.compute.models.VirtualMachineExtensionHandlerInstanceView] :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :vartype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] """ _attribute_map = { @@ -10055,9 +19268,9 @@ def __init__( :paramtype vm_agent_version: str :keyword extension_handlers: The virtual machine extension handler instance view. :paramtype extension_handlers: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionHandlerInstanceView] + list[~azure.mgmt.compute.models.VirtualMachineExtensionHandlerInstanceView] :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :paramtype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] """ super().__init__(**kwargs) self.vm_agent_version = vm_agent_version @@ -10074,7 +19287,7 @@ class VirtualMachineAssessPatchesResult(_serialization.Model): until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", and "CompletedWithWarnings". - :vartype status: str or ~azure.mgmt.compute.v2024_11_01.models.PatchOperationStatus + :vartype status: str or ~azure.mgmt.compute.models.PatchOperationStatus :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. :vartype assessment_activity_id: str @@ -10092,10 +19305,10 @@ class VirtualMachineAssessPatchesResult(_serialization.Model): :ivar available_patches: The list of patches that have been detected as available for installation. :vartype available_patches: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSoftwarePatchProperties] + list[~azure.mgmt.compute.models.VirtualMachineSoftwarePatchProperties] :ivar error: The errors that were encountered during execution of the operation. The details array contains the list of them. - :vartype error: ~azure.mgmt.compute.v2024_11_01.models.ApiError + :vartype error: ~azure.mgmt.compute.models.ApiError """ _validation = { @@ -10238,7 +19451,7 @@ class VirtualMachineExtension(TrackedResource): :vartype type: str :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData + :vartype system_data: ~azure.mgmt.compute.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. @@ -10268,16 +19481,14 @@ class VirtualMachineExtension(TrackedResource): :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. - :vartype instance_view: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionInstanceView + :vartype instance_view: ~azure.mgmt.compute.models.VirtualMachineExtensionInstanceView :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. :vartype suppress_failures: bool :ivar protected_settings_from_key_vault: The extensions protected settings that are passed by reference, and consumed from key vault. - :vartype protected_settings_from_key_vault: - ~azure.mgmt.compute.v2024_11_01.models.KeyVaultSecretReference + :vartype protected_settings_from_key_vault: ~azure.mgmt.compute.models.KeyVaultSecretReference :ivar provision_after_extensions: Collection of extension names after which this extension needs to be provisioned. :vartype provision_after_extensions: list[str] @@ -10364,8 +19575,7 @@ def __init__( protectedSettingsFromKeyVault or no protected settings at all. :paramtype protected_settings: any :keyword instance_view: The virtual machine extension instance view. - :paramtype instance_view: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionInstanceView + :paramtype instance_view: ~azure.mgmt.compute.models.VirtualMachineExtensionInstanceView :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. @@ -10373,7 +19583,7 @@ def __init__( :keyword protected_settings_from_key_vault: The extensions protected settings that are passed by reference, and consumed from key vault. :paramtype protected_settings_from_key_vault: - ~azure.mgmt.compute.v2024_11_01.models.KeyVaultSecretReference + ~azure.mgmt.compute.models.KeyVaultSecretReference :keyword provision_after_extensions: Collection of extension names after which this extension needs to be provisioned. :paramtype provision_after_extensions: list[str] @@ -10402,7 +19612,7 @@ class VirtualMachineExtensionHandlerInstanceView(_serialization.Model): # pylin :ivar type_handler_version: Specifies the version of the script handler. :vartype type_handler_version: str :ivar status: The extension handler status. - :vartype status: ~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus + :vartype status: ~azure.mgmt.compute.models.InstanceViewStatus """ _attribute_map = { @@ -10425,7 +19635,7 @@ def __init__( :keyword type_handler_version: Specifies the version of the script handler. :paramtype type_handler_version: str :keyword status: The extension handler status. - :paramtype status: ~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus + :paramtype status: ~azure.mgmt.compute.models.InstanceViewStatus """ super().__init__(**kwargs) self.type = type @@ -10450,7 +19660,7 @@ class VirtualMachineExtensionImage(TrackedResource): :vartype type: str :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData + :vartype system_data: ~azure.mgmt.compute.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. @@ -10541,9 +19751,9 @@ class VirtualMachineExtensionInstanceView(_serialization.Model): :ivar type_handler_version: Specifies the version of the script handler. :vartype type_handler_version: str :ivar substatuses: The resource status information. - :vartype substatuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :vartype substatuses: list[~azure.mgmt.compute.models.InstanceViewStatus] :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :vartype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] """ _attribute_map = { @@ -10572,9 +19782,9 @@ def __init__( :keyword type_handler_version: Specifies the version of the script handler. :paramtype type_handler_version: str :keyword substatuses: The resource status information. - :paramtype substatuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :paramtype substatuses: list[~azure.mgmt.compute.models.InstanceViewStatus] :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :paramtype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] """ super().__init__(**kwargs) self.name = name @@ -10588,7 +19798,7 @@ class VirtualMachineExtensionsListResult(_serialization.Model): """The List Extension operation response. :ivar value: The list of extensions. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] + :vartype value: list[~azure.mgmt.compute.models.VirtualMachineExtension] """ _attribute_map = { @@ -10598,7 +19808,7 @@ class VirtualMachineExtensionsListResult(_serialization.Model): def __init__(self, *, value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs: Any) -> None: """ :keyword value: The list of extensions. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] + :paramtype value: list[~azure.mgmt.compute.models.VirtualMachineExtension] """ super().__init__(**kwargs) self.value = value @@ -10636,8 +19846,7 @@ class VirtualMachineExtensionUpdate(UpdateResource): :vartype suppress_failures: bool :ivar protected_settings_from_key_vault: The extensions protected settings that are passed by reference, and consumed from key vault. - :vartype protected_settings_from_key_vault: - ~azure.mgmt.compute.v2024_11_01.models.KeyVaultSecretReference + :vartype protected_settings_from_key_vault: ~azure.mgmt.compute.models.KeyVaultSecretReference """ _attribute_map = { @@ -10704,7 +19913,7 @@ def __init__( :keyword protected_settings_from_key_vault: The extensions protected settings that are passed by reference, and consumed from key vault. :paramtype protected_settings_from_key_vault: - ~azure.mgmt.compute.v2024_11_01.models.KeyVaultSecretReference + ~azure.mgmt.compute.models.KeyVaultSecretReference """ super().__init__(tags=tags, **kwargs) self.force_update_tag = force_update_tag @@ -10725,7 +19934,7 @@ class VirtualMachineHealthStatus(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar status: The health status information for the VM. - :vartype status: ~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus + :vartype status: ~azure.mgmt.compute.models.InstanceViewStatus """ _validation = { @@ -10757,12 +19966,12 @@ class VirtualMachineIdentity(_serialization.Model): UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :vartype type: str or ~azure.mgmt.compute.v2024_11_01.models.ResourceIdentityType + :vartype type: str or ~azure.mgmt.compute.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. :vartype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2024_11_01.models.UserAssignedIdentitiesValue] + ~azure.mgmt.compute.models.UserAssignedIdentitiesValue] """ _validation = { @@ -10789,12 +19998,12 @@ def __init__( UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :paramtype type: str or ~azure.mgmt.compute.v2024_11_01.models.ResourceIdentityType + :paramtype type: str or ~azure.mgmt.compute.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2024_11_01.models.UserAssignedIdentitiesValue] + ~azure.mgmt.compute.models.UserAssignedIdentitiesValue] """ super().__init__(**kwargs) self.principal_id: Optional[str] = None @@ -10819,7 +20028,7 @@ class VirtualMachineImageResource(SubResource): `_. :vartype tags: dict[str, str] :ivar extended_location: The extended location of the Virtual Machine. - :vartype extended_location: ~azure.mgmt.compute.v2024_11_01.models.ExtendedLocation + :vartype extended_location: ~azure.mgmt.compute.models.ExtendedLocation """ _validation = { @@ -10857,7 +20066,7 @@ def __init__( `_. :paramtype tags: dict[str, str] :keyword extended_location: The extended location of the Virtual Machine. - :paramtype extended_location: ~azure.mgmt.compute.v2024_11_01.models.ExtendedLocation + :paramtype extended_location: ~azure.mgmt.compute.models.ExtendedLocation """ super().__init__(id=id, **kwargs) self.name = name @@ -10882,30 +20091,28 @@ class VirtualMachineImage(VirtualMachineImageResource): `_. :vartype tags: dict[str, str] :ivar extended_location: The extended location of the Virtual Machine. - :vartype extended_location: ~azure.mgmt.compute.v2024_11_01.models.ExtendedLocation + :vartype extended_location: ~azure.mgmt.compute.models.ExtendedLocation :ivar plan: Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. - :vartype plan: ~azure.mgmt.compute.v2024_11_01.models.PurchasePlan + :vartype plan: ~azure.mgmt.compute.models.PurchasePlan :ivar os_disk_image: Contains the os disk image information. - :vartype os_disk_image: ~azure.mgmt.compute.v2024_11_01.models.OSDiskImage + :vartype os_disk_image: ~azure.mgmt.compute.models.OSDiskImage :ivar data_disk_images: The list of data disk images information. - :vartype data_disk_images: list[~azure.mgmt.compute.v2024_11_01.models.DataDiskImage] + :vartype data_disk_images: list[~azure.mgmt.compute.models.DataDiskImage] :ivar automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. :vartype automatic_os_upgrade_properties: - ~azure.mgmt.compute.v2024_11_01.models.AutomaticOSUpgradeProperties + ~azure.mgmt.compute.models.AutomaticOSUpgradeProperties :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or - ~azure.mgmt.compute.v2024_11_01.models.HyperVGenerationTypes + :vartype hyper_v_generation: str or ~azure.mgmt.compute.models.HyperVGenerationTypes :ivar disallowed: Specifies disallowed configuration for the VirtualMachine created from the image. - :vartype disallowed: ~azure.mgmt.compute.v2024_11_01.models.DisallowedConfiguration + :vartype disallowed: ~azure.mgmt.compute.models.DisallowedConfiguration :ivar features: - :vartype features: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageFeature] + :vartype features: list[~azure.mgmt.compute.models.VirtualMachineImageFeature] :ivar architecture: Specifies the Architecture Type. Known values are: "x64" and "Arm64". - :vartype architecture: str or ~azure.mgmt.compute.v2024_11_01.models.ArchitectureTypes + :vartype architecture: str or ~azure.mgmt.compute.models.ArchitectureTypes :ivar image_deprecation_status: Describes image deprecation status properties on the image. - :vartype image_deprecation_status: - ~azure.mgmt.compute.v2024_11_01.models.ImageDeprecationStatus + :vartype image_deprecation_status: ~azure.mgmt.compute.models.ImageDeprecationStatus """ _validation = { @@ -10964,32 +20171,30 @@ def __init__( `_. :paramtype tags: dict[str, str] :keyword extended_location: The extended location of the Virtual Machine. - :paramtype extended_location: ~azure.mgmt.compute.v2024_11_01.models.ExtendedLocation + :paramtype extended_location: ~azure.mgmt.compute.models.ExtendedLocation :keyword plan: Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. - :paramtype plan: ~azure.mgmt.compute.v2024_11_01.models.PurchasePlan + :paramtype plan: ~azure.mgmt.compute.models.PurchasePlan :keyword os_disk_image: Contains the os disk image information. - :paramtype os_disk_image: ~azure.mgmt.compute.v2024_11_01.models.OSDiskImage + :paramtype os_disk_image: ~azure.mgmt.compute.models.OSDiskImage :keyword data_disk_images: The list of data disk images information. - :paramtype data_disk_images: list[~azure.mgmt.compute.v2024_11_01.models.DataDiskImage] + :paramtype data_disk_images: list[~azure.mgmt.compute.models.DataDiskImage] :keyword automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. :paramtype automatic_os_upgrade_properties: - ~azure.mgmt.compute.v2024_11_01.models.AutomaticOSUpgradeProperties + ~azure.mgmt.compute.models.AutomaticOSUpgradeProperties :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2024_11_01.models.HyperVGenerationTypes + :paramtype hyper_v_generation: str or ~azure.mgmt.compute.models.HyperVGenerationTypes :keyword disallowed: Specifies disallowed configuration for the VirtualMachine created from the image. - :paramtype disallowed: ~azure.mgmt.compute.v2024_11_01.models.DisallowedConfiguration + :paramtype disallowed: ~azure.mgmt.compute.models.DisallowedConfiguration :keyword features: - :paramtype features: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageFeature] + :paramtype features: list[~azure.mgmt.compute.models.VirtualMachineImageFeature] :keyword architecture: Specifies the Architecture Type. Known values are: "x64" and "Arm64". - :paramtype architecture: str or ~azure.mgmt.compute.v2024_11_01.models.ArchitectureTypes + :paramtype architecture: str or ~azure.mgmt.compute.models.ArchitectureTypes :keyword image_deprecation_status: Describes image deprecation status properties on the image. - :paramtype image_deprecation_status: - ~azure.mgmt.compute.v2024_11_01.models.ImageDeprecationStatus + :paramtype image_deprecation_status: ~azure.mgmt.compute.models.ImageDeprecationStatus """ super().__init__(id=id, name=name, location=location, tags=tags, extended_location=extended_location, **kwargs) self.plan = plan @@ -11039,14 +20244,13 @@ class VirtualMachineInstallPatchesParameters(_serialization.Model): :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 - ~azure.mgmt.compute.v2024_11_01.models.VMGuestPatchRebootSetting + :vartype reboot_setting: str or ~azure.mgmt.compute.models.VMGuestPatchRebootSetting :ivar windows_parameters: Input for InstallPatches on a Windows VM, as directly received by the API. - :vartype windows_parameters: ~azure.mgmt.compute.v2024_11_01.models.WindowsParameters + :vartype windows_parameters: ~azure.mgmt.compute.models.WindowsParameters :ivar linux_parameters: Input for InstallPatches on a Linux VM, as directly received by the API. - :vartype linux_parameters: ~azure.mgmt.compute.v2024_11_01.models.LinuxParameters + :vartype linux_parameters: ~azure.mgmt.compute.models.LinuxParameters """ _validation = { @@ -11075,14 +20279,13 @@ def __init__( :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 - ~azure.mgmt.compute.v2024_11_01.models.VMGuestPatchRebootSetting + :paramtype reboot_setting: str or ~azure.mgmt.compute.models.VMGuestPatchRebootSetting :keyword windows_parameters: Input for InstallPatches on a Windows VM, as directly received by the API. - :paramtype windows_parameters: ~azure.mgmt.compute.v2024_11_01.models.WindowsParameters + :paramtype windows_parameters: ~azure.mgmt.compute.models.WindowsParameters :keyword linux_parameters: Input for InstallPatches on a Linux VM, as directly received by the API. - :paramtype linux_parameters: ~azure.mgmt.compute.v2024_11_01.models.LinuxParameters + :paramtype linux_parameters: ~azure.mgmt.compute.models.LinuxParameters """ super().__init__(**kwargs) self.maximum_duration = maximum_duration @@ -11100,13 +20303,13 @@ class VirtualMachineInstallPatchesResult(_serialization.Model): until the operation completes. At that point it will become "Failed", "Succeeded", "Unknown" or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", and "CompletedWithWarnings". - :vartype status: str or ~azure.mgmt.compute.v2024_11_01.models.PatchOperationStatus + :vartype status: str or ~azure.mgmt.compute.models.PatchOperationStatus :ivar installation_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. :vartype installation_activity_id: str :ivar reboot_status: The reboot state of the VM following completion of the operation. Known values are: "Unknown", "NotNeeded", "Required", "Started", "Failed", and "Completed". - :vartype reboot_status: str or ~azure.mgmt.compute.v2024_11_01.models.VMGuestPatchRebootStatus + :vartype reboot_status: str or ~azure.mgmt.compute.models.VMGuestPatchRebootStatus :ivar maintenance_window_exceeded: Whether the operation ran out of time before it completed all its intended actions. :vartype maintenance_window_exceeded: bool @@ -11126,12 +20329,12 @@ class VirtualMachineInstallPatchesResult(_serialization.Model): See errors for details. :vartype failed_patch_count: int :ivar patches: The patches that were installed during the operation. - :vartype patches: list[~azure.mgmt.compute.v2024_11_01.models.PatchInstallationDetail] + :vartype patches: list[~azure.mgmt.compute.models.PatchInstallationDetail] :ivar start_date_time: The UTC timestamp when the operation began. :vartype start_date_time: ~datetime.datetime :ivar error: The errors that were encountered during execution of the operation. The details array contains the list of them. - :vartype error: ~azure.mgmt.compute.v2024_11_01.models.ApiError + :vartype error: ~azure.mgmt.compute.models.ApiError """ _validation = { @@ -11198,33 +20401,31 @@ class VirtualMachineInstanceView(_serialization.Model): :vartype os_version: str :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2024_11_01.models.HyperVGenerationType + :vartype hyper_v_generation: str or ~azure.mgmt.compute.models.HyperVGenerationType :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. :vartype rdp_thumb_print: str :ivar vm_agent: The VM Agent running on the virtual machine. - :vartype vm_agent: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineAgentInstanceView + :vartype vm_agent: ~azure.mgmt.compute.models.VirtualMachineAgentInstanceView :ivar maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :vartype maintenance_redeploy_status: - ~azure.mgmt.compute.v2024_11_01.models.MaintenanceRedeployStatus + :vartype maintenance_redeploy_status: ~azure.mgmt.compute.models.MaintenanceRedeployStatus :ivar disks: The virtual machine disk information. - :vartype disks: list[~azure.mgmt.compute.v2024_11_01.models.DiskInstanceView] + :vartype disks: list[~azure.mgmt.compute.models.DiskInstanceView] :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionInstanceView] + :vartype extensions: list[~azure.mgmt.compute.models.VirtualMachineExtensionInstanceView] :ivar vm_health: The health status for the VM. - :vartype vm_health: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineHealthStatus + :vartype vm_health: ~azure.mgmt.compute.models.VirtualMachineHealthStatus :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view Console Output and Screenshot to diagnose VM status. You can easily view the output of your console log. Azure also enables you to see a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2024_11_01.models.BootDiagnosticsInstanceView + :vartype boot_diagnostics: ~azure.mgmt.compute.models.BootDiagnosticsInstanceView :ivar assigned_host: Resource id of the dedicated host, on which the virtual machine is allocated through automatic placement, when the virtual machine is associated with a dedicated host group that has automatic placement enabled. Minimum api-version: 2020-06-01. :vartype assigned_host: str :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :vartype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] :ivar patch_status: [Preview Feature] The status of virtual machine patch operations. - :vartype patch_status: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachinePatchStatus + :vartype patch_status: ~azure.mgmt.compute.models.VirtualMachinePatchStatus :ivar is_vm_in_standby_pool: [Preview Feature] Specifies whether the VM is currently in or out of the Standby Pool. :vartype is_vm_in_standby_pool: bool @@ -11288,28 +20489,25 @@ def __init__( :paramtype os_version: str :keyword hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2024_11_01.models.HyperVGenerationType + :paramtype hyper_v_generation: str or ~azure.mgmt.compute.models.HyperVGenerationType :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. :paramtype rdp_thumb_print: str :keyword vm_agent: The VM Agent running on the virtual machine. - :paramtype vm_agent: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineAgentInstanceView + :paramtype vm_agent: ~azure.mgmt.compute.models.VirtualMachineAgentInstanceView :keyword maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :paramtype maintenance_redeploy_status: - ~azure.mgmt.compute.v2024_11_01.models.MaintenanceRedeployStatus + :paramtype maintenance_redeploy_status: ~azure.mgmt.compute.models.MaintenanceRedeployStatus :keyword disks: The virtual machine disk information. - :paramtype disks: list[~azure.mgmt.compute.v2024_11_01.models.DiskInstanceView] + :paramtype disks: list[~azure.mgmt.compute.models.DiskInstanceView] :keyword extensions: The extensions information. - :paramtype extensions: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionInstanceView] + :paramtype extensions: list[~azure.mgmt.compute.models.VirtualMachineExtensionInstanceView] :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view Console Output and Screenshot to diagnose VM status. You can easily view the output of your console log. Azure also enables you to see a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2024_11_01.models.BootDiagnosticsInstanceView + :paramtype boot_diagnostics: ~azure.mgmt.compute.models.BootDiagnosticsInstanceView :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :paramtype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] :keyword patch_status: [Preview Feature] The status of virtual machine patch operations. - :paramtype patch_status: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachinePatchStatus + :paramtype patch_status: ~azure.mgmt.compute.models.VirtualMachinePatchStatus """ super().__init__(**kwargs) self.platform_update_domain = platform_update_domain @@ -11363,7 +20561,7 @@ class VirtualMachineListResult(_serialization.Model): All required parameters must be populated in order to send to server. :ivar value: The list of virtual machines. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :vartype value: list[~azure.mgmt.compute.models.VirtualMachine] :ivar next_link: The URI to fetch the next page of VMs. Call ListNext() with this URI to fetch the next page of Virtual Machines. :vartype next_link: str @@ -11383,7 +20581,7 @@ def __init__( ) -> None: """ :keyword value: The list of virtual machines. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :paramtype value: list[~azure.mgmt.compute.models.VirtualMachine] :keyword next_link: The URI to fetch the next page of VMs. Call ListNext() with this URI to fetch the next page of Virtual Machines. :paramtype next_link: str @@ -11405,7 +20603,7 @@ class VirtualMachineNetworkInterfaceConfiguration(_serialization.Model): # pyli :vartype primary: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. Known values are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DeleteOptions + :vartype delete_option: str or ~azure.mgmt.compute.models.DeleteOptions :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated networking-enabled. :vartype enable_accelerated_networking: bool @@ -11417,23 +20615,21 @@ class VirtualMachineNetworkInterfaceConfiguration(_serialization.Model): # pyli :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :vartype enable_ip_forwarding: bool :ivar network_security_group: The network security group. - :vartype network_security_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype network_security_group: ~azure.mgmt.compute.models.SubResource :ivar dns_settings: The dns settings to be applied on the network interfaces. :vartype dns_settings: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineNetworkInterfaceDnsSettingsConfiguration + ~azure.mgmt.compute.models.VirtualMachineNetworkInterfaceDnsSettingsConfiguration :ivar ip_configurations: Specifies the IP configurations of the network interface. :vartype ip_configurations: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineNetworkInterfaceIPConfiguration] + list[~azure.mgmt.compute.models.VirtualMachineNetworkInterfaceIPConfiguration] :ivar dscp_configuration: - :vartype dscp_configuration: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype dscp_configuration: ~azure.mgmt.compute.models.SubResource :ivar auxiliary_mode: Specifies whether the Auxiliary mode is enabled for the Network Interface resource. Known values are: "None", "AcceleratedConnections", and "Floating". - :vartype auxiliary_mode: str or - ~azure.mgmt.compute.v2024_11_01.models.NetworkInterfaceAuxiliaryMode + :vartype auxiliary_mode: str or ~azure.mgmt.compute.models.NetworkInterfaceAuxiliaryMode :ivar auxiliary_sku: Specifies whether the Auxiliary sku is enabled for the Network Interface resource. Known values are: "None", "A1", "A2", "A4", and "A8". - :vartype auxiliary_sku: str or - ~azure.mgmt.compute.v2024_11_01.models.NetworkInterfaceAuxiliarySku + :vartype auxiliary_sku: str or ~azure.mgmt.compute.models.NetworkInterfaceAuxiliarySku """ _validation = { @@ -11488,7 +20684,7 @@ def __init__( :paramtype primary: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. Known values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DeleteOptions + :paramtype delete_option: str or ~azure.mgmt.compute.models.DeleteOptions :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated networking-enabled. :paramtype enable_accelerated_networking: bool @@ -11500,23 +20696,21 @@ def __init__( :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :paramtype enable_ip_forwarding: bool :keyword network_security_group: The network security group. - :paramtype network_security_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype network_security_group: ~azure.mgmt.compute.models.SubResource :keyword dns_settings: The dns settings to be applied on the network interfaces. :paramtype dns_settings: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineNetworkInterfaceDnsSettingsConfiguration + ~azure.mgmt.compute.models.VirtualMachineNetworkInterfaceDnsSettingsConfiguration :keyword ip_configurations: Specifies the IP configurations of the network interface. :paramtype ip_configurations: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineNetworkInterfaceIPConfiguration] + list[~azure.mgmt.compute.models.VirtualMachineNetworkInterfaceIPConfiguration] :keyword dscp_configuration: - :paramtype dscp_configuration: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype dscp_configuration: ~azure.mgmt.compute.models.SubResource :keyword auxiliary_mode: Specifies whether the Auxiliary mode is enabled for the Network Interface resource. Known values are: "None", "AcceleratedConnections", and "Floating". - :paramtype auxiliary_mode: str or - ~azure.mgmt.compute.v2024_11_01.models.NetworkInterfaceAuxiliaryMode + :paramtype auxiliary_mode: str or ~azure.mgmt.compute.models.NetworkInterfaceAuxiliaryMode :keyword auxiliary_sku: Specifies whether the Auxiliary sku is enabled for the Network Interface resource. Known values are: "None", "A1", "A2", "A4", and "A8". - :paramtype auxiliary_sku: str or - ~azure.mgmt.compute.v2024_11_01.models.NetworkInterfaceAuxiliarySku + :paramtype auxiliary_sku: str or ~azure.mgmt.compute.models.NetworkInterfaceAuxiliarySku """ super().__init__(**kwargs) self.name = name @@ -11562,32 +20756,31 @@ class VirtualMachineNetworkInterfaceIPConfiguration(_serialization.Model): # py :ivar name: The IP configuration name. Required. :vartype name: str :ivar subnet: Specifies the identifier of the subnet. - :vartype subnet: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype subnet: ~azure.mgmt.compute.models.SubResource :ivar primary: Specifies the primary network interface in case the virtual machine has more than 1 network interface. :vartype primary: bool :ivar public_ip_address_configuration: The publicIPAddressConfiguration. :vartype public_ip_address_configuration: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachinePublicIPAddressConfiguration + ~azure.mgmt.compute.models.VirtualMachinePublicIPAddressConfiguration :ivar private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2024_11_01.models.IPVersions + :vartype private_ip_address_version: str or ~azure.mgmt.compute.models.IPVersions :ivar application_security_groups: Specifies an array of references to application security group. - :vartype application_security_groups: list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :vartype application_security_groups: list[~azure.mgmt.compute.models.SubResource] :ivar application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A virtual machine can reference backend address pools of multiple application gateways. Multiple virtual machines cannot use the same application gateway. :vartype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + list[~azure.mgmt.compute.models.SubResource] :ivar load_balancer_backend_address_pools: Specifies an array of references to backend address pools of load balancers. A virtual machine can reference backend address pools of one public and one internal load balancer. [Multiple virtual machines cannot use the same basic sku load balancer]. - :vartype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :vartype load_balancer_backend_address_pools: list[~azure.mgmt.compute.models.SubResource] """ _validation = { @@ -11631,33 +20824,31 @@ def __init__( :keyword name: The IP configuration name. Required. :paramtype name: str :keyword subnet: Specifies the identifier of the subnet. - :paramtype subnet: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype subnet: ~azure.mgmt.compute.models.SubResource :keyword primary: Specifies the primary network interface in case the virtual machine has more than 1 network interface. :paramtype primary: bool :keyword public_ip_address_configuration: The publicIPAddressConfiguration. :paramtype public_ip_address_configuration: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachinePublicIPAddressConfiguration + ~azure.mgmt.compute.models.VirtualMachinePublicIPAddressConfiguration :keyword private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2024_11_01.models.IPVersions + :paramtype private_ip_address_version: str or ~azure.mgmt.compute.models.IPVersions :keyword application_security_groups: Specifies an array of references to application security group. - :paramtype application_security_groups: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :paramtype application_security_groups: list[~azure.mgmt.compute.models.SubResource] :keyword application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A virtual machine can reference backend address pools of multiple application gateways. Multiple virtual machines cannot use the same application gateway. :paramtype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + list[~azure.mgmt.compute.models.SubResource] :keyword load_balancer_backend_address_pools: Specifies an array of references to backend address pools of load balancers. A virtual machine can reference backend address pools of one public and one internal load balancer. [Multiple virtual machines cannot use the same basic sku load balancer]. - :paramtype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :paramtype load_balancer_backend_address_pools: list[~azure.mgmt.compute.models.SubResource] """ super().__init__(**kwargs) self.name = name @@ -11677,14 +20868,13 @@ class VirtualMachinePatchStatus(_serialization.Model): :ivar available_patch_summary: The available patch summary of the latest assessment operation for the virtual machine. - :vartype available_patch_summary: ~azure.mgmt.compute.v2024_11_01.models.AvailablePatchSummary + :vartype available_patch_summary: ~azure.mgmt.compute.models.AvailablePatchSummary :ivar last_patch_installation_summary: The installation summary of the latest installation operation for the virtual machine. :vartype last_patch_installation_summary: - ~azure.mgmt.compute.v2024_11_01.models.LastPatchInstallationSummary + ~azure.mgmt.compute.models.LastPatchInstallationSummary :ivar configuration_statuses: The enablement status of the specified patchMode. - :vartype configuration_statuses: - list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :vartype configuration_statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] """ _validation = { @@ -11710,12 +20900,11 @@ def __init__( """ :keyword available_patch_summary: The available patch summary of the latest assessment operation for the virtual machine. - :paramtype available_patch_summary: - ~azure.mgmt.compute.v2024_11_01.models.AvailablePatchSummary + :paramtype available_patch_summary: ~azure.mgmt.compute.models.AvailablePatchSummary :keyword last_patch_installation_summary: The installation summary of the latest installation operation for the virtual machine. :paramtype last_patch_installation_summary: - ~azure.mgmt.compute.v2024_11_01.models.LastPatchInstallationSummary + ~azure.mgmt.compute.models.LastPatchInstallationSummary """ super().__init__(**kwargs) self.available_patch_summary = available_patch_summary @@ -11731,27 +20920,27 @@ class VirtualMachinePublicIPAddressConfiguration(_serialization.Model): # pylin :ivar name: The publicIP address configuration name. Required. :vartype name: str :ivar sku: Describes the public IP Sku. It can only be set with OrchestrationMode as Flexible. - :vartype sku: ~azure.mgmt.compute.v2024_11_01.models.PublicIPAddressSku + :vartype sku: ~azure.mgmt.compute.models.PublicIPAddressSku :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. :vartype idle_timeout_in_minutes: int :ivar delete_option: Specify what happens to the public IP address when the VM is deleted. Known values are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DeleteOptions + :vartype delete_option: str or ~azure.mgmt.compute.models.DeleteOptions :ivar dns_settings: The dns settings to be applied on the publicIP addresses . :vartype dns_settings: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachinePublicIPAddressDnsSettingsConfiguration + ~azure.mgmt.compute.models.VirtualMachinePublicIPAddressDnsSettingsConfiguration :ivar ip_tags: The list of IP tags associated with the public IP address. - :vartype ip_tags: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineIpTag] + :vartype ip_tags: list[~azure.mgmt.compute.models.VirtualMachineIpTag] :ivar public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. - :vartype public_ip_prefix: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype public_ip_prefix: ~azure.mgmt.compute.models.SubResource :ivar public_ip_address_version: 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 'IPv6'. Known values are: "IPv4" and "IPv6". - :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2024_11_01.models.IPVersions + :vartype public_ip_address_version: str or ~azure.mgmt.compute.models.IPVersions :ivar public_ip_allocation_method: Specify the public IP allocation type. Known values are: "Dynamic" and "Static". :vartype public_ip_allocation_method: str or - ~azure.mgmt.compute.v2024_11_01.models.PublicIPAllocationMethod + ~azure.mgmt.compute.models.PublicIPAllocationMethod """ _validation = { @@ -11792,27 +20981,27 @@ def __init__( :paramtype name: str :keyword sku: Describes the public IP Sku. It can only be set with OrchestrationMode as Flexible. - :paramtype sku: ~azure.mgmt.compute.v2024_11_01.models.PublicIPAddressSku + :paramtype sku: ~azure.mgmt.compute.models.PublicIPAddressSku :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. :paramtype idle_timeout_in_minutes: int :keyword delete_option: Specify what happens to the public IP address when the VM is deleted. Known values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DeleteOptions + :paramtype delete_option: str or ~azure.mgmt.compute.models.DeleteOptions :keyword dns_settings: The dns settings to be applied on the publicIP addresses . :paramtype dns_settings: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachinePublicIPAddressDnsSettingsConfiguration + ~azure.mgmt.compute.models.VirtualMachinePublicIPAddressDnsSettingsConfiguration :keyword ip_tags: The list of IP tags associated with the public IP address. - :paramtype ip_tags: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineIpTag] + :paramtype ip_tags: list[~azure.mgmt.compute.models.VirtualMachineIpTag] :keyword public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. - :paramtype public_ip_prefix: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype public_ip_prefix: ~azure.mgmt.compute.models.SubResource :keyword public_ip_address_version: 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 'IPv6'. Known values are: "IPv4" and "IPv6". - :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2024_11_01.models.IPVersions + :paramtype public_ip_address_version: str or ~azure.mgmt.compute.models.IPVersions :keyword public_ip_allocation_method: Specify the public IP allocation type. Known values are: "Dynamic" and "Static". :paramtype public_ip_allocation_method: str or - ~azure.mgmt.compute.v2024_11_01.models.PublicIPAllocationMethod + ~azure.mgmt.compute.models.PublicIPAllocationMethod """ super().__init__(**kwargs) self.name = name @@ -11839,8 +21028,7 @@ class VirtualMachinePublicIPAddressDnsSettingsConfiguration(_serialization.Model that will be created. The generated name label is the concatenation of the hashed domain name label with policy according to the domain name label scope and vm network profile unique ID. Known values are: "TenantReuse", "SubscriptionReuse", "ResourceGroupReuse", and "NoReuse". - :vartype domain_name_label_scope: str or - ~azure.mgmt.compute.v2024_11_01.models.DomainNameLabelScopeTypes + :vartype domain_name_label_scope: str or ~azure.mgmt.compute.models.DomainNameLabelScopeTypes """ _validation = { @@ -11868,8 +21056,7 @@ def __init__( that will be created. The generated name label is the concatenation of the hashed domain name label with policy according to the domain name label scope and vm network profile unique ID. Known values are: "TenantReuse", "SubscriptionReuse", "ResourceGroupReuse", and "NoReuse". - :paramtype domain_name_label_scope: str or - ~azure.mgmt.compute.v2024_11_01.models.DomainNameLabelScopeTypes + :paramtype domain_name_label_scope: str or ~azure.mgmt.compute.models.DomainNameLabelScopeTypes """ super().__init__(**kwargs) self.domain_name_label = domain_name_label @@ -11888,7 +21075,7 @@ class VirtualMachineReimageParameters(_serialization.Model): Disk. :vartype exact_version: str :ivar os_profile: Specifies information required for reimaging the non-ephemeral OS disk. - :vartype os_profile: ~azure.mgmt.compute.v2024_11_01.models.OSProfileProvisioningData + :vartype os_profile: ~azure.mgmt.compute.models.OSProfileProvisioningData """ _attribute_map = { @@ -11914,7 +21101,7 @@ def __init__( Disk. :paramtype exact_version: str :keyword os_profile: Specifies information required for reimaging the non-ephemeral OS disk. - :paramtype os_profile: ~azure.mgmt.compute.v2024_11_01.models.OSProfileProvisioningData + :paramtype os_profile: ~azure.mgmt.compute.models.OSProfileProvisioningData """ super().__init__(**kwargs) self.temp_disk = temp_disk @@ -11939,18 +21126,17 @@ class VirtualMachineRunCommand(TrackedResource): :vartype type: str :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData + :vartype system_data: ~azure.mgmt.compute.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar source: The source of the run command script. - :vartype source: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandScriptSource + :vartype source: ~azure.mgmt.compute.models.VirtualMachineRunCommandScriptSource :ivar parameters: The parameters used by the script. - :vartype parameters: list[~azure.mgmt.compute.v2024_11_01.models.RunCommandInputParameter] + :vartype parameters: list[~azure.mgmt.compute.models.RunCommandInputParameter] :ivar protected_parameters: The parameters used by the script. - :vartype protected_parameters: - list[~azure.mgmt.compute.v2024_11_01.models.RunCommandInputParameter] + :vartype protected_parameters: list[~azure.mgmt.compute.models.RunCommandInputParameter] :ivar async_execution: Optional. If set to true, provisioning will complete as soon as the script starts and will not wait for script to complete. :vartype async_execution: bool @@ -11975,16 +21161,14 @@ class VirtualMachineRunCommand(TrackedResource): role assignment. In case of user-assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged. - :vartype output_blob_managed_identity: - ~azure.mgmt.compute.v2024_11_01.models.RunCommandManagedIdentity + :vartype output_blob_managed_identity: ~azure.mgmt.compute.models.RunCommandManagedIdentity :ivar error_blob_managed_identity: User-assigned managed identity that has access to errorBlobUri storage blob. Use an empty object in case of system-assigned identity. Make sure managed identity has been given access to blob's container with 'Storage Blob Data Contributor' role assignment. In case of user-assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged. - :vartype error_blob_managed_identity: - ~azure.mgmt.compute.v2024_11_01.models.RunCommandManagedIdentity + :vartype error_blob_managed_identity: ~azure.mgmt.compute.models.RunCommandManagedIdentity :ivar provisioning_state: The provisioning state, which only appears in the response. If treatFailureAsDeploymentFailure set to true, any failure in the script will fail the deployment and ProvisioningState will be marked as Failed. If treatFailureAsDeploymentFailure set to @@ -11994,8 +21178,7 @@ class VirtualMachineRunCommand(TrackedResource): error: https://aka.ms/runcommandmanaged#get-execution-status-and-results. :vartype provisioning_state: str :ivar instance_view: The virtual machine run command instance view. - :vartype instance_view: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandInstanceView + :vartype instance_view: ~azure.mgmt.compute.models.VirtualMachineRunCommandInstanceView :ivar treat_failure_as_deployment_failure: Optional. If set to true, any failure in the script will fail the deployment and ProvisioningState will be marked as Failed. If set to false, ProvisioningState would only reflect whether the run command was run or not by the extensions @@ -12069,12 +21252,11 @@ def __init__( :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword source: The source of the run command script. - :paramtype source: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandScriptSource + :paramtype source: ~azure.mgmt.compute.models.VirtualMachineRunCommandScriptSource :keyword parameters: The parameters used by the script. - :paramtype parameters: list[~azure.mgmt.compute.v2024_11_01.models.RunCommandInputParameter] + :paramtype parameters: list[~azure.mgmt.compute.models.RunCommandInputParameter] :keyword protected_parameters: The parameters used by the script. - :paramtype protected_parameters: - list[~azure.mgmt.compute.v2024_11_01.models.RunCommandInputParameter] + :paramtype protected_parameters: list[~azure.mgmt.compute.models.RunCommandInputParameter] :keyword async_execution: Optional. If set to true, provisioning will complete as soon as the script starts and will not wait for script to complete. :paramtype async_execution: bool @@ -12099,16 +21281,14 @@ def __init__( role assignment. In case of user-assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged. - :paramtype output_blob_managed_identity: - ~azure.mgmt.compute.v2024_11_01.models.RunCommandManagedIdentity + :paramtype output_blob_managed_identity: ~azure.mgmt.compute.models.RunCommandManagedIdentity :keyword error_blob_managed_identity: User-assigned managed identity that has access to errorBlobUri storage blob. Use an empty object in case of system-assigned identity. Make sure managed identity has been given access to blob's container with 'Storage Blob Data Contributor' role assignment. In case of user-assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged. - :paramtype error_blob_managed_identity: - ~azure.mgmt.compute.v2024_11_01.models.RunCommandManagedIdentity + :paramtype error_blob_managed_identity: ~azure.mgmt.compute.models.RunCommandManagedIdentity :keyword treat_failure_as_deployment_failure: Optional. If set to true, any failure in the script will fail the deployment and ProvisioningState will be marked as Failed. If set to false, ProvisioningState would only reflect whether the run command was run or not by the @@ -12139,7 +21319,7 @@ class VirtualMachineRunCommandInstanceView(_serialization.Model): :ivar execution_state: Script execution status. Known values are: "Unknown", "Pending", "Running", "Failed", "Succeeded", "TimedOut", and "Canceled". - :vartype execution_state: str or ~azure.mgmt.compute.v2024_11_01.models.ExecutionState + :vartype execution_state: str or ~azure.mgmt.compute.models.ExecutionState :ivar execution_message: Communicate script configuration errors or execution messages. :vartype execution_message: str :ivar exit_code: Exit code returned from script execution. @@ -12153,7 +21333,7 @@ class VirtualMachineRunCommandInstanceView(_serialization.Model): :ivar end_time: Script end time. :vartype end_time: ~datetime.datetime :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :vartype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] """ _attribute_map = { @@ -12183,7 +21363,7 @@ def __init__( """ :keyword execution_state: Script execution status. Known values are: "Unknown", "Pending", "Running", "Failed", "Succeeded", "TimedOut", and "Canceled". - :paramtype execution_state: str or ~azure.mgmt.compute.v2024_11_01.models.ExecutionState + :paramtype execution_state: str or ~azure.mgmt.compute.models.ExecutionState :keyword execution_message: Communicate script configuration errors or execution messages. :paramtype execution_message: str :keyword exit_code: Exit code returned from script execution. @@ -12197,7 +21377,7 @@ def __init__( :keyword end_time: Script end time. :paramtype end_time: ~datetime.datetime :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :paramtype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] """ super().__init__(**kwargs) self.execution_state = execution_state @@ -12226,8 +21406,7 @@ class VirtualMachineRunCommandScriptSource(_serialization.Model): container with 'Storage Blob Data Reader' role assignment. In case of user-assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged. - :vartype script_uri_managed_identity: - ~azure.mgmt.compute.v2024_11_01.models.RunCommandManagedIdentity + :vartype script_uri_managed_identity: ~azure.mgmt.compute.models.RunCommandManagedIdentity """ _attribute_map = { @@ -12260,8 +21439,7 @@ def __init__( to blob's container with 'Storage Blob Data Reader' role assignment. In case of user-assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged. - :paramtype script_uri_managed_identity: - ~azure.mgmt.compute.v2024_11_01.models.RunCommandManagedIdentity + :paramtype script_uri_managed_identity: ~azure.mgmt.compute.models.RunCommandManagedIdentity """ super().__init__(**kwargs) self.script = script @@ -12276,7 +21454,7 @@ class VirtualMachineRunCommandsListResult(_serialization.Model): All required parameters must be populated in order to send to server. :ivar value: The list of run commands. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + :vartype value: list[~azure.mgmt.compute.models.VirtualMachineRunCommand] :ivar next_link: The uri to fetch the next page of run commands. :vartype next_link: str """ @@ -12295,7 +21473,7 @@ def __init__( ) -> None: """ :keyword value: The list of run commands. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + :paramtype value: list[~azure.mgmt.compute.models.VirtualMachineRunCommand] :keyword next_link: The uri to fetch the next page of run commands. :paramtype next_link: str """ @@ -12312,12 +21490,11 @@ class VirtualMachineRunCommandUpdate(UpdateResource): :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar source: The source of the run command script. - :vartype source: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandScriptSource + :vartype source: ~azure.mgmt.compute.models.VirtualMachineRunCommandScriptSource :ivar parameters: The parameters used by the script. - :vartype parameters: list[~azure.mgmt.compute.v2024_11_01.models.RunCommandInputParameter] + :vartype parameters: list[~azure.mgmt.compute.models.RunCommandInputParameter] :ivar protected_parameters: The parameters used by the script. - :vartype protected_parameters: - list[~azure.mgmt.compute.v2024_11_01.models.RunCommandInputParameter] + :vartype protected_parameters: list[~azure.mgmt.compute.models.RunCommandInputParameter] :ivar async_execution: Optional. If set to true, provisioning will complete as soon as the script starts and will not wait for script to complete. :vartype async_execution: bool @@ -12342,16 +21519,14 @@ class VirtualMachineRunCommandUpdate(UpdateResource): role assignment. In case of user-assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged. - :vartype output_blob_managed_identity: - ~azure.mgmt.compute.v2024_11_01.models.RunCommandManagedIdentity + :vartype output_blob_managed_identity: ~azure.mgmt.compute.models.RunCommandManagedIdentity :ivar error_blob_managed_identity: User-assigned managed identity that has access to errorBlobUri storage blob. Use an empty object in case of system-assigned identity. Make sure managed identity has been given access to blob's container with 'Storage Blob Data Contributor' role assignment. In case of user-assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged. - :vartype error_blob_managed_identity: - ~azure.mgmt.compute.v2024_11_01.models.RunCommandManagedIdentity + :vartype error_blob_managed_identity: ~azure.mgmt.compute.models.RunCommandManagedIdentity :ivar provisioning_state: The provisioning state, which only appears in the response. If treatFailureAsDeploymentFailure set to true, any failure in the script will fail the deployment and ProvisioningState will be marked as Failed. If treatFailureAsDeploymentFailure set to @@ -12361,8 +21536,7 @@ class VirtualMachineRunCommandUpdate(UpdateResource): error: https://aka.ms/runcommandmanaged#get-execution-status-and-results. :vartype provisioning_state: str :ivar instance_view: The virtual machine run command instance view. - :vartype instance_view: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandInstanceView + :vartype instance_view: ~azure.mgmt.compute.models.VirtualMachineRunCommandInstanceView :ivar treat_failure_as_deployment_failure: Optional. If set to true, any failure in the script will fail the deployment and ProvisioningState will be marked as Failed. If set to false, ProvisioningState would only reflect whether the run command was run or not by the extensions @@ -12423,12 +21597,11 @@ def __init__( :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword source: The source of the run command script. - :paramtype source: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandScriptSource + :paramtype source: ~azure.mgmt.compute.models.VirtualMachineRunCommandScriptSource :keyword parameters: The parameters used by the script. - :paramtype parameters: list[~azure.mgmt.compute.v2024_11_01.models.RunCommandInputParameter] + :paramtype parameters: list[~azure.mgmt.compute.models.RunCommandInputParameter] :keyword protected_parameters: The parameters used by the script. - :paramtype protected_parameters: - list[~azure.mgmt.compute.v2024_11_01.models.RunCommandInputParameter] + :paramtype protected_parameters: list[~azure.mgmt.compute.models.RunCommandInputParameter] :keyword async_execution: Optional. If set to true, provisioning will complete as soon as the script starts and will not wait for script to complete. :paramtype async_execution: bool @@ -12453,16 +21626,14 @@ def __init__( role assignment. In case of user-assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged. - :paramtype output_blob_managed_identity: - ~azure.mgmt.compute.v2024_11_01.models.RunCommandManagedIdentity + :paramtype output_blob_managed_identity: ~azure.mgmt.compute.models.RunCommandManagedIdentity :keyword error_blob_managed_identity: User-assigned managed identity that has access to errorBlobUri storage blob. Use an empty object in case of system-assigned identity. Make sure managed identity has been given access to blob's container with 'Storage Blob Data Contributor' role assignment. In case of user-assigned identity, make sure you add it under VM's identity. For more info on managed identity and Run Command, refer https://aka.ms/ManagedIdentity and https://aka.ms/RunCommandManaged. - :paramtype error_blob_managed_identity: - ~azure.mgmt.compute.v2024_11_01.models.RunCommandManagedIdentity + :paramtype error_blob_managed_identity: ~azure.mgmt.compute.models.RunCommandManagedIdentity :keyword treat_failure_as_deployment_failure: Optional. If set to true, any failure in the script will fail the deployment and ProvisioningState will be marked as Failed. If set to false, ProvisioningState would only reflect whether the run command was run or not by the @@ -12505,38 +21676,36 @@ class VirtualMachineScaleSet(TrackedResource): :vartype type: str :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData + :vartype system_data: ~azure.mgmt.compute.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar sku: The virtual machine scale set sku. - :vartype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku + :vartype sku: ~azure.mgmt.compute.models.Sku :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 the marketplace image that you want to use and then click **Want to deploy programmatically, Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2024_11_01.models.Plan + :vartype plan: ~azure.mgmt.compute.models.Plan :ivar identity: The identity of the virtual machine scale set, if configured. - :vartype identity: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetIdentity + :vartype identity: ~azure.mgmt.compute.models.VirtualMachineScaleSetIdentity :ivar zones: The availability zones. :vartype zones: list[str] :ivar extended_location: The extended location of the Virtual Machine Scale Set. - :vartype extended_location: ~azure.mgmt.compute.v2024_11_01.models.ExtendedLocation + :vartype extended_location: ~azure.mgmt.compute.models.ExtendedLocation :ivar etag: Etag is property returned in Create/Update/Get response of the VMSS, so that customer can supply it in the header to ensure optimistic updates. :vartype etag: str :ivar upgrade_policy: The upgrade policy. - :vartype upgrade_policy: ~azure.mgmt.compute.v2024_11_01.models.UpgradePolicy + :vartype upgrade_policy: ~azure.mgmt.compute.models.UpgradePolicy :ivar scheduled_events_policy: The ScheduledEventsPolicy. - :vartype scheduled_events_policy: ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsPolicy + :vartype scheduled_events_policy: ~azure.mgmt.compute.models.ScheduledEventsPolicy :ivar automatic_repairs_policy: Policy for automatic repairs. - :vartype automatic_repairs_policy: - ~azure.mgmt.compute.v2024_11_01.models.AutomaticRepairsPolicy + :vartype automatic_repairs_policy: ~azure.mgmt.compute.models.AutomaticRepairsPolicy :ivar virtual_machine_profile: The virtual machine profile. - :vartype virtual_machine_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMProfile + :vartype virtual_machine_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetVMProfile :ivar provisioning_state: The provisioning state, which only appears in the response. :vartype provisioning_state: str :ivar overprovision: Specifies whether the Virtual Machine Scale Set should be overprovisioned. @@ -12560,27 +21729,27 @@ class VirtualMachineScaleSet(TrackedResource): :vartype platform_fault_domain_count: int :ivar proximity_placement_group: Specifies information about the proximity placement group that the virtual machine scale set should be assigned to. Minimum api-version: 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype proximity_placement_group: ~azure.mgmt.compute.models.SubResource :ivar host_group: Specifies information about the dedicated host group that the virtual machine scale set resides in. Minimum api-version: 2020-06-01. - :vartype host_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype host_group: ~azure.mgmt.compute.models.SubResource :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines have the capability to support attaching managed data disks with UltraSSD_LRS storage account type. - :vartype additional_capabilities: ~azure.mgmt.compute.v2024_11_01.models.AdditionalCapabilities + :vartype additional_capabilities: ~azure.mgmt.compute.models.AdditionalCapabilities :ivar scale_in_policy: Specifies the policies applied when scaling in Virtual Machines in the Virtual Machine Scale Set. - :vartype scale_in_policy: ~azure.mgmt.compute.v2024_11_01.models.ScaleInPolicy + :vartype scale_in_policy: ~azure.mgmt.compute.models.ScaleInPolicy :ivar orchestration_mode: Specifies the orchestration mode for the virtual machine scale set. Known values are: "Uniform" and "Flexible". - :vartype orchestration_mode: str or ~azure.mgmt.compute.v2024_11_01.models.OrchestrationMode + :vartype orchestration_mode: str or ~azure.mgmt.compute.models.OrchestrationMode :ivar spot_restore_policy: Specifies the Spot Restore properties for the virtual machine scale set. - :vartype spot_restore_policy: ~azure.mgmt.compute.v2024_11_01.models.SpotRestorePolicy + :vartype spot_restore_policy: ~azure.mgmt.compute.models.SpotRestorePolicy :ivar priority_mix_policy: Specifies the desired targets for mixing Spot and Regular priority VMs within the same VMSS Flex instance. - :vartype priority_mix_policy: ~azure.mgmt.compute.v2024_11_01.models.PriorityMixPolicy + :vartype priority_mix_policy: ~azure.mgmt.compute.models.PriorityMixPolicy :ivar time_created: Specifies the time at which the Virtual Machine Scale Set resource was created. Minimum api-version: 2021-11-01. :vartype time_created: ~datetime.datetime @@ -12588,13 +21757,13 @@ class VirtualMachineScaleSet(TrackedResource): omitted. :vartype constrained_maximum_capacity: bool :ivar resiliency_policy: Policy for Resiliency. - :vartype resiliency_policy: ~azure.mgmt.compute.v2024_11_01.models.ResiliencyPolicy + :vartype resiliency_policy: ~azure.mgmt.compute.models.ResiliencyPolicy :ivar zonal_platform_fault_domain_align_mode: Specifies the align mode between Virtual Machine Scale Set compute and storage Fault Domain count. Known values are: "Aligned" and "Unaligned". :vartype zonal_platform_fault_domain_align_mode: str or - ~azure.mgmt.compute.v2024_11_01.models.ZonalPlatformFaultDomainAlignMode + ~azure.mgmt.compute.models.ZonalPlatformFaultDomainAlignMode :ivar sku_profile: Specifies the sku profile for the virtual machine scale set. - :vartype sku_profile: ~azure.mgmt.compute.v2024_11_01.models.SkuProfile + :vartype sku_profile: ~azure.mgmt.compute.models.SkuProfile """ _validation = { @@ -12696,30 +21865,27 @@ def __init__( # pylint: disable=too-many-locals :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword sku: The virtual machine scale set sku. - :paramtype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku + :paramtype sku: ~azure.mgmt.compute.models.Sku :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 the marketplace image that you want to use and then click **Want to deploy programmatically, Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2024_11_01.models.Plan + :paramtype plan: ~azure.mgmt.compute.models.Plan :keyword identity: The identity of the virtual machine scale set, if configured. - :paramtype identity: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetIdentity + :paramtype identity: ~azure.mgmt.compute.models.VirtualMachineScaleSetIdentity :keyword zones: The availability zones. :paramtype zones: list[str] :keyword extended_location: The extended location of the Virtual Machine Scale Set. - :paramtype extended_location: ~azure.mgmt.compute.v2024_11_01.models.ExtendedLocation + :paramtype extended_location: ~azure.mgmt.compute.models.ExtendedLocation :keyword upgrade_policy: The upgrade policy. - :paramtype upgrade_policy: ~azure.mgmt.compute.v2024_11_01.models.UpgradePolicy + :paramtype upgrade_policy: ~azure.mgmt.compute.models.UpgradePolicy :keyword scheduled_events_policy: The ScheduledEventsPolicy. - :paramtype scheduled_events_policy: - ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsPolicy + :paramtype scheduled_events_policy: ~azure.mgmt.compute.models.ScheduledEventsPolicy :keyword automatic_repairs_policy: Policy for automatic repairs. - :paramtype automatic_repairs_policy: - ~azure.mgmt.compute.v2024_11_01.models.AutomaticRepairsPolicy + :paramtype automatic_repairs_policy: ~azure.mgmt.compute.models.AutomaticRepairsPolicy :keyword virtual_machine_profile: The virtual machine profile. - :paramtype virtual_machine_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMProfile + :paramtype virtual_machine_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetVMProfile :keyword overprovision: Specifies whether the Virtual Machine Scale Set should be overprovisioned. :paramtype overprovision: bool @@ -12740,40 +21906,39 @@ def __init__( # pylint: disable=too-many-locals :paramtype platform_fault_domain_count: int :keyword proximity_placement_group: Specifies information about the proximity placement group that the virtual machine scale set should be assigned to. Minimum api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype proximity_placement_group: ~azure.mgmt.compute.models.SubResource :keyword host_group: Specifies information about the dedicated host group that the virtual machine scale set resides in. Minimum api-version: 2020-06-01. - :paramtype host_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype host_group: ~azure.mgmt.compute.models.SubResource :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines have the capability to support attaching managed data disks with UltraSSD_LRS storage account type. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2024_11_01.models.AdditionalCapabilities + :paramtype additional_capabilities: ~azure.mgmt.compute.models.AdditionalCapabilities :keyword scale_in_policy: Specifies the policies applied when scaling in Virtual Machines in the Virtual Machine Scale Set. - :paramtype scale_in_policy: ~azure.mgmt.compute.v2024_11_01.models.ScaleInPolicy + :paramtype scale_in_policy: ~azure.mgmt.compute.models.ScaleInPolicy :keyword orchestration_mode: Specifies the orchestration mode for the virtual machine scale set. Known values are: "Uniform" and "Flexible". - :paramtype orchestration_mode: str or ~azure.mgmt.compute.v2024_11_01.models.OrchestrationMode + :paramtype orchestration_mode: str or ~azure.mgmt.compute.models.OrchestrationMode :keyword spot_restore_policy: Specifies the Spot Restore properties for the virtual machine scale set. - :paramtype spot_restore_policy: ~azure.mgmt.compute.v2024_11_01.models.SpotRestorePolicy + :paramtype spot_restore_policy: ~azure.mgmt.compute.models.SpotRestorePolicy :keyword priority_mix_policy: Specifies the desired targets for mixing Spot and Regular priority VMs within the same VMSS Flex instance. - :paramtype priority_mix_policy: ~azure.mgmt.compute.v2024_11_01.models.PriorityMixPolicy + :paramtype priority_mix_policy: ~azure.mgmt.compute.models.PriorityMixPolicy :keyword constrained_maximum_capacity: Optional property which must either be set to True or omitted. :paramtype constrained_maximum_capacity: bool :keyword resiliency_policy: Policy for Resiliency. - :paramtype resiliency_policy: ~azure.mgmt.compute.v2024_11_01.models.ResiliencyPolicy + :paramtype resiliency_policy: ~azure.mgmt.compute.models.ResiliencyPolicy :keyword zonal_platform_fault_domain_align_mode: Specifies the align mode between Virtual Machine Scale Set compute and storage Fault Domain count. Known values are: "Aligned" and "Unaligned". :paramtype zonal_platform_fault_domain_align_mode: str or - ~azure.mgmt.compute.v2024_11_01.models.ZonalPlatformFaultDomainAlignMode + ~azure.mgmt.compute.models.ZonalPlatformFaultDomainAlignMode :keyword sku_profile: Specifies the sku profile for the virtual machine scale set. - :paramtype sku_profile: ~azure.mgmt.compute.v2024_11_01.models.SkuProfile + :paramtype sku_profile: ~azure.mgmt.compute.models.SkuProfile """ super().__init__(tags=tags, location=location, **kwargs) self.sku = sku @@ -12821,20 +21986,19 @@ class VirtualMachineScaleSetDataDisk(_serialization.Model): :ivar caching: Specifies the caching requirements. Possible values are: **None,** **ReadOnly,** **ReadWrite.** The default values are: **None for Standard storage. ReadOnly for Premium storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes + :vartype caching: str or ~azure.mgmt.compute.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :vartype write_accelerator_enabled: bool :ivar create_option: The create option. Required. Known values are: "FromImage", "Empty", "Attach", "Copy", and "Restore". - :vartype create_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskCreateOptionTypes + :vartype create_option: str or ~azure.mgmt.compute.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. The property diskSizeGB is the number of bytes x 1024^3 for the disk and the value cannot be larger than 1023. :vartype disk_size_gb: int :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetManagedDiskParameters + :vartype managed_disk: ~azure.mgmt.compute.models.VirtualMachineScaleSetManagedDiskParameters :ivar disk_iops_read_write: Specifies the Read-Write IOPS for the managed disk. Should be used only when StorageAccountType is UltraSSD_LRS. If not specified, a default value would be assigned based on diskSizeGB. @@ -12850,7 +22014,7 @@ class VirtualMachineScaleSetDataDisk(_serialization.Model): :code:`
` **Detach** If this value is used, the data disk is retained after VMSS Flex VM is deleted.\\ :code:`
`\\ :code:`
` The default value is set to **Delete**. Known values are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskDeleteOptionTypes + :vartype delete_option: str or ~azure.mgmt.compute.models.DiskDeleteOptionTypes """ _validation = { @@ -12896,20 +22060,19 @@ def __init__( :keyword caching: Specifies the caching requirements. Possible values are: **None,** **ReadOnly,** **ReadWrite.** The default values are: **None for Standard storage. ReadOnly for Premium storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes + :paramtype caching: str or ~azure.mgmt.compute.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :paramtype write_accelerator_enabled: bool :keyword create_option: The create option. Required. Known values are: "FromImage", "Empty", "Attach", "Copy", and "Restore". - :paramtype create_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskCreateOptionTypes + :paramtype create_option: str or ~azure.mgmt.compute.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. The property diskSizeGB is the number of bytes x 1024^3 for the disk and the value cannot be larger than 1023. :paramtype disk_size_gb: int :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetManagedDiskParameters + :paramtype managed_disk: ~azure.mgmt.compute.models.VirtualMachineScaleSetManagedDiskParameters :keyword disk_iops_read_write: Specifies the Read-Write IOPS for the managed disk. Should be used only when StorageAccountType is UltraSSD_LRS. If not specified, a default value would be assigned based on diskSizeGB. @@ -12925,7 +22088,7 @@ def __init__( :code:`
` **Detach** If this value is used, the data disk is retained after VMSS Flex VM is deleted.\\ :code:`
`\\ :code:`
` The default value is set to **Delete**. Known values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskDeleteOptionTypes + :paramtype delete_option: str or ~azure.mgmt.compute.models.DiskDeleteOptionTypes """ super().__init__(**kwargs) self.name = name @@ -12984,8 +22147,7 @@ class VirtualMachineScaleSetExtension(SubResourceReadOnly): :vartype suppress_failures: bool :ivar protected_settings_from_key_vault: The extensions protected settings that are passed by reference, and consumed from key vault. - :vartype protected_settings_from_key_vault: - ~azure.mgmt.compute.v2024_11_01.models.KeyVaultSecretReference + :vartype protected_settings_from_key_vault: ~azure.mgmt.compute.models.KeyVaultSecretReference """ _validation = { @@ -13067,7 +22229,7 @@ def __init__( :keyword protected_settings_from_key_vault: The extensions protected settings that are passed by reference, and consumed from key vault. :paramtype protected_settings_from_key_vault: - ~azure.mgmt.compute.v2024_11_01.models.KeyVaultSecretReference + ~azure.mgmt.compute.models.KeyVaultSecretReference """ super().__init__(**kwargs) self.type: Optional[str] = None @@ -13092,7 +22254,7 @@ class VirtualMachineScaleSetExtensionListResult(_serialization.Model): # pylint All required parameters must be populated in order to send to server. :ivar value: The list of VM scale set extensions. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] + :vartype value: list[~azure.mgmt.compute.models.VirtualMachineScaleSetExtension] :ivar next_link: The uri to fetch the next page of VM scale set extensions. Call ListNext() with this to fetch the next page of VM scale set extensions. :vartype next_link: str @@ -13112,7 +22274,7 @@ def __init__( ) -> None: """ :keyword value: The list of VM scale set extensions. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] + :paramtype value: list[~azure.mgmt.compute.models.VirtualMachineScaleSetExtension] :keyword next_link: The uri to fetch the next page of VM scale set extensions. Call ListNext() with this to fetch the next page of VM scale set extensions. :paramtype next_link: str @@ -13126,8 +22288,7 @@ class VirtualMachineScaleSetExtensionProfile(_serialization.Model): """Describes a virtual machine scale set extension profile. :ivar extensions: The virtual machine scale set child extension resources. - :vartype extensions: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] + :vartype extensions: list[~azure.mgmt.compute.models.VirtualMachineScaleSetExtension] :ivar extensions_time_budget: Specifies the time alloted for all extensions to start. The time duration should be between 15 minutes and 120 minutes (inclusive) and should be specified in ISO 8601 format. The default value is 90 minutes (PT1H30M). Minimum api-version: 2020-06-01. @@ -13148,8 +22309,7 @@ def __init__( ) -> None: """ :keyword extensions: The virtual machine scale set child extension resources. - :paramtype extensions: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] + :paramtype extensions: list[~azure.mgmt.compute.models.VirtualMachineScaleSetExtension] :keyword extensions_time_budget: Specifies the time alloted for all extensions to start. The time duration should be between 15 minutes and 120 minutes (inclusive) and should be specified in ISO 8601 format. The default value is 90 minutes (PT1H30M). Minimum api-version: 2020-06-01. @@ -13204,8 +22364,7 @@ class VirtualMachineScaleSetExtensionUpdate(SubResourceReadOnly): :vartype suppress_failures: bool :ivar protected_settings_from_key_vault: The extensions protected settings that are passed by reference, and consumed from key vault. - :vartype protected_settings_from_key_vault: - ~azure.mgmt.compute.v2024_11_01.models.KeyVaultSecretReference + :vartype protected_settings_from_key_vault: ~azure.mgmt.compute.models.KeyVaultSecretReference """ _validation = { @@ -13285,7 +22444,7 @@ def __init__( :keyword protected_settings_from_key_vault: The extensions protected settings that are passed by reference, and consumed from key vault. :paramtype protected_settings_from_key_vault: - ~azure.mgmt.compute.v2024_11_01.models.KeyVaultSecretReference + ~azure.mgmt.compute.models.KeyVaultSecretReference """ super().__init__(**kwargs) self.name: Optional[str] = None @@ -13310,7 +22469,7 @@ class VirtualMachineScaleSetHardwareProfile(_serialization.Model): :ivar vm_size_properties: Specifies the properties for customizing the size of the virtual machine. Minimum api-version: 2021-11-01. Please follow the instructions in `VM Customization `_ for more details. - :vartype vm_size_properties: ~azure.mgmt.compute.v2024_11_01.models.VMSizeProperties + :vartype vm_size_properties: ~azure.mgmt.compute.models.VMSizeProperties """ _attribute_map = { @@ -13322,7 +22481,7 @@ def __init__(self, *, vm_size_properties: Optional["_models.VMSizeProperties"] = :keyword vm_size_properties: Specifies the properties for customizing the size of the virtual machine. Minimum api-version: 2021-11-01. Please follow the instructions in `VM Customization `_ for more details. - :paramtype vm_size_properties: ~azure.mgmt.compute.v2024_11_01.models.VMSizeProperties + :paramtype vm_size_properties: ~azure.mgmt.compute.models.VMSizeProperties """ super().__init__(**kwargs) self.vm_size_properties = vm_size_properties @@ -13344,12 +22503,12 @@ class VirtualMachineScaleSetIdentity(_serialization.Model): assigned identities. The type 'None' will remove any identities from the virtual machine scale set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :vartype type: str or ~azure.mgmt.compute.v2024_11_01.models.ResourceIdentityType + :vartype type: str or ~azure.mgmt.compute.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the virtual machine scale set. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. :vartype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2024_11_01.models.UserAssignedIdentitiesValue] + ~azure.mgmt.compute.models.UserAssignedIdentitiesValue] """ _validation = { @@ -13377,13 +22536,13 @@ def __init__( assigned identities. The type 'None' will remove any identities from the virtual machine scale set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :paramtype type: str or ~azure.mgmt.compute.v2024_11_01.models.ResourceIdentityType + :paramtype type: str or ~azure.mgmt.compute.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the virtual machine scale set. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2024_11_01.models.UserAssignedIdentitiesValue] + ~azure.mgmt.compute.models.UserAssignedIdentitiesValue] """ super().__init__(**kwargs) self.principal_id: Optional[str] = None @@ -13399,15 +22558,13 @@ class VirtualMachineScaleSetInstanceView(_serialization.Model): :ivar virtual_machine: The instance view status summary for the virtual machine scale set. :vartype virtual_machine: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetInstanceViewStatusesSummary + ~azure.mgmt.compute.models.VirtualMachineScaleSetInstanceViewStatusesSummary :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionsSummary] + :vartype extensions: list[~azure.mgmt.compute.models.VirtualMachineScaleSetVMExtensionsSummary] :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :vartype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] :ivar orchestration_services: The orchestration services information. - :vartype orchestration_services: - list[~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceSummary] + :vartype orchestration_services: list[~azure.mgmt.compute.models.OrchestrationServiceSummary] """ _validation = { @@ -13426,7 +22583,7 @@ class VirtualMachineScaleSetInstanceView(_serialization.Model): def __init__(self, *, statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs: Any) -> None: """ :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :paramtype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] """ super().__init__(**kwargs) self.virtual_machine: Optional["_models.VirtualMachineScaleSetInstanceViewStatusesSummary"] = None @@ -13441,8 +22598,7 @@ class VirtualMachineScaleSetInstanceViewStatusesSummary(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar statuses_summary: The extensions information. - :vartype statuses_summary: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineStatusCodeCount] + :vartype statuses_summary: list[~azure.mgmt.compute.models.VirtualMachineStatusCodeCount] """ _validation = { @@ -13467,35 +22623,33 @@ class VirtualMachineScaleSetIPConfiguration(_serialization.Model): :ivar name: The IP configuration name. Required. :vartype name: str :ivar subnet: Specifies the identifier of the subnet. - :vartype subnet: ~azure.mgmt.compute.v2024_11_01.models.ApiEntityReference + :vartype subnet: ~azure.mgmt.compute.models.ApiEntityReference :ivar primary: Specifies the primary network interface in case the virtual machine has more than 1 network interface. :vartype primary: bool :ivar public_ip_address_configuration: The publicIPAddressConfiguration. :vartype public_ip_address_configuration: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration + ~azure.mgmt.compute.models.VirtualMachineScaleSetPublicIPAddressConfiguration :ivar private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2024_11_01.models.IPVersion + :vartype private_ip_address_version: str or ~azure.mgmt.compute.models.IPVersion :ivar application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of multiple application gateways. Multiple scale sets cannot use the same application gateway. :vartype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + list[~azure.mgmt.compute.models.SubResource] :ivar application_security_groups: Specifies an array of references to application security group. - :vartype application_security_groups: list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :vartype application_security_groups: list[~azure.mgmt.compute.models.SubResource] :ivar load_balancer_backend_address_pools: Specifies an array of references to backend address pools of load balancers. A scale set can reference backend address pools of one public and one internal load balancer. Multiple scale sets cannot use the same basic sku load balancer. - :vartype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :vartype load_balancer_backend_address_pools: list[~azure.mgmt.compute.models.SubResource] :ivar load_balancer_inbound_nat_pools: Specifies an array of references to inbound Nat pools of the load balancers. A scale set can reference inbound nat pools of one public and one internal load balancer. Multiple scale sets cannot use the same basic sku load balancer. - :vartype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :vartype load_balancer_inbound_nat_pools: list[~azure.mgmt.compute.models.SubResource] """ _validation = { @@ -13541,37 +22695,34 @@ def __init__( :keyword name: The IP configuration name. Required. :paramtype name: str :keyword subnet: Specifies the identifier of the subnet. - :paramtype subnet: ~azure.mgmt.compute.v2024_11_01.models.ApiEntityReference + :paramtype subnet: ~azure.mgmt.compute.models.ApiEntityReference :keyword primary: Specifies the primary network interface in case the virtual machine has more than 1 network interface. :paramtype primary: bool :keyword public_ip_address_configuration: The publicIPAddressConfiguration. :paramtype public_ip_address_configuration: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration + ~azure.mgmt.compute.models.VirtualMachineScaleSetPublicIPAddressConfiguration :keyword private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2024_11_01.models.IPVersion + :paramtype private_ip_address_version: str or ~azure.mgmt.compute.models.IPVersion :keyword application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of multiple application gateways. Multiple scale sets cannot use the same application gateway. :paramtype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + list[~azure.mgmt.compute.models.SubResource] :keyword application_security_groups: Specifies an array of references to application security group. - :paramtype application_security_groups: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :paramtype application_security_groups: list[~azure.mgmt.compute.models.SubResource] :keyword load_balancer_backend_address_pools: Specifies an array of references to backend address pools of load balancers. A scale set can reference backend address pools of one public and one internal load balancer. Multiple scale sets cannot use the same basic sku load balancer. - :paramtype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :paramtype load_balancer_backend_address_pools: list[~azure.mgmt.compute.models.SubResource] :keyword load_balancer_inbound_nat_pools: Specifies an array of references to inbound Nat pools of the load balancers. A scale set can reference inbound nat pools of one public and one internal load balancer. Multiple scale sets cannot use the same basic sku load balancer. - :paramtype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :paramtype load_balancer_inbound_nat_pools: list[~azure.mgmt.compute.models.SubResource] """ super().__init__(**kwargs) self.name = name @@ -13617,8 +22768,7 @@ class VirtualMachineScaleSetListOSUpgradeHistory(_serialization.Model): # pylin All required parameters must be populated in order to send to server. :ivar value: The list of OS upgrades performed on the virtual machine scale set. Required. - :vartype value: - list[~azure.mgmt.compute.v2024_11_01.models.UpgradeOperationHistoricalStatusInfo] + :vartype value: list[~azure.mgmt.compute.models.UpgradeOperationHistoricalStatusInfo] :ivar next_link: The uri to fetch the next page of OS Upgrade History. Call ListNext() with this to fetch the next page of history of upgrades. :vartype next_link: str @@ -13642,8 +22792,7 @@ def __init__( ) -> None: """ :keyword value: The list of OS upgrades performed on the virtual machine scale set. Required. - :paramtype value: - list[~azure.mgmt.compute.v2024_11_01.models.UpgradeOperationHistoricalStatusInfo] + :paramtype value: list[~azure.mgmt.compute.models.UpgradeOperationHistoricalStatusInfo] :keyword next_link: The uri to fetch the next page of OS Upgrade History. Call ListNext() with this to fetch the next page of history of upgrades. :paramtype next_link: str @@ -13659,7 +22808,7 @@ class VirtualMachineScaleSetListResult(_serialization.Model): All required parameters must be populated in order to send to server. :ivar value: The list of virtual machine scale sets. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :vartype value: list[~azure.mgmt.compute.models.VirtualMachineScaleSet] :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call ListNext() with this to fetch the next page of VMSS. :vartype next_link: str @@ -13679,7 +22828,7 @@ def __init__( ) -> None: """ :keyword value: The list of virtual machine scale sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :paramtype value: list[~azure.mgmt.compute.models.VirtualMachineScaleSet] :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call ListNext() with this to fetch the next page of VMSS. :paramtype next_link: str @@ -13695,7 +22844,7 @@ class VirtualMachineScaleSetListSkusResult(_serialization.Model): All required parameters must be populated in order to send to server. :ivar value: The list of skus available for the virtual machine scale set. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetSku] + :vartype value: list[~azure.mgmt.compute.models.VirtualMachineScaleSetSku] :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Set Skus. Call ListNext() with this to fetch the next page of VMSS Skus. :vartype next_link: str @@ -13715,7 +22864,7 @@ def __init__( ) -> None: """ :keyword value: The list of skus available for the virtual machine scale set. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetSku] + :paramtype value: list[~azure.mgmt.compute.models.VirtualMachineScaleSetSku] :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Set Skus. Call ListNext() with this to fetch the next page of VMSS Skus. :paramtype next_link: str @@ -13731,7 +22880,7 @@ class VirtualMachineScaleSetListWithLinkResult(_serialization.Model): All required parameters must be populated in order to send to server. :ivar value: The list of virtual machine scale sets. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :vartype value: list[~azure.mgmt.compute.models.VirtualMachineScaleSet] :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call ListNext() with this to fetch the next page of Virtual Machine Scale Sets. :vartype next_link: str @@ -13751,7 +22900,7 @@ def __init__( ) -> None: """ :keyword value: The list of virtual machine scale sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :paramtype value: list[~azure.mgmt.compute.models.VirtualMachineScaleSet] :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call ListNext() with this to fetch the next page of Virtual Machine Scale Sets. :paramtype next_link: str @@ -13768,14 +22917,12 @@ class VirtualMachineScaleSetManagedDiskParameters(_serialization.Model): # pyli UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", and "PremiumV2_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2024_11_01.models.StorageAccountTypes + :vartype storage_account_type: str or ~azure.mgmt.compute.models.StorageAccountTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for the managed disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSetParameters + :vartype disk_encryption_set: ~azure.mgmt.compute.models.DiskEncryptionSetParameters :ivar security_profile: Specifies the security profile for the managed disk. - :vartype security_profile: ~azure.mgmt.compute.v2024_11_01.models.VMDiskSecurityProfile + :vartype security_profile: ~azure.mgmt.compute.models.VMDiskSecurityProfile """ _attribute_map = { @@ -13797,14 +22944,12 @@ def __init__( UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", and "PremiumV2_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2024_11_01.models.StorageAccountTypes + :paramtype storage_account_type: str or ~azure.mgmt.compute.models.StorageAccountTypes :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id for the managed disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSetParameters + :paramtype disk_encryption_set: ~azure.mgmt.compute.models.DiskEncryptionSetParameters :keyword security_profile: Specifies the security profile for the managed disk. - :paramtype security_profile: ~azure.mgmt.compute.v2024_11_01.models.VMDiskSecurityProfile + :paramtype security_profile: ~azure.mgmt.compute.models.VMDiskSecurityProfile """ super().__init__(**kwargs) self.storage_account_type = storage_account_type @@ -13822,11 +22967,10 @@ class VirtualMachineScaleSetMigrationInfo(_serialization.Model): properties upon triggering a seamless migration without downtime of the VMs via the ConvertToVirtualMachineScaleSet API. :vartype default_virtual_machine_scale_set_info: - ~azure.mgmt.compute.v2024_11_01.models.DefaultVirtualMachineScaleSetInfo + ~azure.mgmt.compute.models.DefaultVirtualMachineScaleSetInfo :ivar migrate_to_virtual_machine_scale_set: Specifies the Virtual Machine Scale Set that the Availability Set is migrated to. - :vartype migrate_to_virtual_machine_scale_set: - ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype migrate_to_virtual_machine_scale_set: ~azure.mgmt.compute.models.SubResource """ _validation = { @@ -13868,26 +23012,24 @@ class VirtualMachineScaleSetNetworkConfiguration(_serialization.Model): # pylin :ivar enable_fpga: Specifies whether the network interface is FPGA networking-enabled. :vartype enable_fpga: bool :ivar network_security_group: The network security group. - :vartype network_security_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype network_security_group: ~azure.mgmt.compute.models.SubResource :ivar dns_settings: The dns settings to be applied on the network interfaces. :vartype dns_settings: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings + ~azure.mgmt.compute.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings :ivar ip_configurations: Specifies the IP configurations of the network interface. :vartype ip_configurations: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetIPConfiguration] + list[~azure.mgmt.compute.models.VirtualMachineScaleSetIPConfiguration] :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :vartype enable_ip_forwarding: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. Known values are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DeleteOptions + :vartype delete_option: str or ~azure.mgmt.compute.models.DeleteOptions :ivar auxiliary_mode: Specifies whether the Auxiliary mode is enabled for the Network Interface resource. Known values are: "None", "AcceleratedConnections", and "Floating". - :vartype auxiliary_mode: str or - ~azure.mgmt.compute.v2024_11_01.models.NetworkInterfaceAuxiliaryMode + :vartype auxiliary_mode: str or ~azure.mgmt.compute.models.NetworkInterfaceAuxiliaryMode :ivar auxiliary_sku: Specifies whether the Auxiliary sku is enabled for the Network Interface resource. Known values are: "None", "A1", "A2", "A4", and "A8". - :vartype auxiliary_sku: str or - ~azure.mgmt.compute.v2024_11_01.models.NetworkInterfaceAuxiliarySku + :vartype auxiliary_sku: str or ~azure.mgmt.compute.models.NetworkInterfaceAuxiliarySku """ _validation = { @@ -13944,26 +23086,24 @@ def __init__( :keyword enable_fpga: Specifies whether the network interface is FPGA networking-enabled. :paramtype enable_fpga: bool :keyword network_security_group: The network security group. - :paramtype network_security_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype network_security_group: ~azure.mgmt.compute.models.SubResource :keyword dns_settings: The dns settings to be applied on the network interfaces. :paramtype dns_settings: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings + ~azure.mgmt.compute.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings :keyword ip_configurations: Specifies the IP configurations of the network interface. :paramtype ip_configurations: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetIPConfiguration] + list[~azure.mgmt.compute.models.VirtualMachineScaleSetIPConfiguration] :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :paramtype enable_ip_forwarding: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. Known values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DeleteOptions + :paramtype delete_option: str or ~azure.mgmt.compute.models.DeleteOptions :keyword auxiliary_mode: Specifies whether the Auxiliary mode is enabled for the Network Interface resource. Known values are: "None", "AcceleratedConnections", and "Floating". - :paramtype auxiliary_mode: str or - ~azure.mgmt.compute.v2024_11_01.models.NetworkInterfaceAuxiliaryMode + :paramtype auxiliary_mode: str or ~azure.mgmt.compute.models.NetworkInterfaceAuxiliaryMode :keyword auxiliary_sku: Specifies whether the Auxiliary sku is enabled for the Network Interface resource. Known values are: "None", "A1", "A2", "A4", and "A8". - :paramtype auxiliary_sku: str or - ~azure.mgmt.compute.v2024_11_01.models.NetworkInterfaceAuxiliarySku + :paramtype auxiliary_sku: str or ~azure.mgmt.compute.models.NetworkInterfaceAuxiliarySku """ super().__init__(**kwargs) self.name = name @@ -14006,14 +23146,14 @@ class VirtualMachineScaleSetNetworkProfile(_serialization.Model): :ivar health_probe: A reference to a load balancer probe used to determine the health of an instance in the virtual machine scale set. The reference will be in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :vartype health_probe: ~azure.mgmt.compute.v2024_11_01.models.ApiEntityReference + :vartype health_probe: ~azure.mgmt.compute.models.ApiEntityReference :ivar network_interface_configurations: The list of network configurations. :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetNetworkConfiguration] + list[~azure.mgmt.compute.models.VirtualMachineScaleSetNetworkConfiguration] :ivar network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with orchestration mode 'Flexible'. Known values are: "2020-11-01" and "2022-11-01". - :vartype network_api_version: str or ~azure.mgmt.compute.v2024_11_01.models.NetworkApiVersion + :vartype network_api_version: str or ~azure.mgmt.compute.models.NetworkApiVersion """ _attribute_map = { @@ -14037,14 +23177,14 @@ def __init__( :keyword health_probe: A reference to a load balancer probe used to determine the health of an instance in the virtual machine scale set. The reference will be in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :paramtype health_probe: ~azure.mgmt.compute.v2024_11_01.models.ApiEntityReference + :paramtype health_probe: ~azure.mgmt.compute.models.ApiEntityReference :keyword network_interface_configurations: The list of network configurations. :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetNetworkConfiguration] + list[~azure.mgmt.compute.models.VirtualMachineScaleSetNetworkConfiguration] :keyword network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with orchestration mode 'Flexible'. Known values are: "2020-11-01" and "2022-11-01". - :paramtype network_api_version: str or ~azure.mgmt.compute.v2024_11_01.models.NetworkApiVersion + :paramtype network_api_version: str or ~azure.mgmt.compute.models.NetworkApiVersion """ super().__init__(**kwargs) self.health_probe = health_probe @@ -14062,7 +23202,7 @@ class VirtualMachineScaleSetOSDisk(_serialization.Model): :ivar caching: Specifies the caching requirements. Possible values are: **None,** **ReadOnly,** **ReadWrite.** The default values are: **None for Standard storage. ReadOnly for Premium storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes + :vartype caching: str or ~azure.mgmt.compute.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :vartype write_accelerator_enabled: bool @@ -14072,10 +23212,10 @@ class VirtualMachineScaleSetOSDisk(_serialization.Model): described above. If you are using a marketplace image, you also use the plan element previously described. Required. Known values are: "FromImage", "Empty", "Attach", "Copy", and "Restore". - :vartype create_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskCreateOptionTypes + :vartype create_option: str or ~azure.mgmt.compute.models.DiskCreateOptionTypes :ivar diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. - :vartype diff_disk_settings: ~azure.mgmt.compute.v2024_11_01.models.DiffDiskSettings + :vartype diff_disk_settings: ~azure.mgmt.compute.models.DiffDiskSettings :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. The property 'diskSizeGB' is the number of bytes x 1024^3 for the disk and the value cannot be larger than 1023. @@ -14083,15 +23223,14 @@ class VirtualMachineScaleSetOSDisk(_serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. Possible values are: **Windows,** **Linux.**. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2024_11_01.models.OperatingSystemTypes + :vartype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes :ivar image: Specifies information about the unmanaged user image to base the scale set on. - :vartype image: ~azure.mgmt.compute.v2024_11_01.models.VirtualHardDisk + :vartype image: ~azure.mgmt.compute.models.VirtualHardDisk :ivar vhd_containers: Specifies the container urls that are used to store operating system disks for the scale set. :vartype vhd_containers: list[str] :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetManagedDiskParameters + :vartype managed_disk: ~azure.mgmt.compute.models.VirtualMachineScaleSetManagedDiskParameters :ivar delete_option: Specifies whether OS Disk should be deleted or detached upon VMSS Flex deletion (This feature is available for VMSS with Flexible OrchestrationMode only). :code:`
`\\ :code:`
` Possible values: :code:`
`\\ :code:`
` **Delete** If this @@ -14100,7 +23239,7 @@ class VirtualMachineScaleSetOSDisk(_serialization.Model): deleted. :code:`
`\\ :code:`
` The default value is set to **Delete**. For an Ephemeral OS Disk, the default value is set to **Delete**. User cannot change the delete option for Ephemeral OS Disk. Known values are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskDeleteOptionTypes + :vartype delete_option: str or ~azure.mgmt.compute.models.DiskDeleteOptionTypes """ _validation = { @@ -14143,7 +23282,7 @@ def __init__( :keyword caching: Specifies the caching requirements. Possible values are: **None,** **ReadOnly,** **ReadWrite.** The default values are: **None for Standard storage. ReadOnly for Premium storage.**. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes + :paramtype caching: str or ~azure.mgmt.compute.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :paramtype write_accelerator_enabled: bool @@ -14153,10 +23292,10 @@ def __init__( element described above. If you are using a marketplace image, you also use the plan element previously described. Required. Known values are: "FromImage", "Empty", "Attach", "Copy", and "Restore". - :paramtype create_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskCreateOptionTypes + :paramtype create_option: str or ~azure.mgmt.compute.models.DiskCreateOptionTypes :keyword diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. - :paramtype diff_disk_settings: ~azure.mgmt.compute.v2024_11_01.models.DiffDiskSettings + :paramtype diff_disk_settings: ~azure.mgmt.compute.models.DiffDiskSettings :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. The property 'diskSizeGB' is the number of bytes x 1024^3 for the disk and the value cannot be larger than 1023. @@ -14164,15 +23303,14 @@ def __init__( :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. Possible values are: **Windows,** **Linux.**. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2024_11_01.models.OperatingSystemTypes + :paramtype os_type: str or ~azure.mgmt.compute.models.OperatingSystemTypes :keyword image: Specifies information about the unmanaged user image to base the scale set on. - :paramtype image: ~azure.mgmt.compute.v2024_11_01.models.VirtualHardDisk + :paramtype image: ~azure.mgmt.compute.models.VirtualHardDisk :keyword vhd_containers: Specifies the container urls that are used to store operating system disks for the scale set. :paramtype vhd_containers: list[str] :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetManagedDiskParameters + :paramtype managed_disk: ~azure.mgmt.compute.models.VirtualMachineScaleSetManagedDiskParameters :keyword delete_option: Specifies whether OS Disk should be deleted or detached upon VMSS Flex deletion (This feature is available for VMSS with Flexible OrchestrationMode only). :code:`
`\\ :code:`
` Possible values: :code:`
`\\ :code:`
` **Delete** If this @@ -14181,7 +23319,7 @@ def __init__( deleted. :code:`
`\\ :code:`
` The default value is set to **Delete**. For an Ephemeral OS Disk, the default value is set to **Delete**. User cannot change the delete option for Ephemeral OS Disk. Known values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskDeleteOptionTypes + :paramtype delete_option: str or ~azure.mgmt.compute.models.DiskDeleteOptionTypes """ super().__init__(**kwargs) self.name = name @@ -14235,18 +23373,18 @@ class VirtualMachineScaleSetOSProfile(_serialization.Model): :vartype custom_data: str :ivar windows_configuration: Specifies Windows operating system settings on the virtual machine. - :vartype windows_configuration: ~azure.mgmt.compute.v2024_11_01.models.WindowsConfiguration + :vartype windows_configuration: ~azure.mgmt.compute.models.WindowsConfiguration :ivar linux_configuration: Specifies the Linux operating system settings on the virtual machine. For a list of supported Linux distributions, see `Linux on Azure-Endorsed Distributions `_. - :vartype linux_configuration: ~azure.mgmt.compute.v2024_11_01.models.LinuxConfiguration + :vartype linux_configuration: ~azure.mgmt.compute.models.LinuxConfiguration :ivar secrets: Specifies set of certificates that should be installed onto the virtual machines in the scale set. To install certificates on a virtual machine it is recommended to use the `Azure Key Vault virtual machine extension for Linux `_ or the `Azure Key Vault virtual machine extension for Windows `_. - :vartype secrets: list[~azure.mgmt.compute.v2024_11_01.models.VaultSecretGroup] + :vartype secrets: list[~azure.mgmt.compute.models.VaultSecretGroup] :ivar allow_extension_operations: Specifies whether extension operations should be allowed on the virtual machine scale set. This may only be set to False when no extensions are present on the virtual machine scale set. @@ -14318,18 +23456,18 @@ def __init__( :paramtype custom_data: str :keyword windows_configuration: Specifies Windows operating system settings on the virtual machine. - :paramtype windows_configuration: ~azure.mgmt.compute.v2024_11_01.models.WindowsConfiguration + :paramtype windows_configuration: ~azure.mgmt.compute.models.WindowsConfiguration :keyword linux_configuration: Specifies the Linux operating system settings on the virtual machine. For a list of supported Linux distributions, see `Linux on Azure-Endorsed Distributions `_. - :paramtype linux_configuration: ~azure.mgmt.compute.v2024_11_01.models.LinuxConfiguration + :paramtype linux_configuration: ~azure.mgmt.compute.models.LinuxConfiguration :keyword secrets: Specifies set of certificates that should be installed onto the virtual machines in the scale set. To install certificates on a virtual machine it is recommended to use the `Azure Key Vault virtual machine extension for Linux `_ or the `Azure Key Vault virtual machine extension for Windows `_. - :paramtype secrets: list[~azure.mgmt.compute.v2024_11_01.models.VaultSecretGroup] + :paramtype secrets: list[~azure.mgmt.compute.models.VaultSecretGroup] :keyword allow_extension_operations: Specifies whether extension operations should be allowed on the virtual machine scale set. This may only be set to False when no extensions are present on the virtual machine scale set. @@ -14358,23 +23496,23 @@ class VirtualMachineScaleSetPublicIPAddressConfiguration(_serialization.Model): :ivar name: The publicIP address configuration name. Required. :vartype name: str :ivar sku: Describes the public IP Sku. It can only be set with OrchestrationMode as Flexible. - :vartype sku: ~azure.mgmt.compute.v2024_11_01.models.PublicIPAddressSku + :vartype sku: ~azure.mgmt.compute.models.PublicIPAddressSku :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. :vartype idle_timeout_in_minutes: int :ivar dns_settings: The dns settings to be applied on the publicIP addresses . :vartype dns_settings: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings + ~azure.mgmt.compute.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings :ivar ip_tags: The list of IP tags associated with the public IP address. - :vartype ip_tags: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetIpTag] + :vartype ip_tags: list[~azure.mgmt.compute.models.VirtualMachineScaleSetIpTag] :ivar public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. - :vartype public_ip_prefix: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype public_ip_prefix: ~azure.mgmt.compute.models.SubResource :ivar public_ip_address_version: 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 'IPv6'. Known values are: "IPv4" and "IPv6". - :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2024_11_01.models.IPVersion + :vartype public_ip_address_version: str or ~azure.mgmt.compute.models.IPVersion :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Known values are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DeleteOptions + :vartype delete_option: str or ~azure.mgmt.compute.models.DeleteOptions """ _validation = { @@ -14413,23 +23551,23 @@ def __init__( :paramtype name: str :keyword sku: Describes the public IP Sku. It can only be set with OrchestrationMode as Flexible. - :paramtype sku: ~azure.mgmt.compute.v2024_11_01.models.PublicIPAddressSku + :paramtype sku: ~azure.mgmt.compute.models.PublicIPAddressSku :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. :paramtype idle_timeout_in_minutes: int :keyword dns_settings: The dns settings to be applied on the publicIP addresses . :paramtype dns_settings: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings + ~azure.mgmt.compute.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings :keyword ip_tags: The list of IP tags associated with the public IP address. - :paramtype ip_tags: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetIpTag] + :paramtype ip_tags: list[~azure.mgmt.compute.models.VirtualMachineScaleSetIpTag] :keyword public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. - :paramtype public_ip_prefix: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype public_ip_prefix: ~azure.mgmt.compute.models.SubResource :keyword public_ip_address_version: 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 'IPv6'. Known values are: "IPv4" and "IPv6". - :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2024_11_01.models.IPVersion + :paramtype public_ip_address_version: str or ~azure.mgmt.compute.models.IPVersion :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Known values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DeleteOptions + :paramtype delete_option: str or ~azure.mgmt.compute.models.DeleteOptions """ super().__init__(**kwargs) self.name = name @@ -14457,8 +23595,7 @@ class VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings( domain name label that generated according to the policy from domain name label scope and vm index will be the domain name labels of the PublicIPAddress resources that will be created. Known values are: "TenantReuse", "SubscriptionReuse", "ResourceGroupReuse", and "NoReuse". - :vartype domain_name_label_scope: str or - ~azure.mgmt.compute.v2024_11_01.models.DomainNameLabelScopeTypes + :vartype domain_name_label_scope: str or ~azure.mgmt.compute.models.DomainNameLabelScopeTypes """ _validation = { @@ -14486,8 +23623,7 @@ def __init__( domain name label that generated according to the policy from domain name label scope and vm index will be the domain name labels of the PublicIPAddress resources that will be created. Known values are: "TenantReuse", "SubscriptionReuse", "ResourceGroupReuse", and "NoReuse". - :paramtype domain_name_label_scope: str or - ~azure.mgmt.compute.v2024_11_01.models.DomainNameLabelScopeTypes + :paramtype domain_name_label_scope: str or ~azure.mgmt.compute.models.DomainNameLabelScopeTypes """ super().__init__(**kwargs) self.domain_name_label = domain_name_label @@ -14505,7 +23641,7 @@ class VirtualMachineScaleSetVMReimageParameters(VirtualMachineReimageParameters) Disk. :vartype exact_version: str :ivar os_profile: Specifies information required for reimaging the non-ephemeral OS disk. - :vartype os_profile: ~azure.mgmt.compute.v2024_11_01.models.OSProfileProvisioningData + :vartype os_profile: ~azure.mgmt.compute.models.OSProfileProvisioningData :ivar force_update_os_disk_for_ephemeral: Parameter to force update ephemeral OS disk for a virtual machine scale set VM. :vartype force_update_os_disk_for_ephemeral: bool @@ -14536,7 +23672,7 @@ def __init__( Disk. :paramtype exact_version: str :keyword os_profile: Specifies information required for reimaging the non-ephemeral OS disk. - :paramtype os_profile: ~azure.mgmt.compute.v2024_11_01.models.OSProfileProvisioningData + :paramtype os_profile: ~azure.mgmt.compute.models.OSProfileProvisioningData :keyword force_update_os_disk_for_ephemeral: Parameter to force update ephemeral OS disk for a virtual machine scale set VM. :paramtype force_update_os_disk_for_ephemeral: bool @@ -14556,7 +23692,7 @@ class VirtualMachineScaleSetReimageParameters(VirtualMachineScaleSetVMReimagePar Disk. :vartype exact_version: str :ivar os_profile: Specifies information required for reimaging the non-ephemeral OS disk. - :vartype os_profile: ~azure.mgmt.compute.v2024_11_01.models.OSProfileProvisioningData + :vartype os_profile: ~azure.mgmt.compute.models.OSProfileProvisioningData :ivar force_update_os_disk_for_ephemeral: Parameter to force update ephemeral OS disk for a virtual machine scale set VM. :vartype force_update_os_disk_for_ephemeral: bool @@ -14593,7 +23729,7 @@ def __init__( Disk. :paramtype exact_version: str :keyword os_profile: Specifies information required for reimaging the non-ephemeral OS disk. - :paramtype os_profile: ~azure.mgmt.compute.v2024_11_01.models.OSProfileProvisioningData + :paramtype os_profile: ~azure.mgmt.compute.models.OSProfileProvisioningData :keyword force_update_os_disk_for_ephemeral: Parameter to force update ephemeral OS disk for a virtual machine scale set VM. :paramtype force_update_os_disk_for_ephemeral: bool @@ -14620,9 +23756,9 @@ class VirtualMachineScaleSetSku(_serialization.Model): :ivar resource_type: The type of resource the sku applies to. :vartype resource_type: str :ivar sku: The Sku. - :vartype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku + :vartype sku: ~azure.mgmt.compute.models.Sku :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetSkuCapacity + :vartype capacity: ~azure.mgmt.compute.models.VirtualMachineScaleSetSkuCapacity """ _validation = { @@ -14658,8 +23794,7 @@ class VirtualMachineScaleSetSkuCapacity(_serialization.Model): :vartype default_capacity: int :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic" and "None". - :vartype scale_type: str or - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetSkuScaleType + :vartype scale_type: str or ~azure.mgmt.compute.models.VirtualMachineScaleSetSkuScaleType """ _validation = { @@ -14692,23 +23827,21 @@ class VirtualMachineScaleSetStorageProfile(_serialization.Model): information about platform images, marketplace images, or virtual machine images. This element is required when you want to use a platform image, marketplace image, or virtual machine image, but is not used in other creation operations. - :vartype image_reference: ~azure.mgmt.compute.v2024_11_01.models.ImageReference + :vartype image_reference: ~azure.mgmt.compute.models.ImageReference :ivar os_disk: Specifies information about the operating system disk used by the virtual machines in the scale set. For more information about disks, see `About disks and VHDs for Azure virtual machines `_. - :vartype os_disk: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetOSDisk + :vartype os_disk: ~azure.mgmt.compute.models.VirtualMachineScaleSetOSDisk :ivar data_disks: Specifies the parameters that are used to add data disks to the virtual machines in the scale set. For more information about disks, see `About disks and VHDs for Azure virtual machines `_. - :vartype data_disks: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetDataDisk] + :vartype data_disks: list[~azure.mgmt.compute.models.VirtualMachineScaleSetDataDisk] :ivar disk_controller_type: Specifies the disk controller type configured for the virtual machines in the scale set. Minimum api-version: 2022-08-01. Known values are: "SCSI" and "NVMe". - :vartype disk_controller_type: str or - ~azure.mgmt.compute.v2024_11_01.models.DiskControllerTypes + :vartype disk_controller_type: str or ~azure.mgmt.compute.models.DiskControllerTypes """ _attribute_map = { @@ -14732,23 +23865,21 @@ def __init__( information about platform images, marketplace images, or virtual machine images. This element is required when you want to use a platform image, marketplace image, or virtual machine image, but is not used in other creation operations. - :paramtype image_reference: ~azure.mgmt.compute.v2024_11_01.models.ImageReference + :paramtype image_reference: ~azure.mgmt.compute.models.ImageReference :keyword os_disk: Specifies information about the operating system disk used by the virtual machines in the scale set. For more information about disks, see `About disks and VHDs for Azure virtual machines `_. - :paramtype os_disk: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetOSDisk + :paramtype os_disk: ~azure.mgmt.compute.models.VirtualMachineScaleSetOSDisk :keyword data_disks: Specifies the parameters that are used to add data disks to the virtual machines in the scale set. For more information about disks, see `About disks and VHDs for Azure virtual machines `_. - :paramtype data_disks: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetDataDisk] + :paramtype data_disks: list[~azure.mgmt.compute.models.VirtualMachineScaleSetDataDisk] :keyword disk_controller_type: Specifies the disk controller type configured for the virtual machines in the scale set. Minimum api-version: 2022-08-01. Known values are: "SCSI" and "NVMe". - :paramtype disk_controller_type: str or - ~azure.mgmt.compute.v2024_11_01.models.DiskControllerTypes + :paramtype disk_controller_type: str or ~azure.mgmt.compute.models.DiskControllerTypes """ super().__init__(**kwargs) self.image_reference = image_reference @@ -14763,22 +23894,21 @@ class VirtualMachineScaleSetUpdate(UpdateResource): :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: The virtual machine scale set sku. - :vartype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku + :vartype sku: ~azure.mgmt.compute.models.Sku :ivar plan: The purchase plan when deploying a virtual machine scale set from VM Marketplace images. - :vartype plan: ~azure.mgmt.compute.v2024_11_01.models.Plan + :vartype plan: ~azure.mgmt.compute.models.Plan :ivar identity: The identity of the virtual machine scale set, if configured. - :vartype identity: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetIdentity + :vartype identity: ~azure.mgmt.compute.models.VirtualMachineScaleSetIdentity :ivar zones: The virtual machine scale set zones. :vartype zones: list[str] :ivar upgrade_policy: The upgrade policy. - :vartype upgrade_policy: ~azure.mgmt.compute.v2024_11_01.models.UpgradePolicy + :vartype upgrade_policy: ~azure.mgmt.compute.models.UpgradePolicy :ivar automatic_repairs_policy: Policy for automatic repairs. - :vartype automatic_repairs_policy: - ~azure.mgmt.compute.v2024_11_01.models.AutomaticRepairsPolicy + :vartype automatic_repairs_policy: ~azure.mgmt.compute.models.AutomaticRepairsPolicy :ivar virtual_machine_profile: The virtual machine profile. :vartype virtual_machine_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdateVMProfile + ~azure.mgmt.compute.models.VirtualMachineScaleSetUpdateVMProfile :ivar overprovision: Specifies whether the Virtual Machine Scale Set should be overprovisioned. :vartype overprovision: bool :ivar do_not_run_extensions_on_overprovisioned_v_ms: When Overprovision is enabled, extensions @@ -14793,28 +23923,28 @@ class VirtualMachineScaleSetUpdate(UpdateResource): Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines have the capability to support attaching managed data disks with UltraSSD_LRS storage account type. - :vartype additional_capabilities: ~azure.mgmt.compute.v2024_11_01.models.AdditionalCapabilities + :vartype additional_capabilities: ~azure.mgmt.compute.models.AdditionalCapabilities :ivar scale_in_policy: Specifies the policies applied when scaling in Virtual Machines in the Virtual Machine Scale Set. - :vartype scale_in_policy: ~azure.mgmt.compute.v2024_11_01.models.ScaleInPolicy + :vartype scale_in_policy: ~azure.mgmt.compute.models.ScaleInPolicy :ivar proximity_placement_group: Specifies information about the proximity placement group that the virtual machine scale set should be assigned to. :code:`
`\\ :code:`
`Minimum api-version: 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype proximity_placement_group: ~azure.mgmt.compute.models.SubResource :ivar priority_mix_policy: Specifies the desired targets for mixing Spot and Regular priority VMs within the same VMSS Flex instance. - :vartype priority_mix_policy: ~azure.mgmt.compute.v2024_11_01.models.PriorityMixPolicy + :vartype priority_mix_policy: ~azure.mgmt.compute.models.PriorityMixPolicy :ivar spot_restore_policy: Specifies the Spot Restore properties for the virtual machine scale set. - :vartype spot_restore_policy: ~azure.mgmt.compute.v2024_11_01.models.SpotRestorePolicy + :vartype spot_restore_policy: ~azure.mgmt.compute.models.SpotRestorePolicy :ivar resiliency_policy: Policy for Resiliency. - :vartype resiliency_policy: ~azure.mgmt.compute.v2024_11_01.models.ResiliencyPolicy + :vartype resiliency_policy: ~azure.mgmt.compute.models.ResiliencyPolicy :ivar zonal_platform_fault_domain_align_mode: Specifies the align mode between Virtual Machine Scale Set compute and storage Fault Domain count. Known values are: "Aligned" and "Unaligned". :vartype zonal_platform_fault_domain_align_mode: str or - ~azure.mgmt.compute.v2024_11_01.models.ZonalPlatformFaultDomainAlignMode + ~azure.mgmt.compute.models.ZonalPlatformFaultDomainAlignMode :ivar sku_profile: Specifies the sku profile for the virtual machine scale set. - :vartype sku_profile: ~azure.mgmt.compute.v2024_11_01.models.SkuProfile + :vartype sku_profile: ~azure.mgmt.compute.models.SkuProfile """ _attribute_map = { @@ -14878,22 +24008,21 @@ def __init__( :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: The virtual machine scale set sku. - :paramtype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku + :paramtype sku: ~azure.mgmt.compute.models.Sku :keyword plan: The purchase plan when deploying a virtual machine scale set from VM Marketplace images. - :paramtype plan: ~azure.mgmt.compute.v2024_11_01.models.Plan + :paramtype plan: ~azure.mgmt.compute.models.Plan :keyword identity: The identity of the virtual machine scale set, if configured. - :paramtype identity: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetIdentity + :paramtype identity: ~azure.mgmt.compute.models.VirtualMachineScaleSetIdentity :keyword zones: The virtual machine scale set zones. :paramtype zones: list[str] :keyword upgrade_policy: The upgrade policy. - :paramtype upgrade_policy: ~azure.mgmt.compute.v2024_11_01.models.UpgradePolicy + :paramtype upgrade_policy: ~azure.mgmt.compute.models.UpgradePolicy :keyword automatic_repairs_policy: Policy for automatic repairs. - :paramtype automatic_repairs_policy: - ~azure.mgmt.compute.v2024_11_01.models.AutomaticRepairsPolicy + :paramtype automatic_repairs_policy: ~azure.mgmt.compute.models.AutomaticRepairsPolicy :keyword virtual_machine_profile: The virtual machine profile. :paramtype virtual_machine_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdateVMProfile + ~azure.mgmt.compute.models.VirtualMachineScaleSetUpdateVMProfile :keyword overprovision: Specifies whether the Virtual Machine Scale Set should be overprovisioned. :paramtype overprovision: bool @@ -14909,30 +24038,29 @@ def __init__( Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines have the capability to support attaching managed data disks with UltraSSD_LRS storage account type. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2024_11_01.models.AdditionalCapabilities + :paramtype additional_capabilities: ~azure.mgmt.compute.models.AdditionalCapabilities :keyword scale_in_policy: Specifies the policies applied when scaling in Virtual Machines in the Virtual Machine Scale Set. - :paramtype scale_in_policy: ~azure.mgmt.compute.v2024_11_01.models.ScaleInPolicy + :paramtype scale_in_policy: ~azure.mgmt.compute.models.ScaleInPolicy :keyword proximity_placement_group: Specifies information about the proximity placement group that the virtual machine scale set should be assigned to. :code:`
`\\ :code:`
`Minimum api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype proximity_placement_group: ~azure.mgmt.compute.models.SubResource :keyword priority_mix_policy: Specifies the desired targets for mixing Spot and Regular priority VMs within the same VMSS Flex instance. - :paramtype priority_mix_policy: ~azure.mgmt.compute.v2024_11_01.models.PriorityMixPolicy + :paramtype priority_mix_policy: ~azure.mgmt.compute.models.PriorityMixPolicy :keyword spot_restore_policy: Specifies the Spot Restore properties for the virtual machine scale set. - :paramtype spot_restore_policy: ~azure.mgmt.compute.v2024_11_01.models.SpotRestorePolicy + :paramtype spot_restore_policy: ~azure.mgmt.compute.models.SpotRestorePolicy :keyword resiliency_policy: Policy for Resiliency. - :paramtype resiliency_policy: ~azure.mgmt.compute.v2024_11_01.models.ResiliencyPolicy + :paramtype resiliency_policy: ~azure.mgmt.compute.models.ResiliencyPolicy :keyword zonal_platform_fault_domain_align_mode: Specifies the align mode between Virtual Machine Scale Set compute and storage Fault Domain count. Known values are: "Aligned" and "Unaligned". :paramtype zonal_platform_fault_domain_align_mode: str or - ~azure.mgmt.compute.v2024_11_01.models.ZonalPlatformFaultDomainAlignMode + ~azure.mgmt.compute.models.ZonalPlatformFaultDomainAlignMode :keyword sku_profile: Specifies the sku profile for the virtual machine scale set. - :paramtype sku_profile: ~azure.mgmt.compute.v2024_11_01.models.SkuProfile + :paramtype sku_profile: ~azure.mgmt.compute.models.SkuProfile """ super().__init__(tags=tags, **kwargs) self.sku = sku @@ -14963,29 +24091,27 @@ class VirtualMachineScaleSetUpdateIPConfiguration(_serialization.Model): # pyli :ivar name: The IP configuration name. :vartype name: str :ivar subnet: The subnet. - :vartype subnet: ~azure.mgmt.compute.v2024_11_01.models.ApiEntityReference + :vartype subnet: ~azure.mgmt.compute.models.ApiEntityReference :ivar primary: Specifies the primary IP Configuration in case the network interface has more than one IP Configuration. :vartype primary: bool :ivar public_ip_address_configuration: The publicIPAddressConfiguration. :vartype public_ip_address_configuration: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration + ~azure.mgmt.compute.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :ivar private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2024_11_01.models.IPVersion + :vartype private_ip_address_version: str or ~azure.mgmt.compute.models.IPVersion :ivar application_gateway_backend_address_pools: The application gateway backend address pools. :vartype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + list[~azure.mgmt.compute.models.SubResource] :ivar application_security_groups: Specifies an array of references to application security group. - :vartype application_security_groups: list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :vartype application_security_groups: list[~azure.mgmt.compute.models.SubResource] :ivar load_balancer_backend_address_pools: The load balancer backend address pools. - :vartype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :vartype load_balancer_backend_address_pools: list[~azure.mgmt.compute.models.SubResource] :ivar load_balancer_inbound_nat_pools: The load balancer inbound nat pools. - :vartype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :vartype load_balancer_inbound_nat_pools: list[~azure.mgmt.compute.models.SubResource] """ _attribute_map = { @@ -15029,31 +24155,28 @@ def __init__( :keyword name: The IP configuration name. :paramtype name: str :keyword subnet: The subnet. - :paramtype subnet: ~azure.mgmt.compute.v2024_11_01.models.ApiEntityReference + :paramtype subnet: ~azure.mgmt.compute.models.ApiEntityReference :keyword primary: Specifies the primary IP Configuration in case the network interface has more than one IP Configuration. :paramtype primary: bool :keyword public_ip_address_configuration: The publicIPAddressConfiguration. :paramtype public_ip_address_configuration: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration + ~azure.mgmt.compute.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :keyword private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2024_11_01.models.IPVersion + :paramtype private_ip_address_version: str or ~azure.mgmt.compute.models.IPVersion :keyword application_gateway_backend_address_pools: The application gateway backend address pools. :paramtype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + list[~azure.mgmt.compute.models.SubResource] :keyword application_security_groups: Specifies an array of references to application security group. - :paramtype application_security_groups: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :paramtype application_security_groups: list[~azure.mgmt.compute.models.SubResource] :keyword load_balancer_backend_address_pools: The load balancer backend address pools. - :paramtype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :paramtype load_balancer_backend_address_pools: list[~azure.mgmt.compute.models.SubResource] :keyword load_balancer_inbound_nat_pools: The load balancer inbound nat pools. - :paramtype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2024_11_01.models.SubResource] + :paramtype load_balancer_inbound_nat_pools: list[~azure.mgmt.compute.models.SubResource] """ super().__init__(**kwargs) self.name = name @@ -15083,26 +24206,24 @@ class VirtualMachineScaleSetUpdateNetworkConfiguration(_serialization.Model): # :ivar enable_fpga: Specifies whether the network interface is FPGA networking-enabled. :vartype enable_fpga: bool :ivar network_security_group: The network security group. - :vartype network_security_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype network_security_group: ~azure.mgmt.compute.models.SubResource :ivar dns_settings: The dns settings to be applied on the network interfaces. :vartype dns_settings: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings + ~azure.mgmt.compute.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings :ivar ip_configurations: The virtual machine scale set IP Configuration. :vartype ip_configurations: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdateIPConfiguration] + list[~azure.mgmt.compute.models.VirtualMachineScaleSetUpdateIPConfiguration] :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :vartype enable_ip_forwarding: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. Known values are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DeleteOptions + :vartype delete_option: str or ~azure.mgmt.compute.models.DeleteOptions :ivar auxiliary_mode: Specifies whether the Auxiliary mode is enabled for the Network Interface resource. Known values are: "None", "AcceleratedConnections", and "Floating". - :vartype auxiliary_mode: str or - ~azure.mgmt.compute.v2024_11_01.models.NetworkInterfaceAuxiliaryMode + :vartype auxiliary_mode: str or ~azure.mgmt.compute.models.NetworkInterfaceAuxiliaryMode :ivar auxiliary_sku: Specifies whether the Auxiliary sku is enabled for the Network Interface resource. Known values are: "None", "A1", "A2", "A4", and "A8". - :vartype auxiliary_sku: str or - ~azure.mgmt.compute.v2024_11_01.models.NetworkInterfaceAuxiliarySku + :vartype auxiliary_sku: str or ~azure.mgmt.compute.models.NetworkInterfaceAuxiliarySku """ _attribute_map = { @@ -15157,26 +24278,24 @@ def __init__( :keyword enable_fpga: Specifies whether the network interface is FPGA networking-enabled. :paramtype enable_fpga: bool :keyword network_security_group: The network security group. - :paramtype network_security_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype network_security_group: ~azure.mgmt.compute.models.SubResource :keyword dns_settings: The dns settings to be applied on the network interfaces. :paramtype dns_settings: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings + ~azure.mgmt.compute.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings :keyword ip_configurations: The virtual machine scale set IP Configuration. :paramtype ip_configurations: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdateIPConfiguration] + list[~azure.mgmt.compute.models.VirtualMachineScaleSetUpdateIPConfiguration] :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :paramtype enable_ip_forwarding: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. Known values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DeleteOptions + :paramtype delete_option: str or ~azure.mgmt.compute.models.DeleteOptions :keyword auxiliary_mode: Specifies whether the Auxiliary mode is enabled for the Network Interface resource. Known values are: "None", "AcceleratedConnections", and "Floating". - :paramtype auxiliary_mode: str or - ~azure.mgmt.compute.v2024_11_01.models.NetworkInterfaceAuxiliaryMode + :paramtype auxiliary_mode: str or ~azure.mgmt.compute.models.NetworkInterfaceAuxiliaryMode :keyword auxiliary_sku: Specifies whether the Auxiliary sku is enabled for the Network Interface resource. Known values are: "None", "A1", "A2", "A4", and "A8". - :paramtype auxiliary_sku: str or - ~azure.mgmt.compute.v2024_11_01.models.NetworkInterfaceAuxiliarySku + :paramtype auxiliary_sku: str or ~azure.mgmt.compute.models.NetworkInterfaceAuxiliarySku """ super().__init__(**kwargs) self.name = name @@ -15199,14 +24318,14 @@ class VirtualMachineScaleSetUpdateNetworkProfile(_serialization.Model): # pylin :ivar health_probe: A reference to a load balancer probe used to determine the health of an instance in the virtual machine scale set. The reference will be in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :vartype health_probe: ~azure.mgmt.compute.v2024_11_01.models.ApiEntityReference + :vartype health_probe: ~azure.mgmt.compute.models.ApiEntityReference :ivar network_interface_configurations: The list of network configurations. :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] + list[~azure.mgmt.compute.models.VirtualMachineScaleSetUpdateNetworkConfiguration] :ivar network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with orchestration mode 'Flexible'. Known values are: "2020-11-01" and "2022-11-01". - :vartype network_api_version: str or ~azure.mgmt.compute.v2024_11_01.models.NetworkApiVersion + :vartype network_api_version: str or ~azure.mgmt.compute.models.NetworkApiVersion """ _attribute_map = { @@ -15232,14 +24351,14 @@ def __init__( :keyword health_probe: A reference to a load balancer probe used to determine the health of an instance in the virtual machine scale set. The reference will be in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :paramtype health_probe: ~azure.mgmt.compute.v2024_11_01.models.ApiEntityReference + :paramtype health_probe: ~azure.mgmt.compute.models.ApiEntityReference :keyword network_interface_configurations: The list of network configurations. :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] + list[~azure.mgmt.compute.models.VirtualMachineScaleSetUpdateNetworkConfiguration] :keyword network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with orchestration mode 'Flexible'. Known values are: "2020-11-01" and "2022-11-01". - :paramtype network_api_version: str or ~azure.mgmt.compute.v2024_11_01.models.NetworkApiVersion + :paramtype network_api_version: str or ~azure.mgmt.compute.models.NetworkApiVersion """ super().__init__(**kwargs) self.health_probe = health_probe @@ -15252,13 +24371,13 @@ class VirtualMachineScaleSetUpdateOSDisk(_serialization.Model): for Updating VMSS OS Disk. :ivar caching: The caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes + :vartype caching: str or ~azure.mgmt.compute.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :vartype write_accelerator_enabled: bool :ivar diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. - :vartype diff_disk_settings: ~azure.mgmt.compute.v2024_11_01.models.DiffDiskSettings + :vartype diff_disk_settings: ~azure.mgmt.compute.models.DiffDiskSettings :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`\\ :code:`
` diskSizeGB is the number of bytes x 1024^3 for the disk and the value cannot be larger than @@ -15267,12 +24386,11 @@ class VirtualMachineScaleSetUpdateOSDisk(_serialization.Model): :ivar image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before using it to attach to the Virtual Machine. If SourceImage is provided, the destination VirtualHardDisk should not exist. - :vartype image: ~azure.mgmt.compute.v2024_11_01.models.VirtualHardDisk + :vartype image: ~azure.mgmt.compute.models.VirtualHardDisk :ivar vhd_containers: The list of virtual hard disk container uris. :vartype vhd_containers: list[str] :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetManagedDiskParameters + :vartype managed_disk: ~azure.mgmt.compute.models.VirtualMachineScaleSetManagedDiskParameters :ivar delete_option: Specifies whether OS Disk should be deleted or detached upon VMSS Flex deletion (This feature is available for VMSS with Flexible OrchestrationMode only). :code:`
`\\ :code:`
` Possible values: :code:`
`\\ :code:`
` **Delete** If this @@ -15281,7 +24399,7 @@ class VirtualMachineScaleSetUpdateOSDisk(_serialization.Model): deleted. :code:`
`\\ :code:`
` The default value is set to **Delete**. For an Ephemeral OS Disk, the default value is set to **Delete**. User cannot change the delete option for Ephemeral OS Disk. Known values are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskDeleteOptionTypes + :vartype delete_option: str or ~azure.mgmt.compute.models.DiskDeleteOptionTypes """ _attribute_map = { @@ -15310,13 +24428,13 @@ def __init__( ) -> None: """ :keyword caching: The caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2024_11_01.models.CachingTypes + :paramtype caching: str or ~azure.mgmt.compute.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :paramtype write_accelerator_enabled: bool :keyword diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. - :paramtype diff_disk_settings: ~azure.mgmt.compute.v2024_11_01.models.DiffDiskSettings + :paramtype diff_disk_settings: ~azure.mgmt.compute.models.DiffDiskSettings :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`\\ :code:`
` diskSizeGB is the number of bytes x 1024^3 for the disk and the value cannot be @@ -15325,12 +24443,11 @@ def __init__( :keyword image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before using it to attach to the Virtual Machine. If SourceImage is provided, the destination VirtualHardDisk should not exist. - :paramtype image: ~azure.mgmt.compute.v2024_11_01.models.VirtualHardDisk + :paramtype image: ~azure.mgmt.compute.models.VirtualHardDisk :keyword vhd_containers: The list of virtual hard disk container uris. :paramtype vhd_containers: list[str] :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetManagedDiskParameters + :paramtype managed_disk: ~azure.mgmt.compute.models.VirtualMachineScaleSetManagedDiskParameters :keyword delete_option: Specifies whether OS Disk should be deleted or detached upon VMSS Flex deletion (This feature is available for VMSS with Flexible OrchestrationMode only). :code:`
`\\ :code:`
` Possible values: :code:`
`\\ :code:`
` **Delete** If this @@ -15339,7 +24456,7 @@ def __init__( deleted. :code:`
`\\ :code:`
` The default value is set to **Delete**. For an Ephemeral OS Disk, the default value is set to **Delete**. User cannot change the delete option for Ephemeral OS Disk. Known values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskDeleteOptionTypes + :paramtype delete_option: str or ~azure.mgmt.compute.models.DiskDeleteOptionTypes """ super().__init__(**kwargs) self.caching = caching @@ -15358,11 +24475,11 @@ class VirtualMachineScaleSetUpdateOSProfile(_serialization.Model): :ivar custom_data: A base-64 encoded string of custom data. :vartype custom_data: str :ivar windows_configuration: The Windows Configuration of the OS profile. - :vartype windows_configuration: ~azure.mgmt.compute.v2024_11_01.models.WindowsConfiguration + :vartype windows_configuration: ~azure.mgmt.compute.models.WindowsConfiguration :ivar linux_configuration: The Linux Configuration of the OS profile. - :vartype linux_configuration: ~azure.mgmt.compute.v2024_11_01.models.LinuxConfiguration + :vartype linux_configuration: ~azure.mgmt.compute.models.LinuxConfiguration :ivar secrets: The List of certificates for addition to the VM. - :vartype secrets: list[~azure.mgmt.compute.v2024_11_01.models.VaultSecretGroup] + :vartype secrets: list[~azure.mgmt.compute.models.VaultSecretGroup] """ _attribute_map = { @@ -15385,11 +24502,11 @@ def __init__( :keyword custom_data: A base-64 encoded string of custom data. :paramtype custom_data: str :keyword windows_configuration: The Windows Configuration of the OS profile. - :paramtype windows_configuration: ~azure.mgmt.compute.v2024_11_01.models.WindowsConfiguration + :paramtype windows_configuration: ~azure.mgmt.compute.models.WindowsConfiguration :keyword linux_configuration: The Linux Configuration of the OS profile. - :paramtype linux_configuration: ~azure.mgmt.compute.v2024_11_01.models.LinuxConfiguration + :paramtype linux_configuration: ~azure.mgmt.compute.models.LinuxConfiguration :keyword secrets: The List of certificates for addition to the VM. - :paramtype secrets: list[~azure.mgmt.compute.v2024_11_01.models.VaultSecretGroup] + :paramtype secrets: list[~azure.mgmt.compute.models.VaultSecretGroup] """ super().__init__(**kwargs) self.custom_data = custom_data @@ -15407,12 +24524,12 @@ class VirtualMachineScaleSetUpdatePublicIPAddressConfiguration(_serialization.Mo :vartype idle_timeout_in_minutes: int :ivar dns_settings: The dns settings to be applied on the publicIP addresses . :vartype dns_settings: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings + ~azure.mgmt.compute.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings :ivar public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. - :vartype public_ip_prefix: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype public_ip_prefix: ~azure.mgmt.compute.models.SubResource :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Known values are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DeleteOptions + :vartype delete_option: str or ~azure.mgmt.compute.models.DeleteOptions """ _attribute_map = { @@ -15443,12 +24560,12 @@ def __init__( :paramtype idle_timeout_in_minutes: int :keyword dns_settings: The dns settings to be applied on the publicIP addresses . :paramtype dns_settings: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings + ~azure.mgmt.compute.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings :keyword public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. - :paramtype public_ip_prefix: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype public_ip_prefix: ~azure.mgmt.compute.models.SubResource :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Known values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2024_11_01.models.DeleteOptions + :paramtype delete_option: str or ~azure.mgmt.compute.models.DeleteOptions """ super().__init__(**kwargs) self.name = name @@ -15462,18 +24579,16 @@ class VirtualMachineScaleSetUpdateStorageProfile(_serialization.Model): # pylin """Describes a virtual machine scale set storage profile. :ivar image_reference: The image reference. - :vartype image_reference: ~azure.mgmt.compute.v2024_11_01.models.ImageReference + :vartype image_reference: ~azure.mgmt.compute.models.ImageReference :ivar os_disk: The OS disk. - :vartype os_disk: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdateOSDisk + :vartype os_disk: ~azure.mgmt.compute.models.VirtualMachineScaleSetUpdateOSDisk :ivar data_disks: The data disks. - :vartype data_disks: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetDataDisk] + :vartype data_disks: list[~azure.mgmt.compute.models.VirtualMachineScaleSetDataDisk] :ivar disk_controller_type: Specifies the disk controller type configured for the virtual machines in the scale set. **Note:** You need to deallocate the virtual machines in the scale set before updating its disk controller type based on the upgrade mode configured for the scale set. Minimum api-version: 2022-08-01. Known values are: "SCSI" and "NVMe". - :vartype disk_controller_type: str or - ~azure.mgmt.compute.v2024_11_01.models.DiskControllerTypes + :vartype disk_controller_type: str or ~azure.mgmt.compute.models.DiskControllerTypes """ _attribute_map = { @@ -15494,18 +24609,16 @@ def __init__( ) -> None: """ :keyword image_reference: The image reference. - :paramtype image_reference: ~azure.mgmt.compute.v2024_11_01.models.ImageReference + :paramtype image_reference: ~azure.mgmt.compute.models.ImageReference :keyword os_disk: The OS disk. - :paramtype os_disk: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdateOSDisk + :paramtype os_disk: ~azure.mgmt.compute.models.VirtualMachineScaleSetUpdateOSDisk :keyword data_disks: The data disks. - :paramtype data_disks: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetDataDisk] + :paramtype data_disks: list[~azure.mgmt.compute.models.VirtualMachineScaleSetDataDisk] :keyword disk_controller_type: Specifies the disk controller type configured for the virtual machines in the scale set. **Note:** You need to deallocate the virtual machines in the scale set before updating its disk controller type based on the upgrade mode configured for the scale set. Minimum api-version: 2022-08-01. Known values are: "SCSI" and "NVMe". - :paramtype disk_controller_type: str or - ~azure.mgmt.compute.v2024_11_01.models.DiskControllerTypes + :paramtype disk_controller_type: str or ~azure.mgmt.compute.models.DiskControllerTypes """ super().__init__(**kwargs) self.image_reference = image_reference @@ -15518,39 +24631,32 @@ class VirtualMachineScaleSetUpdateVMProfile(_serialization.Model): """Describes a virtual machine scale set virtual machine profile. :ivar os_profile: The virtual machine scale set OS profile. - :vartype os_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdateOSProfile + :vartype os_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetUpdateOSProfile :ivar storage_profile: The virtual machine scale set storage profile. - :vartype storage_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdateStorageProfile + :vartype storage_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetUpdateStorageProfile :ivar network_profile: The virtual machine scale set network profile. - :vartype network_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdateNetworkProfile + :vartype network_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetUpdateNetworkProfile :ivar security_posture_reference: The virtual machine scale set security posture reference. - :vartype security_posture_reference: - ~azure.mgmt.compute.v2024_11_01.models.SecurityPostureReferenceUpdate + :vartype security_posture_reference: ~azure.mgmt.compute.models.SecurityPostureReferenceUpdate :ivar security_profile: The virtual machine scale set Security profile. - :vartype security_profile: ~azure.mgmt.compute.v2024_11_01.models.SecurityProfile + :vartype security_profile: ~azure.mgmt.compute.models.SecurityProfile :ivar diagnostics_profile: The virtual machine scale set diagnostics profile. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2024_11_01.models.DiagnosticsProfile + :vartype diagnostics_profile: ~azure.mgmt.compute.models.DiagnosticsProfile :ivar extension_profile: The virtual machine scale set extension profile. - :vartype extension_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtensionProfile + :vartype extension_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetExtensionProfile :ivar license_type: The license type, which is for bring your own license scenario. :vartype license_type: str :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2024_11_01.models.BillingProfile + :vartype billing_profile: ~azure.mgmt.compute.models.BillingProfile :ivar scheduled_events_profile: Specifies Scheduled Event related configurations. - :vartype scheduled_events_profile: - ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsProfile + :vartype scheduled_events_profile: ~azure.mgmt.compute.models.ScheduledEventsProfile :ivar user_data: UserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here. :code:`
`\\ :code:`
`Minimum api-version: 2021-03-01. :vartype user_data: str :ivar hardware_profile: Specifies the hardware profile related details of a scale set. Minimum api-version: 2021-11-01. - :vartype hardware_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetHardwareProfile + :vartype hardware_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetHardwareProfile """ _attribute_map = { @@ -15587,39 +24693,35 @@ def __init__( ) -> None: """ :keyword os_profile: The virtual machine scale set OS profile. - :paramtype os_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdateOSProfile + :paramtype os_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetUpdateOSProfile :keyword storage_profile: The virtual machine scale set storage profile. :paramtype storage_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdateStorageProfile + ~azure.mgmt.compute.models.VirtualMachineScaleSetUpdateStorageProfile :keyword network_profile: The virtual machine scale set network profile. :paramtype network_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdateNetworkProfile + ~azure.mgmt.compute.models.VirtualMachineScaleSetUpdateNetworkProfile :keyword security_posture_reference: The virtual machine scale set security posture reference. :paramtype security_posture_reference: - ~azure.mgmt.compute.v2024_11_01.models.SecurityPostureReferenceUpdate + ~azure.mgmt.compute.models.SecurityPostureReferenceUpdate :keyword security_profile: The virtual machine scale set Security profile. - :paramtype security_profile: ~azure.mgmt.compute.v2024_11_01.models.SecurityProfile + :paramtype security_profile: ~azure.mgmt.compute.models.SecurityProfile :keyword diagnostics_profile: The virtual machine scale set diagnostics profile. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2024_11_01.models.DiagnosticsProfile + :paramtype diagnostics_profile: ~azure.mgmt.compute.models.DiagnosticsProfile :keyword extension_profile: The virtual machine scale set extension profile. - :paramtype extension_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtensionProfile + :paramtype extension_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetExtensionProfile :keyword license_type: The license type, which is for bring your own license scenario. :paramtype license_type: str :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2024_11_01.models.BillingProfile + :paramtype billing_profile: ~azure.mgmt.compute.models.BillingProfile :keyword scheduled_events_profile: Specifies Scheduled Event related configurations. - :paramtype scheduled_events_profile: - ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsProfile + :paramtype scheduled_events_profile: ~azure.mgmt.compute.models.ScheduledEventsProfile :keyword user_data: UserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here. :code:`
`\\ :code:`
`Minimum api-version: 2021-03-01. :paramtype user_data: str :keyword hardware_profile: Specifies the hardware profile related details of a scale set. Minimum api-version: 2021-11-01. - :paramtype hardware_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetHardwareProfile + :paramtype hardware_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetHardwareProfile """ super().__init__(**kwargs) self.os_profile = os_profile @@ -15653,7 +24755,7 @@ class VirtualMachineScaleSetVM(TrackedResource): :vartype type: str :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. - :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData + :vartype system_data: ~azure.mgmt.compute.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. @@ -15661,19 +24763,19 @@ class VirtualMachineScaleSetVM(TrackedResource): :ivar instance_id: The virtual machine instance ID. :vartype instance_id: str :ivar sku: The virtual machine SKU. - :vartype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku + :vartype sku: ~azure.mgmt.compute.models.Sku :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 the marketplace image that you want to use and then click **Want to deploy programmatically, Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2024_11_01.models.Plan + :vartype plan: ~azure.mgmt.compute.models.Plan :ivar resources: The virtual machine child extension resources. - :vartype resources: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] + :vartype resources: list[~azure.mgmt.compute.models.VirtualMachineExtension] :ivar zones: The virtual machine zones. :vartype zones: list[str] :ivar identity: The identity of the virtual machine, if configured. - :vartype identity: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineIdentity + :vartype identity: ~azure.mgmt.compute.models.VirtualMachineIdentity :ivar etag: Etag is property returned in Update/Get response of the VMSS VM, so that customer can supply it in the header to ensure optimistic updates. :vartype etag: str @@ -15683,34 +24785,33 @@ class VirtualMachineScaleSetVM(TrackedResource): :ivar vm_id: Azure VM unique ID. :vartype vm_id: str :ivar instance_view: The virtual machine instance view. - :vartype instance_view: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceView + :vartype instance_view: ~azure.mgmt.compute.models.VirtualMachineScaleSetVMInstanceView :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2024_11_01.models.HardwareProfile + :vartype hardware_profile: ~azure.mgmt.compute.models.HardwareProfile :ivar resilient_vm_deletion_status: Specifies the resilient VM deletion status for the virtual machine. Known values are: "Enabled", "Disabled", "InProgress", and "Failed". :vartype resilient_vm_deletion_status: str or - ~azure.mgmt.compute.v2024_11_01.models.ResilientVMDeletionStatus + ~azure.mgmt.compute.models.ResilientVMDeletionStatus :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2024_11_01.models.StorageProfile + :vartype storage_profile: ~azure.mgmt.compute.models.StorageProfile :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the virtual machine in the scale set. For instance: whether the virtual machine has the capability to support attaching managed data disks with UltraSSD_LRS storage account type. - :vartype additional_capabilities: ~azure.mgmt.compute.v2024_11_01.models.AdditionalCapabilities + :vartype additional_capabilities: ~azure.mgmt.compute.models.AdditionalCapabilities :ivar os_profile: Specifies the operating system settings for the virtual machine. - :vartype os_profile: ~azure.mgmt.compute.v2024_11_01.models.OSProfile + :vartype os_profile: ~azure.mgmt.compute.models.OSProfile :ivar security_profile: Specifies the Security related profile settings for the virtual machine. - :vartype security_profile: ~azure.mgmt.compute.v2024_11_01.models.SecurityProfile + :vartype security_profile: ~azure.mgmt.compute.models.SecurityProfile :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2024_11_01.models.NetworkProfile + :vartype network_profile: ~azure.mgmt.compute.models.NetworkProfile :ivar network_profile_configuration: Specifies the network profile configuration of the virtual machine. :vartype network_profile_configuration: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMNetworkProfileConfiguration + ~azure.mgmt.compute.models.VirtualMachineScaleSetVMNetworkProfileConfiguration :ivar diagnostics_profile: Specifies the boot diagnostic settings state. Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2024_11_01.models.DiagnosticsProfile + :vartype diagnostics_profile: ~azure.mgmt.compute.models.DiagnosticsProfile :ivar availability_set: 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 @@ -15720,7 +24821,7 @@ class VirtualMachineScaleSetVM(TrackedResource): Azure `_. Currently, a VM can only be added to availability set at creation time. An existing VM cannot be added to an availability set. - :vartype availability_set: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype availability_set: ~azure.mgmt.compute.models.SubResource :ivar provisioning_state: The provisioning state, which only appears in the response. :vartype provisioning_state: str :ivar license_type: Specifies that the image or disk that is being used was licensed @@ -15739,8 +24840,7 @@ class VirtualMachineScaleSetVM(TrackedResource): the model of the virtual machine scale set or the customized model for the virtual machine. :vartype model_definition_applied: str :ivar protection_policy: Specifies the protection policy of the virtual machine. - :vartype protection_policy: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMProtectionPolicy + :vartype protection_policy: ~azure.mgmt.compute.models.VirtualMachineScaleSetVMProtectionPolicy :ivar user_data: UserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here. Minimum api-version: 2021-03-01. :vartype user_data: str @@ -15838,36 +24938,35 @@ def __init__( # pylint: disable=too-many-locals image from an API, you must enable the image for programmatic use. In the Azure portal, find the marketplace image that you want to use and then click **Want to deploy programmatically, Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2024_11_01.models.Plan + :paramtype plan: ~azure.mgmt.compute.models.Plan :keyword identity: The identity of the virtual machine, if configured. - :paramtype identity: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineIdentity + :paramtype identity: ~azure.mgmt.compute.models.VirtualMachineIdentity :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2024_11_01.models.HardwareProfile + :paramtype hardware_profile: ~azure.mgmt.compute.models.HardwareProfile :keyword resilient_vm_deletion_status: Specifies the resilient VM deletion status for the virtual machine. Known values are: "Enabled", "Disabled", "InProgress", and "Failed". :paramtype resilient_vm_deletion_status: str or - ~azure.mgmt.compute.v2024_11_01.models.ResilientVMDeletionStatus + ~azure.mgmt.compute.models.ResilientVMDeletionStatus :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2024_11_01.models.StorageProfile + :paramtype storage_profile: ~azure.mgmt.compute.models.StorageProfile :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the virtual machine in the scale set. For instance: whether the virtual machine has the capability to support attaching managed data disks with UltraSSD_LRS storage account type. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2024_11_01.models.AdditionalCapabilities + :paramtype additional_capabilities: ~azure.mgmt.compute.models.AdditionalCapabilities :keyword os_profile: Specifies the operating system settings for the virtual machine. - :paramtype os_profile: ~azure.mgmt.compute.v2024_11_01.models.OSProfile + :paramtype os_profile: ~azure.mgmt.compute.models.OSProfile :keyword security_profile: Specifies the Security related profile settings for the virtual machine. - :paramtype security_profile: ~azure.mgmt.compute.v2024_11_01.models.SecurityProfile + :paramtype security_profile: ~azure.mgmt.compute.models.SecurityProfile :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2024_11_01.models.NetworkProfile + :paramtype network_profile: ~azure.mgmt.compute.models.NetworkProfile :keyword network_profile_configuration: Specifies the network profile configuration of the virtual machine. :paramtype network_profile_configuration: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMNetworkProfileConfiguration + ~azure.mgmt.compute.models.VirtualMachineScaleSetVMNetworkProfileConfiguration :keyword diagnostics_profile: Specifies the boot diagnostic settings state. Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2024_11_01.models.DiagnosticsProfile + :paramtype diagnostics_profile: ~azure.mgmt.compute.models.DiagnosticsProfile :keyword availability_set: 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 @@ -15877,7 +24976,7 @@ def __init__( # pylint: disable=too-many-locals Azure `_. Currently, a VM can only be added to availability set at creation time. An existing VM cannot be added to an availability set. - :paramtype availability_set: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype availability_set: ~azure.mgmt.compute.models.SubResource :keyword license_type: Specifies that the image or disk that is being used was licensed on-premises. :code:`
`\\ :code:`
` Possible values for Windows Server operating system are: :code:`
`\\ :code:`
` Windows_Client :code:`
`\\ :code:`
` Windows_Server @@ -15892,7 +24991,7 @@ def __init__( # pylint: disable=too-many-locals :paramtype license_type: str :keyword protection_policy: Specifies the protection policy of the virtual machine. :paramtype protection_policy: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMProtectionPolicy + ~azure.mgmt.compute.models.VirtualMachineScaleSetVMProtectionPolicy :keyword user_data: UserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here. Minimum api-version: 2021-03-01. :paramtype user_data: str @@ -15964,16 +25063,14 @@ class VirtualMachineScaleSetVMExtension(SubResourceReadOnly): :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. - :vartype instance_view: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionInstanceView + :vartype instance_view: ~azure.mgmt.compute.models.VirtualMachineExtensionInstanceView :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. :vartype suppress_failures: bool :ivar protected_settings_from_key_vault: The extensions protected settings that are passed by reference, and consumed from key vault. - :vartype protected_settings_from_key_vault: - ~azure.mgmt.compute.v2024_11_01.models.KeyVaultSecretReference + :vartype protected_settings_from_key_vault: ~azure.mgmt.compute.models.KeyVaultSecretReference :ivar provision_after_extensions: Collection of extension names after which this extension needs to be provisioned. :vartype provision_after_extensions: list[str] @@ -16053,8 +25150,7 @@ def __init__( protectedSettingsFromKeyVault or no protected settings at all. :paramtype protected_settings: any :keyword instance_view: The virtual machine extension instance view. - :paramtype instance_view: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionInstanceView + :paramtype instance_view: ~azure.mgmt.compute.models.VirtualMachineExtensionInstanceView :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. @@ -16062,7 +25158,7 @@ def __init__( :keyword protected_settings_from_key_vault: The extensions protected settings that are passed by reference, and consumed from key vault. :paramtype protected_settings_from_key_vault: - ~azure.mgmt.compute.v2024_11_01.models.KeyVaultSecretReference + ~azure.mgmt.compute.models.KeyVaultSecretReference :keyword provision_after_extensions: Collection of extension names after which this extension needs to be provisioned. :paramtype provision_after_extensions: list[str] @@ -16090,7 +25186,7 @@ class VirtualMachineScaleSetVMExtensionsListResult(_serialization.Model): # pyl """The List VMSS VM Extension operation response. :ivar value: The list of VMSS VM extensions. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] + :vartype value: list[~azure.mgmt.compute.models.VirtualMachineScaleSetVMExtension] """ _attribute_map = { @@ -16102,8 +25198,7 @@ def __init__( ) -> None: """ :keyword value: The list of VMSS VM extensions. - :paramtype value: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] + :paramtype value: list[~azure.mgmt.compute.models.VirtualMachineScaleSetVMExtension] """ super().__init__(**kwargs) self.value = value @@ -16117,8 +25212,7 @@ class VirtualMachineScaleSetVMExtensionsSummary(_serialization.Model): # pylint :ivar name: The extension name. :vartype name: str :ivar statuses_summary: The extensions information. - :vartype statuses_summary: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineStatusCodeCount] + :vartype statuses_summary: list[~azure.mgmt.compute.models.VirtualMachineStatusCodeCount] """ _validation = { @@ -16177,8 +25271,7 @@ class VirtualMachineScaleSetVMExtensionUpdate(SubResourceReadOnly): :vartype suppress_failures: bool :ivar protected_settings_from_key_vault: The extensions protected settings that are passed by reference, and consumed from key vault. - :vartype protected_settings_from_key_vault: - ~azure.mgmt.compute.v2024_11_01.models.KeyVaultSecretReference + :vartype protected_settings_from_key_vault: ~azure.mgmt.compute.models.KeyVaultSecretReference """ _validation = { @@ -16251,7 +25344,7 @@ def __init__( :keyword protected_settings_from_key_vault: The extensions protected settings that are passed by reference, and consumed from key vault. :paramtype protected_settings_from_key_vault: - ~azure.mgmt.compute.v2024_11_01.models.KeyVaultSecretReference + ~azure.mgmt.compute.models.KeyVaultSecretReference """ super().__init__(**kwargs) self.name: Optional[str] = None @@ -16330,23 +25423,21 @@ class VirtualMachineScaleSetVMInstanceView(_serialization.Model): :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. :vartype rdp_thumb_print: str :ivar vm_agent: The VM Agent running on the virtual machine. - :vartype vm_agent: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineAgentInstanceView + :vartype vm_agent: ~azure.mgmt.compute.models.VirtualMachineAgentInstanceView :ivar maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :vartype maintenance_redeploy_status: - ~azure.mgmt.compute.v2024_11_01.models.MaintenanceRedeployStatus + :vartype maintenance_redeploy_status: ~azure.mgmt.compute.models.MaintenanceRedeployStatus :ivar disks: The disks information. - :vartype disks: list[~azure.mgmt.compute.v2024_11_01.models.DiskInstanceView] + :vartype disks: list[~azure.mgmt.compute.models.DiskInstanceView] :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionInstanceView] + :vartype extensions: list[~azure.mgmt.compute.models.VirtualMachineExtensionInstanceView] :ivar vm_health: The health status for the VM. - :vartype vm_health: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineHealthStatus + :vartype vm_health: ~azure.mgmt.compute.models.VirtualMachineHealthStatus :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view Console Output and Screenshot to diagnose VM status. You can easily view the output of your console log. Azure also enables you to see a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2024_11_01.models.BootDiagnosticsInstanceView + :vartype boot_diagnostics: ~azure.mgmt.compute.models.BootDiagnosticsInstanceView :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :vartype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] :ivar assigned_host: Resource id of the dedicated host, on which the virtual machine is allocated through automatic placement, when the virtual machine is associated with a dedicated host group that has automatic placement enabled. Minimum api-version: 2020-06-01. @@ -16367,7 +25458,7 @@ class VirtualMachineScaleSetVMInstanceView(_serialization.Model): :vartype os_version: str :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2024_11_01.models.HyperVGeneration + :vartype hyper_v_generation: str or ~azure.mgmt.compute.models.HyperVGeneration """ _validation = { @@ -16421,21 +25512,19 @@ def __init__( :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. :paramtype rdp_thumb_print: str :keyword vm_agent: The VM Agent running on the virtual machine. - :paramtype vm_agent: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineAgentInstanceView + :paramtype vm_agent: ~azure.mgmt.compute.models.VirtualMachineAgentInstanceView :keyword maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :paramtype maintenance_redeploy_status: - ~azure.mgmt.compute.v2024_11_01.models.MaintenanceRedeployStatus + :paramtype maintenance_redeploy_status: ~azure.mgmt.compute.models.MaintenanceRedeployStatus :keyword disks: The disks information. - :paramtype disks: list[~azure.mgmt.compute.v2024_11_01.models.DiskInstanceView] + :paramtype disks: list[~azure.mgmt.compute.models.DiskInstanceView] :keyword extensions: The extensions information. - :paramtype extensions: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionInstanceView] + :paramtype extensions: list[~azure.mgmt.compute.models.VirtualMachineExtensionInstanceView] :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view Console Output and Screenshot to diagnose VM status. You can easily view the output of your console log. Azure also enables you to see a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2024_11_01.models.BootDiagnosticsInstanceView + :paramtype boot_diagnostics: ~azure.mgmt.compute.models.BootDiagnosticsInstanceView :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2024_11_01.models.InstanceViewStatus] + :paramtype statuses: list[~azure.mgmt.compute.models.InstanceViewStatus] :keyword placement_group_id: The placement group in which the VM is running. If the VM is deallocated it will not have a placementGroupId. :paramtype placement_group_id: str @@ -16452,7 +25541,7 @@ def __init__( :paramtype os_version: str :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2024_11_01.models.HyperVGeneration + :paramtype hyper_v_generation: str or ~azure.mgmt.compute.models.HyperVGeneration """ super().__init__(**kwargs) self.platform_update_domain = platform_update_domain @@ -16479,7 +25568,7 @@ class VirtualMachineScaleSetVMListResult(_serialization.Model): All required parameters must be populated in order to send to server. :ivar value: The list of virtual machine scale sets VMs. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] + :vartype value: list[~azure.mgmt.compute.models.VirtualMachineScaleSetVM] :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Set VMs. Call ListNext() with this to fetch the next page of VMSS VMs. :vartype next_link: str @@ -16499,7 +25588,7 @@ def __init__( ) -> None: """ :keyword value: The list of virtual machine scale sets VMs. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] + :paramtype value: list[~azure.mgmt.compute.models.VirtualMachineScaleSetVM] :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Set VMs. Call ListNext() with this to fetch the next page of VMSS VMs. :paramtype next_link: str @@ -16514,7 +25603,7 @@ class VirtualMachineScaleSetVMNetworkProfileConfiguration(_serialization.Model): :ivar network_interface_configurations: The list of network configurations. :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetNetworkConfiguration] + list[~azure.mgmt.compute.models.VirtualMachineScaleSetNetworkConfiguration] """ _attribute_map = { @@ -16533,7 +25622,7 @@ def __init__( """ :keyword network_interface_configurations: The list of network configurations. :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetNetworkConfiguration] + list[~azure.mgmt.compute.models.VirtualMachineScaleSetNetworkConfiguration] """ super().__init__(**kwargs) self.network_interface_configurations = network_interface_configurations @@ -16546,24 +25635,21 @@ class VirtualMachineScaleSetVMProfile(_serialization.Model): :ivar os_profile: Specifies the operating system settings for the virtual machines in the scale set. - :vartype os_profile: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetOSProfile + :vartype os_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetOSProfile :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetStorageProfile + :vartype storage_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetStorageProfile :ivar network_profile: Specifies properties of the network interfaces of the virtual machines in the scale set. - :vartype network_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetNetworkProfile + :vartype network_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetNetworkProfile :ivar security_profile: Specifies the Security related profile settings for the virtual machines in the scale set. - :vartype security_profile: ~azure.mgmt.compute.v2024_11_01.models.SecurityProfile + :vartype security_profile: ~azure.mgmt.compute.models.SecurityProfile :ivar diagnostics_profile: Specifies the boot diagnostic settings state. Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2024_11_01.models.DiagnosticsProfile + :vartype diagnostics_profile: ~azure.mgmt.compute.models.DiagnosticsProfile :ivar extension_profile: Specifies a collection of settings for extensions installed on virtual machines in the scale set. - :vartype extension_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtensionProfile + :vartype extension_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetExtensionProfile :ivar license_type: Specifies that the image or disk that is being used was licensed on-premises. :code:`
`\\ :code:`
` Possible values for Windows Server operating system are: :code:`
`\\ :code:`
` Windows_Client :code:`
`\\ :code:`
` Windows_Server @@ -16578,43 +25664,37 @@ class VirtualMachineScaleSetVMProfile(_serialization.Model): :vartype license_type: str :ivar priority: Specifies the priority for the virtual machines in the scale set. Minimum api-version: 2017-10-30-preview. Known values are: "Regular", "Low", and "Spot". - :vartype priority: str or ~azure.mgmt.compute.v2024_11_01.models.VirtualMachinePriorityTypes + :vartype priority: str or ~azure.mgmt.compute.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and "Delete". - :vartype eviction_policy: str or - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineEvictionPolicyTypes + :vartype eviction_policy: str or ~azure.mgmt.compute.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2024_11_01.models.BillingProfile + :vartype billing_profile: ~azure.mgmt.compute.models.BillingProfile :ivar scheduled_events_profile: Specifies Scheduled Event related configurations. - :vartype scheduled_events_profile: - ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsProfile + :vartype scheduled_events_profile: ~azure.mgmt.compute.models.ScheduledEventsProfile :ivar user_data: UserData for the virtual machines in the scale set, which must be base-64 encoded. Customer should not pass any secrets in here. Minimum api-version: 2021-03-01. :vartype user_data: str :ivar capacity_reservation: Specifies the capacity reservation related details of a scale set. Minimum api-version: 2021-04-01. - :vartype capacity_reservation: - ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationProfile + :vartype capacity_reservation: ~azure.mgmt.compute.models.CapacityReservationProfile :ivar application_profile: Specifies the gallery applications that should be made available to the VM/VMSS. - :vartype application_profile: ~azure.mgmt.compute.v2024_11_01.models.ApplicationProfile + :vartype application_profile: ~azure.mgmt.compute.models.ApplicationProfile :ivar hardware_profile: Specifies the hardware profile related details of a scale set. Minimum api-version: 2021-11-01. - :vartype hardware_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetHardwareProfile + :vartype hardware_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetHardwareProfile :ivar service_artifact_reference: Specifies the service artifact reference id used to set same image version for all virtual machines in the scale set when using 'latest' image version. Minimum api-version: 2022-11-01. - :vartype service_artifact_reference: - ~azure.mgmt.compute.v2024_11_01.models.ServiceArtifactReference + :vartype service_artifact_reference: ~azure.mgmt.compute.models.ServiceArtifactReference :ivar security_posture_reference: Specifies the security posture to be used in the scale set. Minimum api-version: 2023-03-01. - :vartype security_posture_reference: - ~azure.mgmt.compute.v2024_11_01.models.SecurityPostureReference + :vartype security_posture_reference: ~azure.mgmt.compute.models.SecurityPostureReference :ivar time_created: Specifies the time in which this VM profile for the Virtual Machine Scale Set was created. This value will be added to VMSS Flex VM tags when creating/updating the VMSS VM Profile. Minimum API version for this property is 2023-09-01. @@ -16671,24 +25751,21 @@ def __init__( """ :keyword os_profile: Specifies the operating system settings for the virtual machines in the scale set. - :paramtype os_profile: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetOSProfile + :paramtype os_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetOSProfile :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetStorageProfile + :paramtype storage_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetStorageProfile :keyword network_profile: Specifies properties of the network interfaces of the virtual machines in the scale set. - :paramtype network_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetNetworkProfile + :paramtype network_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetNetworkProfile :keyword security_profile: Specifies the Security related profile settings for the virtual machines in the scale set. - :paramtype security_profile: ~azure.mgmt.compute.v2024_11_01.models.SecurityProfile + :paramtype security_profile: ~azure.mgmt.compute.models.SecurityProfile :keyword diagnostics_profile: Specifies the boot diagnostic settings state. Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2024_11_01.models.DiagnosticsProfile + :paramtype diagnostics_profile: ~azure.mgmt.compute.models.DiagnosticsProfile :keyword extension_profile: Specifies a collection of settings for extensions installed on virtual machines in the scale set. - :paramtype extension_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtensionProfile + :paramtype extension_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetExtensionProfile :keyword license_type: Specifies that the image or disk that is being used was licensed on-premises. :code:`
`\\ :code:`
` Possible values for Windows Server operating system are: :code:`
`\\ :code:`
` Windows_Client :code:`
`\\ :code:`
` Windows_Server @@ -16703,43 +25780,37 @@ def __init__( :paramtype license_type: str :keyword priority: Specifies the priority for the virtual machines in the scale set. Minimum api-version: 2017-10-30-preview. Known values are: "Regular", "Low", and "Spot". - :paramtype priority: str or ~azure.mgmt.compute.v2024_11_01.models.VirtualMachinePriorityTypes + :paramtype priority: str or ~azure.mgmt.compute.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and "Delete". - :paramtype eviction_policy: str or - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineEvictionPolicyTypes + :paramtype eviction_policy: str or ~azure.mgmt.compute.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2024_11_01.models.BillingProfile + :paramtype billing_profile: ~azure.mgmt.compute.models.BillingProfile :keyword scheduled_events_profile: Specifies Scheduled Event related configurations. - :paramtype scheduled_events_profile: - ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsProfile + :paramtype scheduled_events_profile: ~azure.mgmt.compute.models.ScheduledEventsProfile :keyword user_data: UserData for the virtual machines in the scale set, which must be base-64 encoded. Customer should not pass any secrets in here. Minimum api-version: 2021-03-01. :paramtype user_data: str :keyword capacity_reservation: Specifies the capacity reservation related details of a scale set. Minimum api-version: 2021-04-01. - :paramtype capacity_reservation: - ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationProfile + :paramtype capacity_reservation: ~azure.mgmt.compute.models.CapacityReservationProfile :keyword application_profile: Specifies the gallery applications that should be made available to the VM/VMSS. - :paramtype application_profile: ~azure.mgmt.compute.v2024_11_01.models.ApplicationProfile + :paramtype application_profile: ~azure.mgmt.compute.models.ApplicationProfile :keyword hardware_profile: Specifies the hardware profile related details of a scale set. Minimum api-version: 2021-11-01. - :paramtype hardware_profile: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetHardwareProfile + :paramtype hardware_profile: ~azure.mgmt.compute.models.VirtualMachineScaleSetHardwareProfile :keyword service_artifact_reference: Specifies the service artifact reference id used to set same image version for all virtual machines in the scale set when using 'latest' image version. Minimum api-version: 2022-11-01. - :paramtype service_artifact_reference: - ~azure.mgmt.compute.v2024_11_01.models.ServiceArtifactReference + :paramtype service_artifact_reference: ~azure.mgmt.compute.models.ServiceArtifactReference :keyword security_posture_reference: Specifies the security posture to be used in the scale set. Minimum api-version: 2023-03-01. - :paramtype security_posture_reference: - ~azure.mgmt.compute.v2024_11_01.models.SecurityPostureReference + :paramtype security_posture_reference: ~azure.mgmt.compute.models.SecurityPostureReference """ super().__init__(**kwargs) self.os_profile = os_profile @@ -16876,7 +25947,7 @@ class VirtualMachineSizeListResult(_serialization.Model): """The List Virtual Machine operation response. :ivar value: The list of virtual machine sizes. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] + :vartype value: list[~azure.mgmt.compute.models.VirtualMachineSize] :ivar next_link: The link to the next page of items. :vartype next_link: str """ @@ -16895,7 +25966,7 @@ def __init__( ) -> None: """ :keyword value: The list of virtual machine sizes. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] + :paramtype value: list[~azure.mgmt.compute.models.VirtualMachineSize] :keyword next_link: The link to the next page of items. :paramtype next_link: str """ @@ -16921,8 +25992,7 @@ class VirtualMachineSoftwarePatchProperties(_serialization.Model): :vartype classifications: list[str] :ivar reboot_behavior: Describes the reboot requirements of the patch. Known values are: "Unknown", "NeverReboots", "AlwaysRequiresReboot", and "CanRequestReboot". - :vartype reboot_behavior: str or - ~azure.mgmt.compute.v2024_11_01.models.VMGuestPatchRebootBehavior + :vartype reboot_behavior: str or ~azure.mgmt.compute.models.VMGuestPatchRebootBehavior :ivar activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. :vartype activity_id: str @@ -16932,7 +26002,7 @@ class VirtualMachineSoftwarePatchProperties(_serialization.Model): :vartype last_modified_date_time: ~datetime.datetime :ivar assessment_state: Describes the availability of a given patch. Known values are: "Unknown" and "Available". - :vartype assessment_state: str or ~azure.mgmt.compute.v2024_11_01.models.PatchAssessmentState + :vartype assessment_state: str or ~azure.mgmt.compute.models.PatchAssessmentState """ _validation = { @@ -17016,33 +26086,33 @@ class VirtualMachineUpdate(UpdateResource): image from an API, you must enable the image for programmatic use. In the Azure portal, find the marketplace image that you want to use and then click **Want to deploy programmatically, Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2024_11_01.models.Plan + :vartype plan: ~azure.mgmt.compute.models.Plan :ivar identity: The identity of the virtual machine, if configured. - :vartype identity: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineIdentity + :vartype identity: ~azure.mgmt.compute.models.VirtualMachineIdentity :ivar zones: The virtual machine zones. :vartype zones: list[str] :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2024_11_01.models.HardwareProfile + :vartype hardware_profile: ~azure.mgmt.compute.models.HardwareProfile :ivar scheduled_events_policy: Specifies Redeploy, Reboot and ScheduledEventsAdditionalPublishingTargets Scheduled Event related configurations for the virtual machine. - :vartype scheduled_events_policy: ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsPolicy + :vartype scheduled_events_policy: ~azure.mgmt.compute.models.ScheduledEventsPolicy :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2024_11_01.models.StorageProfile + :vartype storage_profile: ~azure.mgmt.compute.models.StorageProfile :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the virtual machine. - :vartype additional_capabilities: ~azure.mgmt.compute.v2024_11_01.models.AdditionalCapabilities + :vartype additional_capabilities: ~azure.mgmt.compute.models.AdditionalCapabilities :ivar os_profile: Specifies the operating system settings used while creating the virtual machine. Some of the settings cannot be changed once VM is provisioned. - :vartype os_profile: ~azure.mgmt.compute.v2024_11_01.models.OSProfile + :vartype os_profile: ~azure.mgmt.compute.models.OSProfile :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2024_11_01.models.NetworkProfile + :vartype network_profile: ~azure.mgmt.compute.models.NetworkProfile :ivar security_profile: Specifies the Security related profile settings for the virtual machine. - :vartype security_profile: ~azure.mgmt.compute.v2024_11_01.models.SecurityProfile + :vartype security_profile: ~azure.mgmt.compute.models.SecurityProfile :ivar diagnostics_profile: Specifies the boot diagnostic settings state. Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2024_11_01.models.DiagnosticsProfile + :vartype diagnostics_profile: ~azure.mgmt.compute.models.DiagnosticsProfile :ivar availability_set: 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 @@ -17054,41 +26124,40 @@ class VirtualMachineUpdate(UpdateResource): VM is being added should be under the same resource group as the availability set resource. An existing VM cannot be added to an availability set. This property cannot exist along with a non-null properties.virtualMachineScaleSet reference. - :vartype availability_set: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype availability_set: ~azure.mgmt.compute.models.SubResource :ivar virtual_machine_scale_set: Specifies information about the virtual machine scale set that the virtual machine should be assigned to. Virtual machines specified in the same virtual machine scale set are allocated to different nodes to maximize availability. Currently, a VM can only be added to virtual machine scale set at creation time. An existing VM cannot be added to a virtual machine scale set. This property cannot exist along with a non-null properties.availabilitySet reference. Minimum api‐version: 2019‐03‐01. - :vartype virtual_machine_scale_set: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype virtual_machine_scale_set: ~azure.mgmt.compute.models.SubResource :ivar proximity_placement_group: Specifies information about the proximity placement group that the virtual machine should be assigned to. Minimum api-version: 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype proximity_placement_group: ~azure.mgmt.compute.models.SubResource :ivar priority: Specifies the priority for the virtual machine. Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :vartype priority: str or ~azure.mgmt.compute.v2024_11_01.models.VirtualMachinePriorityTypes + :vartype priority: str or ~azure.mgmt.compute.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and "Delete". - :vartype eviction_policy: str or - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineEvictionPolicyTypes + :vartype eviction_policy: str or ~azure.mgmt.compute.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2024_11_01.models.BillingProfile + :vartype billing_profile: ~azure.mgmt.compute.models.BillingProfile :ivar host: Specifies information about the dedicated host that the virtual machine resides in. Minimum api-version: 2018-10-01. - :vartype host: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype host: ~azure.mgmt.compute.models.SubResource :ivar host_group: Specifies information about the dedicated host group that the virtual machine resides in. **Note:** User cannot specify both host and hostGroup properties. Minimum api-version: 2020-06-01. - :vartype host_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :vartype host_group: ~azure.mgmt.compute.models.SubResource :ivar provisioning_state: The provisioning state, which only appears in the response. :vartype provisioning_state: str :ivar instance_view: The virtual machine instance view. - :vartype instance_view: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstanceView + :vartype instance_view: ~azure.mgmt.compute.models.VirtualMachineInstanceView :ivar license_type: Specifies that the image or disk that is being used was licensed on-premises. :code:`
`\\ :code:`
` Possible values for Windows Server operating system are: :code:`
`\\ :code:`
` Windows_Client :code:`
`\\ :code:`
` Windows_Server @@ -17117,18 +26186,16 @@ class VirtualMachineUpdate(UpdateResource): can be viewed in the Virtual Machine Instance View. Minimum api‐version: 2020‐12‐01. :vartype platform_fault_domain: int :ivar scheduled_events_profile: Specifies Scheduled Event related configurations. - :vartype scheduled_events_profile: - ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsProfile + :vartype scheduled_events_profile: ~azure.mgmt.compute.models.ScheduledEventsProfile :ivar user_data: UserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here. Minimum api-version: 2021-03-01. :vartype user_data: str :ivar capacity_reservation: Specifies information about the capacity reservation that is used to allocate virtual machine. Minimum api-version: 2021-04-01. - :vartype capacity_reservation: - ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationProfile + :vartype capacity_reservation: ~azure.mgmt.compute.models.CapacityReservationProfile :ivar application_profile: Specifies the gallery applications that should be made available to the VM/VMSS. - :vartype application_profile: ~azure.mgmt.compute.v2024_11_01.models.ApplicationProfile + :vartype application_profile: ~azure.mgmt.compute.models.ApplicationProfile :ivar time_created: Specifies the time at which the Virtual Machine resource was created. Minimum api-version: 2021-11-01. :vartype time_created: ~datetime.datetime @@ -17215,35 +26282,33 @@ def __init__( # pylint: disable=too-many-locals image from an API, you must enable the image for programmatic use. In the Azure portal, find the marketplace image that you want to use and then click **Want to deploy programmatically, Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2024_11_01.models.Plan + :paramtype plan: ~azure.mgmt.compute.models.Plan :keyword identity: The identity of the virtual machine, if configured. - :paramtype identity: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineIdentity + :paramtype identity: ~azure.mgmt.compute.models.VirtualMachineIdentity :keyword zones: The virtual machine zones. :paramtype zones: list[str] :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2024_11_01.models.HardwareProfile + :paramtype hardware_profile: ~azure.mgmt.compute.models.HardwareProfile :keyword scheduled_events_policy: Specifies Redeploy, Reboot and ScheduledEventsAdditionalPublishingTargets Scheduled Event related configurations for the virtual machine. - :paramtype scheduled_events_policy: - ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsPolicy + :paramtype scheduled_events_policy: ~azure.mgmt.compute.models.ScheduledEventsPolicy :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2024_11_01.models.StorageProfile + :paramtype storage_profile: ~azure.mgmt.compute.models.StorageProfile :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the virtual machine. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2024_11_01.models.AdditionalCapabilities + :paramtype additional_capabilities: ~azure.mgmt.compute.models.AdditionalCapabilities :keyword os_profile: Specifies the operating system settings used while creating the virtual machine. Some of the settings cannot be changed once VM is provisioned. - :paramtype os_profile: ~azure.mgmt.compute.v2024_11_01.models.OSProfile + :paramtype os_profile: ~azure.mgmt.compute.models.OSProfile :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2024_11_01.models.NetworkProfile + :paramtype network_profile: ~azure.mgmt.compute.models.NetworkProfile :keyword security_profile: Specifies the Security related profile settings for the virtual machine. - :paramtype security_profile: ~azure.mgmt.compute.v2024_11_01.models.SecurityProfile + :paramtype security_profile: ~azure.mgmt.compute.models.SecurityProfile :keyword diagnostics_profile: Specifies the boot diagnostic settings state. Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2024_11_01.models.DiagnosticsProfile + :paramtype diagnostics_profile: ~azure.mgmt.compute.models.DiagnosticsProfile :keyword availability_set: 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 @@ -17255,37 +26320,36 @@ def __init__( # pylint: disable=too-many-locals VM is being added should be under the same resource group as the availability set resource. An existing VM cannot be added to an availability set. This property cannot exist along with a non-null properties.virtualMachineScaleSet reference. - :paramtype availability_set: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype availability_set: ~azure.mgmt.compute.models.SubResource :keyword virtual_machine_scale_set: Specifies information about the virtual machine scale set that the virtual machine should be assigned to. Virtual machines specified in the same virtual machine scale set are allocated to different nodes to maximize availability. Currently, a VM can only be added to virtual machine scale set at creation time. An existing VM cannot be added to a virtual machine scale set. This property cannot exist along with a non-null properties.availabilitySet reference. Minimum api‐version: 2019‐03‐01. - :paramtype virtual_machine_scale_set: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype virtual_machine_scale_set: ~azure.mgmt.compute.models.SubResource :keyword proximity_placement_group: Specifies information about the proximity placement group that the virtual machine should be assigned to. Minimum api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype proximity_placement_group: ~azure.mgmt.compute.models.SubResource :keyword priority: Specifies the priority for the virtual machine. Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :paramtype priority: str or ~azure.mgmt.compute.v2024_11_01.models.VirtualMachinePriorityTypes + :paramtype priority: str or ~azure.mgmt.compute.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and "Delete". - :paramtype eviction_policy: str or - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineEvictionPolicyTypes + :paramtype eviction_policy: str or ~azure.mgmt.compute.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual machine. Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2024_11_01.models.BillingProfile + :paramtype billing_profile: ~azure.mgmt.compute.models.BillingProfile :keyword host: Specifies information about the dedicated host that the virtual machine resides in. Minimum api-version: 2018-10-01. - :paramtype host: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype host: ~azure.mgmt.compute.models.SubResource :keyword host_group: Specifies information about the dedicated host group that the virtual machine resides in. **Note:** User cannot specify both host and hostGroup properties. Minimum api-version: 2020-06-01. - :paramtype host_group: ~azure.mgmt.compute.v2024_11_01.models.SubResource + :paramtype host_group: ~azure.mgmt.compute.models.SubResource :keyword license_type: Specifies that the image or disk that is being used was licensed on-premises. :code:`
`\\ :code:`
` Possible values for Windows Server operating system are: :code:`
`\\ :code:`
` Windows_Client :code:`
`\\ :code:`
` Windows_Server @@ -17311,18 +26375,16 @@ def __init__( # pylint: disable=too-many-locals can be viewed in the Virtual Machine Instance View. Minimum api‐version: 2020‐12‐01. :paramtype platform_fault_domain: int :keyword scheduled_events_profile: Specifies Scheduled Event related configurations. - :paramtype scheduled_events_profile: - ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsProfile + :paramtype scheduled_events_profile: ~azure.mgmt.compute.models.ScheduledEventsProfile :keyword user_data: UserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here. Minimum api-version: 2021-03-01. :paramtype user_data: str :keyword capacity_reservation: Specifies information about the capacity reservation that is used to allocate virtual machine. Minimum api-version: 2021-04-01. - :paramtype capacity_reservation: - ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationProfile + :paramtype capacity_reservation: ~azure.mgmt.compute.models.CapacityReservationProfile :keyword application_profile: Specifies the gallery applications that should be made available to the VM/VMSS. - :paramtype application_profile: ~azure.mgmt.compute.v2024_11_01.models.ApplicationProfile + :paramtype application_profile: ~azure.mgmt.compute.models.ApplicationProfile """ super().__init__(tags=tags, **kwargs) self.plan = plan @@ -17367,13 +26429,11 @@ class VMDiskSecurityProfile(_serialization.Model): persisting firmware state in the VMGuestState blob.. **Note:** It can be set for only Confidential VMs. Known values are: "VMGuestStateOnly", "DiskWithVMGuestState", and "NonPersistedTPM". - :vartype security_encryption_type: str or - ~azure.mgmt.compute.v2024_11_01.models.SecurityEncryptionTypes + :vartype security_encryption_type: str or ~azure.mgmt.compute.models.SecurityEncryptionTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for the managed disk that is used for Customer Managed Key encrypted ConfidentialVM OS Disk and VMGuest blob. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSetParameters + :vartype disk_encryption_set: ~azure.mgmt.compute.models.DiskEncryptionSetParameters """ _attribute_map = { @@ -17395,13 +26455,11 @@ def __init__( persisting firmware state in the VMGuestState blob.. **Note:** It can be set for only Confidential VMs. Known values are: "VMGuestStateOnly", "DiskWithVMGuestState", and "NonPersistedTPM". - :paramtype security_encryption_type: str or - ~azure.mgmt.compute.v2024_11_01.models.SecurityEncryptionTypes + :paramtype security_encryption_type: str or ~azure.mgmt.compute.models.SecurityEncryptionTypes :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id for the managed disk that is used for Customer Managed Key encrypted ConfidentialVM OS Disk and VMGuest blob. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2024_11_01.models.DiskEncryptionSetParameters + :paramtype disk_encryption_set: ~azure.mgmt.compute.models.DiskEncryptionSetParameters """ super().__init__(**kwargs) self.security_encryption_type = security_encryption_type @@ -17489,7 +26547,7 @@ class VmImagesInEdgeZoneListResult(_serialization.Model): """The List VmImages in EdgeZone operation response. :ivar value: The list of VMImages in EdgeZone. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :vartype value: list[~azure.mgmt.compute.models.VirtualMachineImageResource] :ivar next_link: The URI to fetch the next page of VMImages in EdgeZone. Call ListNext() with this URI to fetch the next page of VmImages. :vartype next_link: str @@ -17509,7 +26567,7 @@ def __init__( ) -> None: """ :keyword value: The list of VMImages in EdgeZone. - :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :paramtype value: list[~azure.mgmt.compute.models.VirtualMachineImageResource] :keyword next_link: The URI to fetch the next page of VMImages in EdgeZone. Call ListNext() with this URI to fetch the next page of VmImages. :paramtype next_link: str @@ -17610,13 +26668,13 @@ class WindowsConfiguration(_serialization.Model): :ivar additional_unattend_content: Specifies additional base-64 encoded XML formatted information that can be included in the Unattend.xml file, which is used by Windows Setup. :vartype additional_unattend_content: - list[~azure.mgmt.compute.v2024_11_01.models.AdditionalUnattendContent] + list[~azure.mgmt.compute.models.AdditionalUnattendContent] :ivar patch_settings: [Preview Feature] Specifies settings related to VM Guest Patching on Windows. - :vartype patch_settings: ~azure.mgmt.compute.v2024_11_01.models.PatchSettings + :vartype patch_settings: ~azure.mgmt.compute.models.PatchSettings :ivar win_rm: Specifies the Windows Remote Management listeners. This enables remote Windows PowerShell. - :vartype win_rm: ~azure.mgmt.compute.v2024_11_01.models.WinRMConfiguration + :vartype win_rm: ~azure.mgmt.compute.models.WinRMConfiguration :ivar enable_vm_agent_platform_updates: Indicates whether VMAgent Platform Updates are enabled for the Windows Virtual Machine. :vartype enable_vm_agent_platform_updates: bool @@ -17666,13 +26724,13 @@ def __init__( :keyword additional_unattend_content: Specifies additional base-64 encoded XML formatted information that can be included in the Unattend.xml file, which is used by Windows Setup. :paramtype additional_unattend_content: - list[~azure.mgmt.compute.v2024_11_01.models.AdditionalUnattendContent] + list[~azure.mgmt.compute.models.AdditionalUnattendContent] :keyword patch_settings: [Preview Feature] Specifies settings related to VM Guest Patching on Windows. - :paramtype patch_settings: ~azure.mgmt.compute.v2024_11_01.models.PatchSettings + :paramtype patch_settings: ~azure.mgmt.compute.models.PatchSettings :keyword win_rm: Specifies the Windows Remote Management listeners. This enables remote Windows PowerShell. - :paramtype win_rm: ~azure.mgmt.compute.v2024_11_01.models.WinRMConfiguration + :paramtype win_rm: ~azure.mgmt.compute.models.WinRMConfiguration """ super().__init__(**kwargs) self.provision_vm_agent = provision_vm_agent @@ -17690,7 +26748,7 @@ class WindowsParameters(_serialization.Model): :ivar classifications_to_include: The update classifications to select when installing patches for Windows. :vartype classifications_to_include: list[str or - ~azure.mgmt.compute.v2024_11_01.models.VMGuestPatchClassificationWindows] + ~azure.mgmt.compute.models.VMGuestPatchClassificationWindows] :ivar kb_numbers_to_include: Kbs to include in the patch operation. :vartype kb_numbers_to_include: list[str] :ivar kb_numbers_to_exclude: Kbs to exclude in the patch operation. @@ -17725,7 +26783,7 @@ def __init__( :keyword classifications_to_include: The update classifications to select when installing patches for Windows. :paramtype classifications_to_include: list[str or - ~azure.mgmt.compute.v2024_11_01.models.VMGuestPatchClassificationWindows] + ~azure.mgmt.compute.models.VMGuestPatchClassificationWindows] :keyword kb_numbers_to_include: Kbs to include in the patch operation. :paramtype kb_numbers_to_include: list[str] :keyword kb_numbers_to_exclude: Kbs to exclude in the patch operation. @@ -17752,7 +26810,7 @@ class WindowsVMGuestPatchAutomaticByPlatformSettings(_serialization.Model): # p :ivar reboot_setting: Specifies the reboot setting for all AutomaticByPlatform patch installation operations. Known values are: "Unknown", "IfRequired", "Never", and "Always". :vartype reboot_setting: str or - ~azure.mgmt.compute.v2024_11_01.models.WindowsVMGuestPatchAutomaticByPlatformRebootSetting + ~azure.mgmt.compute.models.WindowsVMGuestPatchAutomaticByPlatformRebootSetting :ivar bypass_platform_safety_checks_on_user_schedule: Enables customer to schedule patching without accidental upgrades. :vartype bypass_platform_safety_checks_on_user_schedule: bool @@ -17777,7 +26835,7 @@ def __init__( :keyword reboot_setting: Specifies the reboot setting for all AutomaticByPlatform patch installation operations. Known values are: "Unknown", "IfRequired", "Never", and "Always". :paramtype reboot_setting: str or - ~azure.mgmt.compute.v2024_11_01.models.WindowsVMGuestPatchAutomaticByPlatformRebootSetting + ~azure.mgmt.compute.models.WindowsVMGuestPatchAutomaticByPlatformRebootSetting :keyword bypass_platform_safety_checks_on_user_schedule: Enables customer to schedule patching without accidental upgrades. :paramtype bypass_platform_safety_checks_on_user_schedule: bool @@ -17791,7 +26849,7 @@ class WinRMConfiguration(_serialization.Model): """Describes Windows Remote Management configuration of the VM. :ivar listeners: The list of Windows Remote Management listeners. - :vartype listeners: list[~azure.mgmt.compute.v2024_11_01.models.WinRMListener] + :vartype listeners: list[~azure.mgmt.compute.models.WinRMListener] """ _attribute_map = { @@ -17801,7 +26859,7 @@ class WinRMConfiguration(_serialization.Model): def __init__(self, *, listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs: Any) -> None: """ :keyword listeners: The list of Windows Remote Management listeners. - :paramtype listeners: list[~azure.mgmt.compute.v2024_11_01.models.WinRMListener] + :paramtype listeners: list[~azure.mgmt.compute.models.WinRMListener] """ super().__init__(**kwargs) self.listeners = listeners @@ -17812,7 +26870,7 @@ class WinRMListener(_serialization.Model): :ivar protocol: Specifies the protocol of WinRM listener. Possible values are: **http,** **https.**. Known values are: "Http" and "Https". - :vartype protocol: str or ~azure.mgmt.compute.v2024_11_01.models.ProtocolTypes + :vartype protocol: str or ~azure.mgmt.compute.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault `_. In this case, your @@ -17843,7 +26901,7 @@ def __init__( """ :keyword protocol: Specifies the protocol of WinRM listener. Possible values are: **http,** **https.**. Known values are: "Http" and "Https". - :paramtype protocol: str or ~azure.mgmt.compute.v2024_11_01.models.ProtocolTypes + :paramtype protocol: str or ~azure.mgmt.compute.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault `_. In this case, your diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models/_patch.py similarity index 100% rename from sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/models/_patch.py rename to sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models/_patch.py diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/__init__.py new file mode 100644 index 000000000000..6e78d6482cd3 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/__init__.py @@ -0,0 +1,122 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import Operations # type: ignore +from ._availability_sets_operations import AvailabilitySetsOperations # type: ignore +from ._capacity_reservation_groups_operations import CapacityReservationGroupsOperations # type: ignore +from ._dedicated_host_groups_operations import DedicatedHostGroupsOperations # type: ignore +from ._images_operations import ImagesOperations # type: ignore +from ._virtual_machine_images_edge_zone_operations import VirtualMachineImagesEdgeZoneOperations # type: ignore +from ._virtual_machine_images_operations import VirtualMachineImagesOperations # type: ignore +from ._log_analytics_operations import LogAnalyticsOperations # type: ignore +from ._virtual_machine_extension_images_operations import VirtualMachineExtensionImagesOperations # type: ignore +from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations # type: ignore +from ._usage_operations import UsageOperations # type: ignore +from ._virtual_machine_scale_sets_operations import VirtualMachineScaleSetsOperations # type: ignore +from ._virtual_machines_operations import VirtualMachinesOperations # type: ignore +from ._virtual_machine_sizes_operations import VirtualMachineSizesOperations # type: ignore +from ._proximity_placement_groups_operations import ProximityPlacementGroupsOperations # type: ignore +from ._restore_point_collections_operations import RestorePointCollectionsOperations # type: ignore +from ._ssh_public_keys_operations import SshPublicKeysOperations # type: ignore +from ._capacity_reservations_operations import CapacityReservationsOperations # type: ignore +from ._dedicated_hosts_operations import DedicatedHostsOperations # type: ignore +from ._restore_points_operations import RestorePointsOperations # type: ignore +from ._virtual_machine_scale_set_rolling_upgrades_operations import VirtualMachineScaleSetRollingUpgradesOperations # type: ignore +from ._virtual_machine_scale_set_extensions_operations import VirtualMachineScaleSetExtensionsOperations # type: ignore +from ._virtual_machine_scale_set_vms_operations import VirtualMachineScaleSetVMsOperations # type: ignore +from ._virtual_machine_scale_set_vm_extensions_operations import VirtualMachineScaleSetVMExtensionsOperations # type: ignore +from ._virtual_machine_scale_set_vm_run_commands_operations import VirtualMachineScaleSetVMRunCommandsOperations # type: ignore +from ._virtual_machine_extensions_operations import VirtualMachineExtensionsOperations # type: ignore +from ._cloud_service_role_instances_operations import CloudServiceRoleInstancesOperations # type: ignore +from ._cloud_service_roles_operations import CloudServiceRolesOperations # type: ignore +from ._cloud_services_operations import CloudServicesOperations # type: ignore +from ._cloud_services_update_domain_operations import CloudServicesUpdateDomainOperations # type: ignore +from ._cloud_service_operating_systems_operations import CloudServiceOperatingSystemsOperations # type: ignore +from ._disks_operations import DisksOperations # type: ignore +from ._disk_accesses_operations import DiskAccessesOperations # type: ignore +from ._disk_encryption_sets_operations import DiskEncryptionSetsOperations # type: ignore +from ._disk_restore_point_operations import DiskRestorePointOperations # type: ignore +from ._snapshots_operations import SnapshotsOperations # type: ignore +from ._resource_skus_operations import ResourceSkusOperations # type: ignore +from ._galleries_operations import GalleriesOperations # type: ignore +from ._gallery_images_operations import GalleryImagesOperations # type: ignore +from ._gallery_image_versions_operations import GalleryImageVersionsOperations # type: ignore +from ._gallery_applications_operations import GalleryApplicationsOperations # type: ignore +from ._gallery_application_versions_operations import GalleryApplicationVersionsOperations # type: ignore +from ._gallery_sharing_profile_operations import GallerySharingProfileOperations # type: ignore +from ._shared_galleries_operations import SharedGalleriesOperations # type: ignore +from ._shared_gallery_images_operations import SharedGalleryImagesOperations # type: ignore +from ._shared_gallery_image_versions_operations import SharedGalleryImageVersionsOperations # type: ignore +from ._community_galleries_operations import CommunityGalleriesOperations # type: ignore +from ._community_gallery_images_operations import CommunityGalleryImagesOperations # type: ignore +from ._community_gallery_image_versions_operations import CommunityGalleryImageVersionsOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "Operations", + "AvailabilitySetsOperations", + "CapacityReservationGroupsOperations", + "DedicatedHostGroupsOperations", + "ImagesOperations", + "VirtualMachineImagesEdgeZoneOperations", + "VirtualMachineImagesOperations", + "LogAnalyticsOperations", + "VirtualMachineExtensionImagesOperations", + "VirtualMachineRunCommandsOperations", + "UsageOperations", + "VirtualMachineScaleSetsOperations", + "VirtualMachinesOperations", + "VirtualMachineSizesOperations", + "ProximityPlacementGroupsOperations", + "RestorePointCollectionsOperations", + "SshPublicKeysOperations", + "CapacityReservationsOperations", + "DedicatedHostsOperations", + "RestorePointsOperations", + "VirtualMachineScaleSetRollingUpgradesOperations", + "VirtualMachineScaleSetExtensionsOperations", + "VirtualMachineScaleSetVMsOperations", + "VirtualMachineScaleSetVMExtensionsOperations", + "VirtualMachineScaleSetVMRunCommandsOperations", + "VirtualMachineExtensionsOperations", + "CloudServiceRoleInstancesOperations", + "CloudServiceRolesOperations", + "CloudServicesOperations", + "CloudServicesUpdateDomainOperations", + "CloudServiceOperatingSystemsOperations", + "DisksOperations", + "DiskAccessesOperations", + "DiskEncryptionSetsOperations", + "DiskRestorePointOperations", + "SnapshotsOperations", + "ResourceSkusOperations", + "GalleriesOperations", + "GalleryImagesOperations", + "GalleryImageVersionsOperations", + "GalleryApplicationsOperations", + "GalleryApplicationVersionsOperations", + "GallerySharingProfileOperations", + "SharedGalleriesOperations", + "SharedGalleryImagesOperations", + "SharedGalleryImageVersionsOperations", + "CommunityGalleriesOperations", + "CommunityGalleryImagesOperations", + "CommunityGalleryImageVersionsOperations", +] +__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/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_availability_sets_operations.py new file mode 100644 index 000000000000..540b77adba0c --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_availability_sets_operations.py @@ -0,0 +1,1523 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request( + subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") + path_format_arguments = { + "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") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets", + ) + 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 + ), + } + + _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_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", + ) + 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 + ), + "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") + + # 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_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", + ) + 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 + ), + "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") + + # 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_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_cancel_migration_to_virtual_machine_scale_set_request( # pylint: disable=name-too-long + resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/cancelMigrationToVirtualMachineScaleSet", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_convert_to_virtual_machine_scale_set_request( # pylint: disable=name-too-long + resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/convertToVirtualMachineScaleSet", + ) + 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 + ), + "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") + + # 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_start_migration_to_virtual_machine_scale_set_request( # pylint: disable=name-too-long + resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/startMigrationToVirtualMachineScaleSet", + ) + 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 + ), + "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") + + # 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_validate_migration_to_virtual_machine_scale_set_request( # pylint: disable=name-too-long + resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/validateMigrationToVirtualMachineScaleSet", + ) + 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 + ), + "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") + + # 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_list_available_sizes_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`availability_sets` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, expand: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.AvailabilitySet"]: + """Lists all availability sets in a subscription. + + :param expand: The expand expression to apply to the operation. Allowed values are + 'instanceView'. Default value is None. + :type expand: str + :return: An iterator like instance of either AvailabilitySet or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.AvailabilitySetListResult] = 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_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.AvailabilitySet"]: + """Lists all availability sets 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 AvailabilitySet or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.AvailabilitySetListResult] = 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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + 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, 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.models.AvailabilitySet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) + + _request = build_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) + + _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("AvailabilitySet", 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, + availability_set_name: str, + parameters: _models.AvailabilitySet, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AvailabilitySet: + """Create or update an availability set. + + :param resource_group_name: The name of the resource group. 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.models.AvailabilitySet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.AvailabilitySet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + availability_set_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AvailabilitySet: + """Create or update an availability set. + + :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: IO[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.models.AvailabilitySet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + availability_set_name: str, + parameters: Union[_models.AvailabilitySet, IO[bytes]], + **kwargs: Any + ) -> _models.AvailabilitySet: + """Create or update an availability set. + + :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.models.AvailabilitySet or IO[bytes] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AvailabilitySet") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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("AvailabilitySet", 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, + availability_set_name: str, + parameters: _models.AvailabilitySetUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AvailabilitySet: + """Update 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 + :param parameters: Parameters supplied to the Update Availability Set operation. Required. + :type parameters: ~azure.mgmt.compute.models.AvailabilitySetUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.AvailabilitySet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + availability_set_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AvailabilitySet: + """Update an availability set. + + :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: IO[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.models.AvailabilitySet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + availability_set_name: str, + parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], + **kwargs: Any + ) -> _models.AvailabilitySet: + """Update 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 + :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.models.AvailabilitySetUpdate or IO[bytes] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AvailabilitySetUpdate") + + _request = build_update_request( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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("AvailabilitySet", 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. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :return: None or the result of cls(response) + :rtype: None + :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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_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 cancel_migration_to_virtual_machine_scale_set( # pylint: disable=inconsistent-return-statements,name-too-long + self, resource_group_name: str, availability_set_name: str, **kwargs: Any + ) -> None: + """Cancel the migration operation on an Availability Set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :return: None or the result of cls(response) + :rtype: None + :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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_cancel_migration_to_virtual_machine_scale_set_request( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 _convert_to_virtual_machine_scale_set_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: Optional[Union[_models.ConvertToVirtualMachineScaleSetInput, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "ConvertToVirtualMachineScaleSetInput") + else: + _json = None + + _request = build_convert_to_virtual_machine_scale_set_request( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: Optional[_models.ConvertToVirtualMachineScaleSetInput] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the + Availability Set. This does not trigger a downtime on the Virtual Machines. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Default value is None. + :type parameters: ~azure.mgmt.compute.models.ConvertToVirtualMachineScaleSetInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of 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_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the + Availability Set. This does not trigger a downtime on the Virtual Machines. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Default value is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: Optional[Union[_models.ConvertToVirtualMachineScaleSetInput, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the + Availability Set. This does not trigger a downtime on the Virtual Machines. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. Is + either a ConvertToVirtualMachineScaleSetInput type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.models.ConvertToVirtualMachineScaleSetInput or IO[bytes] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._convert_to_virtual_machine_scale_set_initial( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, 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 + + @overload + def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: _models.MigrateToVirtualMachineScaleSetInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual + Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that + triggers a downtime on the Virtual Machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Required. + :type parameters: ~azure.mgmt.compute.models.MigrateToVirtualMachineScaleSetInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual + Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that + triggers a downtime on the Virtual Machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def start_migration_to_virtual_machine_scale_set( # pylint: disable=inconsistent-return-statements,name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: Union[_models.MigrateToVirtualMachineScaleSetInput, IO[bytes]], + **kwargs: Any + ) -> None: + """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual + Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that + triggers a downtime on the Virtual Machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. Is + either a MigrateToVirtualMachineScaleSetInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.models.MigrateToVirtualMachineScaleSetInput or IO[bytes] + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrateToVirtualMachineScaleSetInput") + + _request = build_start_migration_to_virtual_machine_scale_set_request( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 + + @overload + def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: _models.MigrateToVirtualMachineScaleSetInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Validates that the Virtual Machines in the Availability Set can be migrated to the provided + Virtual Machine Scale Set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Required. + :type parameters: ~azure.mgmt.compute.models.MigrateToVirtualMachineScaleSetInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Validates that the Virtual Machines in the Availability Set can be migrated to the provided + Virtual Machine Scale Set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_migration_to_virtual_machine_scale_set( # pylint: disable=inconsistent-return-statements,name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: Union[_models.MigrateToVirtualMachineScaleSetInput, IO[bytes]], + **kwargs: Any + ) -> None: + """Validates that the Virtual Machines in the Availability Set can be migrated to the provided + Virtual Machine Scale Set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. Is + either a MigrateToVirtualMachineScaleSetInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.models.MigrateToVirtualMachineScaleSetInput or IO[bytes] + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrateToVirtualMachineScaleSetInput") + + _request = build_validate_migration_to_virtual_machine_scale_set_request( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 + + @distributed_trace + def list_available_sizes( + self, resource_group_name: str, availability_set_name: str, **kwargs: Any + ) -> ItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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 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/operations/_capacity_reservation_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_capacity_reservation_groups_operations.py new file mode 100644 index 000000000000..9bc037805c80 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_capacity_reservation_groups_operations.py @@ -0,0 +1,845 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request( + subscription_id: str, + *, + expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, + resource_ids_only: Optional[Union[str, _models.ResourceIdOptionsForGetCapacityReservationGroups]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/capacityReservationGroups" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + if resource_ids_only is not None: + _params["resourceIdsOnly"] = _SERIALIZER.query("resource_ids_only", resource_ids_only, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups", + ) + 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 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + 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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", + ) + 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 + ), + "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") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, capacity_reservation_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", + ) + 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 + ), + "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") + + # 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_update_request( + resource_group_name: str, capacity_reservation_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", + ) + 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 + ), + "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") + + # 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_delete_request( + resource_group_name: str, capacity_reservation_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class CapacityReservationGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`capacity_reservation_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + ) -> ItemPaged["_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 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. + :type expand: str or ~azure.mgmt.compute.models.ExpandTypesForGetCapacityReservationGroups + :param 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. + :type resource_ids_only: str or + ~azure.mgmt.compute.models.ResourceIdOptionsForGetCapacityReservationGroups + :return: An iterator like instance of either CapacityReservationGroup or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CapacityReservationGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + 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 + ) -> ItemPaged["_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 + :param 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. + :type expand: str or ~azure.mgmt.compute.models.ExpandTypesForGetCapacityReservationGroups + :return: An iterator like instance of either CapacityReservationGroup or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CapacityReservationGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + expand: Optional[Union[str, _models.CapacityReservationGroupInstanceViewTypes]] = None, + **kwargs: Any + ) -> _models.CapacityReservationGroup: + """The operation that retrieves information about a capacity reservation group. + + :param resource_group_name: The name of the resource group. 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 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. + :type expand: str or ~azure.mgmt.compute.models.CapacityReservationGroupInstanceViewTypes + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.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 = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) + + _request = build_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) + + _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("CapacityReservationGroup", 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, + 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. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param parameters: Parameters supplied to the Create capacity reservation Group. Required. + :type parameters: ~azure.mgmt.compute.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.models.CapacityReservationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CapacityReservationGroup: + """The operation to create or update a capacity reservation group. When updating a capacity + reservation group, only tags and sharing profile may be modified. Please refer to + https://aka.ms/CapacityReservation for more details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param parameters: Parameters supplied to the Create capacity reservation Group. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.CapacityReservationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + parameters: Union[_models.CapacityReservationGroup, IO[bytes]], + **kwargs: Any + ) -> _models.CapacityReservationGroup: + """The operation to create or update a capacity reservation group. When updating a capacity + reservation group, only tags and sharing profile may be modified. Please refer to + https://aka.ms/CapacityReservation for more details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param parameters: Parameters supplied to the Create capacity reservation Group. Is either a + CapacityReservationGroup type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.models.CapacityReservationGroup or IO[bytes] + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CapacityReservationGroup") + + _request = build_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) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CapacityReservationGroup", 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, + 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. 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: ~azure.mgmt.compute.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.models.CapacityReservationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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.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.models.CapacityReservationGroupUpdate or IO[bytes] + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CapacityReservationGroupUpdate") + + _request = build_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 = 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 + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any + ) -> None: + """The operation to delete a capacity reservation group. This operation is allowed only if all the + associated resources are disassociated from the reservation group and all capacity reservations + under the reservation group have also been deleted. Please refer to + https://aka.ms/CapacityReservation for more details. + + :param resource_group_name: The name of the resource group. 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_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) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_capacity_reservations_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_capacity_reservations_operations.py new file mode 100644 index 000000000000..043a359a7e25 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_capacity_reservations_operations.py @@ -0,0 +1,963 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}", + ) + 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 + ), + "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") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + 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-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}", + ) + 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 + ), + "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") + + # 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_update_request( + 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-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}", + ) + 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 + ), + "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") + + # 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_delete_request( + 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-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class CapacityReservationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`capacity_reservations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_capacity_reservation_group( + self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any + ) -> ItemPaged["_models.CapacityReservation"]: + """Lists all of the capacity reservations in the specified capacity reservation group. Use the + nextLink property in the response to get the next page of capacity reservations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.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", "2024-11-01")) + cls: ClsType[_models.CapacityReservationListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_capacity_reservation_group_request( + resource_group_name=resource_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CapacityReservationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def 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. 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 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. + :type expand: str or ~azure.mgmt.compute.models.CapacityReservationInstanceViewTypes + :return: CapacityReservation or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + + _request = build_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, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CapacityReservation") + + _request = build_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) + + _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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, 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. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Create capacity reservation. Required. + :type parameters: ~azure.mgmt.compute.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.models.CapacityReservation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CapacityReservation]: + """The operation to create or update a capacity reservation. Please note some properties can be + set only during capacity reservation creation. Please refer to + https://aka.ms/CapacityReservation for more details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Create capacity reservation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either CapacityReservation or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.CapacityReservation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: Union[_models.CapacityReservation, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.CapacityReservation]: + """The operation to create or update a capacity reservation. Please note some properties can be + set only during capacity reservation creation. Please refer to + https://aka.ms/CapacityReservation for more details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Create capacity reservation. Is either a + CapacityReservation type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + capacity_reservation_name=capacity_reservation_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.CapacityReservation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CapacityReservation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CapacityReservationUpdate") + + _request = build_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) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: _models.CapacityReservationUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CapacityReservation]: + """The operation to update a capacity reservation. + + :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.models.CapacityReservationUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either CapacityReservation or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.CapacityReservation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CapacityReservation]: + """The operation to update a capacity reservation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Update capacity reservation operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either CapacityReservation or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.CapacityReservation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.CapacityReservation]: + """The operation to update a capacity reservation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Update capacity reservation operation. Is either + a CapacityReservationUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._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 _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, + 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_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, + 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, + capacity_reservation_group_name: str, + capacity_reservation_name: 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. + + :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 + :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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + 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) + + 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_cloud_service_operating_systems_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_cloud_service_operating_systems_operations.py new file mode 100644 index 000000000000..81b693cd6f22 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_cloud_service_operating_systems_operations.py @@ -0,0 +1,418 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_os_version_request( + location: str, os_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", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsVersions/{osVersionName}", + ) + path_format_arguments = { + "location": _SERIALIZER.url("location", location, "str"), + "osVersionName": _SERIALIZER.url("os_version_name", os_version_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_os_versions_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsVersions", + ) + path_format_arguments = { + "location": _SERIALIZER.url("location", location, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_os_family_request(location: str, os_family_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsFamilies/{osFamilyName}", + ) + path_format_arguments = { + "location": _SERIALIZER.url("location", location, "str"), + "osFamilyName": _SERIALIZER.url("os_family_name", os_family_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_os_families_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsFamilies", + ) + path_format_arguments = { + "location": _SERIALIZER.url("location", location, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class CloudServiceOperatingSystemsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`cloud_service_operating_systems` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get_os_version(self, location: str, os_version_name: str, **kwargs: Any) -> _models.OSVersion: + """Gets properties of a guest operating system version that can be specified in the XML service + configuration (.cscfg) for a cloud service. + + :param location: Name of the location that the OS version pertains to. Required. + :type location: str + :param os_version_name: Name of the OS version. Required. + :type os_version_name: str + :return: OSVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.OSVersion + :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", "2024-11-04")) + cls: ClsType[_models.OSVersion] = kwargs.pop("cls", None) + + _request = build_get_os_version_request( + location=location, + os_version_name=os_version_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("OSVersion", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_os_versions(self, location: str, **kwargs: Any) -> ItemPaged["_models.OSVersion"]: + """Gets a list of all guest operating system versions available to be specified in the XML service + configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the + next page of OS versions. Do this till nextLink is null to fetch all the OS versions. + + :param location: Name of the location that the OS versions pertain to. Required. + :type location: str + :return: An iterator like instance of either OSVersion or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.models.OSVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + cls: ClsType[_models.OSVersionListResult] = 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_list_os_versions_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OSVersionListResult", 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_os_family(self, location: str, os_family_name: str, **kwargs: Any) -> _models.OSFamily: + """Gets properties of a guest operating system family that can be specified in the XML service + configuration (.cscfg) for a cloud service. + + :param location: Name of the location that the OS family pertains to. Required. + :type location: str + :param os_family_name: Name of the OS family. Required. + :type os_family_name: str + :return: OSFamily or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.OSFamily + :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", "2024-11-04")) + cls: ClsType[_models.OSFamily] = kwargs.pop("cls", None) + + _request = build_get_os_family_request( + location=location, + os_family_name=os_family_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("OSFamily", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_os_families(self, location: str, **kwargs: Any) -> ItemPaged["_models.OSFamily"]: + """Gets a list of all guest operating system families available to be specified in the XML service + configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the + next page of OS Families. Do this till nextLink is null to fetch all the OS Families. + + :param location: Name of the location that the OS families pertain to. Required. + :type location: str + :return: An iterator like instance of either OSFamily or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.models.OSFamily] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + cls: ClsType[_models.OSFamilyListResult] = 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_list_os_families_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OSFamilyListResult", 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/operations/_cloud_service_role_instances_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_cloud_service_role_instances_operations.py new file mode 100644 index 000000000000..472263b65b45 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_cloud_service_role_instances_operations.py @@ -0,0 +1,1040 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Iterator, Optional, TypeVar, Union, cast + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_delete_request( + role_instance_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}", + ) + path_format_arguments = { + "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}", + ) + path_format_arguments = { + "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_instance_view_request( + role_instance_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/instanceView", + ) + path_format_arguments = { + "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restart_request( + role_instance_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/restart", + ) + path_format_arguments = { + "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_reimage_request( + role_instance_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/reimage", + ) + path_format_arguments = { + "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rebuild_request( + role_instance_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/rebuild", + ) + path_format_arguments = { + "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_remote_desktop_file_request( + role_instance_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/x-rdp") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/remoteDesktopFile", + ) + path_format_arguments = { + "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class CloudServiceRoleInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`cloud_service_role_instances` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _delete_initial( + self, role_instance_name: str, resource_group_name: str, cloud_service_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", "2024-11-04")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a role instance from a cloud service. + + :param role_instance_name: Name of the role instance. Required. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_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", "2024-11-04")) + 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( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get( + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any + ) -> _models.RoleInstance: + """Gets a role instance from a cloud service. + + :param role_instance_name: Name of the role instance. Required. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param expand: The expand expression to apply to the operation. 'UserData' is not supported for + cloud services. Known values are: "instanceView", "userData", and "resiliencyView". Default + value is None. + :type expand: str or ~azure.mgmt.compute.models.InstanceViewTypes + :return: RoleInstance or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.RoleInstance + :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", "2024-11-04")) + cls: ClsType[_models.RoleInstance] = kwargs.pop("cls", None) + + _request = build_get_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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("RoleInstance", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_instance_view( + self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> _models.RoleInstanceView: + """Retrieves information about the run-time state of a role instance in a cloud service. + + :param role_instance_name: Name of the role instance. Required. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :return: RoleInstanceView or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.RoleInstanceView + :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", "2024-11-04")) + cls: ClsType[_models.RoleInstanceView] = kwargs.pop("cls", None) + + _request = build_get_instance_view_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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("RoleInstanceView", 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, + cloud_service_name: str, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any + ) -> ItemPaged["_models.RoleInstance"]: + """Gets the list of all role instances in a cloud service. Use nextLink property in the response + to get the next page of role instances. Do this till nextLink is null to fetch all the role + instances. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param expand: The expand expression to apply to the operation. 'UserData' is not supported for + cloud services. Known values are: "instanceView", "userData", and "resiliencyView". Default + value is None. + :type expand: str or ~azure.mgmt.compute.models.InstanceViewTypes + :return: An iterator like instance of either RoleInstance or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.models.RoleInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + cls: ClsType[_models.RoleInstanceListResult] = 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_list_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RoleInstanceListResult", 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 _restart_initial( + self, role_instance_name: str, resource_group_name: str, cloud_service_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", "2024-11-04")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_restart_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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 + + return deserialized # type: ignore + + @distributed_trace + def begin_restart( + self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> LROPoller[None]: + """The Reboot Role Instance asynchronous operation requests a reboot of a role instance in the + cloud service. + + :param role_instance_name: Name of the role instance. Required. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_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", "2024-11-04")) + 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( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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, role_instance_name: str, resource_group_name: str, cloud_service_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", "2024-11-04")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_reimage_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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 + + return deserialized # type: ignore + + @distributed_trace + def begin_reimage( + self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> LROPoller[None]: + """The Reimage Role Instance asynchronous operation reinstalls the operating system on instances + of web roles or worker roles. + + :param role_instance_name: Name of the role instance. Required. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_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", "2024-11-04")) + 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( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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 _rebuild_initial( + self, role_instance_name: str, resource_group_name: str, cloud_service_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", "2024-11-04")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_rebuild_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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 + + return deserialized # type: ignore + + @distributed_trace + def begin_rebuild( + self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> LROPoller[None]: + """The Rebuild Role Instance asynchronous operation reinstalls the operating system on instances + of web roles or worker roles and initializes the storage resources that are used by them. If + you do not want to initialize storage resources, you can use Reimage Role Instance. + + :param role_instance_name: Name of the role instance. Required. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_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", "2024-11-04")) + 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._rebuild_initial( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get_remote_desktop_file( + self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> Iterator[bytes]: + """Gets a remote desktop file for a role instance in a cloud service. + + :param role_instance_name: Name of the role instance. Required. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :return: Iterator[bytes] or the result of cls(response) + :rtype: Iterator[bytes] + :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", "2024-11-04")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_get_remote_desktop_file_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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]: + 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_cloud_service_roles_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_cloud_service_roles_operations.py new file mode 100644 index 000000000000..4e81b62eabe4 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_cloud_service_roles_operations.py @@ -0,0 +1,250 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + role_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roles/{roleName}", + ) + path_format_arguments = { + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roles", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class CloudServiceRolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`cloud_service_roles` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, role_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> _models.CloudServiceRole: + """Gets a role from a cloud service. + + :param role_name: Name of the role. Required. + :type role_name: str + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :return: CloudServiceRole or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.CloudServiceRole + :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", "2024-11-04")) + cls: ClsType[_models.CloudServiceRole] = kwargs.pop("cls", None) + + _request = build_get_request( + role_name=role_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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("CloudServiceRole", 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, cloud_service_name: str, **kwargs: Any + ) -> ItemPaged["_models.CloudServiceRole"]: + """Gets a list of all roles in a cloud service. Use nextLink property in the response to get the + next page of roles. Do this till nextLink is null to fetch all the roles. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :return: An iterator like instance of either CloudServiceRole or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.models.CloudServiceRole] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + cls: ClsType[_models.CloudServiceRoleListResult] = 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_list_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CloudServiceRoleListResult", 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/operations/_cloud_services_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_cloud_services_operations.py new file mode 100644 index 000000000000..af9733678318 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_cloud_services_operations.py @@ -0,0 +1,2152 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request( + resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + 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/cloudServices/{cloudServiceName}", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # 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_update_request( + resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + 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/cloudServices/{cloudServiceName}", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # 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_delete_request( + resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_instance_view_request( + resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/instanceView", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_all_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/cloudServices") + path_format_arguments = { + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_start_request( + resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/start", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_power_off_request( + resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/poweroff", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restart_request( + resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + 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/cloudServices/{cloudServiceName}/restart", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # 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_reimage_request( + resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + 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/cloudServices/{cloudServiceName}/reimage", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # 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_rebuild_request( + resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + 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/cloudServices/{cloudServiceName}/rebuild", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # 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_delete_instances_request( + resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + 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/cloudServices/{cloudServiceName}/delete", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # 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) + + +class CloudServicesOperations: # 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.ComputeManagementClient`'s + :attr:`cloud_services` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_or_update_initial( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.CloudService, 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", "2024-11-04")) + 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, "CloudService") + else: + _json = None + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.CloudService] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CloudService]: + """Create or update a cloud service. Please note some properties can be set only during cloud + service creation. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: The cloud service object. Default value is None. + :type parameters: ~azure.mgmt.compute.models.CloudService + :keyword content_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 CloudService or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.CloudService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CloudService]: + """Create or update a cloud service. Please note some properties can be set only during cloud + service creation. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: The cloud service object. 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 CloudService or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.CloudService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.CloudService, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.CloudService]: + """Create or update a cloud service. Please note some properties can be set only during cloud + service creation. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: The cloud service object. Is either a CloudService type or a IO[bytes] type. + Default value is None. + :type parameters: ~azure.mgmt.compute.models.CloudService or IO[bytes] + :return: An instance of LROPoller that returns either CloudService or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.CloudService] + :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", "2024-11-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CloudService] = 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, + cloud_service_name=cloud_service_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("CloudService", 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.CloudService].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CloudService]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.CloudServiceUpdate, 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", "2024-11-04")) + 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, "CloudServiceUpdate") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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]: + 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, + cloud_service_name: str, + parameters: Optional[_models.CloudServiceUpdate] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CloudService]: + """Update a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: The cloud service object. Default value is None. + :type parameters: ~azure.mgmt.compute.models.CloudServiceUpdate + :keyword content_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 CloudService or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.CloudService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CloudService]: + """Update a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: The cloud service object. 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 CloudService or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.CloudService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.CloudServiceUpdate, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.CloudService]: + """Update a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: The cloud service object. Is either a CloudServiceUpdate type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.compute.models.CloudServiceUpdate or IO[bytes] + :return: An instance of LROPoller that returns either CloudService or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.CloudService] + :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", "2024-11-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CloudService] = 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, + cloud_service_name=cloud_service_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("CloudService", 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.CloudService].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CloudService]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial(self, resource_group_name: str, cloud_service_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", "2024-11-04")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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, cloud_service_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_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", "2024-11-04")) + 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, + cloud_service_name=cloud_service_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, cloud_service_name: str, **kwargs: Any) -> _models.CloudService: + """Display information about a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :return: CloudService or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.CloudService + :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", "2024-11-04")) + cls: ClsType[_models.CloudService] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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("CloudService", 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, cloud_service_name: str, **kwargs: Any + ) -> _models.CloudServiceInstanceView: + """Gets the status of a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :return: CloudServiceInstanceView or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.CloudServiceInstanceView + :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", "2024-11-04")) + cls: ClsType[_models.CloudServiceInstanceView] = kwargs.pop("cls", None) + + _request = build_get_instance_view_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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("CloudServiceInstanceView", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_all(self, **kwargs: Any) -> ItemPaged["_models.CloudService"]: + """Gets a list of all cloud services in the subscription, regardless of the associated resource + group. Use nextLink property in the response to get the next page of Cloud Services. Do this + till nextLink is null to fetch all the Cloud Services. + + :return: An iterator like instance of either CloudService or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.models.CloudService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + cls: ClsType[_models.CloudServiceListResult] = 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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CloudServiceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.CloudService"]: + """Gets a list of all cloud services under a resource group. Use nextLink property in the response + to get the next page of Cloud Services. Do this till nextLink is null to fetch all the Cloud + Services. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :return: An iterator like instance of either CloudService or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.models.CloudService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + cls: ClsType[_models.CloudServiceListResult] = 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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CloudServiceListResult", 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, cloud_service_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", "2024-11-04")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_start_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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 + + return deserialized # type: ignore + + @distributed_trace + def begin_start(self, resource_group_name: str, cloud_service_name: str, **kwargs: Any) -> LROPoller[None]: + """Starts the cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_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", "2024-11-04")) + 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, + cloud_service_name=cloud_service_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 _power_off_initial(self, resource_group_name: str, cloud_service_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", "2024-11-04")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_power_off_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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 + + return deserialized # type: ignore + + @distributed_trace + def begin_power_off(self, resource_group_name: str, cloud_service_name: str, **kwargs: Any) -> LROPoller[None]: + """Power off the cloud service. Note that resources are still attached and you are getting charged + for the resources. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_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", "2024-11-04")) + 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, + cloud_service_name=cloud_service_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 _restart_initial( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.RoleInstances, 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", "2024-11-04")) + 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, "RoleInstances") + else: + _json = None + + _request = build_restart_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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_restart( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Restarts one or more role instances in a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: ~azure.mgmt.compute.models.RoleInstances + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_restart( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Restarts one or more role instances in a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. 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_restart( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Restarts one or more role instances in a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Is either a RoleInstances type or + a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.models.RoleInstances 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", "2024-11-04")) + 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, + cloud_service_name=cloud_service_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _reimage_initial( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.RoleInstances, 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", "2024-11-04")) + 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, "RoleInstances") + else: + _json = None + + _request = build_reimage_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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_reimage( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Reimage asynchronous operation reinstalls the operating system on instances of web roles or + worker roles. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: ~azure.mgmt.compute.models.RoleInstances + :keyword content_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, + cloud_service_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Reimage asynchronous operation reinstalls the operating system on instances of web roles or + worker roles. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. 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, + cloud_service_name: str, + parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Reimage asynchronous operation reinstalls the operating system on instances of web roles or + worker roles. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Is either a RoleInstances type or + a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.models.RoleInstances 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", "2024-11-04")) + 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, + cloud_service_name=cloud_service_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _rebuild_initial( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.RoleInstances, 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", "2024-11-04")) + 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, "RoleInstances") + else: + _json = None + + _request = build_rebuild_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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_rebuild( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker + roles and initializes the storage resources that are used by them. If you do not want to + initialize storage resources, you can use Reimage Role Instances. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: ~azure.mgmt.compute.models.RoleInstances + :keyword content_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_rebuild( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker + roles and initializes the storage resources that are used by them. If you do not want to + initialize storage resources, you can use Reimage Role Instances. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. 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_rebuild( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker + roles and initializes the storage resources that are used by them. If you do not want to + initialize storage resources, you can use Reimage Role Instances. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Is either a RoleInstances type or + a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.models.RoleInstances 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", "2024-11-04")) + 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._rebuild_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _delete_instances_initial( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.RoleInstances, 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", "2024-11-04")) + 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, "RoleInstances") + else: + _json = None + + _request = build_delete_instances_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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_delete_instances( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Deletes role instances in a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: ~azure.mgmt.compute.models.RoleInstances + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_delete_instances( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Deletes role instances in a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. 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_delete_instances( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes role instances in a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Is either a RoleInstances type or + a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.models.RoleInstances 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", "2024-11-04")) + 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, + cloud_service_name=cloud_service_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_cloud_services_update_domain_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_cloud_services_update_domain_operations.py new file mode 100644 index 000000000000..e9327f6b2430 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_cloud_services_update_domain_operations.py @@ -0,0 +1,496 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_walk_update_domain_request( + resource_group_name: str, cloud_service_name: str, update_domain: int, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + 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/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), + "updateDomain": _SERIALIZER.url("update_domain", update_domain, "int"), + "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") + + # 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_get_update_domain_request( + resource_group_name: str, cloud_service_name: str, update_domain: int, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), + "updateDomain": _SERIALIZER.url("update_domain", update_domain, "int"), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_update_domains_request( + resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains", + ) + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class CloudServicesUpdateDomainOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`cloud_services_update_domain` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _walk_update_domain_initial( + self, + resource_group_name: str, + cloud_service_name: str, + update_domain: int, + parameters: Optional[Union[_models.UpdateDomain, 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", "2024-11-04")) + 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, "UpdateDomain") + else: + _json = None + + _request = build_walk_update_domain_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + update_domain=update_domain, + 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_walk_update_domain( + self, + resource_group_name: str, + cloud_service_name: str, + update_domain: int, + parameters: Optional[_models.UpdateDomain] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Updates the role instances in the specified update domain. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param update_domain: Specifies an integer value that identifies the update domain. Update + domains are identified with a zero-based index: the first update domain has an ID of 0, the + second has an ID of 1, and so on. Required. + :type update_domain: int + :param parameters: The update domain object. Default value is None. + :type parameters: ~azure.mgmt.compute.models.UpdateDomain + :keyword content_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_walk_update_domain( + self, + resource_group_name: str, + cloud_service_name: str, + update_domain: int, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Updates the role instances in the specified update domain. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param update_domain: Specifies an integer value that identifies the update domain. Update + domains are identified with a zero-based index: the first update domain has an ID of 0, the + second has an ID of 1, and so on. Required. + :type update_domain: int + :param parameters: The update domain object. 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_walk_update_domain( + self, + resource_group_name: str, + cloud_service_name: str, + update_domain: int, + parameters: Optional[Union[_models.UpdateDomain, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Updates the role instances in the specified update domain. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param update_domain: Specifies an integer value that identifies the update domain. Update + domains are identified with a zero-based index: the first update domain has an ID of 0, the + second has an ID of 1, and so on. Required. + :type update_domain: int + :param parameters: The update domain object. Is either a UpdateDomain type or a IO[bytes] type. + Default value is None. + :type parameters: ~azure.mgmt.compute.models.UpdateDomain 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", "2024-11-04")) + 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._walk_update_domain_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + update_domain=update_domain, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get_update_domain( + self, resource_group_name: str, cloud_service_name: str, update_domain: int, **kwargs: Any + ) -> _models.UpdateDomain: + """Gets the specified update domain of a cloud service. Use nextLink property in the response to + get the next page of update domains. Do this till nextLink is null to fetch all the update + domains. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :param update_domain: Specifies an integer value that identifies the update domain. Update + domains are identified with a zero-based index: the first update domain has an ID of 0, the + second has an ID of 1, and so on. Required. + :type update_domain: int + :return: UpdateDomain or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.UpdateDomain + :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", "2024-11-04")) + cls: ClsType[_models.UpdateDomain] = kwargs.pop("cls", None) + + _request = build_get_update_domain_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + update_domain=update_domain, + 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("UpdateDomain", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_update_domains( + self, resource_group_name: str, cloud_service_name: str, **kwargs: Any + ) -> ItemPaged["_models.UpdateDomain"]: + """Gets a list of all update domains in a cloud service. + + :param resource_group_name: Name of the resource group. Required. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. Required. + :type cloud_service_name: str + :return: An iterator like instance of either UpdateDomain or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.models.UpdateDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) + cls: ClsType[_models.UpdateDomainListResult] = 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_list_update_domains_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("UpdateDomainListResult", 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/operations/_community_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_community_galleries_operations.py new file mode 100644 index 000000000000..06b11b45f396 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_community_galleries_operations.py @@ -0,0 +1,138 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_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")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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) + + +class CommunityGalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`community_galleries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, location: str, public_gallery_name: str, **kwargs: Any) -> _models.CommunityGallery: + """Get a community gallery by gallery public name. + + :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.models.CommunityGallery + :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", "2023-07-03")) + cls: ClsType[_models.CommunityGallery] = kwargs.pop("cls", None) + + _request = build_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) + + _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("CommunityGallery", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_community_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_community_gallery_image_versions_operations.py new file mode 100644 index 000000000000..1a4316ea1c28 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_community_gallery_image_versions_operations.py @@ -0,0 +1,271 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + 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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + 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 {}) + + 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", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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) + + +class CommunityGalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`community_gallery_image_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + 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: 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.models.CommunityGalleryImageVersion + :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", "2023-07-03")) + cls: ClsType[_models.CommunityGalleryImageVersion] = kwargs.pop("cls", None) + + _request = build_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, + 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("CommunityGalleryImageVersion", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, location: str, public_gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> ItemPaged["_models.CommunityGalleryImageVersion"]: + """List community gallery image versions inside an 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: An iterator like instance of either CommunityGalleryImageVersion or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "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_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: + _request = HttpRequest("GET", next_link) + _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) + 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/operations/_community_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_community_gallery_images_operations.py new file mode 100644 index 000000000000..2378e7e8dccc --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_community_gallery_images_operations.py @@ -0,0 +1,248 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + 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 {}) + + 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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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_list_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")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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) + + +class CommunityGalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`community_gallery_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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.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", "2023-07-03")) + cls: ClsType[_models.CommunityGalleryImage] = kwargs.pop("cls", None) + + _request = build_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CommunityGalleryImage", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, location: str, public_gallery_name: str, **kwargs: Any + ) -> ItemPaged["_models.CommunityGalleryImage"]: + """List community gallery images inside 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 + :return: An iterator like instance of either CommunityGalleryImage or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CommunityGalleryImageList", 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/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_dedicated_host_groups_operations.py new file mode 100644 index 000000000000..77981f3f88cc --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_dedicated_host_groups_operations.py @@ -0,0 +1,776 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups") + path_format_arguments = { + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups", + ) + 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 + ), + } + + _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_get_request( + resource_group_name: str, + host_group_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + 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_update_request( + resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + 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_delete_request( + resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class DedicatedHostGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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 + + if response.status_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 + ) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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 + + if response.status_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, + 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 + :param expand: The expand expression to apply on the operation. 'InstanceView' will retrieve + the list of instance views of the dedicated hosts under the dedicated host group. 'UserData' is + not supported for dedicated host group. Known values are: "instanceView", "userData", and + "resiliencyView". Default value is None. + :type expand: str or ~azure.mgmt.compute.models.InstanceViewTypes + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) + + _request = build_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) + + _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("DedicatedHostGroup", 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, + host_group_name: str, + parameters: _models.DedicatedHostGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DedicatedHostGroup: + """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host + Groups please see [Dedicated Host Documentation] + (https://go.microsoft.com/fwlink/?linkid=2082596). + + :param resource_group_name: The name of the resource group. 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.models.DedicatedHostGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.DedicatedHostGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + host_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DedicatedHostGroup: + """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host + Groups please see [Dedicated Host Documentation] + (https://go.microsoft.com/fwlink/?linkid=2082596). + + :param resource_group_name: The name of the resource group. 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: IO[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.models.DedicatedHostGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + host_group_name: str, + parameters: Union[_models.DedicatedHostGroup, IO[bytes]], + **kwargs: Any + ) -> _models.DedicatedHostGroup: + """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host + Groups please see [Dedicated Host Documentation] + (https://go.microsoft.com/fwlink/?linkid=2082596). + + :param resource_group_name: The name of the resource group. 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.models.DedicatedHostGroup or IO[bytes] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DedicatedHostGroup") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + host_group_name: str, + parameters: _models.DedicatedHostGroupUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DedicatedHostGroup: + """Update an dedicated host group. + + :param resource_group_name: The name of the resource group. 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.models.DedicatedHostGroupUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.DedicatedHostGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + host_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DedicatedHostGroup: + """Update an dedicated host group. + + :param resource_group_name: The name of the resource group. 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: IO[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.models.DedicatedHostGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + host_group_name: str, + parameters: Union[_models.DedicatedHostGroupUpdate, IO[bytes]], + **kwargs: Any + ) -> _models.DedicatedHostGroup: + """Update an 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 + :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.models.DedicatedHostGroupUpdate or IO[bytes] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DedicatedHostGroupUpdate") + + _request = build_update_request( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :return: None or the result of cls(response) + :rtype: None + :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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_dedicated_hosts_operations.py new file mode 100644 index 000000000000..9d2f14cfe2be --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_dedicated_hosts_operations.py @@ -0,0 +1,1346 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_host_group_request( + resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + host_group_name: str, + host_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), + "hostName": _SERIALIZER.url("host_name", host_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), + "hostName": _SERIALIZER.url("host_name", host_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_update_request( + resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), + "hostName": _SERIALIZER.url("host_name", host_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_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 {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), + "hostName": _SERIALIZER.url("host_name", host_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) + + +def build_list_available_sizes_request( + resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}/hostSizes", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), + "hostName": _SERIALIZER.url("host_name", host_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_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}/redeploy", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), + "hostName": _SERIALIZER.url("host_name", host_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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}/restart", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), + "hostName": _SERIALIZER.url("host_name", host_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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class DedicatedHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_host_group( + self, resource_group_name: str, host_group_name: str, **kwargs: Any + ) -> ItemPaged["_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. 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.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", "2024-11-01")) + cls: ClsType[_models.DedicatedHostListResult] = 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_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, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DedicatedHostListResult", 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, + 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. 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 + :param expand: The expand expression to apply on the operation. 'InstanceView' will retrieve + the list of instance views of the dedicated host. 'UserData' is not supported for dedicated + host. Known values are: "instanceView", "userData", and "resiliencyView". Default value is + None. + :type expand: str or ~azure.mgmt.compute.models.InstanceViewTypes + :return: DedicatedHost or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.DedicatedHost] = kwargs.pop("cls", None) + + _request = build_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 + + def _create_or_update_initial( + self, + resource_group_name: str, + host_group_name: str, + host_name: str, + parameters: Union[_models.DedicatedHost, 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DedicatedHost") + + _request = build_create_or_update_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, + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + host_group_name: str, + host_name: str, + parameters: _models.DedicatedHost, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DedicatedHost]: + """Create or update a dedicated host . + + :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 + :param parameters: Parameters supplied to the Create Dedicated Host. Required. + :type parameters: ~azure.mgmt.compute.models.DedicatedHost + :keyword content_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 DedicatedHost or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.DedicatedHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + host_group_name: str, + host_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DedicatedHost]: + """Create or update a dedicated host . + + :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 + :param parameters: Parameters supplied to the Create Dedicated Host. 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 DedicatedHost or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.DedicatedHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + host_group_name: str, + host_name: str, + parameters: Union[_models.DedicatedHost, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.DedicatedHost]: + """Create or update a dedicated host . + + :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 + :param parameters: Parameters supplied to the Create Dedicated Host. Is either a DedicatedHost + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.models.DedicatedHost or IO[bytes] + :return: An instance of LROPoller that returns either DedicatedHost or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.DedicatedHost] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DedicatedHost] = 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, + host_group_name=host_group_name, + host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DedicatedHost]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + host_group_name: str, + host_name: str, + parameters: Union[_models.DedicatedHostUpdate, 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DedicatedHostUpdate") + + _request = build_update_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, + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + host_group_name: str, + host_name: str, + parameters: _models.DedicatedHostUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DedicatedHost]: + """Update a dedicated host . + + :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 + :param parameters: Parameters supplied to the Update Dedicated Host operation. Required. + :type parameters: ~azure.mgmt.compute.models.DedicatedHostUpdate + :keyword content_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 DedicatedHost or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.DedicatedHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + host_group_name: str, + host_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DedicatedHost]: + """Update a dedicated host . + + :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 + :param parameters: Parameters supplied to the Update Dedicated Host 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 DedicatedHost or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.DedicatedHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + host_group_name: str, + host_name: str, + parameters: Union[_models.DedicatedHostUpdate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.DedicatedHost]: + """Update a dedicated host . + + :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 + :param parameters: Parameters supplied to the Update Dedicated Host operation. Is either a + DedicatedHostUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.models.DedicatedHostUpdate or IO[bytes] + :return: An instance of LROPoller that returns either DedicatedHost or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.DedicatedHost] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DedicatedHost] = 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, + host_group_name=host_group_name, + host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DedicatedHost]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + host_name=host_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, host_group_name: str, host_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete a dedicated host. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param host_name: The name of the dedicated host. Required. + :type host_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + host_name=host_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_available_sizes( + self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any + ) -> ItemPaged[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. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param host_name: The name of the dedicated host. Required. + :type host_name: str + :return: An iterator like instance of either str or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[str] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + 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_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: + _request = HttpRequest("GET", next_link) + _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 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 _redeploy_initial( + self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_redeploy_request( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + host_name=host_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_redeploy( + self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Redeploy the dedicated host. The operation will complete successfully once the dedicated host + has migrated to a new node and is running. To determine the health of VMs deployed on the + dedicated host after the redeploy check the Resource Health Center in the Azure Portal. Please + refer to https://docs.microsoft.com/azure/service-health/resource-health-overview for more + details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param host_name: The name of the dedicated host. Required. + :type host_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._redeploy_initial( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + host_name=host_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _restart_initial( + self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any + ) -> Iterator[bytes]: + 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_restart_request( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + host_name=host_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_restart( + 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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param host_name: The name of the dedicated host. Required. + :type host_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._restart_initial( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + host_name=host_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_disk_accesses_operations.py new file mode 100644 index 000000000000..3a09903351b0 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_disk_accesses_operations.py @@ -0,0 +1,1614 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_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", "2023-10-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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_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_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", "2023-10-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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_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_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_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_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_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) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_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-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses") + path_format_arguments = { + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_private_link_resources_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", "2023-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateLinkResources", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_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_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-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}/privateEndpointConnections/{privateEndpointConnectionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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" + ), + } + + _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_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", "2023-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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" + ), + } + + _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_delete_a_private_endpoint_connection_request( # pylint: disable=name-too-long + resource_group_name: str, + disk_access_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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" + ), + } + + _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) + + +def build_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", "2023-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_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) + + +class DiskAccessesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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]: + 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", "2023-10-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk_access, (IOBase, bytes)): + _content = disk_access + else: + _json = self._serialize.body(disk_access, "DiskAccess") + + _request = build_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) + + _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_create_or_update( + self, + resource_group_name: str, + disk_access_name: str, + disk_access: _models.DiskAccess, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DiskAccess]: + """Creates or updates a disk access resource. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the Put disk access operation. + Required. + :type disk_access: ~azure.mgmt.compute.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.models.DiskAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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.models.DiskAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the Put disk access operation. + Is either a DiskAccess type or a IO[bytes] type. Required. + :type disk_access: ~azure.mgmt.compute.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.models.DiskAccess] + :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", "2023-10-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) + + 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 + + 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 + ) + + def _update_initial( + 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, + 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", "2023-10-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk_access, (IOBase, bytes)): + _content = disk_access + else: + _json = self._serialize.body(disk_access, "DiskAccessUpdate") + + _request = build_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) + + _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, + disk_access_name: str, + disk_access: _models.DiskAccessUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DiskAccess]: + """Updates (patches) a disk access resource. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the Patch disk access operation. + Required. + :type disk_access: ~azure.mgmt.compute.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 DiskAccess or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.DiskAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + disk_access_name: str, + disk_access: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DiskAccess]: + """Updates (patches) a disk access resource. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the 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 DiskAccess or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.DiskAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + 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. + :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.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.models.DiskAccess] + :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", "2023-10-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._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) + + 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 + + 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 + ) + + @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.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", "2023-10-02")) + cls: ClsType[_models.DiskAccess] = kwargs.pop("cls", None) + + _request = build_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]: + 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", "2023-10-02")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_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) + + _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_access_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes 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 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", "2023-10-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 + + 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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.DiskAccess"]: + """Lists all the disk access resources 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 DiskAccess or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2023-10-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_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: + _request = HttpRequest("GET", next_link) + _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(self, **kwargs: Any) -> ItemPaged["_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.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", "2023-10-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_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: + _request = HttpRequest("GET", next_link) + _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_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. + :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.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", "2023-10-02")) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + _request = build_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 + + 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 + ) -> 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", "2023-10-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(private_endpoint_connection, (IOBase, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + _request = build_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 = 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_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 + ) -> 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. + :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.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 PrivateEndpointConnection or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + 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 + ) -> 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. + :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 LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.PrivateEndpointConnection] + :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. + + :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.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.models.PrivateEndpointConnection] + :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", "2023-10-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, 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( + 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 + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + 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 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.PrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PrivateEndpointConnection]( + 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.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_get_a_private_endpoint_connection_request( + resource_group_name=resource_group_name, + disk_access_name=disk_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_a_private_endpoint_connection_initial( # pylint: disable=name-too-long + self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> 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", "2023-10-02")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_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) + + _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_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. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_a_private_endpoint_connection_initial( + resource_group_name=resource_group_name, + disk_access_name=disk_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + 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_private_endpoint_connections( + self, resource_group_name: str, disk_access_name: str, **kwargs: Any + ) -> ItemPaged["_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.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", "2023-10-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_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: + _request = HttpRequest("GET", next_link) + _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) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_disk_encryption_sets_operations.py new file mode 100644 index 000000000000..f995dc98c5eb --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_disk_encryption_sets_operations.py @@ -0,0 +1,1031 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_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_update_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_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_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_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_delete_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_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) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_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-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") + path_format_arguments = { + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_associated_resources_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}/associatedResources", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_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) + + +class DiskEncryptionSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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", "2023-10-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk_encryption_set, (IOBase, bytes)): + _content = disk_encryption_set + else: + _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + disk_encryption_set_name=disk_encryption_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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_create_or_update( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: _models.DiskEncryptionSet, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DiskEncryptionSet]: + """Creates or updates a disk encryption set. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk + encryption set operation. Required. + :type disk_encryption_set: ~azure.mgmt.compute.models.DiskEncryptionSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.DiskEncryptionSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DiskEncryptionSet]: + """Creates or updates a disk encryption set. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk + encryption set operation. Required. + :type disk_encryption_set: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.DiskEncryptionSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.DiskEncryptionSet]: + """Creates or updates a disk encryption set. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk + encryption set operation. Is either a DiskEncryptionSet type or a IO[bytes] type. Required. + :type disk_encryption_set: ~azure.mgmt.compute.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.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", "2023-10-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._create_or_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 + ) + + 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, + 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", "2023-10-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_update_request( + resource_group_name=resource_group_name, + disk_encryption_set_name=disk_encryption_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, + 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. + :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.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.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.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.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.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", "2023-10-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.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", "2023-10-02")) + cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) + + _request = build_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", "2023-10-02")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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 + :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", "2023-10-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, **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) -> ItemPaged["_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.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", "2023-10-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_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: + _request = HttpRequest("GET", next_link) + _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 list(self, **kwargs: Any) -> ItemPaged["_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.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", "2023-10-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_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: + _request = HttpRequest("GET", next_link) + _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 list_associated_resources( + self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any + ) -> ItemPaged[str]: + """Lists all resources that are encrypted with this 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: 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", "2023-10-02")) + cls: ClsType[_models.ResourceUriList] = 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_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, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ResourceUriList", 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/operations/_disk_restore_point_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_disk_restore_point_operations.py new file mode 100644 index 000000000000..03a45fe95a60 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_disk_restore_point_operations.py @@ -0,0 +1,713 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + 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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + } + + _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_list_by_restore_point_request( + 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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + 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", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + } + + _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_grant_access_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-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", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + } + + _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_revoke_access_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + 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", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + } + + _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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class DiskRestorePointOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`disk_restore_point` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. + + :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 + :return: DiskRestorePoint or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.DiskRestorePoint + :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", "2023-10-02")) + cls: ClsType[_models.DiskRestorePoint] = kwargs.pop("cls", None) + + _request = build_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 + ) -> ItemPaged["_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.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", "2023-10-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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DiskRestorePointList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _grant_access_initial( + self, + resource_group_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, + grant_access_data: Union[_models.GrantAccessData, IO[bytes]], + **kwargs: Any + ) -> 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", "2023-10-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(grant_access_data, (IOBase, bytes)): + _content = grant_access_data + else: + _json = self._serialize.body(grant_access_data, "GrantAccessData") + + _request = build_grant_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, + 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_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: _models.GrantAccessData, + *, + 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: ~azure.mgmt.compute.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 AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.AccessUri] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + 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: 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.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.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.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", "2023-10-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", "2023-10-02")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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 + + return deserialized # type: ignore + + @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. + + :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 + :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", "2023-10-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._revoke_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, + 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_disks_operations.py new file mode 100644 index 000000000000..353d4a047d4a --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_disks_operations.py @@ -0,0 +1,1245 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_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", "2023-10-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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskName": _SERIALIZER.url("disk_name", disk_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_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", "2023-10-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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskName": _SERIALIZER.url("disk_name", disk_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_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", "2023-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskName": _SERIALIZER.url("disk_name", disk_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_delete_request(resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskName": _SERIALIZER.url("disk_name", disk_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_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-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") + path_format_arguments = { + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_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", "2023-10-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", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskName": _SERIALIZER.url("disk_name", disk_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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_revoke_access_request( + resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "diskName": _SERIALIZER.url("disk_name", disk_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`disks` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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, + 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", "2023-10-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, (IOBase, bytes)): + _content = disk + else: + _json = self._serialize.body(disk, "Disk") + + _request = build_create_or_update_request( + resource_group_name=resource_group_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) + + _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_create_or_update( + self, + resource_group_name: str, + disk_name: str, + disk: _models.Disk, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Disk]: + """Creates or updates 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 + :param disk: Disk object supplied in the body of the Put disk operation. Required. + :type disk: ~azure.mgmt.compute.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 Disk or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.Disk] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + disk_name: str, + disk: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Disk]: + """Creates or updates 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 + :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 Disk or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.Disk] + :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. + + :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 + :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.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.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", "2023-10-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._create_or_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, **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 _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, + 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", "2023-10-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, (IOBase, bytes)): + _content = disk + else: + _json = self._serialize.body(disk, "DiskUpdate") + + _request = build_update_request( + resource_group_name=resource_group_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) + + _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, + disk_name: str, + disk: _models.DiskUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Disk]: + """Updates (patches) a disk. + + :param resource_group_name: The name of the resource group. Required. + :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.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.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. 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.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. 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.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.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", "2023-10-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, **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 + ) + + @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.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", "2023-10-02")) + cls: ClsType[_models.Disk] = kwargs.pop("cls", None) + + _request = build_get_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) + + _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("Disk", 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_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", "2023-10-02")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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. + :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 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", "2023-10-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_name=disk_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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Disk"]: + """Lists all the disks 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 Disk or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2023-10-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_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: + _request = HttpRequest("GET", next_link) + _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 list(self, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.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", "2023-10-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_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: + _request = HttpRequest("GET", next_link) + _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) + + 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, + 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", "2023-10-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(grant_access_data, (IOBase, bytes)): + _content = grant_access_data + else: + _json = self._serialize.body(grant_access_data, "GrantAccessData") + + _request = build_grant_access_request( + resource_group_name=resource_group_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) + + _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_grant_access( + self, + resource_group_name: str, + disk_name: str, + grant_access_data: _models.GrantAccessData, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AccessUri]: + """Grants access to a disk. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_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.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 AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.AccessUri] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_grant_access( + self, + resource_group_name: str, + disk_name: str, + grant_access_data: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AccessUri]: + """Grants access to a disk. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_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 AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.AccessUri] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_grant_access( + self, + resource_group_name: str, + disk_name: str, + grant_access_data: Union[_models.GrantAccessData, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AccessUri]: + """Grants access to a disk. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param disk_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.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.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", "2023-10-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, + disk_name=disk_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, 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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_revoke_access_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]: + 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_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. + :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 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", "2023-10-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._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 + ) + 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_galleries_operations.py new file mode 100644 index 000000000000..6d4a46011b2e --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_galleries_operations.py @@ -0,0 +1,929 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_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 + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", 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 + 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_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/{galleryName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", 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 + 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_get_request( + resource_group_name: str, + gallery_name: str, + subscription_id: str, + *, + select: Optional[Union[str, _models.SelectPermissions]] = None, + expand: Optional[Union[str, _models.GalleryExpandParams]] = 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")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "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 + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_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 {}) + + 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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", 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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-03")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_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")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries") + path_format_arguments = { + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class GalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`galleries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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, + 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", "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_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 + + 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) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + gallery_name: str, + gallery: _models.Gallery, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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. + Required. + :type gallery_name: str + :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. + Required. + :type gallery: ~azure.mgmt.compute.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.models.Gallery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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.models.Gallery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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. Is + either a Gallery type or a IO[bytes] type. Required. + :type gallery: ~azure.mgmt.compute.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.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", "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) + + 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, **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 _update_initial( + self, + resource_group_name: str, + gallery_name: str, + gallery: Union[_models.GalleryUpdate, 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", "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, "GalleryUpdate") + + _request = build_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]: + 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, + 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. 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 update Shared Image Gallery operation. Required. + :type gallery: ~azure.mgmt.compute.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.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. 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 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.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. 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 update Shared Image Gallery operation. Is either a + GalleryUpdate type or a IO[bytes] type. Required. + :type gallery: ~azure.mgmt.compute.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.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", "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, **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 + ) + + @distributed_trace + 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 + :param select: The select expression to apply on the operation. "Permissions" Default value is + None. + :type select: str or ~azure.mgmt.compute.models.SelectPermissions + :param expand: The expand query option to apply on the operation. "SharingProfile/Groups" + Default value is None. + :type expand: str or ~azure.mgmt.compute.models.GalleryExpandParams + :return: Gallery or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2023-07-03")) + cls: ClsType[_models.Gallery] = kwargs.pop("cls", None) + + _request = build_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) + 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 + + def _delete_initial(self, resource_group_name: str, gallery_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", "2023-07-03")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_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) + + _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, gallery_name: str, **kwargs: Any) -> LROPoller[None]: + """Delete 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 to be deleted. 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = 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")) + 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, + 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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.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", "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_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: + _request = HttpRequest("GET", next_link) + _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: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_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.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", "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_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: + _request = HttpRequest("GET", next_link) + _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: + 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/operations/_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_gallery_application_versions_operations.py new file mode 100644 index 000000000000..8f307bf4cfa4 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_gallery_application_versions_operations.py @@ -0,0 +1,1004 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request( + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application_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}/versions/{galleryApplicationVersionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + "galleryApplicationVersionName": _SERIALIZER.url( + "gallery_application_version_name", gallery_application_version_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_update_request( + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application_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}/versions/{galleryApplicationVersionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + "galleryApplicationVersionName": _SERIALIZER.url( + "gallery_application_version_name", gallery_application_version_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_get_request( + 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")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + "galleryApplicationVersionName": _SERIALIZER.url( + "gallery_application_version_name", gallery_application_version_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) + + +def build_delete_request( + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application_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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + "galleryApplicationVersionName": _SERIALIZER.url( + "gallery_application_version_name", gallery_application_version_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) + + +def build_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 {}) + + 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}/versions", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + } + + _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) + + +class GalleryApplicationVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`gallery_application_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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]], + **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", "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_application_version, (IOBase, bytes)): + _content = gallery_application_version + else: + _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersion") + + _request = build_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, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application_version_name: str, + gallery_application_version: _models.GalleryApplicationVersion, + *, + 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. + :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 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.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 GalleryApplicationVersion or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.GalleryApplicationVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + 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], + *, + 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. + :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 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] + :keyword content_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.models.GalleryApplicationVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + 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]], + **kwargs: Any + ) -> LROPoller[_models.GalleryApplicationVersion]: + """Create or update 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 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.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.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", "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, 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_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 + ) + 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: 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.GalleryApplicationVersion].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.GalleryApplicationVersion]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + 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]], + **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", "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_application_version, (IOBase, bytes)): + _content = gallery_application_version + else: + _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersionUpdate") + + _request = build_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, + 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]: + 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, + gallery_application_name: str, + gallery_application_version_name: str, + gallery_application_version: _models.GalleryApplicationVersionUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GalleryApplicationVersion]: + """Update 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 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.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 GalleryApplicationVersion or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.GalleryApplicationVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + 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], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GalleryApplicationVersion]: + """Update 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 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] + :keyword content_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.models.GalleryApplicationVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + 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]], + **kwargs: Any + ) -> LROPoller[_models.GalleryApplicationVersion]: + """Update 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 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.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.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", "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, 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_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 + ) + 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: 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.GalleryApplicationVersion].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + 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, + 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 + :param expand: The expand expression to apply on the operation. Known values are: + "ReplicationStatus" and "UefiSettings". Default value is None. + :type expand: str or ~azure.mgmt.compute.models.ReplicationStatusTypes + :return: GalleryApplicationVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2023-07-03")) + cls: ClsType[_models.GalleryApplicationVersion] = kwargs.pop("cls", None) + + _request = build_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 {}) + + _headers = 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")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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, + 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, + gallery_name: str, + gallery_application_name: str, + gallery_application_version_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Delete 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 + deleted. 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: + """ + _headers = 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")) + 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, + gallery_application_version_name=gallery_application_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 + + 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_application( + self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any + ) -> ItemPaged["_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.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", "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_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: + _request = HttpRequest("GET", next_link) + _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) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_gallery_applications_operations.py new file mode 100644 index 000000000000..e15d7f4bcdd3 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_gallery_applications_operations.py @@ -0,0 +1,893 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request( + 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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + } + + _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_update_request( + 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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + } + + _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_get_request( + 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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + } + + _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_delete_request( + 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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + } + + _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) + + +def build_list_by_gallery_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")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", 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) + + +class GalleryApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_or_update_initial( + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application: Union[_models.GalleryApplication, 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", "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_application, (IOBase, bytes)): + _content = gallery_application + else: + _json = self._serialize.body(gallery_application, "GalleryApplication") + + _request = build_create_or_update_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, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application: _models.GalleryApplication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GalleryApplication]: + """Create or update 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 is to be created. 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. + :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.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 GalleryApplication or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.GalleryApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_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]: + """Create or update 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 is to be created. 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. + :type gallery_application_name: str + :param gallery_application: Parameters supplied to the create or 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.models.GalleryApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application: Union[_models.GalleryApplication, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.GalleryApplication]: + """Create or update 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 is to be created. 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. + :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.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.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", "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._create_or_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, **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 _update_initial( + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application: Union[_models.GalleryApplicationUpdate, 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", "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_application, (IOBase, bytes)): + _content = gallery_application + else: + _json = self._serialize.body(gallery_application, "GalleryApplicationUpdate") + + _request = build_update_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, + 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]: + 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, + gallery_application_name: str, + gallery_application: _models.GalleryApplicationUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GalleryApplication]: + """Update 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 is to be updated. 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. + :type gallery_application_name: str + :param gallery_application: Parameters supplied to the update gallery Application operation. + Required. + :type gallery_application: ~azure.mgmt.compute.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.models.GalleryApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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 is to be updated. 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. + :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.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. 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. + :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. + :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.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.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", "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, **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 + ) + + @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.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", "2023-07-03")) + cls: ClsType[_models.GalleryApplication] = kwargs.pop("cls", None) + + _request = build_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 + ) -> 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", "2023-07-03")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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) + 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, 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. 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. + :type gallery_name: str + :param gallery_application_name: The name of the gallery Application Definition to be deleted. + 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", "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, **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 + ) -> ItemPaged["_models.GalleryApplication"]: + """List gallery Application 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 Application Gallery from which Application + Definitions are to be listed. 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.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", "2023-07-03")) + cls: ClsType[_models.GalleryApplicationList] = 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_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: + _request = HttpRequest("GET", next_link) + _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: + 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/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_gallery_image_versions_operations.py new file mode 100644 index 000000000000..3e2694997c61 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_gallery_image_versions_operations.py @@ -0,0 +1,991 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request( + 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + } + + _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_update_request( + 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + } + + _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_get_request( + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_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")) + 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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + } + + _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) + + +def build_delete_request( + 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")) + 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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + } + + _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) + + +def build_list_by_gallery_image_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")) + 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", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + } + + _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) + + +class GalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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", "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_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + 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.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.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. 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.models.GalleryImageVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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.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.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", "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, **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, + 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", "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, "GalleryImageVersionUpdate") + + _request = build_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]: + 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, + 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. + + :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.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.models.GalleryImageVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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 LROPoller that returns either GalleryImageVersion or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.GalleryImageVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + 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 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.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.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", "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._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, **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 + ) + + @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 + :param expand: The expand expression to apply on the operation. Known values are: + "ReplicationStatus" and "UefiSettings". Default value is None. + :type expand: str or ~azure.mgmt.compute.models.ReplicationStatusTypes + :return: GalleryImageVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2023-07-03")) + cls: ClsType[_models.GalleryImageVersion] = kwargs.pop("cls", None) + + _request = build_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( + 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, + 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", "2023-07-03")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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, + 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, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + **kwargs: Any + ) -> LROPoller[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 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", "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 + + 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_image( + self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> ItemPaged["_models.GalleryImageVersion"]: + """List gallery image versions in 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 + resides. 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) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2023-07-03")) + cls: ClsType[_models.GalleryImageVersionList] = 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_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, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GalleryImageVersionList", 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/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_gallery_images_operations.py new file mode 100644 index 000000000000..84b70f996357 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_gallery_images_operations.py @@ -0,0 +1,889 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + } + + _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_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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + } + + _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_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")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + } + + _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_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 {}) + + 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}/images/{galleryImageName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "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"), + } + + _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) + + +def build_list_by_gallery_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")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", 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) + + +class GalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`gallery_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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 + ) -> 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", "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") + + _request = build_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 = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + 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.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.models.GalleryImage] + :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: IO[bytes], + *, + 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: IO[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.models.GalleryImage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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.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.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", "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) + + 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: 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, + ) + return LROPoller[_models.GalleryImage]( + 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: Union[_models.GalleryImageUpdate, 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", "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") + + _request = build_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 = 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: + 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, + 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.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.models.GalleryImage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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.models.GalleryImage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image: Union[_models.GalleryImageUpdate, IO[bytes]], + **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. Is either a + GalleryImageUpdate type or a IO[bytes] type. Required. + :type gallery_image: ~azure.mgmt.compute.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.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", "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) + + 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: 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, + ) + 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_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.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", "2023-07-03")) + cls: ClsType[_models.GalleryImage] = kwargs.pop("cls", None) + + _request = build_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) + raise HttpResponseError(response=response, 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 _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", "2023-07-03")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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) + + _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, gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> LROPoller[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 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", "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 + ) -> ItemPaged["_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.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", "2023-07-03")) + cls: ClsType[_models.GalleryImageList] = 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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GalleryImageList", 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/operations/_gallery_sharing_profile_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_gallery_sharing_profile_operations.py new file mode 100644 index 000000000000..348d96ae031c --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_gallery_sharing_profile_operations.py @@ -0,0 +1,283 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_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/{galleryName}/share", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "galleryName": _SERIALIZER.url("gallery_name", 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 + 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) + + +class GallerySharingProfileOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`gallery_sharing_profile` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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", "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_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.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.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.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.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.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", "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 + ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_images_operations.py new file mode 100644 index 000000000000..c24afb42213f --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_images_operations.py @@ -0,0 +1,935 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") + path_format_arguments = { + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images", + ) + 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 + ), + } + + _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_get_request( + resource_group_name: str, image_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", + ) + 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 + ), + "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 + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", + ) + 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 + ), + "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") + + # 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_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", + ) + 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 + ), + "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") + + # 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_delete_request(resource_group_name: str, image_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ImageListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ImageListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, image_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Image: + """Gets an image. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param image_name: The name of the image. Required. + :type image_name: str + :param expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :return: Image or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.Image] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + image_name=image_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Image", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Image") + + _request = build_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 = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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, + image_name: str, + parameters: _models.Image, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Image]: + """Create or 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 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.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 Image or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.Image] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + image_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Image]: + """Create or 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 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 Image or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.Image] + :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. + + :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.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.models.Image] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._create_or_update_initial( + resource_group_name=resource_group_name, + image_name=image_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Image", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: 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( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Image]( + 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]], + **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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ImageUpdate") + + _request = build_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 = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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_update( + self, + resource_group_name: str, + image_name: str, + parameters: _models.ImageUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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 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.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 Image or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.Image] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + image_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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 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 Image or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.Image] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + image_name: str, + parameters: Union[_models.ImageUpdate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_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 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.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.models.Image] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_initial( + resource_group_name=resource_group_name, + image_name=image_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Image", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: 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( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Image]( + 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]: + 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + image_name=image_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, image_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes an Image. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param image_name: The name of the image. Required. + :type image_name: str + :return: An instance of 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + image_name=image_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_log_analytics_operations.py new file mode 100644 index 000000000000..85595b8b4e36 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_log_analytics_operations.py @@ -0,0 +1,482 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_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-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval", + ) + path_format_arguments = { + "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") + + # 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_export_throttled_requests_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests", + ) + path_format_arguments = { + "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") + + # 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) + + +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`log_analytics` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _export_request_rate_by_interval_initial( + self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RequestRateByIntervalInput") + + _request = build_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, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["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, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_export_request_rate_by_interval( + self, + location: str, + parameters: _models.RequestRateByIntervalInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LogAnalyticsOperationResult]: + """Export logs that show Api requests made by this subscription in the given time window to show + throttling activities. + + :param 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.models.RequestRateByIntervalInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.LogAnalyticsOperationResult] + :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. + + :param location: The name of Azure region. Required. + :type location: str + :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.LogAnalyticsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_export_request_rate_by_interval( + self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.LogAnalyticsOperationResult]: + """Export logs that show Api requests made by this subscription in the given time window to show + throttling activities. + + :param location: The name of Azure region. Required. + :type location: str + :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. Is + either a RequestRateByIntervalInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.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.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", "2024-11-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, 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, + 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("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, 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.LogAnalyticsOperationResult].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 + ) + + def _export_throttled_requests_initial( + self, location: str, parameters: Union[_models.ThrottledRequestsInput, 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ThrottledRequestsInput") + + _request = build_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, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["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, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_export_throttled_requests( + self, + location: str, + parameters: _models.ThrottledRequestsInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LogAnalyticsOperationResult]: + """Export logs that show total throttled Api requests for this subscription in the given time + window. + + :param location: The name of Azure region. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.compute.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.models.LogAnalyticsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_export_throttled_requests( + self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.LogAnalyticsOperationResult]: + """Export logs that show total throttled Api requests for this subscription in the given time + window. + + :param location: The name of Azure region. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.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. + + :param location: The name of Azure region. Required. + :type location: str + :param parameters: The request body. Is either a ThrottledRequestsInput type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.compute.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.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", "2024-11-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, 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, + 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("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, 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.LogAnalyticsOperationResult].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 + ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_operations.py new file mode 100644 index 000000000000..f9a41590d4b7 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_operations.py @@ -0,0 +1,136 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/operations") + + # 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) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: + """List the operations for the provider. + + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.OperationListResult] = 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_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(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 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/v2025_01_02/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_patch.py similarity index 100% rename from sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/operations/_patch.py rename to sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_patch.py diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_proximity_placement_groups_operations.py new file mode 100644 index 000000000000..76844a1fdddd --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_proximity_placement_groups_operations.py @@ -0,0 +1,784 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups" + ) + path_format_arguments = { + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups", + ) + 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 + ), + } + + _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_get_request( + resource_group_name: str, + proximity_placement_group_name: str, + subscription_id: str, + *, + include_colocation_status: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", + ) + 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 + ), + "proximityPlacementGroupName": _SERIALIZER.url( + "proximity_placement_group_name", proximity_placement_group_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if include_colocation_status is not None: + _params["includeColocationStatus"] = _SERIALIZER.query( + "include_colocation_status", include_colocation_status, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", + ) + 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 + ), + "proximityPlacementGroupName": _SERIALIZER.url( + "proximity_placement_group_name", proximity_placement_group_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # 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_update_request( + resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", + ) + 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 + ), + "proximityPlacementGroupName": _SERIALIZER.url( + "proximity_placement_group_name", proximity_placement_group_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # 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_delete_request( + resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", + ) + 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 + ), + "proximityPlacementGroupName": _SERIALIZER.url( + "proximity_placement_group_name", proximity_placement_group_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ProximityPlacementGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.ProximityPlacementGroup"]: + """Lists all proximity placement groups in a subscription. + + :return: An iterator like instance of either ProximityPlacementGroup or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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 + ) -> ItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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 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 + :param include_colocation_status: includeColocationStatus=true enables fetching the colocation + status of all the resources in the proximity placement group. Default value is None. + :type include_colocation_status: str + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + proximity_placement_group_name=proximity_placement_group_name, + subscription_id=self._config.subscription_id, + include_colocation_status=include_colocation_status, + api_version=api_version, + headers=_headers, + params=_params, + ) + _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("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.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.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.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + 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 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.models.ProximityPlacementGroup or IO[bytes] + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProximityPlacementGroup") + + _request = build_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, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("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.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.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.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + 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 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.models.ProximityPlacementGroupUpdate or IO[bytes] + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProximityPlacementGroupUpdate") + + _request = build_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, + ) + _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("ProximityPlacementGroup", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any + ) -> None: + """Delete a proximity placement group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param proximity_placement_group_name: The name of the proximity placement group. Required. + :type proximity_placement_group_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_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, + 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_resource_skus_operations.py similarity index 78% rename from sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/_operations.py rename to sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_resource_skus_operations.py index 67f0d90f3544..47d4a9f18c4b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_resource_skus_operations.py @@ -7,7 +7,6 @@ # -------------------------------------------------------------------------- from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar -import urllib.parse from azure.core import PipelineClient from azure.core.exceptions import ( @@ -36,19 +35,23 @@ _SERIALIZER.client_side_validation = False -def build_resource_skus_list_request( - subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +def build_list_request( + subscription_id: str, + *, + filter: Optional[str] = None, + include_extended_locations: 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", "2019-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/skus") 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 @@ -57,6 +60,10 @@ def build_resource_skus_list_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if include_extended_locations is not None: + _params["includeExtendedLocations"] = _SERIALIZER.query( + "include_extended_locations", include_extended_locations, "str" + ) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -70,7 +77,7 @@ class ResourceSkusOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_04_01.ComputeManagementClient`'s + :class:`~azure.mgmt.compute.ComputeManagementClient`'s :attr:`resource_skus` attribute. """ @@ -82,23 +89,27 @@ def __init__(self, *args, **kwargs) -> None: self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = 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, *, filter: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.ResourceSku"]: + def list( + self, filter: Optional[str] = None, include_extended_locations: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.ResourceSku"]: """Gets the list of Microsoft.Compute SKUs available for your Subscription. - :keyword filter: The filter to apply on the operation. Only **location** filter is supported + :param filter: The filter to apply on the operation. Only **location** filter is supported currently. Default value is None. - :paramtype filter: str + :type filter: str + :param include_extended_locations: To Include Extended Locations information or not in the + response. Default value is None. + :type include_extended_locations: str :return: An iterator like instance of either ResourceSku or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_04_01.models.ResourceSku] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.models.ResourceSku] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) cls: ClsType[_models.ResourceSkusResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -112,9 +123,10 @@ def list(self, *, filter: Optional[str] = None, **kwargs: Any) -> ItemPaged["_mo def prepare_request(next_link=None): if not next_link: - _request = build_resource_skus_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, + include_extended_locations=include_extended_locations, api_version=api_version, headers=_headers, params=_params, @@ -122,18 +134,7 @@ def prepare_request(next_link=None): _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 = HttpRequest("GET", next_link) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -156,7 +157,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/operations/_restore_point_collections_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_restore_point_collections_operations.py new file mode 100644 index 000000000000..78a9bb041ca6 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_restore_point_collections_operations.py @@ -0,0 +1,853 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_all_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/restorePointCollections" + ) + path_format_arguments = { + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections", + ) + 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 + ), + } + + _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_get_request( + resource_group_name: str, + restore_point_collection_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.RestorePointCollectionExpandOptions]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}", + ) + 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 + ), + "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") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + 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-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}", + ) + 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 + ), + "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") + + # 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_update_request( + 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-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}", + ) + 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 + ), + "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") + + # 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_delete_request( + 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-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class RestorePointCollectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`restore_point_collections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_all(self, **kwargs: Any) -> ItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.RestorePointCollection"]: + """Gets the list of restore point collections 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 RestorePointCollection or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RestorePointCollectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_group_name: str, + restore_point_collection_name: str, + expand: Optional[Union[str, _models.RestorePointCollectionExpandOptions]] = None, + **kwargs: Any + ) -> _models.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 + :param 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. + :type expand: str or ~azure.mgmt.compute.models.RestorePointCollectionExpandOptions + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + restore_point_collection_name: str, + parameters: _models.RestorePointCollection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to create or update the restore point collection. Please refer to + https://aka.ms/RestorePoints for more details. When updating a restore point collection, only + tags may be modified. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Create or Update restore point collection + operation. Required. + :type parameters: ~azure.mgmt.compute.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.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + restore_point_collection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to create or update the restore point collection. Please refer to + https://aka.ms/RestorePoints for more details. When updating a restore point collection, only + tags may be modified. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Create or Update restore point collection + operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.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]], + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to create or update the restore point collection. Please refer to + https://aka.ms/RestorePoints for more details. When updating a restore point collection, only + tags may be modified. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Create or Update restore point collection + operation. Is either a RestorePointCollection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.models.RestorePointCollection or IO[bytes] + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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, "RestorePointCollection") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RestorePointCollection", 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, + restore_point_collection_name: str, + parameters: _models.RestorePointCollectionUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to update the restore point collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Update restore point collection operation. + Required. + :type parameters: ~azure.mgmt.compute.models.RestorePointCollectionUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + restore_point_collection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to update the restore point collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Update restore point collection operation. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + restore_point_collection_name: str, + parameters: Union[_models.RestorePointCollectionUpdate, IO[bytes]], + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to update the restore point collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Update restore point collection operation. Is + either a RestorePointCollectionUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.models.RestorePointCollectionUpdate or IO[bytes] + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RestorePointCollectionUpdate") + + _request = build_update_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) + + 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 + ) -> 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, restore_point_collection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """The operation to delete the restore point collection. This operation will also delete all the + contained restore points. + + :param resource_group_name: The name of the resource group. 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_restore_points_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_restore_points_operations.py new file mode 100644 index 000000000000..1a6567d52260 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_restore_points_operations.py @@ -0,0 +1,590 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + restore_point_collection_name: str, + restore_point_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.RestorePointExpandOptions]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}", + ) + 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 + ), + "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 + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_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-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}", + ) + 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 + ), + "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") + + # 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_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class RestorePointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`restore_points` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + restore_point_collection_name: str, + restore_point_name: str, + expand: Optional[Union[str, _models.RestorePointExpandOptions]] = None, + **kwargs: Any + ) -> _models.RestorePoint: + """The operation to get the restore point. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param restore_point_name: The name of the restore point. Required. + :type restore_point_name: str + :param 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. + :type expand: str or ~azure.mgmt.compute.models.RestorePointExpandOptions + :return: RestorePoint or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + restore_point_name=restore_point_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RestorePoint", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + restore_point_collection_name: str, + restore_point_name: str, + parameters: Union[_models.RestorePoint, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RestorePoint") + + _request = build_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) + + _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 [201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = 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( + self, + resource_group_name: str, + restore_point_collection_name: str, + restore_point_name: str, + parameters: _models.RestorePoint, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RestorePoint]: + """The operation to create the restore point. Updating properties of an existing restore point is + not allowed. + + :param resource_group_name: The name of the resource group. 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.models.RestorePoint + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either RestorePoint or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.RestorePoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + restore_point_collection_name: str, + restore_point_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RestorePoint]: + """The operation to create the restore point. Updating properties of an existing restore point is + not allowed. + + :param resource_group_name: The name of the resource group. 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: IO[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.models.RestorePoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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.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.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", "2024-11-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, + 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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) + + _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, 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. 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 + :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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + restore_point_name=restore_point_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_shared_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_shared_galleries_operations.py new file mode 100644 index 000000000000..979bfaf515b8 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_shared_galleries_operations.py @@ -0,0 +1,247 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_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")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "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) + + +def build_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")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), + "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_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) + + +class SharedGalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`shared_galleries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, location: str, shared_to: Optional[Union[str, _models.SharedToValues]] = None, **kwargs: Any + ) -> ItemPaged["_models.SharedGallery"]: + """List shared galleries by subscription id or tenant id. + + :param location: Resource location. Required. + :type location: str + :param shared_to: The query parameter to decide what shared galleries to fetch when doing + listing operations. "tenant" Default value is None. + :type shared_to: str or ~azure.mgmt.compute.models.SharedToValues + :return: An iterator like instance of either SharedGallery or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "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_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: + _request = HttpRequest("GET", next_link) + _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.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", "2023-07-03")) + cls: ClsType[_models.SharedGallery] = kwargs.pop("cls", None) + + _request = build_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_shared_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_shared_gallery_image_versions_operations.py new file mode 100644 index 000000000000..2bbc3cf2efe2 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_shared_gallery_image_versions_operations.py @@ -0,0 +1,290 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + 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 {}) + + 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}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}/versions", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), + "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_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) + + +def build_get_request( + 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")) + 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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), + "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 + + # 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) + + +class SharedGalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`shared_gallery_image_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + ) -> ItemPaged["_models.SharedGalleryImageVersion"]: + """List shared gallery image versions 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 + :param shared_to: The query parameter to decide what shared galleries to fetch when doing + listing operations. "tenant" Default value is None. + :type shared_to: str or ~azure.mgmt.compute.models.SharedToValues + :return: An iterator like instance of either SharedGalleryImageVersion or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + 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, 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, + gallery_image_version_name: str, + **kwargs: Any + ) -> _models.SharedGalleryImageVersion: + """Get a shared gallery image version 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 + :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.models.SharedGalleryImageVersion + :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", "2023-07-03")) + cls: ClsType[_models.SharedGalleryImageVersion] = kwargs.pop("cls", None) + + _request = build_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, + 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("SharedGalleryImageVersion", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_shared_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_shared_gallery_images_operations.py new file mode 100644 index 000000000000..eb6b5dd0fcd0 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_shared_gallery_images_operations.py @@ -0,0 +1,265 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + location: str, + gallery_unique_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 {}) + + 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}/sharedGalleries/{galleryUniqueName}/images", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), + "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_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) + + +def build_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 {}) + + 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}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), + "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_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) + + +class SharedGalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`shared_gallery_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + location: str, + gallery_unique_name: str, + shared_to: Optional[Union[str, _models.SharedToValues]] = None, + **kwargs: Any + ) -> ItemPaged["_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 + :param shared_to: The query parameter to decide what shared galleries to fetch when doing + listing operations. "tenant" Default value is None. + :type shared_to: str or ~azure.mgmt.compute.models.SharedToValues + :return: An iterator like instance of either SharedGalleryImage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "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_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: + _request = HttpRequest("GET", next_link) + _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.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", "2023-07-03")) + cls: ClsType[_models.SharedGalleryImage] = kwargs.pop("cls", None) + + _request = build_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_snapshots_operations.py new file mode 100644 index 000000000000..25a80cd93c7c --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_snapshots_operations.py @@ -0,0 +1,1259 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_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", "2023-10-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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_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_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", "2023-10-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}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_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_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", "2023-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_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_delete_request( + resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_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-10-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") + path_format_arguments = { + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_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", "2023-10-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}/beginGetAccess", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_revoke_access_request( + resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`snapshots` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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, + 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", "2023-10-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(snapshot, (IOBase, bytes)): + _content = snapshot + else: + _json = self._serialize.body(snapshot, "Snapshot") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + snapshot_name=snapshot_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _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_create_or_update( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: _models.Snapshot, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Snapshot]: + """Creates or updates a snapshot. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. + :type snapshot: ~azure.mgmt.compute.models.Snapshot + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Snapshot]: + """Creates or updates a snapshot. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. + :type snapshot: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.Snapshot]: + """Creates or updates a snapshot. + + :param resource_group_name: The name of the resource group. Required. + :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.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.models.Snapshot] + :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", "2023-10-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._create_or_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, **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 _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, + 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", "2023-10-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(snapshot, (IOBase, bytes)): + _content = snapshot + else: + _json = self._serialize.body(snapshot, "SnapshotUpdate") + + _request = build_update_request( + resource_group_name=resource_group_name, + snapshot_name=snapshot_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _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, + snapshot_name: str, + snapshot: _models.SnapshotUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Snapshot]: + """Updates (patches) a snapshot. + + :param resource_group_name: The name of the resource group. 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.models.SnapshotUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Snapshot]: + """Updates (patches) a snapshot. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. + Required. + :type snapshot: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: Union[_models.SnapshotUpdate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Snapshot]: + """Updates (patches) a snapshot. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. Is + either a SnapshotUpdate type or a IO[bytes] type. Required. + :type snapshot: ~azure.mgmt.compute.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.models.Snapshot] + :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", "2023-10-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, **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 + ) + + @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.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", "2023-10-02")) + cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) + + _request = build_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]: + 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", "2023-10-02")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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) + + 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, snapshot_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes 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: 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", "2023-10-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, + snapshot_name=snapshot_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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Snapshot"]: + """Lists snapshots 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 Snapshot or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2023-10-02")) + cls: ClsType[_models.SnapshotList] = 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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + 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) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.Snapshot"]: + """Lists snapshots under a subscription. + + :return: An iterator like instance of either Snapshot or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2023-10-02")) + cls: ClsType[_models.SnapshotList] = 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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + 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) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _grant_access_initial( + self, + resource_group_name: str, + snapshot_name: str, + grant_access_data: Union[_models.GrantAccessData, 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", "2023-10-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(grant_access_data, (IOBase, bytes)): + _content = grant_access_data + else: + _json = self._serialize.body(grant_access_data, "GrantAccessData") + + _request = build_grant_access_request( + resource_group_name=resource_group_name, + snapshot_name=snapshot_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _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_grant_access( + self, + resource_group_name: str, + snapshot_name: str, + grant_access_data: _models.GrantAccessData, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AccessUri]: + """Grants access to a snapshot. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param grant_access_data: Access data object supplied in the body of the get snapshot access + operation. Required. + :type grant_access_data: ~azure.mgmt.compute.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 AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.AccessUri] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_grant_access( + self, + resource_group_name: str, + snapshot_name: str, + grant_access_data: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AccessUri]: + """Grants access to a snapshot. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param 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 AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.AccessUri] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_grant_access( + self, + resource_group_name: str, + snapshot_name: str, + grant_access_data: Union[_models.GrantAccessData, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AccessUri]: + """Grants access to a snapshot. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param 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.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.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", "2023-10-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, + snapshot_name=snapshot_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, 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", "2023-10-02")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_revoke_access_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]: + 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_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. + :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", "2023-10-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._revoke_access_initial( + resource_group_name=resource_group_name, + snapshot_name=snapshot_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_ssh_public_keys_operations.py new file mode 100644 index 000000000000..b7b1bef8eab9 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_ssh_public_keys_operations.py @@ -0,0 +1,928 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/sshPublicKeys") + path_format_arguments = { + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys", + ) + 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 + ), + } + + _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_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", + ) + 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 + ), + "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_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_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-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", + ) + 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 + ), + "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_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_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-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", + ) + 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 + ), + "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_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_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-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", + ) + 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 + ), + "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_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) + + +def build_generate_key_pair_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-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}/generateKeyPair", + ) + 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 + ), + "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class SshPublicKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> ItemPaged["_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. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either SshPublicKeyResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def 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. 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.models.SshPublicKeyResource + :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", "2024-11-01")) + cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) + + _request = build_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) + + _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("SshPublicKeyResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create( + self, + resource_group_name: str, + ssh_public_key_name: str, + parameters: _models.SshPublicKeyResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SshPublicKeyResource: + """Creates a new SSH public key resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to create the SSH public key. Required. + :type parameters: ~azure.mgmt.compute.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.models.SshPublicKeyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + ssh_public_key_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SshPublicKeyResource: + """Creates a new SSH public key resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to create the SSH public key. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.SshPublicKeyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + ssh_public_key_name: str, + parameters: Union[_models.SshPublicKeyResource, IO[bytes]], + **kwargs: Any + ) -> _models.SshPublicKeyResource: + """Creates a new SSH public key resource. + + :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.models.SshPublicKeyResource or IO[bytes] + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.SshPublicKeyResource + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SshPublicKeyResource") + + _request = build_create_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, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SshPublicKeyResource", 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, + ssh_public_key_name: str, + parameters: _models.SshPublicKeyUpdateResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SshPublicKeyResource: + """Updates a new SSH public key resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to update the SSH public key. Required. + :type parameters: ~azure.mgmt.compute.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.models.SshPublicKeyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.SshPublicKeyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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. Is either a + SshPublicKeyUpdateResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.models.SshPublicKeyUpdateResource or IO[bytes] + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.SshPublicKeyResource + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SshPublicKeyUpdateResource") + + _request = build_update_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, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SshPublicKeyResource", 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, ssh_public_key_name: str, **kwargs: Any + ) -> None: + """Delete an SSH public key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_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) + + _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 + + @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. + + :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.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.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.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.models.SshGenerateKeyPairInputParameters or IO[bytes] + :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.SshPublicKeyGenerateKeyPairResult + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SshPublicKeyGenerateKeyPairResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "SshGenerateKeyPairInputParameters") + else: + _json = None + + _request = build_generate_key_pair_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, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SshPublicKeyGenerateKeyPairResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_usage_operations.py similarity index 74% rename from sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/_operations.py rename to sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_usage_operations.py index 0073102bbce1..133be70a57c4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_usage_operations.py @@ -7,7 +7,6 @@ # -------------------------------------------------------------------------- from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar -import urllib.parse from azure.core import PipelineClient from azure.core.exceptions import ( @@ -36,17 +35,20 @@ _SERIALIZER.client_side_validation = False -def build_resource_skus_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/skus") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages" + ) path_format_arguments = { - "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 @@ -60,14 +62,14 @@ def build_resource_skus_list_request(subscription_id: str, **kwargs: Any) -> Htt return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class ResourceSkusOperations: +class UsageOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_09_01.ComputeManagementClient`'s - :attr:`resource_skus` attribute. + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`usage` attribute. """ models = _models @@ -78,21 +80,23 @@ def __init__(self, *args, **kwargs) -> None: self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = 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) -> ItemPaged["_models.ResourceSku"]: - """Gets the list of Microsoft.Compute SKUs available for your Subscription. - - :return: An iterator like instance of either ResourceSku or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_09_01.models.ResourceSku] + def list(self, location: str, **kwargs: Any) -> ItemPaged["_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.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 "2017-09-01")) - cls: ClsType[_models.ResourceSkusResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.ListUsagesResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -105,7 +109,8 @@ def list(self, **kwargs: Any) -> ItemPaged["_models.ResourceSku"]: def prepare_request(next_link=None): if not next_link: - _request = build_resource_skus_list_request( + _request = build_list_request( + location=location, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -114,24 +119,13 @@ def prepare_request(next_link=None): _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 = HttpRequest("GET", next_link) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): - deserialized = self._deserialize("ResourceSkusResult", pipeline_response) + deserialized = self._deserialize("ListUsagesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_extension_images_operations.py new file mode 100644 index 000000000000..1ef5b66b8920 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_extension_images_operations.py @@ -0,0 +1,356 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, List, Optional, TypeVar + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_types_request(location: str, publisher_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types", + ) + path_format_arguments = { + "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 + + # 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_list_versions_request( + location: str, + publisher_name: str, + type: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + "type": _SERIALIZER.url("type", type, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if orderby is not None: + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + location: str, publisher_name: str, type: str, version: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}", + ) + path_format_arguments = { + "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 + _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) + + +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_types( + self, location: str, publisher_name: str, **kwargs: Any + ) -> List[_models.VirtualMachineExtensionImage]: + """Gets a list of virtual machine extension image types. + + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: Required. + :type publisher_name: str + :return: list of VirtualMachineExtensionImage or the result of cls(response) + :rtype: list[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) + + _request = build_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) + + _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 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 + :param filter: The filter to apply on the operation. Default value is None. + :type filter: str + :param top: Default value is None. + :type top: int + :param orderby: Default value is None. + :type orderby: str + :return: list of VirtualMachineExtensionImage or the result of cls(response) + :rtype: list[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) + + _request = build_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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineExtensionImage] = kwargs.pop("cls", None) + + _request = build_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_extensions_operations.py new file mode 100644 index 000000000000..8e7e9030bae3 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_extensions_operations.py @@ -0,0 +1,920 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, vm_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions", + ) + 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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + vm_name: str, + vm_extension_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", + ) + 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") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, vm_name: str, vm_extension_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + 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}", + ) + 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 + 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_update_request( + resource_group_name: str, vm_name: str, vm_extension_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + 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}", + ) + 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 + 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_delete_request( + resource_group_name: str, vm_name: str, vm_extension_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", + ) + 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 VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. + + :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 expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :return: VirtualMachineExtensionsListResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.VirtualMachineExtensionsListResult + :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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + vm_name=vm_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VirtualMachineExtensionsListResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # 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. 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 vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :return: VirtualMachineExtension or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) + + _request = build_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) + + 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_name: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineExtension, 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters + else: + _json = self._serialize.body(extension_parameters, "VirtualMachineExtension") + + _request = build_create_or_update_request( + resource_group_name=resource_group_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, + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + vm_extension_name: str, + extension_parameters: _models.VirtualMachineExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineExtension]: + """The operation to create or update 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_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.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 VirtualMachineExtension or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachineExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + vm_extension_name: str, + extension_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineExtension]: + """The operation to create or update 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_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. + 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.models.VirtualMachineExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineExtension]: + """The operation to create or update 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_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.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.models.VirtualMachineExtension] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, + 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("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, 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( + 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 + ) + + def _update_initial( + self, + resource_group_name: str, + vm_name: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters + else: + _json = self._serialize.body(extension_parameters, "VirtualMachineExtensionUpdate") + + _request = build_update_request( + resource_group_name=resource_group_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, + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + vm_name: str, + vm_extension_name: str, + extension_parameters: _models.VirtualMachineExtensionUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineExtension]: + """The operation to update the extension. + + :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 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.models.VirtualMachineExtensionUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachineExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + 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 + ) -> LROPoller[_models.VirtualMachineExtension]: + """The operation to update 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_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. + 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.models.VirtualMachineExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + 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.VirtualMachineExtension]: + """The operation to update 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_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.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.models.VirtualMachineExtension] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, + 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("VirtualMachineExtension", 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.VirtualMachineExtension].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 + ) + + def _delete_initial( + self, resource_group_name: str, vm_name: str, vm_extension_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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + vm_name=vm_name, + 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) + + _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, vm_name: str, vm_extension_name: str, **kwargs: Any + ) -> LROPoller[None]: + """The operation to delete 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_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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + 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, + 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) + + 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_images_edge_zone_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_images_edge_zone_operations.py new file mode 100644 index 000000000000..59d0d4c2cfc1 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_images_edge_zone_operations.py @@ -0,0 +1,574 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, List, Optional, TypeVar + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_publishers_request(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-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers", + ) + path_format_arguments = { + "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 + _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_list_offers_request( + 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-11-01")) + 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", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _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_list_skus_request( + 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-11-01")) + 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", + ) + path_format_arguments = { + "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 + + # 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_list_request( + 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-11-01")) + 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", + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + "offer": _SERIALIZER.url("offer", offer, "str"), + "skus": _SERIALIZER.url("skus", skus, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if orderby is not None: + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + 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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}", + ) + path_format_arguments = { + "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 + + # 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) + + +class VirtualMachineImagesEdgeZoneOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`virtual_machine_images_edge_zone` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _request = build_list_publishers_request( + location=location, + edge_zone=edge_zone, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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, edge_zone: str, publisher_name: str, **kwargs: Any + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of virtual machine image offers for the specified location, edge zone and + publisher. + + :param location: The name of Azure region. Required. + :type location: str + :param edge_zone: The name of the edge zone. Required. + :type edge_zone: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _request = build_list_offers_request( + location=location, + edge_zone=edge_zone, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_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.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _request = build_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) + + _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( + 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. + + :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 expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :param top: An integer value specifying the number of images to return that matches supplied + values. Default value is None. + :type top: int + :param orderby: Specifies the order of the results returned. Formatted as an OData query. + Default value is None. + :type orderby: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _request = build_list_request( + location=location, + edge_zone=edge_zone, + publisher_name=publisher_name, + offer=offer, + skus=skus, + subscription_id=self._config.subscription_id, + expand=expand, + top=top, + orderby=orderby, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get( + self, location: str, 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 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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) + + _request = build_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_images_operations.py new file mode 100644 index 000000000000..1807a92c8a54 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_images_operations.py @@ -0,0 +1,745 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, List, Optional, TypeVar + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_edge_zone_request(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-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/vmimages", + ) + path_format_arguments = { + "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 + _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_list_publishers_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers" + ) + path_format_arguments = { + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_offers_request(location: str, publisher_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers", + ) + path_format_arguments = { + "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 + + # 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_list_skus_request( + location: str, publisher_name: str, offer: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus", + ) + path_format_arguments = { + "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 + + # 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_list_request( + 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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", + ) + path_format_arguments = { + "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="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}", + ) + path_format_arguments = { + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + "offer": _SERIALIZER.url("offer", offer, "str"), + "skus": _SERIALIZER.url("skus", skus, "str"), + "version": _SERIALIZER.url("version", version, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _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_list_with_properties_request( + location: str, + publisher_name: str, + offer: str, + skus: str, + subscription_id: str, + *, + expand: str, + 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-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", + ) + path_format_arguments = { + "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") + _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. + + :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.models.VmImagesInEdgeZoneListResult + :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", "2024-11-01")) + cls: ClsType[_models.VmImagesInEdgeZoneListResult] = kwargs.pop("cls", None) + + _request = build_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) + + _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("VmImagesInEdgeZoneListResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_publishers(self, location: str, **kwargs: Any) -> List[_models.VirtualMachineImageResource]: + """Gets a list of virtual machine image publishers for the specified Azure location. + + :param location: The name of Azure region. Required. + :type location: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _request = build_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 = 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. + + :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.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _request = build_list_offers_request( + location=location, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @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. + + :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.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _request = build_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) + + _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( + self, + location: str, + publisher_name: str, + offer: str, + skus: str, + expand: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of all virtual machine image versions for the specified location, publisher, offer, + and SKU. + + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :param skus: A valid image SKU. Required. + :type skus: str + :param expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :param top: Default value is None. + :type top: int + :param orderby: Default value is None. + :type orderby: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _request = build_list_request( + location=location, + publisher_name=publisher_name, + offer=offer, + skus=skus, + subscription_id=self._config.subscription_id, + expand=expand, + top=top, + orderby=orderby, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get( + self, location: str, publisher_name: str, offer: str, skus: str, version: str, **kwargs: Any + ) -> _models.VirtualMachineImage: + """Gets a virtual machine image. + + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :param skus: A valid image SKU. Required. + :type skus: str + :param version: A valid image SKU version. Required. + :type version: str + :return: VirtualMachineImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) + + _request = build_get_request( + location=location, + publisher_name=publisher_name, + offer=offer, + skus=skus, + version=version, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VirtualMachineImage", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_with_properties( + self, + location: str, + publisher_name: str, + offer: str, + skus: str, + expand: str, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> List[_models.VirtualMachineImage]: + """list_with_properties. + + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :param skus: A valid image SKU. Required. + :type skus: str + :param expand: The expand expression to apply on the operation. Required. + :type expand: str + :param top: Default value is None. + :type top: int + :param orderby: Default value is None. + :type orderby: str + :return: list of VirtualMachineImage or the result of cls(response) + :rtype: list[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImage]] = kwargs.pop("cls", None) + + _request = build_list_with_properties_request( + location=location, + publisher_name=publisher_name, + offer=offer, + skus=skus, + subscription_id=self._config.subscription_id, + expand=expand, + top=top, + orderby=orderby, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_run_commands_operations.py new file mode 100644 index 000000000000..829118f1e292 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_run_commands_operations.py @@ -0,0 +1,1108 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json, text/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands" + ) + path_format_arguments = { + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(location: str, command_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json, text/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}", + ) + path_format_arguments = { + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "commandId": _SERIALIZER.url("command_id", command_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _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_list_by_virtual_machine_request( + resource_group_name: str, vm_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands", + ) + 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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_by_virtual_machine_request( + 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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", + ) + 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"), + "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="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, vm_name: str, run_command_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", + ) + 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"), + "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") + + # 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_update_request( + resource_group_name: str, vm_name: str, run_command_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", + ) + 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"), + "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") + + # 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_delete_request( + resource_group_name: str, vm_name: str, run_command_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", + ) + 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"), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class VirtualMachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, location: str, **kwargs: Any) -> ItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RunCommandListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + 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, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: + """Gets specific run command for a subscription in a location. + + :param location: The name of Azure region. Required. + :type location: str + :param command_id: The command id. Required. + :type command_id: str + :return: RunCommandDocument or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.RunCommandDocument + :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", "2024-11-01")) + cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) + + _request = build_get_request( + location=location, + command_id=command_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("RunCommandDocument", 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 + ) -> ItemPaged["_models.VirtualMachineRunCommand"]: + """The operation to get all run commands 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 VirtualMachine. Required. + :type vm_name: str + :param expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :return: An iterator like instance of either VirtualMachineRunCommand or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineRunCommandsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def 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 + :param expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :return: VirtualMachineRunCommand or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + + _request = build_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) + + _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 + + 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, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_command, (IOBase, bytes)): + _content = run_command + else: + _json = self._serialize.body(run_command, "VirtualMachineRunCommand") + + _request = build_create_or_update_request( + resource_group_name=resource_group_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, + ) + _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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. 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: ~azure.mgmt.compute.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.models.VirtualMachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + run_command_name: str, + run_command: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineRunCommand]: + """The operation to create or update the run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. + Required. + :type run_command: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.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.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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._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): + deserialized = self._deserialize("VirtualMachineRunCommand", 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.VirtualMachineRunCommand].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.VirtualMachineRunCommand]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + vm_name: str, + run_command_name: str, + run_command: Union[_models.VirtualMachineRunCommandUpdate, 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_command, (IOBase, bytes)): + _content = run_command + else: + _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") + + _request = build_update_request( + resource_group_name=resource_group_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, + ) + _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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + vm_name: 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. + + :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: ~azure.mgmt.compute.models.VirtualMachineRunCommandUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + vm_name: str, + run_command_name: str, + run_command: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineRunCommand]: + """The operation to update the run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. + Required. + :type run_command: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + vm_name: str, + run_command_name: str, + run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineRunCommand]: + """The operation to update the run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. Is + either a VirtualMachineRunCommandUpdate type or a IO[bytes] type. Required. + :type run_command: ~azure.mgmt.compute.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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + run_command_name=run_command_name, + run_command=run_command, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + 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, 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.VirtualMachineRunCommand].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.VirtualMachineRunCommand]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, vm_name: str, run_command_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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + vm_name=vm_name, + run_command_name=run_command_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, 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. 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 + :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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + 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) + + 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_scale_set_extensions_operations.py new file mode 100644 index 000000000000..3e45a41c69ef --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_scale_set_extensions_operations.py @@ -0,0 +1,937 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + 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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", + ) + 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 + ), + "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") + + # 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_update_request( + resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", + ) + 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 + ), + "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") + + # 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_delete_request( + resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +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.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> ItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetExtensionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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 + :param expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :return: VirtualMachineScaleSetExtension or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) + + _request = build_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, + 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, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters + else: + _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtension") + + _request = build_create_or_update_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, + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, 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, + 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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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 + :param extension_parameters: Parameters supplied to the Create VM scale set Extension + operation. Required. + :type extension_parameters: ~azure.mgmt.compute.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.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. The name is case insensitive. + Required. + :type 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 + :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.models.VirtualMachineScaleSetExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. The name is case insensitive. + Required. + :type 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 + :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.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.models.VirtualMachineScaleSetExtension] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, + extension_parameters=extension_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, 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.VirtualMachineScaleSetExtension].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.VirtualMachineScaleSetExtension]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters + else: + _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtensionUpdate") + + _request = build_update_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, + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: + """The operation to update an extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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 + :param extension_parameters: Parameters supplied to the Update VM scale set Extension + operation. Required. + :type extension_parameters: ~azure.mgmt.compute.models.VirtualMachineScaleSetExtensionUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachineScaleSetExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: + """The operation to update an extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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 + :param extension_parameters: Parameters supplied to the Update VM scale set Extension + operation. Required. + :type extension_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachineScaleSetExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: + """The operation to update an extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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 + :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.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.models.VirtualMachineScaleSetExtension] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, + extension_parameters=extension_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, 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.VirtualMachineScaleSetExtension].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.VirtualMachineScaleSetExtension]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_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, + 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, 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. The name is case insensitive. + Required. + :type 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 + :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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py new file mode 100644 index 000000000000..fdf9cae2382b --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -0,0 +1,584 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Iterator, Optional, TypeVar, Union, cast + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_start_extension_upgrade_request( + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_start_os_upgrade_request( + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_cancel_request( + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_latest_request( + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +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.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + 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, + 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_start_extension_upgrade_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) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._start_extension_upgrade_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + 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 _start_os_upgrade_initial( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_start_os_upgrade_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) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_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. The name is case insensitive. + Required. + :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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._start_os_upgrade_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _cancel_initial(self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_cancel_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) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_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. The name is case insensitive. + Required. + :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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._cancel_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get_latest( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> _models.RollingUpgradeStatusInfo: + """Gets the status of the latest virtual machine scale set rolling upgrade. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: RollingUpgradeStatusInfo or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.RollingUpgradeStatusInfo] = kwargs.pop("cls", None) + + _request = build_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 + ) + + response = pipeline_response.http_response + + if response.status_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_scale_set_vm_extensions_operations.py new file mode 100644 index 000000000000..b488c5c00f07 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -0,0 +1,997 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + 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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions", + ) + 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 + ), + "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) + + +def build_get_request( + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", + ) + 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 + ), + "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") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", + ) + 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 + ), + "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") + + # 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_update_request( + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", + ) + 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 + ), + "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") + + # 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_delete_request( + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +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.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: + """The operation to get all extensions of an instance in Virtual Machine Scaleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :return: VirtualMachineScaleSetVMExtensionsListResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "VirtualMachineScaleSetVMExtensionsListResult", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + 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. The name is case insensitive. + Required. + :type 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 expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :return: VirtualMachineScaleSetVMExtension or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) + + _request = build_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, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters + else: + _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetVMExtension") + + _request = build_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) + + _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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, 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.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.models.VirtualMachineScaleSetVMExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: + """The operation to create or update the VMSS VM extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension + operation. Required. + :type extension_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachineScaleSetVMExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: + """The operation to create or update the VMSS VM extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.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.models.VirtualMachineScaleSetVMExtension] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_extension_name=vm_extension_name, + extension_parameters=extension_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, 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 _update_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetVMExtensionUpdate, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters + else: + _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetVMExtensionUpdate") + + _request = build_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) + + _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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.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.models.VirtualMachineScaleSetVMExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.models.VirtualMachineScaleSetVMExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.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.models.VirtualMachineScaleSetVMExtension] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_extension_name=vm_extension_name, + extension_parameters=extension_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, 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.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 _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, + 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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) + + _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, 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 resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + 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) + + 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_scale_set_vm_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_scale_set_vm_run_commands_operations.py new file mode 100644 index 000000000000..f375317288b8 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_scale_set_vm_run_commands_operations.py @@ -0,0 +1,1001 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + 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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands", + ) + 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 + ), + "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) + + +def build_get_request( + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + run_command_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + run_command_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", + ) + 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 + ), + "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") + + # 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_update_request( + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + run_command_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", + ) + 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 + ), + "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") + + # 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_delete_request( + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + run_command_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + 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}", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +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.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_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. 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 expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :return: An iterator like instance of either VirtualMachineRunCommand or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineRunCommandsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def 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. 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 + :param expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :return: VirtualMachineRunCommand or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + + _request = build_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 + + 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]], + **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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_command, (IOBase, bytes)): + _content = run_command + else: + _json = self._serialize.body(run_command, "VirtualMachineRunCommand") + + _request = build_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, + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, 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, + 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 VMSS VM 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_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: ~azure.mgmt.compute.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.models.VirtualMachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + 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], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineRunCommand]: + """The operation to create or update the VMSS VM 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_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. + 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.models.VirtualMachineRunCommand] + :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, + run_command_name: str, + run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineRunCommand]: + """The operation to create or update the VMSS VM 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_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. + :type run_command: ~azure.mgmt.compute.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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._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, + 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("VirtualMachineRunCommand", 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.VirtualMachineRunCommand].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.VirtualMachineRunCommand]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _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]], + **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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_command, (IOBase, bytes)): + _content = run_command + else: + _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") + + _request = build_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, + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_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 VMSS VM 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_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: Resource create parameters. Required. + :type run_command: ~azure.mgmt.compute.models.VirtualMachineRunCommandUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_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 VMSS VM 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_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: Resource create parameters. 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.models.VirtualMachineRunCommand] + :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]], + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineRunCommand]: + """The operation to update the VMSS VM 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_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: Resource create parameters. Is either a VirtualMachineRunCommandUpdate type + or a IO[bytes] type. Required. + :type run_command: ~azure.mgmt.compute.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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + vm_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, + 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("VirtualMachineRunCommand", 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.VirtualMachineRunCommand].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.VirtualMachineRunCommand]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + 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, + 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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, + 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, vm_scale_set_name: str, instance_id: str, run_command_name: str, **kwargs: Any + ) -> LROPoller[None]: + """The operation to delete the VMSS VM 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_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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + 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, + 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) + + 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_scale_set_vms_operations.py new file mode 100644 index 000000000000..320dd0f8b4b3 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_scale_set_vms_operations.py @@ -0,0 +1,3064 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, + virtual_machine_scale_set_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + select: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines", + ) + 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 + ), + "virtualMachineScaleSetName": _SERIALIZER.url( + "virtual_machine_scale_set_name", virtual_machine_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 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 + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + 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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}", + ) + 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 + ), + "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) + + +def build_update_request( + 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 +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}", + ) + 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 + ), + "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") + + # 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) + + +def build_delete_request( + 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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}", + ) + 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 + ), + "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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_approve_rolling_upgrade_request( + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/approveRollingUpgrade", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_attach_detach_data_disks_request( + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/attachDetachDataDisks", + ) + 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 + ), + "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") + + # 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_deallocate_request( + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/deallocate", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_instance_view_request( + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/instanceView", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_perform_maintenance_request( + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/performMaintenance", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_power_off_request( + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + subscription_id: str, + *, + skip_shutdown: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/powerOff", + ) + 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 + ), + "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 + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_redeploy_request( + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + 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", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_reimage_request( + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/reimage", + ) + 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 + ), + "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") + + # 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_reimage_all_request( + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/reimageall", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restart_request( + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/restart", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_retrieve_boot_diagnostics_data_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + subscription_id: str, + *, + sas_uri_expiration_time_in_minutes: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/retrieveBootDiagnosticsData", + ) + 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 + ), + "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 + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_run_command_request( + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommand", + ) + 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 + ), + "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") + + # 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_simulate_eviction_request( + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + 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", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_start_request( + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/start", + ) + 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 + ), + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class VirtualMachineScaleSetVMsOperations: # 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.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + ) -> ItemPaged["_models.VirtualMachineScaleSetVM"]: + """Gets a list of all virtual machines in a VM scale sets. + + :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 VirtualMachineScaleSet. Required. + :type virtual_machine_scale_set_name: str + :param 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. + :type filter: str + :param select: The list parameters. Allowed values are 'instanceView', 'instanceView/statuses'. + Default value is None. + :type select: str + :param expand: The expand expression to apply to the operation. Allowed values are + 'instanceView'. Default value is None. + :type expand: str + :return: An iterator like instance of either VirtualMachineScaleSetVM or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetVMListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetVMListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @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. The name is case insensitive. + Required. + :type 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 expand: The expand expression to apply on the operation. 'InstanceView' will retrieve + the instance view of the virtual machine. 'UserData' will retrieve the UserData of the virtual + machine. Known values are: "instanceView", "userData", and "resiliencyView". Default value is + None. + :type expand: str or ~azure.mgmt.compute.models.InstanceViewTypes + :return: VirtualMachineScaleSetVM or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetVM] = kwargs.pop("cls", None) + + _request = build_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 + + def _update_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualMachineScaleSetVM") + + _request = build_update_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + 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 + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: + """Updates a virtual machine of 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 Update Virtual Machine Scale Sets VM operation. + Required. + :type parameters: ~azure.mgmt.compute.models.VirtualMachineScaleSetVM + :param 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. + :type if_match: str + :param 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. + :type 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 VirtualMachineScaleSetVM or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachineScaleSetVM] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: + """Updates a virtual machine of a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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 Update Virtual Machine Scale Sets VM operation. + Required. + :type parameters: IO[bytes] + :param 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. + :type if_match: str + :param 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. + :type 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 VirtualMachineScaleSetVM or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachineScaleSetVM] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: + """Updates a virtual machine of 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 Update Virtual Machine Scale Sets VM operation. + Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.models.VirtualMachineScaleSetVM or IO[bytes] + :param 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. + :type if_match: str + :param 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. + :type 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.models.VirtualMachineScaleSetVM] + :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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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) + + 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 + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.VirtualMachineScaleSetVM].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.VirtualMachineScaleSetVM]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + force_deletion=force_deletion, + api_version=api_version, + headers=_headers, + params=_params, + ) + _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, + vm_scale_set_name: str, + instance_id: str, + force_deletion: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes 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 + :param force_deletion: Optional parameter to force delete a virtual machine from a VM scale + set. (Feature in Preview). Default value is None. + :type 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + 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, 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 _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, + 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_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. The name is case insensitive. + Required. + :type 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._approve_rolling_upgrade_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + 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 _attach_detach_data_disks_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.AttachDetachDataDisksRequest, 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AttachDetachDataDisksRequest") + + _request = build_attach_detach_data_disks_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 + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_attach_detach_data_disks( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + parameters: _models.AttachDetachDataDisksRequest, + *, + 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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.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.models.StorageProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_attach_detach_data_disks( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageProfile]: + """Attach and detach data disks to/from a virtual machine in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.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.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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageProfile] = kwargs.pop("cls", None) + polling: Union[bool, 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = 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_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. The name is case insensitive. + Required. + :type 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._deallocate_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get_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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetVMInstanceView] = kwargs.pop("cls", None) + + _request = build_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 + + def _perform_maintenance_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_perform_maintenance_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = 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_perform_maintenance( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> LROPoller[None]: + """Performs maintenance on a virtual machine in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._perform_maintenance_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _power_off_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + skip_shutdown: 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_power_off_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + skip_shutdown=skip_shutdown, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = 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_power_off( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + skip_shutdown: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached + and you are getting charged for the resources. Instead, use deallocate to release resources and + avoid charges. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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 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. + :type 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._power_off_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + skip_shutdown=skip_shutdown, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _redeploy_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_redeploy( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> LROPoller[None]: + """Shuts down the virtual machine in the virtual machine scale set, moves it to a new node, and + powers it back on. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._redeploy_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + 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 + ) -> 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(vm_scale_set_vm_reimage_input, (IOBase, bytes)): + _content = vm_scale_set_vm_reimage_input + else: + if vm_scale_set_vm_reimage_input is not None: + _json = self._serialize.body(vm_scale_set_vm_reimage_input, "VirtualMachineScaleSetVMReimageParameters") + else: + _json = None + + _request = build_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, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_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. The name is case insensitive. + Required. + :type 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.models.VirtualMachineScaleSetVMReimageParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_reimage( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_scale_set_vm_reimage_input: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. + Default value is None. + :type vm_scale_set_vm_reimage_input: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_reimage( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_scale_set_vm_reimage_input: Optional[ + Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] + ] = None, + **kwargs: Any + ) -> 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. The name is case insensitive. + Required. + :type 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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._reimage_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + 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, + 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_reimage_all_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = 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_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. The name is case insensitive. + Required. + :type 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._reimage_all_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _restart_initial( + self, resource_group_name: str, 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = 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_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. The name is case insensitive. + Required. + :type 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._restart_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def 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 + :param 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. + :type sas_uri_expiration_time_in_minutes: int + :return: RetrieveBootDiagnosticsDataResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) + + _request = build_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 _run_command_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.RunCommandInput, 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RunCommandInput") + + _request = build_run_command_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 + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_run_command( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + parameters: _models.RunCommandInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RunCommandResult]: + """Run command on a virtual machine in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the Run command operation. Required. + :type parameters: ~azure.mgmt.compute.models.RunCommandInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either RunCommandResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.RunCommandResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_run_command( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RunCommandResult]: + """Run command on a virtual machine in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the Run command operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either RunCommandResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.RunCommandResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_run_command( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.RunCommandInput, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.RunCommandResult]: + """Run command on a virtual machine in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the Run command operation. Is either a + RunCommandInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.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.models.RunCommandResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._run_command_initial( + resource_group_name=resource_group_name, + vm_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("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, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.RunCommandResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.RunCommandResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_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, + 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_start_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) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = 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_start( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> LROPoller[None]: + """Starts a virtual machine in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._start_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_scale_sets_operations.py similarity index 52% rename from sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_operations.py rename to sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_scale_sets_operations.py index af2c94def74d..12f0a794a116 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_scale_sets_operations.py @@ -9,7 +9,6 @@ from collections.abc import MutableMapping from io import IOBase from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse from azure.core import PipelineClient from azure.core.exceptions import ( @@ -42,25 +41,21 @@ _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_list_by_location_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachineScaleSets", ) 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), + "location": _SERIALIZER.url("location", location, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -69,32 +64,24 @@ 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 -) -> HttpRequest: +def build_list_all_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", "2020-05-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets" ) 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 @@ -103,31 +90,28 @@ 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 -) -> HttpRequest: +def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets", ) 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 @@ -141,54 +125,39 @@ 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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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_get_request( + resource_group_name: str, + vm_scale_set_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.ExpandTypesForGetVMScaleSets]] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", ) 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"), } _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") @@ -196,17 +165,33 @@ def build_disks_list_by_resource_group_request( # pylint: disable=name-too-long return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disks_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_create_or_update_request( + 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", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -215,30 +200,44 @@ def build_disks_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest _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_disks_grant_access_request( - resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any +def build_update_request( + 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", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", ) 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 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -247,57 +246,78 @@ def build_disks_grant_access_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_disks_revoke_access_request( - resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any +def build_delete_request( + resource_group_name: str, + vm_scale_set_name: str, + subscription_id: str, + *, + force_deletion: Optional[bool] = None, + **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", ) 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 + ), + "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 + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_snapshots_create_or_update_request( - resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any +def build_approve_rolling_upgrade_request( + 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", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/approveRollingUpgrade", ) 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 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -310,28 +330,30 @@ 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="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_snapshots_update_request( - resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any +def build_convert_to_single_placement_group_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup", ) 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 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -344,106 +366,160 @@ def build_snapshots_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="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_snapshots_get_request( - resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any +def build_deallocate_request( + 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", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate", ) 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 + ), + "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 hibernate is not None: + _params["hibernate"] = _SERIALIZER.query("hibernate", hibernate, "bool") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_snapshots_delete_request( - resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any +def build_delete_instances_request( + resource_group_name: str, + vm_scale_set_name: str, + subscription_id: str, + *, + force_deletion: Optional[bool] = None, + **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete", ) 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 + ), + "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="DELETE", url=_url, params=_params, **kwargs) + 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_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", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk", ) 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"), } _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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_snapshots_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_get_instance_view_request( + 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", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView", + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -457,25 +533,27 @@ 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_update_instances_request( + 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", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade", ) 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 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -491,50 +569,26 @@ def build_snapshots_grant_access_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_snapshots_revoke_access_request( - resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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_get_os_upgrade_history_request( + 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", "2020-05-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory", ) 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 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -543,32 +597,32 @@ 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_perform_maintenance_request( + 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", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance", ) 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 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -581,58 +635,72 @@ def build_disk_encryption_sets_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_disk_encryption_sets_get_request( - resource_group_name: str, disk_encryption_set_name: str, subscription_id: str, **kwargs: Any +def build_power_off_request( + resource_group_name: str, + vm_scale_set_name: str, + subscription_id: str, + *, + skip_shutdown: Optional[bool] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff", ) 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 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip_shutdown is not None: + _params["skipShutdown"] = _SERIALIZER.query("skip_shutdown", skip_shutdown, "bool") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_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_reapply_request( + 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", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reapply", ) 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 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -643,50 +711,30 @@ def build_disk_encryption_sets_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_disk_encryption_sets_list_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any +def build_redeploy_request( + 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", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy", ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -695,30 +743,34 @@ 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_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_reimage_request( + 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", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage", ) 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 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -731,28 +783,30 @@ def build_disk_accesses_create_or_update_request( # pylint: disable=name-too-lo _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_disk_accesses_update_request( - resource_group_name: str, disk_access_name: str, subscription_id: str, **kwargs: Any +def build_reimage_all_request( + 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", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall", ) 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 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -765,27 +819,30 @@ 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="POST", 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_restart_request( + 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", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart", ) 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 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -794,29 +851,34 @@ def build_disk_accesses_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_disk_accesses_delete_request( - resource_group_name: str, disk_access_name: str, subscription_id: str, **kwargs: Any +def build_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", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/setOrchestrationServiceState", ) 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 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -825,52 +887,33 @@ def build_disk_accesses_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="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_accesses_list_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any +def build_list_skus_request( + 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", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus", ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_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", "2020-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -884,24 +927,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_start_request( + 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", "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateLinkResources", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start", ) 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 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -910,19 +956,21 @@ 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="POST", url=_url, params=_params, headers=_headers, **kwargs) -class DisksOperations: +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.v2020_05_01.ComputeManagementClient`'s - :attr:`disks` attribute. + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models @@ -933,11 +981,24 @@ def __init__(self, *args, **kwargs) -> None: self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = 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_name: str, disk: Union[_models.Disk, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: + @distributed_trace + def list_by_location(self, location: str, **kwargs: Any) -> ItemPaged["_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.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -946,82 +1007,358 @@ 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 "2020-05-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + def prepare_request(next_link=None): + if not next_link: - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk, (IOBase, bytes)): - _content = disk - else: - _json = self._serialize.body(disk, "Disk") + _request = build_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) - _request = build_disks_create_or_update_request( - resource_group_name=resource_group_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) + else: + _request = HttpRequest("GET", next_link) + _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("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) - response = pipeline_response.http_response + def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return ItemPaged(get_next, extract_data) - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_name: str, - disk: _models.Disk, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Creates or updates a disk. + @distributed_trace + def list_all(self, **kwargs: Any) -> ItemPaged["_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. - :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 - :param disk: Disk object supplied in the body of the Put disk operation. Required. - :type disk: ~azure.mgmt.compute.v2020_05_01.models.Disk - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". + :return: An iterator like instance of either VirtualMachineScaleSet or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = 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_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + 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) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.VirtualMachineScaleSet"]: + """Gets a list of all VM scale sets under a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either VirtualMachineScaleSet or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_group_name: str, + vm_scale_set_name: str, + expand: Optional[Union[str, _models.ExpandTypesForGetVMScaleSets]] = None, + **kwargs: Any + ) -> _models.VirtualMachineScaleSet: + """Display information about a virtual machine scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param 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. + :type expand: str or ~azure.mgmt.compute.models.ExpandTypesForGetVMScaleSets + :return: VirtualMachineScaleSet or the result of cls(response) + :rtype: ~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualMachineScaleSet") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, 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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.models.VirtualMachineScaleSet + :param 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. + :type if_match: str + :param 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. + :type 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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.Disk] + :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1029,63 +1366,89 @@ def begin_create_or_update( def begin_create_or_update( self, resource_group_name: str, - disk_name: str, - disk: IO[bytes], + 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.Disk]: - """Creates or updates a disk. + ) -> LROPoller[_models.VirtualMachineScaleSet]: + """Create or update a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param 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 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] + :param 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. + :type if_match: str + :param 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. + :type 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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.Disk] + :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachineScaleSet] :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, + 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. 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.v2020_05_01.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.v2020_05_01.models.Disk] + :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.models.VirtualMachineScaleSet or IO[bytes] + :param 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. + :type if_match: str + :param 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. + :type 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.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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, - disk_name=disk_name, - disk=disk, + 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, @@ -1097,30 +1460,38 @@ 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("VirtualMachineScaleSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.Disk].from_continuation_token( + return LROPoller[_models.VirtualMachineScaleSet].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.Disk]( + return LROPoller[_models.VirtualMachineScaleSet]( 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, + 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, @@ -1133,22 +1504,24 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(disk, (IOBase, bytes)): - _content = disk + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - _json = self._serialize.body(disk, "DiskUpdate") + _json = self._serialize.body(parameters, "VirtualMachineScaleSetUpdate") - _request = build_disks_update_request( + _request = build_update_request( resource_group_name=resource_group_name, - disk_name=disk_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, @@ -1166,7 +1539,7 @@ def _update_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): @@ -1174,10 +1547,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 @@ -1185,27 +1562,37 @@ def _update_initial( def begin_update( self, resource_group_name: str, - disk_name: str, - disk: _models.DiskUpdate, + vm_scale_set_name: str, + parameters: _models.VirtualMachineScaleSetUpdate, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Updates (patches) a disk. + ) -> 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 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.v2020_05_01.models.DiskUpdate + :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.models.VirtualMachineScaleSetUpdate + :param 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. + :type if_match: str + :param 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. + :type 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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.Disk] + :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1213,63 +1600,89 @@ def begin_update( def begin_update( self, resource_group_name: str, - disk_name: str, - disk: IO[bytes], + 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.Disk]: - """Updates (patches) a disk. + ) -> 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 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 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] + :param 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. + :type if_match: str + :param 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. + :type 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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.Disk] + :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachineScaleSet] :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, + 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. 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.v2020_05_01.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.v2020_05_01.models.Disk] + :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.models.VirtualMachineScaleSetUpdate or IO[bytes] + :param 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. + :type if_match: str + :param 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. + :type 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.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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, - disk_name=disk_name, - disk=disk, + 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, @@ -1281,85 +1694,38 @@ def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Disk", 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("VirtualMachineScaleSet", 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.Disk].from_continuation_token( + return LROPoller[_models.VirtualMachineScaleSet].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.Disk]( + return LROPoller[_models.VirtualMachineScaleSet]( 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.v2020_05_01.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 "2020-05-01")) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) - - _request = build_disks_get_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) - - _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("Disk", 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_name: str, **kwargs: Any) -> Iterator[bytes]: + 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, @@ -1371,13 +1737,14 @@ def _delete_initial(self, resource_group_name: str, disk_name: str, **kwargs: An _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_disks_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, - disk_name=disk_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, @@ -1400,23 +1767,32 @@ def _delete_initial(self, resource_group_name: str, disk_name: str, **kwargs: An map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def begin_delete(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a disk. + def begin_delete( + self, resource_group_name: str, vm_scale_set_name: str, force_deletion: Optional[bool] = None, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param 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 vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param force_deletion: Optional parameter to force delete a VM scale set. (Feature in Preview). + Default value is None. + :type 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: @@ -1424,7 +1800,7 @@ def begin_delete(self, resource_group_name: str, disk_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1432,7 +1808,8 @@ 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, + vm_scale_set_name=vm_scale_set_name, + force_deletion=force_deletion, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -1447,7 +1824,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: @@ -1461,162 +1840,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 list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Disk"]: - """Lists all the disks 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 Disk or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_05_01.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 "2020-05-01")) - 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 list(self, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2020_05_01.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 "2020-05-01")) - cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disks_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) - - def _grant_access_initial( + def _approve_rolling_upgrade_initial( self, resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, 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 = { @@ -1630,21 +1858,24 @@ def _grant_access_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(grant_access_data, (IOBase, bytes)): - _content = grant_access_data + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_disks_grant_access_request( + _request = build_approve_rolling_upgrade_request( resource_group_name=resource_group_name, - disk_name=disk_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -1663,7 +1894,7 @@ def _grant_access_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): @@ -1671,108 +1902,113 @@ 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 = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, 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_approve_rolling_upgrade( self, resource_group_name: str, - disk_name: str, - grant_access_data: _models.GrantAccessData, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. + ) -> 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. 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.v2020_05_01.models.GrantAccessData + :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.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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.AccessUri] + :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_grant_access( + def begin_approve_rolling_upgrade( self, resource_group_name: str, - disk_name: str, - grant_access_data: IO[bytes], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. + ) -> 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. 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 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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.AccessUri] + :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_grant_access( + def begin_approve_rolling_upgrade( self, resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. + ) -> 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. 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.v2020_05_01.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.v2020_05_01.models.AccessUri] + :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.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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessUri] = 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._grant_access_initial( + raw_result = self._approve_rolling_upgrade_initial( resource_group_name=resource_group_name, - disk_name=disk_name, - grant_access_data=grant_access_data, + 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, @@ -1783,11 +2019,9 @@ def begin_grant_access( 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) + 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( @@ -1798,17 +2032,91 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.AccessUri].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.AccessUri]( - 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 + + @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.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. - def _revoke_access_initial(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> Iterator[bytes]: + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param 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.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, @@ -1817,124 +2125,55 @@ def _revoke_access_initial(self, resource_group_name: str, disk_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 "2020-05-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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_disks_revoke_access_request( + _request = build_convert_to_single_placement_group_request( resource_group_name=resource_group_name, - disk_name=disk_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 + _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) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, None, {}) # 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. - - :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 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 "2020-05-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._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 - ) - 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 SnapshotsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_05_01.ComputeManagementClient`'s - :attr:`snapshots` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any + def _deallocate_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + hibernate: Optional[bool] = None, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1947,22 +2186,26 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(snapshot, "Snapshot") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_snapshots_create_or_update_request( + _request = build_deallocate_request( resource_group_name=resource_group_name, - snapshot_name=snapshot_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, @@ -1988,102 +2231,133 @@ 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_deallocate( self, resource_group_name: str, - snapshot_name: str, - snapshot: _models.Snapshot, + vm_scale_set_name: str, + hibernate: Optional[bool] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. + ) -> 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. 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.v2020_05_01.models.Snapshot + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param 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. + :type hibernate: 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.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 Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.Snapshot] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_or_update( + def begin_deallocate( self, resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], + vm_scale_set_name: str, + hibernate: Optional[bool] = None, + vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. + ) -> 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. 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: IO[bytes] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param 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. + :type hibernate: 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: IO[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.v2020_05_01.models.Snapshot] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_or_update( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. + def begin_deallocate( + self, + resource_group_name: str, + vm_scale_set_name: str, + hibernate: Optional[bool] = None, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and + releases the compute resources. You are not billed for the compute resources that this virtual + machine scale set deallocates. - :param resource_group_name: The name of the resource 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.v2020_05_01.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.v2020_05_01.models.Snapshot] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param 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. + :type hibernate: bool + :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.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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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._deallocate_initial( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - snapshot=snapshot, + vm_scale_set_name=vm_scale_set_name, + hibernate=hibernate, + vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2094,34 +2368,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("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 _delete_instances_initial( self, resource_group_name: str, - snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], + force_deletion: Optional[bool] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -2135,22 +2408,23 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(snapshot, "SnapshotUpdate") + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceRequiredIDs") - _request = build_snapshots_update_request( + _request = build_delete_instances_request( resource_group_name=resource_group_name, - snapshot_name=snapshot_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, @@ -2176,108 +2450,124 @@ 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, - snapshot_name: str, - snapshot: _models.SnapshotUpdate, + vm_scale_set_name: str, + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, + force_deletion: Optional[bool] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. + ) -> 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 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. + :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 snapshot: ~azure.mgmt.compute.v2020_05_01.models.SnapshotUpdate + :type vm_instance_i_ds: ~azure.mgmt.compute.models.VirtualMachineScaleSetVMInstanceRequiredIDs + :param force_deletion: Optional parameter to force delete virtual machines from the VM scale + set. (Feature in Preview). Default value is None. + :type 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 Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.Snapshot] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update( + def begin_delete_instances( self, resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], + vm_scale_set_name: str, + vm_instance_i_ds: IO[bytes], + force_deletion: Optional[bool] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. + ) -> 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 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. + :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 snapshot: IO[bytes] + :type vm_instance_i_ds: IO[bytes] + :param force_deletion: Optional parameter to force delete virtual machines from the VM scale + set. (Feature in Preview). Default value is None. + :type 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 Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.Snapshot] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update( + def begin_delete_instances( self, resource_group_name: str, - snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], + force_deletion: Optional[bool] = None, **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. + ) -> 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 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.v2020_05_01.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.v2020_05_01.models.Snapshot] + :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.models.VirtualMachineScaleSetVMInstanceRequiredIDs + or IO[bytes] + :param force_deletion: Optional parameter to force delete virtual machines from the VM scale + set. (Feature in Preview). Default value is None. + :type 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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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._update_initial( + raw_result = self._delete_instances_initial( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - snapshot=snapshot, + 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, @@ -2288,41 +2578,56 @@ 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("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 @distributed_trace - def get(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> _models.Snapshot: - """Gets information about a snapshot. + 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. + :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: Snapshot or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_05_01.models.Snapshot + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param platform_update_domain: The platform update domain for which a manual recovery walk is + requested. Required. + :type platform_update_domain: int + :param zone: The zone in which the manual recovery walk is requested for cross zone virtual + machine scale set. Default value is None. + :type zone: str + :param placement_group_id: The placement group id for which the manual recovery walk is + requested. Default value is None. + :type placement_group_id: str + :return: RecoveryWalkResponse or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.RecoveryWalkResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2336,13 +2641,16 @@ def get(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) - cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.RecoveryWalkResponse] = kwargs.pop("cls", None) - _request = build_snapshots_get_request( + _request = build_force_recovery_service_fabric_platform_update_domain_walk_request( resource_group_name=resource_group_name, - snapshot_name=snapshot_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, @@ -2360,14 +2668,28 @@ def get(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> _m 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) + deserialized = self._deserialize("RecoveryWalkResponse", 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]: + @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.models.VirtualMachineScaleSetInstanceView + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2379,14 +2701,75 @@ def _delete_initial(self, resource_group_name: str, snapshot_name: str, **kwargs _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetInstanceView] = kwargs.pop("cls", None) + + _request = build_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, + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, 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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_snapshots_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_update_instances_request( resource_group_name=resource_group_name, - snapshot_name=snapshot_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, ) @@ -2400,7 +2783,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): @@ -2408,40 +2791,113 @@ 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 + @overload + def begin_update_instances( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.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: + """ + + @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_delete(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a snapshot. + def begin_update_instances( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - :param resource_group_name: The name of the resource group. Required. + :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 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.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 = 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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) 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, - snapshot_name=snapshot_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, @@ -2455,7 +2911,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: @@ -2470,20 +2928,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 list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Snapshot"]: - """Lists snapshots under a resource group. + def get_os_upgrade_history( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> ItemPaged["_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 - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_05_01.models.Snapshot] + :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.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 "2020-05-01")) - cls: ClsType[_models.SnapshotList] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2496,8 +2961,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_snapshots_list_by_resource_group_request( + _request = build_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, @@ -2506,24 +2972,13 @@ def prepare_request(next_link=None): _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 = HttpRequest("GET", next_link) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): - deserialized = self._deserialize("SnapshotList", pipeline_response) + deserialized = self._deserialize("VirtualMachineScaleSetListOSUpgradeHistory", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -2546,85 +3001,219 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.Snapshot"]: - """Lists snapshots under a subscription. - - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_05_01.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 "2020-05-01")) - cls: ClsType[_models.SnapshotList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, + def _perform_maintenance_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) - 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_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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds + else: + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") else: - # 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 + _json = None - 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) + _request = build_perform_maintenance_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) - 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, 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) - return pipeline_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")) - return ItemPaged(get_next, extract_data) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_perform_maintenance( + 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]: + """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. The name is case insensitive. + Required. + :type 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.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_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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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, + 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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._perform_maintenance_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + vm_instance_i_ds=vm_instance_i_ds, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, 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 _grant_access_initial( + def _power_off_initial( self, resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], + vm_scale_set_name: str, + skip_shutdown: Optional[bool] = None, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -2638,22 +3227,26 @@ def _grant_access_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(grant_access_data, (IOBase, bytes)): - _content = grant_access_data + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_snapshots_grant_access_request( + _request = build_power_off_request( resource_group_name=resource_group_name, - snapshot_name=snapshot_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, @@ -2679,108 +3272,133 @@ 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_power_off( self, resource_group_name: str, - snapshot_name: str, - grant_access_data: _models.GrantAccessData, + vm_scale_set_name: str, + skip_shutdown: Optional[bool] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. + ) -> LROPoller[None]: + """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still + attached and you are getting charged for the resources. Instead, use deallocate to release + resources and avoid charges. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param 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 - operation. Required. - :type grant_access_data: ~azure.mgmt.compute.v2020_05_01.models.GrantAccessData + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param 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. + :type 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.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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.AccessUri] + :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_grant_access( + def begin_power_off( self, resource_group_name: str, - snapshot_name: str, - grant_access_data: IO[bytes], + vm_scale_set_name: str, + skip_shutdown: Optional[bool] = None, + vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. + ) -> LROPoller[None]: + """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still + attached and you are getting charged for the resources. Instead, use deallocate to release + resources and avoid charges. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param 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 - operation. Required. - :type grant_access_data: IO[bytes] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param 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. + :type 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: IO[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.v2020_05_01.models.AccessUri] + :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_grant_access( + def begin_power_off( self, resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], + vm_scale_set_name: str, + skip_shutdown: Optional[bool] = None, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. + ) -> LROPoller[None]: + """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still + attached and you are getting charged for the resources. Instead, use deallocate to release + resources and avoid charges. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param 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 - operation. Is either a GrantAccessData type or a IO[bytes] type. Required. - :type grant_access_data: ~azure.mgmt.compute.v2020_05_01.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.v2020_05_01.models.AccessUri] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param 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. + :type skip_shutdown: bool + :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.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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessUri] = 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._grant_access_initial( + raw_result = self._power_off_initial( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - grant_access_data=grant_access_data, + vm_scale_set_name=vm_scale_set_name, + skip_shutdown=skip_shutdown, + vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2791,11 +3409,9 @@ def begin_grant_access( 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) + 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( @@ -2806,17 +3422,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.AccessUri].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.AccessUri]( - 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 _revoke_access_initial(self, resource_group_name: str, snapshot_name: 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, @@ -2828,12 +3442,12 @@ def _revoke_access_initial(self, resource_group_name: str, snapshot_name: str, * _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_snapshots_revoke_access_request( + _request = build_reapply_request( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2857,23 +3471,28 @@ 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_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 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 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: @@ -2881,15 +3500,15 @@ def begin_revoke_access(self, resource_group_name: str, snapshot_name: str, **kw _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._revoke_access_initial( + raw_result = self._reapply_initial( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, + vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -2920,32 +3539,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 - -class DiskEncryptionSetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_05_01.ComputeManagementClient`'s - :attr:`disk_encryption_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _redeploy_initial( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, 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 = { @@ -2959,21 +3557,24 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) 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(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_disk_encryption_sets_create_or_update_request( + _request = build_redeploy_request( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3000,112 +3601,114 @@ 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_redeploy( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSet, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. + ) -> LROPoller[None]: + """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, + and powers them back on. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param 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.v2020_05_01.models.DiskEncryptionSet + :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.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 DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSet] + :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_redeploy( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. + ) -> LROPoller[None]: + """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, + and powers them back on. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param 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 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 DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSet] + :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_redeploy( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. + ) -> LROPoller[None]: + """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, + and powers them back on. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param 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.v2020_05_01.models.DiskEncryptionSet 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.models.VirtualMachineScaleSetVMInstanceIDs 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.v2020_05_01.models.DiskEncryptionSet] + :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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._redeploy_initial( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - disk_encryption_set=disk_encryption_set, + 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, @@ -3116,34 +3719,32 @@ def begin_create_or_update( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSet", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.DiskEncryptionSet].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.DiskEncryptionSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _update_initial( + def _reimage_initial( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSetUpdate, IO[bytes]], + vm_scale_set_name: str, + vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -3157,21 +3758,24 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) 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(vm_scale_set_reimage_input, (IOBase, bytes)): + _content = vm_scale_set_reimage_input else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSetUpdate") + if vm_scale_set_reimage_input is not None: + _json = self._serialize.body(vm_scale_set_reimage_input, "VirtualMachineScaleSetReimageParameters") + else: + _json = None - _request = build_disk_encryption_sets_update_request( + _request = build_reimage_request( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3198,279 +3802,118 @@ 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_reimage( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSetUpdate, + vm_scale_set_name: str, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Updates (patches) a disk encryption 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 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.v2020_05_01.models.DiskEncryptionSetUpdate + :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.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 DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSet] + :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_reimage( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], + vm_scale_set_name: str, + vm_scale_set_reimage_input: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Updates (patches) a disk encryption 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 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 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 DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSet] + :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_reimage( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSetUpdate, IO[bytes]], + vm_scale_set_name: str, + vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Updates (patches) a disk encryption 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. - :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.v2020_05_01.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.v2020_05_01.models.DiskEncryptionSet] + :type 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.models.VirtualMachineScaleSetReimageParameters or IO[bytes] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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.v2020_05_01.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 "2020-05-01")) - 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 "2020-05-01")) - 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 - :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 "2020-05-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( + raw_result = self._reimage_initial( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_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, @@ -3484,7 +3927,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: @@ -3498,183 +3943,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 list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_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.v2020_05_01.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 "2020-05-01")) - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_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.v2020_05_01.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 "2020-05-01")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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 DiskAccessesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_05_01.ComputeManagementClient`'s - :attr:`disk_accesses` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _reimage_all_initial( self, resource_group_name: str, - disk_access_name: str, - disk_access: Union[_models.DiskAccess, 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 = { @@ -3688,21 +3961,24 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(disk_access, "DiskAccess") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_disk_accesses_create_or_update_request( + _request = build_reimage_all_request( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3729,108 +4005,114 @@ 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_reimage_all( self, resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccess, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. + ) -> 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 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.v2020_05_01.models.DiskAccess + :type 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.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 DiskAccess or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskAccess] + :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_reimage_all( self, resource_group_name: str, - disk_access_name: str, - disk_access: IO[bytes], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. + ) -> 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 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: IO[bytes] + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskAccess] + :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_reimage_all( self, resource_group_name: str, - disk_access_name: str, - disk_access: Union[_models.DiskAccess, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. + ) -> 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 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.v2020_05_01.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.v2020_05_01.models.DiskAccess] + :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.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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiskAccess] = 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._reimage_all_initial( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - disk_access=disk_access, + 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, @@ -3841,34 +4123,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("DiskAccess", 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.DiskAccess].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.DiskAccess]( - 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 _restart_initial( self, resource_group_name: str, - disk_access_name: str, - disk_access: Union[_models.DiskAccessUpdate, 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 = { @@ -3882,21 +4162,24 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(disk_access, "DiskAccessUpdate") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_disk_accesses_update_request( + _request = build_restart_request( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3923,108 +4206,111 @@ 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_restart( self, resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccessUpdate, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. + ) -> LROPoller[None]: + """Restarts one or more virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param 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.v2020_05_01.models.DiskAccessUpdate + :type 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.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 DiskAccess or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskAccess] + :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_restart( self, resource_group_name: str, - disk_access_name: str, - disk_access: IO[bytes], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. + ) -> LROPoller[None]: + """Restarts one or more virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param 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 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 DiskAccess or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskAccess] + :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_restart( self, resource_group_name: str, - disk_access_name: str, - disk_access: Union[_models.DiskAccessUpdate, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. + ) -> 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 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.v2020_05_01.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.v2020_05_01.models.DiskAccess] + :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.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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiskAccess] = 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._restart_initial( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - disk_access=disk_access, + 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, @@ -4035,86 +4321,34 @@ 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("DiskAccess", 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)) - 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, + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) - 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_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.v2020_05_01.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 "2020-05-01")) - 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 + 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 _delete_initial(self, resource_group_name: str, disk_access_name: str, **kwargs: Any) -> Iterator[bytes]: + 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]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4123,17 +4357,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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) 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(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OrchestrationServiceStateInput") + + _request = build_set_orchestration_service_state_request( resource_group_name=resource_group_name, - disk_access_name=disk_access_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, ) @@ -4147,7 +4393,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): @@ -4155,40 +4401,110 @@ 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 + @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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_set_orchestration_service_state( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Changes ServiceState property for a given service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def begin_delete(self, resource_group_name: str, disk_access_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a disk access resource. + def begin_set_orchestration_service_state( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Changes ServiceState property for a given service. - :param resource_group_name: The name of the resource group. Required. + :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 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.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 = 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 "2020-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) 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._set_orchestration_service_state_initial( resource_group_name=resource_group_name, - disk_access_name=disk_access_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, @@ -4202,7 +4518,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: @@ -4217,20 +4535,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 list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.DiskAccess"]: - """Lists all the disk access resources under a resource group. + def list_skus( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> ItemPaged["_models.VirtualMachineScaleSetSku"]: + """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM + instances allowed for each SKU. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :return: An iterator like instance of either DiskAccess or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_05_01.models.DiskAccess] + :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.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 "2020-05-01")) - cls: ClsType[_models.DiskAccessList] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetListSkusResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4243,8 +4568,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_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, @@ -4253,24 +4579,13 @@ def prepare_request(next_link=None): _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 = HttpRequest("GET", next_link) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): - deserialized = self._deserialize("DiskAccessList", pipeline_response) + deserialized = self._deserialize("VirtualMachineScaleSetListSkusResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -4293,20 +4608,13 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_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.v2020_05_01.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 "2020-05-01")) - cls: ClsType[_models.DiskAccessList] = kwargs.pop("cls", None) - + 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, @@ -4315,112 +4623,185 @@ def list(self, **kwargs: Any) -> ItemPaged["_models.DiskAccess"]: } 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_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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds + else: + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") else: - # 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_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. - :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.v2020_05_01.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 "2020-05-01")) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + _json = None - _request = build_disk_accesses_get_private_link_resources_request( + _request = build_start_request( resource_group_name=resource_group_name, - disk_access_name=disk_access_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("PrivateLinkResourceListResult", 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_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. The name is case insensitive. + Required. + :type 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.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 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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type 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.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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._start_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + vm_instance_i_ds=vm_instance_i_ds, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_sizes_operations.py new file mode 100644 index 000000000000..8744f276399e --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machine_sizes_operations.py @@ -0,0 +1,149 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ComputeManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes" + ) + path_format_arguments = { + "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, location: str, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _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 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/v2022_09_04/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machines_operations.py similarity index 57% rename from sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/operations/_operations.py rename to sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machines_operations.py index ed95dc296e48..4465e4d54c90 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/operations/_virtual_machines_operations.py @@ -9,7 +9,6 @@ from collections.abc import MutableMapping from io import IOBase from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse from azure.core import PipelineClient from azure.core.exceptions import ( @@ -42,25 +41,21 @@ _SERIALIZER.client_side_validation = False -def build_cloud_service_role_instances_delete_request( # pylint: disable=name-too-long - role_instance_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_list_by_location_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines", ) path_format_arguments = { - "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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 @@ -71,40 +66,37 @@ def build_cloud_service_role_instances_delete_request( # pylint: disable=name-t # 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_cloud_service_role_instances_get_request( # pylint: disable=name-too-long - role_instance_name: str, - resource_group_name: str, - cloud_service_name: str, +def build_list_all_request( subscription_id: str, *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + status_only: Optional[str] = None, + filter: Optional[str] = None, + expand: Optional[Union[str, _models.ExpandTypesForListVMs]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}", - ) + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { - "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if status_only is not None: + _params["statusOnly"] = _SERIALIZER.query("status_only", status_only, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: _params["$expand"] = _SERIALIZER.query("expand", expand, "str") @@ -114,31 +106,40 @@ def build_cloud_service_role_instances_get_request( # pylint: disable=name-too- return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_cloud_service_role_instances_get_instance_view_request( # pylint: disable=name-too-long - role_instance_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +def build_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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/instanceView", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines", ) path_format_arguments = { - "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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") @@ -146,9 +147,9 @@ def build_cloud_service_role_instances_get_instance_view_request( # pylint: dis return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_cloud_service_role_instances_list_request( # pylint: disable=name-too-long +def build_get_request( resource_group_name: str, - cloud_service_name: str, + vm_name: str, subscription_id: str, *, expand: Optional[Union[str, _models.InstanceViewTypes]] = None, @@ -157,18 +158,20 @@ def build_cloud_service_role_instances_list_request( # pylint: disable=name-too _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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 @@ -184,57 +187,33 @@ def build_cloud_service_role_instances_list_request( # pylint: disable=name-too return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_cloud_service_role_instances_restart_request( # pylint: disable=name-too-long - role_instance_name: str, resource_group_name: str, cloud_service_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", "2022-09-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/restart", - ) - path_format_arguments = { - "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_service_role_instances_reimage_request( # pylint: disable=name-too-long - role_instance_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +def build_create_or_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", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/reimage", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", ) path_format_arguments = { - "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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 @@ -243,62 +222,44 @@ def build_cloud_service_role_instances_reimage_request( # pylint: disable=name- _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_cloud_service_role_instances_rebuild_request( # pylint: disable=name-too-long - role_instance_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +def build_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", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/rebuild", - ) - path_format_arguments = { - "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_service_role_instances_get_remote_desktop_file_request( # pylint: disable=name-too-long - role_instance_name: str, resource_group_name: str, cloud_service_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", "2022-09-04")) - accept = _headers.pop("Accept", "application/x-rdp") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/remoteDesktopFile", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", ) path_format_arguments = { - "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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 @@ -307,61 +268,77 @@ def build_cloud_service_role_instances_get_remote_desktop_file_request( # pylin _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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_cloud_service_roles_get_request( - role_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +def build_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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roles/{roleName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", ) path_format_arguments = { - "roleName": _SERIALIZER.url("role_name", role_name, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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 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_cloud_service_roles_list_request( - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +def build_assess_patches_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", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roles", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/assessPatches", ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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 @@ -372,28 +349,30 @@ def build_cloud_service_roles_list_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_cloud_services_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +def build_attach_detach_data_disks_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", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/attachDetachDataDisks", ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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 @@ -406,28 +385,28 @@ def build_cloud_services_create_or_update_request( # pylint: disable=name-too-l _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_cloud_services_update_request( - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_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", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture", ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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 @@ -440,27 +419,29 @@ def build_cloud_services_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="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_cloud_services_delete_request( - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +def build_convert_to_managed_disks_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", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks", ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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 @@ -471,58 +452,64 @@ def build_cloud_services_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_cloud_services_get_request( - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +def build_deallocate_request( + resource_group_name: str, vm_name: str, subscription_id: str, *, hibernate: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate", ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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 hibernate is not None: + _params["hibernate"] = _SERIALIZER.query("hibernate", hibernate, "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_cloud_services_get_instance_view_request( # pylint: disable=name-too-long - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +def build_generalize_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", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/instanceView", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize", ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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 @@ -533,48 +520,30 @@ def build_cloud_services_get_instance_view_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) - - -def build_cloud_services_list_all_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", "2022-09-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/cloudServices") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # 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_cloud_services_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_install_patches_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", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/installPatches", ) 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 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -583,29 +552,33 @@ def build_cloud_services_list_request(resource_group_name: str, subscription_id: _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_cloud_services_start_request( - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +def build_instance_view_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", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/start", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView", ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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 @@ -616,27 +589,30 @@ def build_cloud_services_start_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_cloud_services_power_off_request( - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +def build_migrate_to_vm_scale_set_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", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/poweroff", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/migrateToVirtualMachineScaleSet", ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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 @@ -645,30 +621,33 @@ def build_cloud_services_power_off_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_cloud_services_restart_request( - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +def build_perform_maintenance_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", "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/restart", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance", ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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 @@ -677,66 +656,64 @@ def build_cloud_services_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) -def build_cloud_services_reimage_request( - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +def build_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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/reimage", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff", ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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 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="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_cloud_services_rebuild_request( - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/rebuild", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reapply", ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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 @@ -745,32 +722,29 @@ def build_cloud_services_rebuild_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_cloud_services_delete_instances_request( # pylint: disable=name-too-long - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/delete", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy", ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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 @@ -779,33 +753,30 @@ def build_cloud_services_delete_instances_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) -def build_cloud_services_update_domain_walk_update_domain_request( # pylint: disable=name-too-long - resource_group_name: str, cloud_service_name: str, update_domain: int, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_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", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage", ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "updateDomain": _SERIALIZER.url("update_domain", update_domain, "int"), - "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 @@ -818,28 +789,27 @@ def build_cloud_services_update_domain_walk_update_domain_request( # pylint: di _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_cloud_services_update_domain_get_update_domain_request( # pylint: disable=name-too-long - resource_group_name: str, cloud_service_name: str, update_domain: int, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart", ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "updateDomain": _SERIALIZER.url("update_domain", update_domain, "int"), - "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 @@ -850,58 +820,72 @@ def build_cloud_services_update_domain_get_update_domain_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_cloud_services_update_domain_list_update_domains_request( # pylint: disable=name-too-long - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any +def build_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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/retrieveBootDiagnosticsData", ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_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 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_cloud_service_operating_systems_get_os_version_request( # pylint: disable=name-too-long - location: str, os_version_name: str, subscription_id: str, **kwargs: Any +def build_run_command_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", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsVersions/{osVersionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand", ) path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "osVersionName": _SERIALIZER.url("os_version_name", os_version_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 @@ -910,28 +894,33 @@ def build_cloud_service_operating_systems_get_os_version_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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_cloud_service_operating_systems_list_os_versions_request( # pylint: disable=name-too-long - location: str, subscription_id: str, **kwargs: Any +def build_simulate_eviction_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", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsVersions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/simulateEviction", ) 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 @@ -942,27 +931,27 @@ def build_cloud_service_operating_systems_list_os_versions_request( # pylint: d # 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_cloud_service_operating_systems_get_os_family_request( # pylint: disable=name-too-long - location: str, os_family_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsFamilies/{osFamilyName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start", ) path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "osFamilyName": _SERIALIZER.url("os_family_name", os_family_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 @@ -973,26 +962,29 @@ def build_cloud_service_operating_systems_get_os_family_request( # pylint: disa # 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_cloud_service_operating_systems_list_os_families_request( # pylint: disable=name-too-long - location: str, subscription_id: str, **kwargs: Any +def build_list_available_sizes_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", "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsFamilies", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes", ) 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 @@ -1006,14 +998,14 @@ def build_cloud_service_operating_systems_list_os_families_request( # pylint: d return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class CloudServiceRoleInstancesOperations: +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.v2022_09_04.ComputeManagementClient`'s - :attr:`cloud_service_role_instances` attribute. + :class:`~azure.mgmt.compute.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models @@ -1024,11 +1016,23 @@ def __init__(self, *args, **kwargs) -> None: self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = 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 _delete_initial( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> Iterator[bytes]: + @distributed_trace + def list_by_location(self, location: str, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1037,126 +1041,241 @@ 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 "2022-09-04")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + _request = build_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) - _request = build_cloud_service_role_instances_delete_request( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + else: + _request = HttpRequest("GET", next_link) + _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("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) - 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, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a role instance from a cloud service. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + def list_all( + self, + status_only: Optional[str] = None, + filter: Optional[str] = None, + expand: Optional[Union[str, _models.ExpandTypesForListVMs]] = None, + **kwargs: Any + ) -> ItemPaged["_models.VirtualMachine"]: + """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 status_only: statusOnly=true enables fetching run time status of all Virtual Machines in + the subscription. Default value is None. + :type status_only: str + :param 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. + :type filter: str + :param 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. + :type expand: str or ~azure.mgmt.compute.models.ExpandTypesForListVMs + :return: An iterator like instance of either VirtualMachine or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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 "2022-09-04")) - 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( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.VirtualMachineListResult] = 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_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: + _request = HttpRequest("GET", next_link) + _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: - 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 list( + self, + resource_group_name: str, + filter: Optional[str] = None, + expand: Optional[Union[str, _models.ExpandTypeForListVMs]] = None, + **kwargs: Any + ) -> ItemPaged["_models.VirtualMachine"]: + """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 + :param 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. + :type filter: str + :param 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. + :type expand: str or ~azure.mgmt.compute.models.ExpandTypeForListVMs + :return: An iterator like instance of either VirtualMachine or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.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", "2024-11-01")) + cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_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: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace def get( self, - role_instance_name: str, resource_group_name: str, - cloud_service_name: str, - *, + vm_name: str, expand: Optional[Union[str, _models.InstanceViewTypes]] = None, **kwargs: Any - ) -> _models.RoleInstance: - """Gets a role instance from a cloud service. + ) -> _models.VirtualMachine: + """Retrieves information about the model view or the instance view of a virtual machine. - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :keyword expand: The expand expression to apply to the operation. 'UserData' is not supported - for cloud services. Known values are: "instanceView" and "userData". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2022_09_04.models.InstanceViewTypes - :return: RoleInstance or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_09_04.models.RoleInstance + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param expand: The expand expression to apply on the operation. 'InstanceView' retrieves a + snapshot of the runtime properties of the virtual machine that is managed by the platform and + can change outside of control plane operations. 'UserData' retrieves the UserData property as + part of the VM model view that was provided by the user during the VM Create/Update operation. + Known values are: "instanceView", "userData", and "resiliencyView". Default value is None. + :type expand: str or ~azure.mgmt.compute.models.InstanceViewTypes + :return: VirtualMachine or the result of cls(response) + :rtype: ~azure.mgmt.compute.models.VirtualMachine :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1170,13 +1289,12 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) - cls: ClsType[_models.RoleInstance] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) - _request = build_cloud_service_role_instances_get_request( - role_instance_name=role_instance_name, + _request = build_get_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, @@ -1196,29 +1314,22 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleInstance", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def get_instance_view( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> _models.RoleInstanceView: - """Retrieves information about the run-time state of a role instance in a cloud service. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: RoleInstanceView or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_09_04.models.RoleInstanceView - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _create_or_update_initial( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.VirtualMachine, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1227,136 +1338,235 @@ 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 "2022-09-04")) - cls: ClsType[_models.RoleInstanceView] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_cloud_service_role_instances_get_instance_view_request( - role_instance_name=role_instance_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, "VirtualMachine") + + _request = build_create_or_update_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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) - _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("RoleInstanceView", 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 - @distributed_trace - def list( + @overload + def begin_create_or_update( self, resource_group_name: str, - cloud_service_name: str, + vm_name: str, + parameters: _models.VirtualMachine, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + content_type: str = "application/json", **kwargs: Any - ) -> ItemPaged["_models.RoleInstance"]: - """Gets the list of all role instances in a cloud service. Use nextLink property in the response - to get the next page of role instances. Do this till nextLink is null to fetch all the role - instances. + ) -> LROPoller[_models.VirtualMachine]: + """The operation to create or update a virtual machine. Please note some properties can be set + only during virtual machine creation. - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :keyword expand: The expand expression to apply to the operation. 'UserData' is not supported - for cloud services. Known values are: "instanceView" and "userData". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2022_09_04.models.InstanceViewTypes - :return: An iterator like instance of either RoleInstance or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_09_04.models.RoleInstance] + :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.models.VirtualMachine + :param 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. + :type if_match: str + :param 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. + :type if_none_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachine or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.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 "2022-09-04")) - cls: ClsType[_models.RoleInstanceListResult] = kwargs.pop("cls", None) + @overload + def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachine]: + """The operation to create or update a virtual machine. Please note some properties can be set + only during virtual machine creation. - 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 Create Virtual Machine operation. Required. + :type parameters: IO[bytes] + :param 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. + :type if_match: str + :param 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. + :type if_none_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachine or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ - def prepare_request(next_link=None): - if not next_link: + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.VirtualMachine, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.VirtualMachine]: + """The operation to create or update a virtual machine. Please note some properties can be set + only during virtual machine creation. - _request = build_cloud_service_role_instances_list_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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) + :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.models.VirtualMachine or IO[bytes] + :param 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. + :type if_match: str + :param 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. + :type 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.models.VirtualMachine] + :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", "2024-11-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._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 + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleInstanceListResult", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachine", 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.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 _restart_initial( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + def _update_initial( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.VirtualMachineUpdate, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1366,18 +1576,31 @@ 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 "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_cloud_service_role_instances_restart_request( - role_instance_name=role_instance_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, "VirtualMachineUpdate") + + _request = build_update_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, ) @@ -1391,7 +1614,7 @@ def _restart_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): @@ -1399,44 +1622,144 @@ def _restart_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + vm_name: str, + parameters: _models.VirtualMachineUpdate, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachine]: + """The operation to update a virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Update Virtual Machine operation. Required. + :type parameters: ~azure.mgmt.compute.models.VirtualMachineUpdate + :param 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. + :type if_match: str + :param 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. + :type if_none_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachine or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + vm_name: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachine]: + """The operation to update a virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Update Virtual Machine operation. Required. + :type parameters: IO[bytes] + :param 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. + :type if_match: str + :param 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. + :type if_none_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachine or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def begin_restart( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The Reboot Role Instance asynchronous operation requests a reboot of a role instance in the - cloud service. + 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 role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_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 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.models.VirtualMachineUpdate or IO[bytes] + :param 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. + :type if_match: str + :param 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. + :type 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.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 "2022-09-04")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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._restart_initial( - role_instance_name=role_instance_name, + raw_result = self._update_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, @@ -1445,27 +1768,38 @@ def begin_restart( 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 + return LROPoller[_models.VirtualMachine]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _reimage_initial( - self, role_instance_name: str, resource_group_name: str, cloud_service_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, @@ -1478,14 +1812,14 @@ def _reimage_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_cloud_service_role_instances_reimage_request( - role_instance_name=role_instance_name, + _request = build_delete_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, + force_deletion=force_deletion, api_version=api_version, headers=_headers, params=_params, @@ -1500,7 +1834,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): @@ -1508,26 +1842,32 @@ 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 @distributed_trace - def begin_reimage( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + def begin_delete( + self, resource_group_name: str, vm_name: str, force_deletion: Optional[bool] = None, **kwargs: Any ) -> LROPoller[None]: - """The Reimage Role Instance asynchronous operation reinstalls the operating system on instances - of web roles or worker roles. + """The operation to delete a virtual machine. - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param force_deletion: Optional parameter to force delete virtual machines. Default value is + None. + :type 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: @@ -1535,16 +1875,16 @@ def begin_reimage( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._reimage_initial( - role_instance_name=role_instance_name, + raw_result = self._delete_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, + force_deletion=force_deletion, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -1559,7 +1899,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: @@ -1573,9 +1915,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 _rebuild_initial( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **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, @@ -1587,13 +1927,12 @@ def _rebuild_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_cloud_service_role_instances_rebuild_request( - role_instance_name=role_instance_name, + _request = build_assess_patches_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1617,44 +1956,47 @@ def _rebuild_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_rebuild( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The Rebuild Role Instance asynchronous operation reinstalls the operating system on instances - of web roles or worker roles and initializes the storage resources that are used by them. If - you do not want to initialize storage resources, you can use Reimage Role Instance. + def begin_assess_patches( + self, resource_group_name: str, vm_name: str, **kwargs: Any + ) -> LROPoller[_models.VirtualMachineAssessPatchesResult]: + """Assess patches on the VM. - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_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 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.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 "2022-09-04")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + 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._rebuild_initial( - role_instance_name=role_instance_name, + raw_result = self._assess_patches_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -1664,41 +2006,38 @@ def begin_rebuild( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineAssessPatchesResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[None].from_continuation_token( + return LROPoller[_models.VirtualMachineAssessPatchesResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[_models.VirtualMachineAssessPatchesResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - @distributed_trace - def get_remote_desktop_file( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any + def _attach_detach_data_disks_initial( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], + **kwargs: Any ) -> Iterator[bytes]: - """Gets a remote desktop file for a role instance in a cloud service. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: Iterator[bytes] or the result of cls(response) - :rtype: Iterator[bytes] - :raises ~azure.core.exceptions.HttpResponseError: - """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1707,18 +2046,29 @@ def get_remote_desktop_file( } 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 "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_cloud_service_role_instances_get_remote_desktop_file_request( - role_instance_name=role_instance_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, "AttachDetachDataDisksRequest") + + _request = build_attach_detach_data_disks_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, ) @@ -1732,7 +2082,7 @@ def get_remote_desktop_file( 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): @@ -1740,202 +2090,153 @@ def get_remote_desktop_file( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + def begin_attach_detach_data_disks( + self, + resource_group_name: str, + vm_name: str, + parameters: _models.AttachDetachDataDisksRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageProfile]: + """Attach and detach data disks to/from the virtual machine. -class CloudServiceRolesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_09_04.ComputeManagementClient`'s - :attr:`cloud_service_roles` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, role_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> _models.CloudServiceRole: - """Gets a role from a cloud service. - - :param role_name: Name of the role. Required. - :type role_name: str - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: CloudServiceRole or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceRole + :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.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.models.StorageProfile] :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 "2022-09-04")) - cls: ClsType[_models.CloudServiceRole] = kwargs.pop("cls", None) - - _request = build_cloud_service_roles_get_request( - role_name=role_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("CloudServiceRole", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + @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. - 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 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.models.StorageProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def list( - self, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> ItemPaged["_models.CloudServiceRole"]: - """Gets a list of all roles in a cloud service. Use nextLink property in the response to get the - next page of roles. Do this till nextLink is null to fetch all the roles. + def begin_attach_detach_data_disks( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.StorageProfile]: + """Attach and detach data disks to/from the virtual machine. - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An iterator like instance of either CloudServiceRole or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_09_04.models.CloudServiceRole] + :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.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.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 "2022-09-04")) - cls: ClsType[_models.CloudServiceRoleListResult] = 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_cloud_service_roles_list_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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 + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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("CloudServiceRoleListResult", 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 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) - - -class CloudServicesOperations: # 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.v2022_09_04.ComputeManagementClient`'s - :attr:`cloud_services` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + elif polling is False: + polling_method = cast(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 _create_or_update_initial( + def _capture_initial( self, resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.CloudService, IO[bytes]]] = None, + vm_name: str, + parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -1949,7 +2250,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) @@ -1959,14 +2260,11 @@ def _create_or_update_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - if parameters is not None: - _json = self._serialize.body(parameters, "CloudService") - else: - _json = None + _json = self._serialize.body(parameters, "VirtualMachineCaptureParameters") - _request = build_cloud_services_create_or_update_request( + _request = build_capture_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -1985,7 +2283,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): @@ -1993,105 +2291,113 @@ 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_capture( self, resource_group_name: str, - cloud_service_name: str, - parameters: Optional[_models.CloudService] = None, + vm_name: str, + parameters: _models.VirtualMachineCaptureParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.CloudService]: - """Create or update a cloud service. Please note some properties can be set only during cloud - service creation. + ) -> 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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.CloudService + :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.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 CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_09_04.models.CloudService] + :return: An instance of LROPoller that returns either VirtualMachineCaptureResult or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachineCaptureResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_or_update( + def begin_capture( self, resource_group_name: str, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, + vm_name: str, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.CloudService]: - """Create or update a cloud service. Please note some properties can be set only during cloud - service creation. + ) -> 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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. Default value is None. + :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 CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_09_04.models.CloudService] + :return: An instance of LROPoller that returns either VirtualMachineCaptureResult or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.VirtualMachineCaptureResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_or_update( + def begin_capture( self, resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.CloudService, IO[bytes]]] = None, + vm_name: str, + parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.CloudService]: - """Create or update a cloud service. Please note some properties can be set only during cloud - service creation. + ) -> 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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. Is either a CloudService type or a IO[bytes] type. - Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.CloudService or IO[bytes] - :return: An instance of LROPoller that returns either CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_09_04.models.CloudService] + :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.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.models.VirtualMachineCaptureResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CloudService] = kwargs.pop("cls", 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._create_or_update_initial( + raw_result = self._capture_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, parameters=parameters, api_version=api_version, content_type=content_type, @@ -2104,34 +2410,32 @@ def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CloudService", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineCaptureResult", 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.CloudService].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[_models.CloudService]( + return LROPoller[_models.VirtualMachineCaptureResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _update_initial( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.CloudServiceUpdate, IO[bytes]]] = None, - **kwargs: Any + def _convert_to_managed_disks_initial( + self, resource_group_name: str, vm_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2141,32 +2445,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 "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) 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, "CloudServiceUpdate") - else: - _json = None - - _request = build_cloud_services_update_request( + _request = build_convert_to_managed_disks_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, ) @@ -2180,7 +2469,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): @@ -2188,105 +2477,162 @@ 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, - cloud_service_name: str, - parameters: Optional[_models.CloudServiceUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CloudService]: - """Update a cloud service. + @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. - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceUpdate - :keyword content_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 CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_09_04.models.CloudService] + :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 {}) - @overload - def begin_update( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CloudService]: - """Update a cloud service. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._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 + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. 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 CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_09_04.models.CloudService] - :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 _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, + 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", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_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 = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace - def begin_update( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.CloudServiceUpdate, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.CloudService]: - """Update a cloud service. + 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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. Is either a CloudServiceUpdate type or a IO[bytes] - type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceUpdate or IO[bytes] - :return: An instance of LROPoller that returns either CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_09_04.models.CloudService] + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param hibernate: Optional parameter to hibernate a virtual machine. Default value is None. + :type hibernate: bool + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CloudService] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._update_initial( + raw_result = self._deallocate_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - parameters=parameters, + vm_name=vm_name, + hibernate=hibernate, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -2295,30 +2641,47 @@ 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("CloudService", 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.CloudService].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.CloudService]( - 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, cloud_service_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, @@ -2330,14 +2693,71 @@ def _delete_initial(self, resource_group_name: str, cloud_service_name: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_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", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_cloud_services_delete_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_install_patches_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, ) @@ -2351,7 +2771,7 @@ def _delete_initial(self, resource_group_name: str, cloud_service_name: str, **k 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): @@ -2359,38 +2779,119 @@ def _delete_initial(self, resource_group_name: str, cloud_service_name: str, **k map_error(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, cloud_service_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a cloud service. + @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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_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 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.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.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.models.VirtualMachineInstallPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_install_patches( + self, + resource_group_name: str, + vm_name: str, + install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: + """Installs patches on the VM. + + :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.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.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 "2022-09-04")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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._delete_initial( + raw_result = self._install_patches_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, @@ -2399,35 +2900,44 @@ def begin_delete(self, resource_group_name: str, cloud_service_name: str, **kwar raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineInstallPatchesResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[None].from_continuation_token( + return LROPoller[_models.VirtualMachineInstallPatchesResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[_models.VirtualMachineInstallPatchesResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace - def get(self, resource_group_name: str, cloud_service_name: str, **kwargs: Any) -> _models.CloudService: - """Display information about a cloud service. + 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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: CloudService or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_09_04.models.CloudService + :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.models.VirtualMachineInstanceView :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2441,12 +2951,12 @@ def get(self, resource_group_name: str, cloud_service_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) - cls: ClsType[_models.CloudService] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) - _request = build_cloud_services_get_request( + _request = build_instance_view_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2465,27 +2975,20 @@ def get(self, resource_group_name: str, cloud_service_name: str, **kwargs: Any) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("CloudService", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineInstanceView", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def get_instance_view( - self, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> _models.CloudServiceInstanceView: - """Gets the status of a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: CloudServiceInstanceView or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceInstanceView - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _migrate_to_vm_scale_set_initial( + self, + resource_group_name: str, + vm_name: str, + parameters: Optional[Union[_models.MigrateVMToVirtualMachineScaleSetInput, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2494,196 +2997,189 @@ 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 "2022-09-04")) - cls: ClsType[_models.CloudServiceInstanceView] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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, "MigrateVMToVirtualMachineScaleSetInput") + else: + _json = None - _request = build_cloud_services_get_instance_view_request( + _request = build_migrate_to_vm_scale_set_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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 [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("CloudServiceInstanceView", 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_all(self, **kwargs: Any) -> ItemPaged["_models.CloudService"]: - """Gets a list of all cloud services in the subscription, regardless of the associated resource - group. Use nextLink property in the response to get the next page of Cloud Services. Do this - till nextLink is null to fetch all the Cloud Services. + @overload + def begin_migrate_to_vm_scale_set( + self, + resource_group_name: str, + vm_name: str, + parameters: Optional[_models.MigrateVMToVirtualMachineScaleSetInput] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. - :return: An iterator like instance of either CloudService or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_09_04.models.CloudService] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Migrate Virtual Machine operation. Default value + is None. + :type parameters: ~azure.mgmt.compute.models.MigrateVMToVirtualMachineScaleSetInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) - cls: ClsType[_models.CloudServiceListResult] = 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_cloud_services_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("CloudServiceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response + @overload + def begin_migrate_to_vm_scale_set( + self, + resource_group_name: str, + vm_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. - 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_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Migrate Virtual Machine operation. Default value + is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.CloudService"]: - """Gets a list of all cloud services under a resource group. Use nextLink property in the response - to get the next page of Cloud Services. Do this till nextLink is null to fetch all the Cloud - Services. + def begin_migrate_to_vm_scale_set( + self, + resource_group_name: str, + vm_name: str, + parameters: Optional[Union[_models.MigrateVMToVirtualMachineScaleSetInput, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. - :param resource_group_name: Name of the 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 CloudService or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_09_04.models.CloudService] + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Migrate Virtual Machine operation. Is either a + MigrateVMToVirtualMachineScaleSetInput type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.models.MigrateVMToVirtualMachineScaleSetInput or + IO[bytes] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) - cls: ClsType[_models.CloudServiceListResult] = 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_cloud_services_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 + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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._migrate_to_vm_scale_set_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - def extract_data(pipeline_response): - deserialized = self._deserialize("CloudServiceListResult", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) + return cls(pipeline_response, None, {}) # type: ignore - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _start_initial(self, resource_group_name: str, cloud_service_name: str, **kwargs: Any) -> Iterator[bytes]: + def _perform_maintenance_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2695,12 +3191,12 @@ def _start_initial(self, resource_group_name: str, cloud_service_name: str, **kw _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_cloud_services_start_request( + _request = build_perform_maintenance_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2724,21 +3220,27 @@ def _start_initial(self, resource_group_name: str, cloud_service_name: str, **kw map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def begin_start(self, resource_group_name: str, cloud_service_name: str, **kwargs: Any) -> LROPoller[None]: - """Starts the cloud service. + 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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_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: @@ -2746,15 +3248,15 @@ def begin_start(self, resource_group_name: str, cloud_service_name: str, **kwarg _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._start_initial( + raw_result = self._perform_maintenance_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -2769,7 +3271,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: @@ -2783,7 +3287,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 _power_off_initial(self, resource_group_name: str, cloud_service_name: str, **kwargs: Any) -> Iterator[bytes]: + 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, @@ -2795,13 +3301,14 @@ def _power_off_initial(self, resource_group_name: str, cloud_service_name: str, _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_cloud_services_power_off_request( + _request = build_power_off_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, + skip_shutdown=skip_shutdown, api_version=api_version, headers=_headers, params=_params, @@ -2824,22 +3331,34 @@ def _power_off_initial(self, resource_group_name: str, cloud_service_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_power_off(self, resource_group_name: str, cloud_service_name: str, **kwargs: Any) -> LROPoller[None]: - """Power off the cloud service. Note that resources are still attached and you are getting charged - for the resources. + 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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param 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. + :type 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: @@ -2847,7 +3366,7 @@ def begin_power_off(self, resource_group_name: str, cloud_service_name: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -2855,7 +3374,8 @@ def begin_power_off(self, resource_group_name: str, cloud_service_name: str, **k if cont_token is None: raw_result = self._power_off_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, + skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -2870,7 +3390,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: @@ -2884,13 +3406,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 _restart_initial( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: + def _reapply_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2899,32 +3415,17 @@ def _restart_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 "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) 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, "RoleInstances") - else: - _json = None - - _request = build_cloud_services_restart_request( + _request = build_reapply_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, ) @@ -2944,104 +3445,46 @@ def _restart_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) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - @overload - def begin_restart( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[_models.RoleInstances] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more role instances in a cloud service. + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.RoleInstances - :keyword content_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: - """ + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - @overload - def begin_restart( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more role instances in a cloud service. + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. 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: - """ + return deserialized # type: ignore @distributed_trace - def begin_restart( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more role instances in a cloud service. + 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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Is either a RoleInstances type or - a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.RoleInstances or IO[bytes] + :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 = 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 "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._restart_initial( + raw_result = self._reapply_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - parameters=parameters, + vm_name=vm_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -3055,7 +3498,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: @@ -3069,13 +3514,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 _reimage_initial( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **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, @@ -3084,32 +3523,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 "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) 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, "RoleInstances") - else: - _json = None - - _request = build_cloud_services_reimage_request( + _request = build_redeploy_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, ) @@ -3131,105 +3555,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, - cloud_service_name: str, - parameters: Optional[_models.RoleInstances] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimage asynchronous operation reinstalls the operating system on instances of web roles or - worker roles. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.RoleInstances - :keyword content_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, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimage asynchronous operation reinstalls the operating system on instances of web roles or - worker roles. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. 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, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Reimage asynchronous operation reinstalls the operating system on instances of web roles or - worker roles. + 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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Is either a RoleInstances type or - a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.RoleInstances or IO[bytes] + :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 = 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 "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._reimage_initial( + raw_result = self._redeploy_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - parameters=parameters, + vm_name=vm_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -3243,7 +3606,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: @@ -3257,11 +3622,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 - def _rebuild_initial( + def _reimage_initial( self, resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, + vm_name: str, + parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -3275,7 +3640,7 @@ def _rebuild_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) @@ -3286,13 +3651,13 @@ def _rebuild_initial( _content = parameters else: if parameters is not None: - _json = self._serialize.body(parameters, "RoleInstances") + _json = self._serialize.body(parameters, "VirtualMachineReimageParameters") else: _json = None - _request = build_cloud_services_rebuild_request( + _request = build_reimage_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3319,33 +3684,43 @@ def _rebuild_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_rebuild( + def begin_reimage( self, resource_group_name: str, - cloud_service_name: str, - parameters: Optional[_models.RoleInstances] = None, + vm_name: str, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: - """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker - roles and initializes the storage resources that are used by them. If you do not want to - initialize storage resources, you can use Reimage Role Instances. - - :param resource_group_name: Name of the resource group. Required. + """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, + for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial + state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If + deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is + delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should + be updated accordingly before performing the reimage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.RoleInstances + :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.models.VirtualMachineReimageParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -3355,24 +3730,29 @@ def begin_rebuild( """ @overload - def begin_rebuild( + def begin_reimage( self, resource_group_name: str, - cloud_service_name: str, + vm_name: str, parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: - """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker - roles and initializes the storage resources that are used by them. If you do not want to - initialize storage resources, you can use Reimage Role Instances. - - :param resource_group_name: Name of the resource group. Required. + """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, + for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial + state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If + deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is + delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should + be updated accordingly before performing the reimage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. + :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". @@ -3383,24 +3763,28 @@ def begin_rebuild( """ @distributed_trace - def begin_rebuild( + def begin_reimage( self, resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, + vm_name: str, + parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[None]: - """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker - roles and initializes the storage resources that are used by them. If you do not want to - initialize storage resources, you can use Reimage Role Instances. - - :param resource_group_name: Name of the resource group. Required. + """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, + for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial + state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If + deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is + delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should + be updated accordingly before performing the reimage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Is either a RoleInstances type or - a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.RoleInstances or IO[bytes] + :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.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: @@ -3408,16 +3792,16 @@ def begin_rebuild( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) 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._rebuild_initial( + raw_result = self._reimage_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, + vm_name=vm_name, parameters=parameters, api_version=api_version, content_type=content_type, @@ -3434,7 +3818,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: @@ -3448,13 +3834,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 _delete_instances_initial( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **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, @@ -3463,32 +3843,17 @@ 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 "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) 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, "RoleInstances") - else: - _json = None - - _request = build_cloud_services_delete_instances_request( + _request = build_restart_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, ) @@ -3510,102 +3875,44 @@ def _delete_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 == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - def begin_delete_instances( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[_models.RoleInstances] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Deletes role instances in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.RoleInstances - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_delete_instances( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Deletes role instances in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. 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_delete_instances( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes role instances in a cloud service. + 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: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Is either a RoleInstances type or - a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.RoleInstances or IO[bytes] + :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 = 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 "2022-09-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._restart_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - parameters=parameters, + vm_name=vm_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -3619,7 +3926,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: @@ -3633,33 +3942,77 @@ 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. -class CloudServicesUpdateDomainOperations: - """ - .. 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_name: The name of the virtual machine. Required. + :type vm_name: str + :param 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. + :type sas_uri_expiration_time_in_minutes: int + :return: RetrieveBootDiagnosticsDataResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.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 {}) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_09_04.ComputeManagementClient`'s - :attr:`cloud_services_update_domain` 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", "2024-11-01")) + cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_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 = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def _walk_update_domain_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("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, - cloud_service_name: str, - update_domain: int, - parameters: Optional[Union[_models.UpdateDomain, IO[bytes]]] = None, + vm_name: str, + parameters: Union[_models.RunCommandInput, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -3673,7 +4026,7 @@ def _walk_update_domain_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) @@ -3682,16 +4035,12 @@ def _walk_update_domain_initial( _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "UpdateDomain") - else: - _json = None + else: + _json = self._serialize.body(parameters, "RunCommandInput") - _request = build_cloud_services_update_domain_walk_update_domain_request( + _request = build_run_command_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - update_domain=update_domain, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3718,115 +4067,110 @@ def _walk_update_domain_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_walk_update_domain( + def begin_run_command( self, resource_group_name: str, - cloud_service_name: str, - update_domain: int, - parameters: Optional[_models.UpdateDomain] = None, + vm_name: str, + parameters: _models.RunCommandInput, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Updates the role instances in the specified update domain. + ) -> LROPoller[_models.RunCommandResult]: + """Run command on the VM. - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param update_domain: Specifies an integer value that identifies the update domain. Update - domains are identified with a zero-based index: the first update domain has an ID of 0, the - second has an ID of 1, and so on. Required. - :type update_domain: int - :param parameters: The update domain object. Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.UpdateDomain + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Run command operation. Required. + :type parameters: ~azure.mgmt.compute.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 None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An instance of LROPoller that returns either RunCommandResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_walk_update_domain( + def begin_run_command( self, resource_group_name: str, - cloud_service_name: str, - update_domain: int, - parameters: Optional[IO[bytes]] = None, + vm_name: str, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Updates the role instances in the specified update domain. + ) -> LROPoller[_models.RunCommandResult]: + """Run command on the VM. - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param update_domain: Specifies an integer value that identifies the update domain. Update - domains are identified with a zero-based index: the first update domain has an ID of 0, the - second has an ID of 1, and so on. Required. - :type update_domain: int - :param parameters: The update domain object. Default value is None. + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Run command operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An instance of LROPoller that returns either RunCommandResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_walk_update_domain( + def begin_run_command( self, resource_group_name: str, - cloud_service_name: str, - update_domain: int, - parameters: Optional[Union[_models.UpdateDomain, IO[bytes]]] = None, + vm_name: str, + parameters: Union[_models.RunCommandInput, IO[bytes]], **kwargs: Any - ) -> LROPoller[None]: - """Updates the role instances in the specified update domain. + ) -> LROPoller[_models.RunCommandResult]: + """Run command on the VM. - :param resource_group_name: Name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param update_domain: Specifies an integer value that identifies the update domain. Update - domains are identified with a zero-based index: the first update domain has an ID of 0, the - second has an ID of 1, and so on. Required. - :type update_domain: int - :param parameters: The update domain object. Is either a UpdateDomain type or a IO[bytes] type. - Default value is None. - :type parameters: ~azure.mgmt.compute.v2022_09_04.models.UpdateDomain 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 vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Run command operation. Is either a + RunCommandInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.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.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = 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._walk_update_domain_initial( + raw_result = self._run_command_initial( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - update_domain=update_domain, + vm_name=vm_name, parameters=parameters, api_version=api_version, content_type=content_type, @@ -3838,43 +4182,44 @@ def begin_walk_update_domain( 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("RunCommandResult", 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.RunCommandResult].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.RunCommandResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace - def get_update_domain( - self, resource_group_name: str, cloud_service_name: str, update_domain: int, **kwargs: Any - ) -> _models.UpdateDomain: - """Gets the specified update domain of a cloud service. Use nextLink property in the response to - get the next page of update domains. Do this till nextLink is null to fetch all the update - domains. - - :param resource_group_name: Name of the resource group. Required. + 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. The name is case insensitive. + Required. :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param update_domain: Specifies an integer value that identifies the update domain. Update - domains are identified with a zero-based index: the first update domain has an ID of 0, the - second has an ID of 1, and so on. Required. - :type update_domain: int - :return: UpdateDomain or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_09_04.models.UpdateDomain + :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 = { @@ -3888,13 +4233,12 @@ def get_update_domain( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) - cls: ClsType[_models.UpdateDomain] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_cloud_services_update_domain_get_update_domain_request( + _request = build_simulate_eviction_request( resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - update_domain=update_domain, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3909,133 +4253,14 @@ def get_update_domain( 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("UpdateDomain", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_update_domains( - self, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> ItemPaged["_models.UpdateDomain"]: - """Gets a list of all update domains in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An iterator like instance of either UpdateDomain or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_09_04.models.UpdateDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) - cls: ClsType[_models.UpdateDomainListResult] = 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_cloud_services_update_domain_list_update_domains_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("UpdateDomainListResult", 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 CloudServiceOperatingSystemsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_09_04.ComputeManagementClient`'s - :attr:`cloud_service_operating_systems` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_os_version(self, location: str, os_version_name: str, **kwargs: Any) -> _models.OSVersion: - """Gets properties of a guest operating system version that can be specified in the XML service - configuration (.cscfg) for a cloud service. + return cls(pipeline_response, None, {}) # type: ignore - :param location: Name of the location that the OS version pertains to. Required. - :type location: str - :param os_version_name: Name of the OS version. Required. - :type os_version_name: str - :return: OSVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_09_04.models.OSVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _start_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4047,12 +4272,12 @@ def get_os_version(self, location: str, os_version_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-09-04")) - cls: ClsType[_models.OSVersion] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_cloud_service_operating_systems_get_os_version_request( - location=location, - os_version_name=os_version_name, + _request = build_start_request( + resource_group_name=resource_group_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4060,175 +4285,110 @@ def get_os_version(self, location: str, os_version_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("OSVersion", 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_os_versions(self, location: str, **kwargs: Any) -> ItemPaged["_models.OSVersion"]: - """Gets a list of all guest operating system versions available to be specified in the XML service - configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the - next page of OS versions. Do this till nextLink is null to fetch all the OS versions. + def begin_start(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: + """The operation to start a virtual machine. - :param location: Name of the location that the OS versions pertain to. Required. - :type location: str - :return: An iterator like instance of either OSVersion or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_09_04.models.OSVersion] + :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 "2022-09-04")) - cls: ClsType[_models.OSVersionListResult] = 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_cloud_service_operating_systems_list_os_versions_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 + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._start_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 extract_data(pipeline_response): - deserialized = self._deserialize("OSVersionListResult", 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) - - @distributed_trace - def get_os_family(self, location: str, os_family_name: str, **kwargs: Any) -> _models.OSFamily: - """Gets properties of a guest operating system family that can be specified in the XML service - configuration (.cscfg) for a cloud service. - - :param location: Name of the location that the OS family pertains to. Required. - :type location: str - :param os_family_name: Name of the OS family. Required. - :type os_family_name: str - :return: OSFamily or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_09_04.models.OSFamily - :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 "2022-09-04")) - cls: ClsType[_models.OSFamily] = kwargs.pop("cls", None) - - _request = build_cloud_service_operating_systems_get_os_family_request( - location=location, - os_family_name=os_family_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("OSFamily", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + 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_os_families(self, location: str, **kwargs: Any) -> ItemPaged["_models.OSFamily"]: - """Gets a list of all guest operating system families available to be specified in the XML service - configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the - next page of OS Families. Do this till nextLink is null to fetch all the OS Families. - - :param location: Name of the location that the OS families pertain to. Required. - :type location: str - :return: An iterator like instance of either OSFamily or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_09_04.models.OSFamily] + def list_available_sizes( + self, resource_group_name: str, vm_name: str, **kwargs: Any + ) -> ItemPaged["_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.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 "2022-09-04")) - cls: ClsType[_models.OSFamilyListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4241,8 +4401,9 @@ def list_os_families(self, location: str, **kwargs: Any) -> ItemPaged["_models.O def prepare_request(next_link=None): if not next_link: - _request = build_cloud_service_operating_systems_list_os_families_request( - location=location, + _request = build_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, @@ -4251,24 +4412,13 @@ def prepare_request(next_link=None): _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 = HttpRequest("GET", next_link) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): - deserialized = self._deserialize("OSFamilyListResult", pipeline_response) + deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2016_03_30/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_compute_management_client.py deleted file mode 100644 index b38aa7a3fcd0..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_compute_management_client.py +++ /dev/null @@ -1,173 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ( - AvailabilitySetsOperations, - UsageOperations, - VirtualMachineExtensionImagesOperations, - VirtualMachineExtensionsOperations, - VirtualMachineImagesOperations, - VirtualMachineScaleSetVMsOperations, - VirtualMachineScaleSetsOperations, - VirtualMachineSizesOperations, - VirtualMachinesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2016_03_30.operations.AvailabilitySetsOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2016_03_30.operations.VirtualMachineExtensionImagesOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2016_03_30.operations.VirtualMachineExtensionsOperations - :ivar virtual_machines: VirtualMachinesOperations operations - :vartype virtual_machines: azure.mgmt.compute.v2016_03_30.operations.VirtualMachinesOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2016_03_30.operations.VirtualMachineImagesOperations - :ivar usage: UsageOperations operations - :vartype usage: azure.mgmt.compute.v2016_03_30.operations.UsageOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2016_03_30.operations.VirtualMachineSizesOperations - :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations - :vartype virtual_machine_scale_sets: - azure.mgmt.compute.v2016_03_30.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2016_03_30.operations.VirtualMachineScaleSetVMsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2016-03-30". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.availability_sets = AvailabilitySetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2016-03-30" - ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2016-03-30" - ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2016-03-30" - ) - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2016-03-30" - ) - self.virtual_machine_images = VirtualMachineImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2016-03-30" - ) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2016-03-30") - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2016-03-30" - ) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2016-03-30" - ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( - self._client, self._config, self._serialize, self._deserialize, "2016-03-30" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_configuration.py deleted file mode 100644 index bdd2989f6395..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2016-03-30". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2016-03-30") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_metadata.json deleted file mode 100644 index 737cec47afbe..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_metadata.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "chosen_version": "2016-03-30", - "total_api_version_list": ["2016-03-30"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "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.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "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.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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": { - "availability_sets": "AvailabilitySetsOperations", - "virtual_machine_extension_images": "VirtualMachineExtensionImagesOperations", - "virtual_machine_extensions": "VirtualMachineExtensionsOperations", - "virtual_machines": "VirtualMachinesOperations", - "virtual_machine_images": "VirtualMachineImagesOperations", - "usage": "UsageOperations", - "virtual_machine_sizes": "VirtualMachineSizesOperations", - "virtual_machine_scale_sets": "VirtualMachineScaleSetsOperations", - "virtual_machine_scale_set_vms": "VirtualMachineScaleSetVMsOperations" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ 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 deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2016_03_30/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/_compute_management_client.py deleted file mode 100644 index 163be6650839..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/_compute_management_client.py +++ /dev/null @@ -1,178 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ( - AvailabilitySetsOperations, - UsageOperations, - VirtualMachineExtensionImagesOperations, - VirtualMachineExtensionsOperations, - VirtualMachineImagesOperations, - VirtualMachineScaleSetVMsOperations, - VirtualMachineScaleSetsOperations, - VirtualMachineSizesOperations, - VirtualMachinesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2016_03_30.aio.operations.AvailabilitySetsOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2016_03_30.aio.operations.VirtualMachineExtensionImagesOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2016_03_30.aio.operations.VirtualMachineExtensionsOperations - :ivar virtual_machines: VirtualMachinesOperations operations - :vartype virtual_machines: - azure.mgmt.compute.v2016_03_30.aio.operations.VirtualMachinesOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2016_03_30.aio.operations.VirtualMachineImagesOperations - :ivar usage: UsageOperations operations - :vartype usage: azure.mgmt.compute.v2016_03_30.aio.operations.UsageOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2016_03_30.aio.operations.VirtualMachineSizesOperations - :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations - :vartype virtual_machine_scale_sets: - azure.mgmt.compute.v2016_03_30.aio.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2016_03_30.aio.operations.VirtualMachineScaleSetVMsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2016-03-30". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.availability_sets = AvailabilitySetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2016-03-30" - ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2016-03-30" - ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2016-03-30" - ) - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2016-03-30" - ) - self.virtual_machine_images = VirtualMachineImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2016-03-30" - ) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2016-03-30") - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2016-03-30" - ) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2016-03-30" - ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( - self._client, self._config, self._serialize, self._deserialize, "2016-03-30" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/_configuration.py deleted file mode 100644 index 565952c24cce..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2016-03-30". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2016-03-30") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/__init__.py deleted file mode 100644 index c585bc95261e..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/__init__.py +++ /dev/null @@ -1,41 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import AvailabilitySetsOperations # type: ignore -from ._operations import VirtualMachineExtensionImagesOperations # type: ignore -from ._operations import VirtualMachineExtensionsOperations # type: ignore -from ._operations import VirtualMachinesOperations # type: ignore -from ._operations import VirtualMachineImagesOperations # type: ignore -from ._operations import UsageOperations # type: ignore -from ._operations import VirtualMachineSizesOperations # type: ignore -from ._operations import VirtualMachineScaleSetsOperations # type: ignore -from ._operations import VirtualMachineScaleSetVMsOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AvailabilitySetsOperations", - "VirtualMachineExtensionImagesOperations", - "VirtualMachineExtensionsOperations", - "VirtualMachinesOperations", - "VirtualMachineImagesOperations", - "UsageOperations", - "VirtualMachineSizesOperations", - "VirtualMachineScaleSetsOperations", - "VirtualMachineScaleSetVMsOperations", -] -__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/v2016_03_30/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_operations.py deleted file mode 100644 index 373080251731..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_operations.py +++ /dev/null @@ -1,6414 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, Dict, IO, List, Literal, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import ( - build_availability_sets_create_or_update_request, - build_availability_sets_delete_request, - build_availability_sets_get_request, - build_availability_sets_list_available_sizes_request, - build_availability_sets_list_by_subscription_request, - build_availability_sets_list_request, - build_usage_list_request, - build_virtual_machine_extension_images_get_request, - build_virtual_machine_extension_images_list_types_request, - build_virtual_machine_extension_images_list_versions_request, - build_virtual_machine_extensions_create_or_update_request, - build_virtual_machine_extensions_delete_request, - build_virtual_machine_extensions_get_request, - build_virtual_machine_extensions_update_request, - build_virtual_machine_images_get_request, - build_virtual_machine_images_list_offers_request, - build_virtual_machine_images_list_publishers_request, - build_virtual_machine_images_list_request, - build_virtual_machine_images_list_skus_request, - build_virtual_machine_scale_set_vms_deallocate_request, - build_virtual_machine_scale_set_vms_delete_request, - build_virtual_machine_scale_set_vms_get_instance_view_request, - build_virtual_machine_scale_set_vms_get_request, - build_virtual_machine_scale_set_vms_list_request, - build_virtual_machine_scale_set_vms_power_off_request, - build_virtual_machine_scale_set_vms_reimage_request, - build_virtual_machine_scale_set_vms_restart_request, - build_virtual_machine_scale_set_vms_start_request, - build_virtual_machine_scale_sets_create_or_update_request, - build_virtual_machine_scale_sets_deallocate_request, - build_virtual_machine_scale_sets_delete_instances_request, - build_virtual_machine_scale_sets_delete_request, - build_virtual_machine_scale_sets_get_instance_view_request, - build_virtual_machine_scale_sets_get_request, - build_virtual_machine_scale_sets_list_all_request, - build_virtual_machine_scale_sets_list_request, - build_virtual_machine_scale_sets_list_skus_request, - build_virtual_machine_scale_sets_power_off_request, - build_virtual_machine_scale_sets_reimage_request, - build_virtual_machine_scale_sets_restart_request, - build_virtual_machine_scale_sets_start_request, - build_virtual_machine_scale_sets_update_instances_request, - build_virtual_machine_sizes_list_request, - build_virtual_machines_capture_request, - build_virtual_machines_create_or_update_request, - build_virtual_machines_deallocate_request, - build_virtual_machines_delete_request, - build_virtual_machines_generalize_request, - build_virtual_machines_get_extensions_request, - build_virtual_machines_get_request, - build_virtual_machines_list_all_request, - build_virtual_machines_list_available_sizes_request, - build_virtual_machines_list_request, - build_virtual_machines_power_off_request, - build_virtual_machines_redeploy_request, - build_virtual_machines_restart_request, - build_virtual_machines_start_request, -) -from .._configuration import ComputeManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AvailabilitySetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2016_03_30.aio.ComputeManagementClient`'s - :attr:`availability_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - name: str, - parameters: _models.AvailabilitySet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param name: The name of the availability set. Required. - :type name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2016_03_30.models.AvailabilitySet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2016_03_30.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param name: The name of the availability set. Required. - :type name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2016_03_30.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, resource_group_name: str, name: str, parameters: Union[_models.AvailabilitySet, IO[bytes]], **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param name: The name of the availability set. Required. - :type 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.v2016_03_30.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySet") - - _request = build_availability_sets_create_or_update_request( - resource_group_name=resource_group_name, - name=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("AvailabilitySet", 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 - ) -> Optional[_models.OperationStatusResponse]: - """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: OperationStatusResponse or None or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse or 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 "2016-03-30")) - cls: ClsType[Optional[_models.OperationStatusResponse]] = kwargs.pop("cls", None) - - _request = build_availability_sets_delete_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("OperationStatusResponse", 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, 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.v2016_03_30.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", 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) - - _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("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription( - self, *, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. - - :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.v2016_03_30.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 "2016-03-30")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, 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(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets 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 AvailabilitySet or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, 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_available_sizes( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes that can be used to create a new virtual machine in - an existing availability set. - - :param resource_group_name: The name of the resource group. Required. - :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.v2016_03_30.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 "2016-03-30")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_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 - - if response.status_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 VirtualMachineExtensionImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2016_03_30.aio.ComputeManagementClient`'s - :attr:`virtual_machine_extension_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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. - - :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.v2016_03_30.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 "2016-03-30")) - 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 = 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 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 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.v2016_03_30.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 "2016-03-30")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - - _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) - - _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 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 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.v2016_03_30.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 "2016-03-30")) - 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 = 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 - - -class VirtualMachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2016_03_30.aio.ComputeManagementClient`'s - :attr:`virtual_machine_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, 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 "2016-03-30")) - 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, "VirtualMachineExtension") - - _request = build_virtual_machine_extensions_create_or_update_request( - resource_group_name=resource_group_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, - 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) - - 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, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2016_03_30.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 VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_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 create or 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 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] - :keyword content_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.v2016_03_30.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2016_03_30.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.v2016_03_30.models.VirtualMachineExtension] - :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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2016-03-30")) - 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( - resource_group_name=resource_group_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, - 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, - 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. - - :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: - ~azure.mgmt.compute.v2016_03_30.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.v2016_03_30.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.v2016_03_30.models.VirtualMachineExtension] - :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.v2016_03_30.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.v2016_03_30.models.VirtualMachineExtension] - :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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2016-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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) - - _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, vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """The operation to delete 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 deleted. - 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - vm_extension_name=vm_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, - 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.v2016_03_30.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 "2016-03-30")) - cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_get_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -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.v2016_03_30.aio.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_extensions( - 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.v2016_03_30.models.VirtualMachineExtensionsListResult - :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 "2016-03-30")) - cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machines_get_extensions_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 - - 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, - 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 "2016-03-30")) - 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, "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 = 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_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. 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.v2016_03_30.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.v2016_03_30.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. 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.v2016_03_30.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. 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.v2016_03_30.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.v2016_03_30.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - 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 - ) - 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) - 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": "azure-async-operation"}, **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 _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, 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 "2016-03-30")) - 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, - 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) - - 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, - vm_name: str, - parameters: _models.VirtualMachine, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to create or 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 Create Virtual Machine operation. Required. - :type parameters: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachine - :keyword content_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.v2016_03_30.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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to create or 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 Create 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 VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to create or 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 Create Virtual Machine operation. Is either a - VirtualMachine type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachine or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - 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, - 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, **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, **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 "2016-03-30")) - 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, - 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, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """The operation to delete 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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: Literal["instanceView"] = "instanceView", **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - 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 _deallocate_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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - 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, - 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, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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 - ) -> _models.OperationStatusResponse: - """Sets the state of the virtual machine to generalized. - - :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: OperationStatusResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse - :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 "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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) - - deserialized = self._deserialize("OperationStatusResponse", 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) -> AsyncItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - 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, - 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("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) - - 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) -> AsyncItemPaged["_models.VirtualMachine"]: - """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. - - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - 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, - 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("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) - - 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_available_sizes( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes to which the specified virtual machine can be - resized. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_available_sizes_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 - - if response.status_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_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 "2016-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_power_off_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_power_off( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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. - :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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._power_off_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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]: - 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 "2016-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_restart_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - 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_restart( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """The operation to restart 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._restart_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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]: - 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 "2016-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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_start( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2016-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_redeploy_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_redeploy( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._redeploy_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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.v2016_03_30.aio.ComputeManagementClient`'s - :attr:`virtual_machine_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.v2016_03_30.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 "2016-03-30")) - 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.v2016_03_30.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 "2016-03-30")) - 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.v2016_03_30.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 "2016-03-30")) - 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. - - :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.v2016_03_30.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 "2016-03-30")) - 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) - 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. - - :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.v2016_03_30.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 "2016-03-30")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _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) - - _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 - - -class UsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2016_03_30.aio.ComputeManagementClient`'s - :attr:`usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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 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.v2016_03_30.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 "2016-03-30")) - 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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ListUsagesResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class VirtualMachineSizesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2016_03_30.aio.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes for a subscription in a location. - - :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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_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 - - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2016_03_30.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - name: str, - parameters: Union[_models.VirtualMachineScaleSet, 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 "2016-03-30")) - 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, - name=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) - - 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, - name: str, - parameters: _models.VirtualMachineScaleSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param name: The name of the VM scale set to create or update. Required. - :type name: str - :param parameters: The scale set object. Required. - :type parameters: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSet - :keyword content_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.v2016_03_30.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param name: The name of the VM scale set to create or update. Required. - :type name: str - :param parameters: The scale set object. 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 VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param name: The name of the VM scale set to create or update. Required. - :type name: str - :param parameters: The scale set object. Is either a VirtualMachineScaleSet type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSet or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - 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, - name=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("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 _delete_initial( - self, resource_group_name: str, vm_scale_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 "2016-03-30")) - cls: ClsType[AsyncIterator[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, - 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, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, **kwargs: Any - ) -> _models.VirtualMachineScaleSet: - """Display information about a 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 - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - 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, - 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 _deallocate_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 "2016-03-30")) - 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_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_deallocate( - 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[_models.OperationStatusResponse]: - """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. - :type 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.v2016_03_30.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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_deallocate( - 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[_models.OperationStatusResponse]: - """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. - :type 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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, - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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. - :type 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.v2016_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2016-03-30")) - 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: - _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, - 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_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2016_03_30.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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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. - 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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.v2016_03_30.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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.v2016_03_30.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 "2016-03-30")) - 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) -> AsyncItemPaged["_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 - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - 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_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("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 - def list_all(self, **kwargs: Any) -> AsyncItemPaged["_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.v2016_03_30.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 "2016-03-30")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = 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_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("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) - - 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_skus( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineScaleSetSku"]: - """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM - instances allowed for each SKU. - - :param resource_group_name: The name of the resource group. Required. - :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.v2016_03_30.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 "2016-03-30")) - 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 - - 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 _power_off_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 "2016-03-30")) - 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_power_off_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_power_off( - 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[_models.OperationStatusResponse]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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.v2016_03_30.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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_power_off( - 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[_models.OperationStatusResponse]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async 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, - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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.v2016_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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 "2016-03-30")) - 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_restart_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2016_03_30.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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, - 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 "2016-03-30")) - 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 - 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_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[_models.OperationStatusResponse]: - """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.v2016_03_30.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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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.v2016_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2016-03-30")) - 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: - _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, - 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_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2016_03_30.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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, **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 "2016-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_sets_reimage_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - 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_reimage( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Reimages (upgrade the operating system) 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 - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineScaleSetVMsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2016_03_30.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _reimage_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **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 "2016-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_reimage_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - 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 - - @distributed_trace_async - async def begin_reimage( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _deallocate_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_deallocate( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and - releases the compute resources it uses. You are not billed for the compute resources of this - virtual machine once it is deallocated. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, **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 "2016-03-30")) - 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, - 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, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Deletes 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: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, **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 - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - 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, - 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("VirtualMachineScaleSetVM", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_instance_view( - self, resource_group_name: str, vm_scale_set_name: str, 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.v2016_03_30.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 "2016-03-30")) - 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 - ) -> AsyncItemPaged["_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.v2016_03_30.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 "2016-03-30")) - 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, **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 "2016-03-30")) - 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, - 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, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, - 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 "2016-03-30")) - cls: ClsType[AsyncIterator[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 = 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_restart( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Restarts 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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 - ) -> 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 "2016-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_start_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - 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[_models.OperationStatusResponse]: - """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 - :param vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/__init__.py deleted file mode 100644 index c2171ba8800c..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/__init__.py +++ /dev/null @@ -1,222 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - AdditionalUnattendContent, - ApiEntityReference, - ApiError, - ApiErrorBase, - AvailabilitySet, - AvailabilitySetListResult, - BootDiagnostics, - BootDiagnosticsInstanceView, - ComputeLongRunningOperationProperties, - DataDisk, - DataDiskImage, - DiagnosticsProfile, - DiskEncryptionSettings, - DiskInstanceView, - HardwareProfile, - ImageReference, - InnerError, - InstanceViewStatus, - KeyVaultKeyReference, - KeyVaultSecretReference, - LinuxConfiguration, - ListUsagesResult, - NetworkInterfaceReference, - NetworkProfile, - OSDisk, - OSDiskImage, - OSProfile, - OperationStatusResponse, - Plan, - PurchasePlan, - Resource, - Sku, - SshConfiguration, - SshPublicKey, - StorageProfile, - SubResource, - UpdateResource, - UpgradePolicy, - Usage, - UsageName, - VaultCertificate, - VaultSecretGroup, - VirtualHardDisk, - VirtualMachine, - VirtualMachineAgentInstanceView, - VirtualMachineCaptureParameters, - VirtualMachineCaptureResult, - VirtualMachineExtension, - VirtualMachineExtensionHandlerInstanceView, - VirtualMachineExtensionImage, - VirtualMachineExtensionInstanceView, - VirtualMachineExtensionUpdate, - VirtualMachineExtensionsListResult, - VirtualMachineIdentity, - VirtualMachineImage, - VirtualMachineImageResource, - VirtualMachineInstanceView, - VirtualMachineListResult, - VirtualMachineScaleSet, - VirtualMachineScaleSetExtension, - VirtualMachineScaleSetExtensionProfile, - VirtualMachineScaleSetIPConfiguration, - VirtualMachineScaleSetIdentity, - VirtualMachineScaleSetInstanceView, - VirtualMachineScaleSetInstanceViewStatusesSummary, - VirtualMachineScaleSetListResult, - VirtualMachineScaleSetListSkusResult, - VirtualMachineScaleSetListWithLinkResult, - VirtualMachineScaleSetNetworkConfiguration, - VirtualMachineScaleSetNetworkProfile, - VirtualMachineScaleSetOSDisk, - VirtualMachineScaleSetOSProfile, - VirtualMachineScaleSetSku, - VirtualMachineScaleSetSkuCapacity, - VirtualMachineScaleSetStorageProfile, - VirtualMachineScaleSetVM, - VirtualMachineScaleSetVMExtensionsSummary, - VirtualMachineScaleSetVMInstanceIDs, - VirtualMachineScaleSetVMInstanceRequiredIDs, - VirtualMachineScaleSetVMInstanceView, - VirtualMachineScaleSetVMListResult, - VirtualMachineScaleSetVMProfile, - VirtualMachineSize, - VirtualMachineSizeListResult, - VirtualMachineStatusCodeCount, - WinRMConfiguration, - WinRMListener, - WindowsConfiguration, -) - -from ._compute_management_client_enums import ( # type: ignore - CachingTypes, - DiskCreateOptionTypes, - OperatingSystemTypes, - ProtocolTypes, - SettingNames, - StatusLevelTypes, - UpgradeMode, - VirtualMachineScaleSetSkuScaleType, - VirtualMachineSizeTypes, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AdditionalUnattendContent", - "ApiEntityReference", - "ApiError", - "ApiErrorBase", - "AvailabilitySet", - "AvailabilitySetListResult", - "BootDiagnostics", - "BootDiagnosticsInstanceView", - "ComputeLongRunningOperationProperties", - "DataDisk", - "DataDiskImage", - "DiagnosticsProfile", - "DiskEncryptionSettings", - "DiskInstanceView", - "HardwareProfile", - "ImageReference", - "InnerError", - "InstanceViewStatus", - "KeyVaultKeyReference", - "KeyVaultSecretReference", - "LinuxConfiguration", - "ListUsagesResult", - "NetworkInterfaceReference", - "NetworkProfile", - "OSDisk", - "OSDiskImage", - "OSProfile", - "OperationStatusResponse", - "Plan", - "PurchasePlan", - "Resource", - "Sku", - "SshConfiguration", - "SshPublicKey", - "StorageProfile", - "SubResource", - "UpdateResource", - "UpgradePolicy", - "Usage", - "UsageName", - "VaultCertificate", - "VaultSecretGroup", - "VirtualHardDisk", - "VirtualMachine", - "VirtualMachineAgentInstanceView", - "VirtualMachineCaptureParameters", - "VirtualMachineCaptureResult", - "VirtualMachineExtension", - "VirtualMachineExtensionHandlerInstanceView", - "VirtualMachineExtensionImage", - "VirtualMachineExtensionInstanceView", - "VirtualMachineExtensionUpdate", - "VirtualMachineExtensionsListResult", - "VirtualMachineIdentity", - "VirtualMachineImage", - "VirtualMachineImageResource", - "VirtualMachineInstanceView", - "VirtualMachineListResult", - "VirtualMachineScaleSet", - "VirtualMachineScaleSetExtension", - "VirtualMachineScaleSetExtensionProfile", - "VirtualMachineScaleSetIPConfiguration", - "VirtualMachineScaleSetIdentity", - "VirtualMachineScaleSetInstanceView", - "VirtualMachineScaleSetInstanceViewStatusesSummary", - "VirtualMachineScaleSetListResult", - "VirtualMachineScaleSetListSkusResult", - "VirtualMachineScaleSetListWithLinkResult", - "VirtualMachineScaleSetNetworkConfiguration", - "VirtualMachineScaleSetNetworkProfile", - "VirtualMachineScaleSetOSDisk", - "VirtualMachineScaleSetOSProfile", - "VirtualMachineScaleSetSku", - "VirtualMachineScaleSetSkuCapacity", - "VirtualMachineScaleSetStorageProfile", - "VirtualMachineScaleSetVM", - "VirtualMachineScaleSetVMExtensionsSummary", - "VirtualMachineScaleSetVMInstanceIDs", - "VirtualMachineScaleSetVMInstanceRequiredIDs", - "VirtualMachineScaleSetVMInstanceView", - "VirtualMachineScaleSetVMListResult", - "VirtualMachineScaleSetVMProfile", - "VirtualMachineSize", - "VirtualMachineSizeListResult", - "VirtualMachineStatusCodeCount", - "WinRMConfiguration", - "WinRMListener", - "WindowsConfiguration", - "CachingTypes", - "DiskCreateOptionTypes", - "OperatingSystemTypes", - "ProtocolTypes", - "SettingNames", - "StatusLevelTypes", - "UpgradeMode", - "VirtualMachineScaleSetSkuScaleType", - "VirtualMachineSizeTypes", -] -__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/v2016_03_30/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/_compute_management_client_enums.py deleted file mode 100644 index 315c9749872d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/_compute_management_client_enums.py +++ /dev/null @@ -1,169 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the caching requirements. :code:`
`\\ :code:`
` Possible values are: - :code:`
`\\ :code:`
` **None** :code:`
`\\ :code:`
` **ReadOnly** :code:`
`\\ - :code:`
` **ReadWrite** :code:`
`\\ :code:`
` Default: **None for Standard storage. - ReadOnly for Premium storage**. - """ - - NONE = "None" - READ_ONLY = "ReadOnly" - READ_WRITE = "ReadWrite" - - -class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies how the virtual machine should be created.\\ :code:`
`\\ :code:`
` Possible - values are:\\ :code:`
`\\ :code:`
` **Attach** \\u2013 This value is used when you are - using a specialized disk to create the virtual machine.\\ :code:`
`\\ :code:`
` - **FromImage** \\u2013 This value is used when you are using an image to create the virtual - machine. If you are using a platform image, you also use the imageReference element described - above. If you are using a marketplace image, you also use the plan element previously - described. - """ - - FROM_IMAGE = "FromImage" - EMPTY = "Empty" - ATTACH = "Attach" - - -class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The operating system of the osDiskImage.""" - - WINDOWS = "Windows" - LINUX = "Linux" - - -class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the protocol of listener. :code:`
`\\ :code:`
` Possible values are: - :code:`
`\\ **http** :code:`
`\\ :code:`
` **https**. - """ - - HTTP = "Http" - HTTPS = "Https" - - -class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the name of the setting to which the content applies. Possible values are: - FirstLogonCommands and AutoLogon. - """ - - AUTO_LOGON = "AutoLogon" - FIRST_LOGON_COMMANDS = "FirstLogonCommands" - - -class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The level code.""" - - INFO = "Info" - WARNING = "Warning" - ERROR = "Error" - - -class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the mode of an upgrade to virtual machines in the scale set.\\ :code:`
`\\ - :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` **Manual** - You control - the application of updates to virtual machines in the scale set. You do this by using the - manualUpgrade action.\\ :code:`
`\\ :code:`
` **Automatic** - All virtual machines in - the scale set are automatically updated at the same time. - """ - - AUTOMATIC = "Automatic" - MANUAL = "Manual" - - -class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scale type applicable to the sku.""" - - AUTOMATIC = "Automatic" - NONE = "None" - - -class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the size of the virtual machine. For more information about virtual machine sizes, - see `Sizes for virtual machines - `_. - :code:`
`\\ :code:`
` The available VM sizes depend on region and availability set. For a - list of available sizes use these APIs: :code:`
`\\ :code:`
` `List all available - virtual machine sizes in an availability set - `_ - :code:`
`\\ :code:`
` `List all available virtual machine sizes in a region - `_ :code:`
`\\ - :code:`
` `List all available virtual machine sizes for resizing - `_. - """ - - BASIC_A0 = "Basic_A0" - BASIC_A1 = "Basic_A1" - BASIC_A2 = "Basic_A2" - BASIC_A3 = "Basic_A3" - BASIC_A4 = "Basic_A4" - STANDARD_A0 = "Standard_A0" - STANDARD_A1 = "Standard_A1" - STANDARD_A2 = "Standard_A2" - STANDARD_A3 = "Standard_A3" - STANDARD_A4 = "Standard_A4" - STANDARD_A5 = "Standard_A5" - STANDARD_A6 = "Standard_A6" - STANDARD_A7 = "Standard_A7" - STANDARD_A8 = "Standard_A8" - STANDARD_A9 = "Standard_A9" - STANDARD_A10 = "Standard_A10" - STANDARD_A11 = "Standard_A11" - STANDARD_D1 = "Standard_D1" - STANDARD_D2 = "Standard_D2" - STANDARD_D3 = "Standard_D3" - STANDARD_D4 = "Standard_D4" - STANDARD_D11 = "Standard_D11" - STANDARD_D12 = "Standard_D12" - STANDARD_D13 = "Standard_D13" - STANDARD_D14 = "Standard_D14" - STANDARD_D1_V2 = "Standard_D1_v2" - STANDARD_D2_V2 = "Standard_D2_v2" - STANDARD_D3_V2 = "Standard_D3_v2" - STANDARD_D4_V2 = "Standard_D4_v2" - STANDARD_D5_V2 = "Standard_D5_v2" - STANDARD_D11_V2 = "Standard_D11_v2" - STANDARD_D12_V2 = "Standard_D12_v2" - STANDARD_D13_V2 = "Standard_D13_v2" - STANDARD_D14_V2 = "Standard_D14_v2" - STANDARD_D15_V2 = "Standard_D15_v2" - STANDARD_DS1 = "Standard_DS1" - STANDARD_DS2 = "Standard_DS2" - STANDARD_DS3 = "Standard_DS3" - STANDARD_DS4 = "Standard_DS4" - STANDARD_DS11 = "Standard_DS11" - STANDARD_DS12 = "Standard_DS12" - STANDARD_DS13 = "Standard_DS13" - STANDARD_DS14 = "Standard_DS14" - STANDARD_DS1_V2 = "Standard_DS1_v2" - STANDARD_DS2_V2 = "Standard_DS2_v2" - STANDARD_DS3_V2 = "Standard_DS3_v2" - STANDARD_DS4_V2 = "Standard_DS4_v2" - STANDARD_DS5_V2 = "Standard_DS5_v2" - STANDARD_DS11_V2 = "Standard_DS11_v2" - STANDARD_DS12_V2 = "Standard_DS12_v2" - STANDARD_DS13_V2 = "Standard_DS13_v2" - STANDARD_DS14_V2 = "Standard_DS14_v2" - STANDARD_DS15_V2 = "Standard_DS15_v2" - STANDARD_G1 = "Standard_G1" - STANDARD_G2 = "Standard_G2" - STANDARD_G3 = "Standard_G3" - STANDARD_G4 = "Standard_G4" - STANDARD_G5 = "Standard_G5" - STANDARD_GS1 = "Standard_GS1" - STANDARD_GS2 = "Standard_GS2" - STANDARD_GS3 = "Standard_GS3" - STANDARD_GS4 = "Standard_GS4" - STANDARD_GS5 = "Standard_GS5" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/_models_py3.py deleted file mode 100644 index f82bbd30f565..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/_models_py3.py +++ /dev/null @@ -1,4493 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from collections.abc import MutableMapping -import datetime -from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models -JSON = MutableMapping[str, Any] - - -class AdditionalUnattendContent(_serialization.Model): - """Specifies additional XML formatted information that can be included in the Unattend.xml file, - which is used by Windows Setup. Contents are defined by setting name, component name, and the - pass in which the content is applied. - - :ivar pass_name: The pass name. Currently, the only allowable value is OobeSystem. Default - value is "OobeSystem". - :vartype pass_name: str - :ivar component_name: The component name. Currently, the only allowable value is - Microsoft-Windows-Shell-Setup. Default value is "Microsoft-Windows-Shell-Setup". - :vartype component_name: str - :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon" and - "FirstLogonCommands". - :vartype setting_name: str or ~azure.mgmt.compute.v2016_03_30.models.SettingNames - :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for - the specified path and component. The XML must be less than 4KB and must include the root - element for the setting or feature that is being inserted. - :vartype content: str - """ - - _attribute_map = { - "pass_name": {"key": "passName", "type": "str"}, - "component_name": {"key": "componentName", "type": "str"}, - "setting_name": {"key": "settingName", "type": "str"}, - "content": {"key": "content", "type": "str"}, - } - - def __init__( - self, - *, - pass_name: Optional[Literal["OobeSystem"]] = None, - component_name: Optional[Literal["Microsoft-Windows-Shell-Setup"]] = None, - setting_name: Optional[Union[str, "_models.SettingNames"]] = None, - content: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword pass_name: The pass name. Currently, the only allowable value is OobeSystem. Default - value is "OobeSystem". - :paramtype pass_name: str - :keyword component_name: The component name. Currently, the only allowable value is - Microsoft-Windows-Shell-Setup. Default value is "Microsoft-Windows-Shell-Setup". - :paramtype component_name: str - :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon" and - "FirstLogonCommands". - :paramtype setting_name: str or ~azure.mgmt.compute.v2016_03_30.models.SettingNames - :keyword content: Specifies the XML formatted content that is added to the unattend.xml file - for the specified path and component. The XML must be less than 4KB and must include the root - element for the setting or feature that is being inserted. - :paramtype content: str - """ - super().__init__(**kwargs) - self.pass_name = pass_name - self.component_name = component_name - self.setting_name = setting_name - self.content = content - - -class ApiEntityReference(_serialization.Model): - """The API entity reference. - - :ivar id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class ApiError(_serialization.Model): - """Api error. - - :ivar details: The Api error details. - :vartype details: list[~azure.mgmt.compute.v2016_03_30.models.ApiErrorBase] - :ivar innererror: The Api inner error. - :vartype innererror: ~azure.mgmt.compute.v2016_03_30.models.InnerError - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "details": {"key": "details", "type": "[ApiErrorBase]"}, - "innererror": {"key": "innererror", "type": "InnerError"}, - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - details: Optional[List["_models.ApiErrorBase"]] = None, - innererror: Optional["_models.InnerError"] = None, - code: Optional[str] = None, - target: Optional[str] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword details: The Api error details. - :paramtype details: list[~azure.mgmt.compute.v2016_03_30.models.ApiErrorBase] - :keyword innererror: The Api inner error. - :paramtype innererror: ~azure.mgmt.compute.v2016_03_30.models.InnerError - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.details = details - self.innererror = innererror - self.code = code - self.target = target - self.message = message - - -class ApiErrorBase(_serialization.Model): - """Api error base. - - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.target = target - self.message = message - - -class Resource(_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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - - -class AvailabilitySet(Resource): - """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 `Manage the - availability of virtual machines - `_. - :code:`
`\\ :code:`
` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
`\\ :code:`
` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability 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. - :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] - :ivar platform_update_domain_count: Update Domain count. - :vartype platform_update_domain_count: int - :ivar platform_fault_domain_count: Fault Domain count. - :vartype platform_fault_domain_count: int - :ivar virtual_machines: A list of references to all virtual machines in the availability set. - :vartype virtual_machines: list[~azure.mgmt.compute.v2016_03_30.models.SubResource] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2016_03_30.models.InstanceViewStatus] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "statuses": {"readonly": 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}"}, - "platform_update_domain_count": {"key": "properties.platformUpdateDomainCount", "type": "int"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResource]"}, - "statuses": {"key": "properties.statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - platform_update_domain_count: Optional[int] = None, - platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["_models.SubResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword platform_update_domain_count: Update Domain count. - :paramtype platform_update_domain_count: int - :keyword platform_fault_domain_count: Fault Domain count. - :paramtype platform_fault_domain_count: int - :keyword virtual_machines: A list of references to all virtual machines in the availability - set. - :paramtype virtual_machines: list[~azure.mgmt.compute.v2016_03_30.models.SubResource] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.platform_update_domain_count = platform_update_domain_count - self.platform_fault_domain_count = platform_fault_domain_count - self.virtual_machines = virtual_machines - self.statuses: Optional[List["_models.InstanceViewStatus"]] = None - - -class AvailabilitySetListResult(_serialization.Model): - """The List Availability Set operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of availability sets. Required. - :vartype value: list[~azure.mgmt.compute.v2016_03_30.models.AvailabilitySet] - :ivar next_link: The URI to fetch the next page of AvailabilitySets. Call ListNext() with this - URI to fetch the next page of AvailabilitySets. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AvailabilitySet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of availability sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2016_03_30.models.AvailabilitySet] - :keyword next_link: The URI to fetch the next page of AvailabilitySets. Call ListNext() with - this URI to fetch the next page of AvailabilitySets. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class BootDiagnostics(_serialization.Model): - """Boot Diagnostics is a debugging feature which allows you to view Console Output and Screenshot - to diagnose VM status. :code:`
`\\ :code:`
` You can easily view the output of your - console log. :code:`
`\\ :code:`
` Azure also enables you to see a screenshot of the VM - from the hypervisor. - - :ivar enabled: Whether boot diagnostics should be enabled on the Virtual Machine. - :vartype enabled: bool - :ivar storage_uri: Uri of the storage account to use for placing the console output and - screenshot. - :vartype storage_uri: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "storage_uri": {"key": "storageUri", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, storage_uri: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Whether boot diagnostics should be enabled on the Virtual Machine. - :paramtype enabled: bool - :keyword storage_uri: Uri of the storage account to use for placing the console output and - screenshot. - :paramtype storage_uri: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.storage_uri = storage_uri - - -class BootDiagnosticsInstanceView(_serialization.Model): - """The instance view of a virtual machine boot diagnostics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar console_screenshot_blob_uri: The console screenshot blob URI. - :vartype console_screenshot_blob_uri: str - :ivar serial_console_log_blob_uri: The Linux serial console log blob Uri. - :vartype serial_console_log_blob_uri: str - """ - - _validation = { - "console_screenshot_blob_uri": {"readonly": True}, - "serial_console_log_blob_uri": {"readonly": True}, - } - - _attribute_map = { - "console_screenshot_blob_uri": {"key": "consoleScreenshotBlobUri", "type": "str"}, - "serial_console_log_blob_uri": {"key": "serialConsoleLogBlobUri", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.console_screenshot_blob_uri: Optional[str] = None - self.serial_console_log_blob_uri: Optional[str] = None - - -class ComputeLongRunningOperationProperties(_serialization.Model): - """Compute-specific operation properties, including output. - - :ivar output: Operation output data (raw JSON). - :vartype output: JSON - """ - - _attribute_map = { - "output": {"key": "output", "type": "object"}, - } - - def __init__(self, *, output: Optional[JSON] = None, **kwargs: Any) -> None: - """ - :keyword output: Operation output data (raw JSON). - :paramtype output: JSON - """ - super().__init__(**kwargs) - self.output = output - - -class DataDisk(_serialization.Model): - """Describes a data disk. - - All required parameters must be populated in order to send to server. - - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - :ivar name: The disk name. Required. - :vartype name: str - :ivar vhd: The virtual hard disk. Required. - :vartype vhd: ~azure.mgmt.compute.v2016_03_30.models.VirtualHardDisk - :ivar image: 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. - :vartype image: ~azure.mgmt.compute.v2016_03_30.models.VirtualHardDisk - :ivar caching: Specifies the caching requirements. :code:`
`\\ :code:`
` Possible values - are: :code:`
`\\ :code:`
` **None** :code:`
`\\ :code:`
` **ReadOnly** - :code:`
`\\ :code:`
` **ReadWrite** :code:`
`\\ :code:`
` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2016_03_30.models.CachingTypes - :ivar create_option: Specifies how the virtual machine should be created.\\ :code:`
`\\ - :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
`\\ - :code:`
` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2016_03_30.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
`\\ :code:`
` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - """ - - _validation = { - "lun": {"required": True}, - "name": {"required": True}, - "vhd": {"required": True}, - "create_option": {"required": True}, - } - - _attribute_map = { - "lun": {"key": "lun", "type": "int"}, - "name": {"key": "name", "type": "str"}, - "vhd": {"key": "vhd", "type": "VirtualHardDisk"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "caching": {"key": "caching", "type": "str"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - } - - def __init__( - self, - *, - lun: int, - name: str, - vhd: "_models.VirtualHardDisk", - create_option: Union[str, "_models.DiskCreateOptionTypes"], - image: Optional["_models.VirtualHardDisk"] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - :keyword name: The disk name. Required. - :paramtype name: str - :keyword vhd: The virtual hard disk. Required. - :paramtype vhd: ~azure.mgmt.compute.v2016_03_30.models.VirtualHardDisk - :keyword image: 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. - :paramtype image: ~azure.mgmt.compute.v2016_03_30.models.VirtualHardDisk - :keyword caching: Specifies the caching requirements. :code:`
`\\ :code:`
` Possible - values are: :code:`
`\\ :code:`
` **None** :code:`
`\\ :code:`
` **ReadOnly** - :code:`
`\\ :code:`
` **ReadWrite** :code:`
`\\ :code:`
` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2016_03_30.models.CachingTypes - :keyword create_option: Specifies how the virtual machine should be created.\\ :code:`
`\\ - :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
`\\ - :code:`
` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2016_03_30.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
`\\ - :code:`
` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - """ - super().__init__(**kwargs) - self.lun = lun - self.name = name - self.vhd = vhd - self.image = image - self.caching = caching - self.create_option = create_option - self.disk_size_gb = disk_size_gb - - -class DataDiskImage(_serialization.Model): - """Contains the data disk images information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - :vartype lun: int - """ - - _validation = { - "lun": {"readonly": True}, - } - - _attribute_map = { - "lun": {"key": "lun", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.lun: Optional[int] = None - - -class DiagnosticsProfile(_serialization.Model): - """Specifies the boot diagnostic settings state. :code:`
`\\ :code:`
`Minimum api-version: - 2015-06-15. - - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
`\\ :code:`
` You can easily - view the output of your console log. :code:`
`\\ :code:`
` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2016_03_30.models.BootDiagnostics - """ - - _attribute_map = { - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnostics"}, - } - - def __init__(self, *, boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs: Any) -> None: - """ - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
`\\ :code:`
` You can easily - view the output of your console log. :code:`
`\\ :code:`
` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2016_03_30.models.BootDiagnostics - """ - super().__init__(**kwargs) - self.boot_diagnostics = boot_diagnostics - - -class DiskEncryptionSettings(_serialization.Model): - """Describes a Encryption Settings for a Disk. - - :ivar disk_encryption_key: Specifies the location of the disk encryption key, which is a Key - Vault Secret. - :vartype disk_encryption_key: ~azure.mgmt.compute.v2016_03_30.models.KeyVaultSecretReference - :ivar key_encryption_key: Specifies the location of the key encryption key in Key Vault. - :vartype key_encryption_key: ~azure.mgmt.compute.v2016_03_30.models.KeyVaultKeyReference - :ivar enabled: Specifies whether disk encryption should be enabled on the virtual machine. - :vartype enabled: bool - """ - - _attribute_map = { - "disk_encryption_key": {"key": "diskEncryptionKey", "type": "KeyVaultSecretReference"}, - "key_encryption_key": {"key": "keyEncryptionKey", "type": "KeyVaultKeyReference"}, - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__( - self, - *, - disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, - key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, - enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_key: Specifies the location of the disk encryption key, which is a Key - Vault Secret. - :paramtype disk_encryption_key: ~azure.mgmt.compute.v2016_03_30.models.KeyVaultSecretReference - :keyword key_encryption_key: Specifies the location of the key encryption key in Key Vault. - :paramtype key_encryption_key: ~azure.mgmt.compute.v2016_03_30.models.KeyVaultKeyReference - :keyword enabled: Specifies whether disk encryption should be enabled on the virtual machine. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.disk_encryption_key = disk_encryption_key - self.key_encryption_key = key_encryption_key - self.enabled = enabled - - -class DiskInstanceView(_serialization.Model): - """The instance view of the disk. - - :ivar name: The disk name. - :vartype name: str - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2016_03_30.models.InstanceViewStatus] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2016_03_30.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.name = name - self.statuses = statuses - - -class HardwareProfile(_serialization.Model): - """Specifies the hardware settings for the virtual machine. - - :ivar vm_size: Specifies the size of the virtual machine. For more information about virtual - machine sizes, see `Sizes for virtual machines - `_. - :code:`
`\\ :code:`
` The available VM sizes depend on region and availability set. For a - list of available sizes use these APIs: :code:`
`\\ :code:`
` `List all available - virtual machine sizes in an availability set - `_ - :code:`
`\\ :code:`
` `List all available virtual machine sizes in a region - `_ :code:`
`\\ - :code:`
` `List all available virtual machine sizes for resizing - `_. Known - values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", - "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", - "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_D1", - "Standard_D2", "Standard_D3", "Standard_D4", "Standard_D11", "Standard_D12", "Standard_D13", - "Standard_D14", "Standard_D1_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", - "Standard_D5_v2", "Standard_D11_v2", "Standard_D12_v2", "Standard_D13_v2", "Standard_D14_v2", - "Standard_D15_v2", "Standard_DS1", "Standard_DS2", "Standard_DS3", "Standard_DS4", - "Standard_DS11", "Standard_DS12", "Standard_DS13", "Standard_DS14", "Standard_DS1_v2", - "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2", "Standard_DS11_v2", - "Standard_DS12_v2", "Standard_DS13_v2", "Standard_DS14_v2", "Standard_DS15_v2", "Standard_G1", - "Standard_G2", "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", - "Standard_GS3", "Standard_GS4", and "Standard_GS5". - :vartype vm_size: str or ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineSizeTypes - """ - - _attribute_map = { - "vm_size": {"key": "vmSize", "type": "str"}, - } - - def __init__( - self, *, vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs: Any - ) -> None: - """ - :keyword vm_size: Specifies the size of the virtual machine. For more information about virtual - machine sizes, see `Sizes for virtual machines - `_. - :code:`
`\\ :code:`
` The available VM sizes depend on region and availability set. For a - list of available sizes use these APIs: :code:`
`\\ :code:`
` `List all available - virtual machine sizes in an availability set - `_ - :code:`
`\\ :code:`
` `List all available virtual machine sizes in a region - `_ :code:`
`\\ - :code:`
` `List all available virtual machine sizes for resizing - `_. Known - values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", - "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", - "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_D1", - "Standard_D2", "Standard_D3", "Standard_D4", "Standard_D11", "Standard_D12", "Standard_D13", - "Standard_D14", "Standard_D1_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", - "Standard_D5_v2", "Standard_D11_v2", "Standard_D12_v2", "Standard_D13_v2", "Standard_D14_v2", - "Standard_D15_v2", "Standard_DS1", "Standard_DS2", "Standard_DS3", "Standard_DS4", - "Standard_DS11", "Standard_DS12", "Standard_DS13", "Standard_DS14", "Standard_DS1_v2", - "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2", "Standard_DS11_v2", - "Standard_DS12_v2", "Standard_DS13_v2", "Standard_DS14_v2", "Standard_DS15_v2", "Standard_G1", - "Standard_G2", "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", - "Standard_GS3", "Standard_GS4", and "Standard_GS5". - :paramtype vm_size: str or ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineSizeTypes - """ - super().__init__(**kwargs) - self.vm_size = vm_size - - -class ImageReference(_serialization.Model): - """Specifies information about the image to use. You can specify information about platform - images, marketplace images, or virtual machine images. This element is required when you want - to use a platform image, marketplace image, or virtual machine image, but is not used in other - creation operations. NOTE: Image reference publisher and offer can only be set when you create - the scale set. - - :ivar publisher: The image publisher. - :vartype publisher: str - :ivar offer: Specifies the offer of the platform image or marketplace image used to create the - virtual machine. - :vartype offer: str - :ivar sku: The image SKU. - :vartype sku: str - :ivar version: Specifies the version of the platform image or marketplace image used to create - the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and - Build are decimal numbers. Specify 'latest' to use the latest version of an image available at - deploy time. Even if you use 'latest', the VM image will not automatically update after deploy - time even if a new version becomes available. - :vartype version: str - """ - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "offer": {"key": "offer", "type": "str"}, - "sku": {"key": "sku", "type": "str"}, - "version": {"key": "version", "type": "str"}, - } - - def __init__( - self, - *, - publisher: Optional[str] = None, - offer: Optional[str] = None, - sku: Optional[str] = None, - version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword publisher: The image publisher. - :paramtype publisher: str - :keyword offer: Specifies the offer of the platform image or marketplace image used to create - the virtual machine. - :paramtype offer: str - :keyword sku: The image SKU. - :paramtype sku: str - :keyword version: Specifies the version of the platform image or marketplace image used to - create the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, - Minor, and Build are decimal numbers. Specify 'latest' to use the latest version of an image - available at deploy time. Even if you use 'latest', the VM image will not automatically update - after deploy time even if a new version becomes available. - :paramtype version: str - """ - super().__init__(**kwargs) - self.publisher = publisher - self.offer = offer - self.sku = sku - self.version = version - - -class InnerError(_serialization.Model): - """Inner error details. - - :ivar exceptiontype: The exception type. - :vartype exceptiontype: str - :ivar errordetail: The internal error message or exception dump. - :vartype errordetail: str - """ - - _attribute_map = { - "exceptiontype": {"key": "exceptiontype", "type": "str"}, - "errordetail": {"key": "errordetail", "type": "str"}, - } - - def __init__( - self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword exceptiontype: The exception type. - :paramtype exceptiontype: str - :keyword errordetail: The internal error message or exception dump. - :paramtype errordetail: str - """ - super().__init__(**kwargs) - self.exceptiontype = exceptiontype - self.errordetail = errordetail - - -class InstanceViewStatus(_serialization.Model): - """Instance view status. - - :ivar code: The status code. - :vartype code: str - :ivar level: The level code. Known values are: "Info", "Warning", and "Error". - :vartype level: str or ~azure.mgmt.compute.v2016_03_30.models.StatusLevelTypes - :ivar display_status: The short localizable label for the status. - :vartype display_status: str - :ivar message: The detailed status message, including for alerts and error messages. - :vartype message: str - :ivar time: The time of the status. - :vartype time: ~datetime.datetime - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "level": {"key": "level", "type": "str"}, - "display_status": {"key": "displayStatus", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "time": {"key": "time", "type": "iso-8601"}, - } - - def __init__( - self, - *, - code: Optional[str] = None, - level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, - display_status: Optional[str] = None, - message: Optional[str] = None, - time: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword code: The status code. - :paramtype code: str - :keyword level: The level code. Known values are: "Info", "Warning", and "Error". - :paramtype level: str or ~azure.mgmt.compute.v2016_03_30.models.StatusLevelTypes - :keyword display_status: The short localizable label for the status. - :paramtype display_status: str - :keyword message: The detailed status message, including for alerts and error messages. - :paramtype message: str - :keyword time: The time of the status. - :paramtype time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.code = code - self.level = level - self.display_status = display_status - self.message = message - self.time = time - - -class KeyVaultKeyReference(_serialization.Model): - """Describes a reference to Key Vault Key. - - All required parameters must be populated in order to send to server. - - :ivar key_url: The URL referencing a key encryption key in Key Vault. Required. - :vartype key_url: str - :ivar source_vault: The relative URL of the Key Vault containing the key. Required. - :vartype source_vault: ~azure.mgmt.compute.v2016_03_30.models.SubResource - """ - - _validation = { - "key_url": {"required": True}, - "source_vault": {"required": True}, - } - - _attribute_map = { - "key_url": {"key": "keyUrl", "type": "str"}, - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - } - - def __init__(self, *, key_url: str, source_vault: "_models.SubResource", **kwargs: Any) -> None: - """ - :keyword key_url: The URL referencing a key encryption key in Key Vault. Required. - :paramtype key_url: str - :keyword source_vault: The relative URL of the Key Vault containing the key. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2016_03_30.models.SubResource - """ - super().__init__(**kwargs) - self.key_url = key_url - self.source_vault = source_vault - - -class KeyVaultSecretReference(_serialization.Model): - """Describes a reference to Key Vault Secret. - - All required parameters must be populated in order to send to server. - - :ivar secret_url: The URL referencing a secret in a Key Vault. Required. - :vartype secret_url: str - :ivar source_vault: The relative URL of the Key Vault containing the secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2016_03_30.models.SubResource - """ - - _validation = { - "secret_url": {"required": True}, - "source_vault": {"required": True}, - } - - _attribute_map = { - "secret_url": {"key": "secretUrl", "type": "str"}, - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - } - - def __init__(self, *, secret_url: str, source_vault: "_models.SubResource", **kwargs: Any) -> None: - """ - :keyword secret_url: The URL referencing a secret in a Key Vault. Required. - :paramtype secret_url: str - :keyword source_vault: The relative URL of the Key Vault containing the secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2016_03_30.models.SubResource - """ - super().__init__(**kwargs) - self.secret_url = secret_url - self.source_vault = source_vault - - -class LinuxConfiguration(_serialization.Model): - """Specifies the Linux operating system settings on the virtual machine. :code:`
`\\ - :code:`
`For a list of supported Linux distributions, see `Linux on Azure-Endorsed - Distributions - `_ - :code:`
`\\ :code:`
` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - - :ivar disable_password_authentication: Specifies whether password authentication should be - disabled. - :vartype disable_password_authentication: bool - :ivar ssh: Specifies the ssh key configuration for a Linux OS. - :vartype ssh: ~azure.mgmt.compute.v2016_03_30.models.SshConfiguration - """ - - _attribute_map = { - "disable_password_authentication": {"key": "disablePasswordAuthentication", "type": "bool"}, - "ssh": {"key": "ssh", "type": "SshConfiguration"}, - } - - def __init__( - self, - *, - disable_password_authentication: Optional[bool] = None, - ssh: Optional["_models.SshConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword disable_password_authentication: Specifies whether password authentication should be - disabled. - :paramtype disable_password_authentication: bool - :keyword ssh: Specifies the ssh key configuration for a Linux OS. - :paramtype ssh: ~azure.mgmt.compute.v2016_03_30.models.SshConfiguration - """ - super().__init__(**kwargs) - self.disable_password_authentication = disable_password_authentication - self.ssh = ssh - - -class ListUsagesResult(_serialization.Model): - """The List Usages operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of compute resource usages. Required. - :vartype value: list[~azure.mgmt.compute.v2016_03_30.models.Usage] - :ivar next_link: The URI to fetch the next page of compute resource usage information. Call - ListNext() with this to fetch the next page of compute resource usage information. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Usage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of compute resource usages. Required. - :paramtype value: list[~azure.mgmt.compute.v2016_03_30.models.Usage] - :keyword next_link: The URI to fetch the next page of compute resource usage information. Call - ListNext() with this to fetch the next page of compute resource usage information. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SubResource(_serialization.Model): - """SubResource. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class NetworkInterfaceReference(SubResource): - """Describes a network interface reference. - - :ivar id: Resource Id. - :vartype id: str - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - primary: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - """ - super().__init__(id=id, **kwargs) - self.primary = primary - - -class NetworkProfile(_serialization.Model): - """Specifies the network interfaces of the virtual machine. - - :ivar network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the virtual machine. - :vartype network_interfaces: - list[~azure.mgmt.compute.v2016_03_30.models.NetworkInterfaceReference] - """ - - _attribute_map = { - "network_interfaces": {"key": "networkInterfaces", "type": "[NetworkInterfaceReference]"}, - } - - def __init__( - self, *, network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs: Any - ) -> None: - """ - :keyword network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the virtual machine. - :paramtype network_interfaces: - list[~azure.mgmt.compute.v2016_03_30.models.NetworkInterfaceReference] - """ - super().__init__(**kwargs) - self.network_interfaces = network_interfaces - - -class OperationStatusResponse(_serialization.Model): - """Operation status response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation ID. - :vartype name: str - :ivar status: Operation status. - :vartype status: str - :ivar start_time: Start time of the operation. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the operation. - :vartype end_time: ~datetime.datetime - :ivar error: Api error. - :vartype error: ~azure.mgmt.compute.v2016_03_30.models.ApiError - """ - - _validation = { - "name": {"readonly": True}, - "status": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - "error": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "error": {"key": "error", "type": "ApiError"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.status: Optional[str] = None - self.start_time: Optional[datetime.datetime] = None - self.end_time: Optional[datetime.datetime] = None - self.error: Optional["_models.ApiError"] = None - - -class OSDisk(_serialization.Model): - """Specifies information about the operating system disk used by the virtual machine. - :code:`
`\\ :code:`
` For more information about disks, see `About disks and VHDs for - Azure virtual machines - `_. - - All required parameters must be populated in order to send to server. - - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from user-image or a specialized VHD. :code:`
`\\ :code:`
` - Possible values are: :code:`
`\\ :code:`
` **Windows** :code:`
`\\ :code:`
` - **Linux**. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2016_03_30.models.OperatingSystemTypes - :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`\\ - :code:`
` Minimum api-version: 2015-06-15. - :vartype encryption_settings: ~azure.mgmt.compute.v2016_03_30.models.DiskEncryptionSettings - :ivar name: The disk name. Required. - :vartype name: str - :ivar vhd: The virtual hard disk. Required. - :vartype vhd: ~azure.mgmt.compute.v2016_03_30.models.VirtualHardDisk - :ivar image: 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. - :vartype image: ~azure.mgmt.compute.v2016_03_30.models.VirtualHardDisk - :ivar caching: Specifies the caching requirements. :code:`
`\\ :code:`
` Possible values - are: :code:`
`\\ :code:`
` **None** :code:`
`\\ :code:`
` **ReadOnly** - :code:`
`\\ :code:`
` **ReadWrite** :code:`
`\\ :code:`
` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2016_03_30.models.CachingTypes - :ivar create_option: Specifies how the virtual machine should be created.\\ :code:`
`\\ - :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
`\\ - :code:`
` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2016_03_30.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
`\\ :code:`
` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - """ - - _validation = { - "name": {"required": True}, - "vhd": {"required": True}, - "create_option": {"required": True}, - } - - _attribute_map = { - "os_type": {"key": "osType", "type": "str"}, - "encryption_settings": {"key": "encryptionSettings", "type": "DiskEncryptionSettings"}, - "name": {"key": "name", "type": "str"}, - "vhd": {"key": "vhd", "type": "VirtualHardDisk"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "caching": {"key": "caching", "type": "str"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - } - - def __init__( - self, - *, - name: str, - vhd: "_models.VirtualHardDisk", - create_option: Union[str, "_models.DiskCreateOptionTypes"], - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, - image: Optional["_models.VirtualHardDisk"] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from user-image or a specialized VHD. :code:`
`\\ :code:`
` - Possible values are: :code:`
`\\ :code:`
` **Windows** :code:`
`\\ :code:`
` - **Linux**. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2016_03_30.models.OperatingSystemTypes - :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`\\ - :code:`
` Minimum api-version: 2015-06-15. - :paramtype encryption_settings: ~azure.mgmt.compute.v2016_03_30.models.DiskEncryptionSettings - :keyword name: The disk name. Required. - :paramtype name: str - :keyword vhd: The virtual hard disk. Required. - :paramtype vhd: ~azure.mgmt.compute.v2016_03_30.models.VirtualHardDisk - :keyword image: 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. - :paramtype image: ~azure.mgmt.compute.v2016_03_30.models.VirtualHardDisk - :keyword caching: Specifies the caching requirements. :code:`
`\\ :code:`
` Possible - values are: :code:`
`\\ :code:`
` **None** :code:`
`\\ :code:`
` **ReadOnly** - :code:`
`\\ :code:`
` **ReadWrite** :code:`
`\\ :code:`
` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2016_03_30.models.CachingTypes - :keyword create_option: Specifies how the virtual machine should be created.\\ :code:`
`\\ - :code:`
` Possible values are:\\ :code:`
`\\ :code:`
` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
`\\ - :code:`
` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2016_03_30.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
`\\ - :code:`
` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - """ - super().__init__(**kwargs) - self.os_type = os_type - self.encryption_settings = encryption_settings - self.name = name - self.vhd = vhd - self.image = image - self.caching = caching - self.create_option = create_option - self.disk_size_gb = disk_size_gb - - -class OSDiskImage(_serialization.Model): - """Contains the os disk image information. - - All required parameters must be populated in order to send to server. - - :ivar operating_system: The operating system of the osDiskImage. Required. Known values are: - "Windows" and "Linux". - :vartype operating_system: str or ~azure.mgmt.compute.v2016_03_30.models.OperatingSystemTypes - """ - - _validation = { - "operating_system": {"required": True}, - } - - _attribute_map = { - "operating_system": {"key": "operatingSystem", "type": "str"}, - } - - def __init__(self, *, operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs: Any) -> None: - """ - :keyword operating_system: The operating system of the osDiskImage. Required. Known values are: - "Windows" and "Linux". - :paramtype operating_system: str or ~azure.mgmt.compute.v2016_03_30.models.OperatingSystemTypes - """ - super().__init__(**kwargs) - self.operating_system = operating_system - - -class OSProfile(_serialization.Model): - """Specifies the operating system settings for the virtual machine. - - :ivar computer_name: Specifies the host OS name of the virtual machine. :code:`
`\\ - :code:`
` This name cannot be updated after the VM is created. :code:`
`\\ :code:`
` - **Max-length (Windows):** 15 characters :code:`
`\\ :code:`
` **Max-length (Linux):** 64 - characters. :code:`
`\\ :code:`
` For naming conventions and restrictions see `Azure - infrastructure services implementation guidelines - `_. - :vartype computer_name: str - :ivar admin_username: Specifies the name of the administrator account. :code:`
`\\ - :code:`
` **Windows-only restriction:** Cannot end in "." :code:`
`\\ :code:`
` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
`\\ :code:`
` **Minimum-length - (Linux):** 1 character :code:`
`\\ :code:`
` **Max-length (Linux):** 64 characters - :code:`
`\\ :code:`
` **Max-length (Windows):** 20 characters :code:`
`\\ - :code:`
`\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :vartype admin_username: str - :ivar admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :vartype admin_password: str - :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` For using cloud-init for - your VM, see `Using cloud-init to customize a Linux VM during creation - `_. - :vartype custom_data: str - :ivar windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :vartype windows_configuration: ~azure.mgmt.compute.v2016_03_30.models.WindowsConfiguration - :ivar linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :vartype linux_configuration: ~azure.mgmt.compute.v2016_03_30.models.LinuxConfiguration - :ivar secrets: Specifies set of certificates that should be installed onto the virtual machine. - :vartype secrets: list[~azure.mgmt.compute.v2016_03_30.models.VaultSecretGroup] - """ - - _attribute_map = { - "computer_name": {"key": "computerName", "type": "str"}, - "admin_username": {"key": "adminUsername", "type": "str"}, - "admin_password": {"key": "adminPassword", "type": "str"}, - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - } - - def __init__( - self, - *, - computer_name: Optional[str] = None, - admin_username: Optional[str] = None, - admin_password: Optional[str] = None, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword computer_name: Specifies the host OS name of the virtual machine. :code:`
    `\\ - :code:`
    ` This name cannot be updated after the VM is created. :code:`
    `\\ :code:`
    ` - **Max-length (Windows):** 15 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 - characters. :code:`
    `\\ :code:`
    ` For naming conventions and restrictions see `Azure - infrastructure services implementation guidelines - `_. - :paramtype computer_name: str - :keyword admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :paramtype admin_username: str - :keyword admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :paramtype admin_password: str - :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` For using cloud-init for - your VM, see `Using cloud-init to customize a Linux VM during creation - `_. - :paramtype custom_data: str - :keyword windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :paramtype windows_configuration: ~azure.mgmt.compute.v2016_03_30.models.WindowsConfiguration - :keyword linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :paramtype linux_configuration: ~azure.mgmt.compute.v2016_03_30.models.LinuxConfiguration - :keyword secrets: Specifies set of certificates that should be installed onto the virtual - machine. - :paramtype secrets: list[~azure.mgmt.compute.v2016_03_30.models.VaultSecretGroup] - """ - super().__init__(**kwargs) - self.computer_name = computer_name - self.admin_username = admin_username - self.admin_password = admin_password - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - - -class Plan(_serialization.Model): - """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 the marketplace - image that you want to use and then click **Want to deploy programmatically, Get Started ->**. - Enter any required information and then click **Save**. - - :ivar name: The plan ID. - :vartype name: str - :ivar publisher: The publisher ID. - :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. - :vartype product: str - :ivar promotion_code: The promotion code. - :vartype promotion_code: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - "promotion_code": {"key": "promotionCode", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - publisher: Optional[str] = None, - product: Optional[str] = None, - promotion_code: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The plan ID. - :paramtype name: str - :keyword publisher: The publisher ID. - :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. - :paramtype product: str - :keyword promotion_code: The promotion code. - :paramtype promotion_code: str - """ - super().__init__(**kwargs) - self.name = name - self.publisher = publisher - self.product = product - self.promotion_code = promotion_code - - -class PurchasePlan(_serialization.Model): - """Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. - - All required parameters must be populated in order to send to server. - - :ivar publisher: The publisher ID. Required. - :vartype publisher: str - :ivar name: The plan ID. Required. - :vartype name: 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 - """ - - _validation = { - "publisher": {"required": True}, - "name": {"required": True}, - "product": {"required": True}, - } - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "product": {"key": "product", "type": "str"}, - } - - def __init__(self, *, publisher: str, name: str, product: str, **kwargs: Any) -> None: - """ - :keyword publisher: The publisher ID. Required. - :paramtype publisher: str - :keyword name: The plan ID. Required. - :paramtype name: 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 - """ - super().__init__(**kwargs) - self.publisher = publisher - self.name = name - self.product = product - - -class Sku(_serialization.Model): - """Describes a virtual machine scale set sku. NOTE: If the new VM SKU is not supported on the - hardware the scale set is currently on, you need to deallocate the VMs in the scale set before - you modify the SKU name. - - :ivar name: The sku name. - :vartype name: str - :ivar tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
    `\\ - :code:`
    ` Possible Values:\\ :code:`
    `\\ :code:`
    ` **Standard**\\ :code:`
    `\\ :code:`
    ` **Basic**. - :vartype tier: str - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: int - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "capacity": {"key": "capacity", "type": "int"}, - } - - def __init__( - self, *, name: Optional[str] = None, tier: Optional[str] = None, capacity: Optional[int] = None, **kwargs: Any - ) -> None: - """ - :keyword name: The sku name. - :paramtype name: str - :keyword tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
    `\\ - :code:`
    ` Possible Values:\\ :code:`
    `\\ :code:`
    ` **Standard**\\ :code:`
    `\\ :code:`
    ` **Basic**. - :paramtype tier: str - :keyword capacity: Specifies the number of virtual machines in the scale set. - :paramtype capacity: int - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - self.capacity = capacity - - -class SshConfiguration(_serialization.Model): - """SSH configuration for Linux based VMs running on Azure. - - :ivar public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :vartype public_keys: list[~azure.mgmt.compute.v2016_03_30.models.SshPublicKey] - """ - - _attribute_map = { - "public_keys": {"key": "publicKeys", "type": "[SshPublicKey]"}, - } - - def __init__(self, *, public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs: Any) -> None: - """ - :keyword public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :paramtype public_keys: list[~azure.mgmt.compute.v2016_03_30.models.SshPublicKey] - """ - super().__init__(**kwargs) - self.public_keys = public_keys - - -class SshPublicKey(_serialization.Model): - """Contains information about SSH certificate public key and the path on the Linux VM where the - public key is placed. - - :ivar path: Specifies the full path on the created VM where ssh public key is stored. If the - file already exists, the specified key is appended to the file. Example: - /home/user/.ssh/authorized_keys. - :vartype path: str - :ivar key_data: SSH public key certificate used to authenticate with the VM through ssh. The - key needs to be at least 2048-bit and in ssh-rsa format. :code:`
    `\\ :code:`
    ` For - creating ssh keys, see `Create SSH keys on Linux and Mac for Linux VMs in Azure - `_. - :vartype key_data: str - """ - - _attribute_map = { - "path": {"key": "path", "type": "str"}, - "key_data": {"key": "keyData", "type": "str"}, - } - - def __init__(self, *, path: Optional[str] = None, key_data: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword path: Specifies the full path on the created VM where ssh public key is stored. If the - file already exists, the specified key is appended to the file. Example: - /home/user/.ssh/authorized_keys. - :paramtype path: str - :keyword key_data: SSH public key certificate used to authenticate with the VM through ssh. The - key needs to be at least 2048-bit and in ssh-rsa format. :code:`
    `\\ :code:`
    ` For - creating ssh keys, see `Create SSH keys on Linux and Mac for Linux VMs in Azure - `_. - :paramtype key_data: str - """ - super().__init__(**kwargs) - self.path = path - self.key_data = key_data - - -class StorageProfile(_serialization.Model): - """Specifies the storage settings for the virtual machine disks. - - :ivar image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :vartype image_reference: ~azure.mgmt.compute.v2016_03_30.models.ImageReference - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2016_03_30.models.OSDisk - :ivar data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype data_disks: list[~azure.mgmt.compute.v2016_03_30.models.DataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "OSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[DataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.OSDisk"] = None, - data_disks: Optional[List["_models.DataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :paramtype image_reference: ~azure.mgmt.compute.v2016_03_30.models.ImageReference - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2016_03_30.models.OSDisk - :keyword data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype data_disks: list[~azure.mgmt.compute.v2016_03_30.models.DataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class UpdateResource(_serialization.Model): - """The Update Resource model definition. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class UpgradePolicy(_serialization.Model): - """Describes an upgrade policy - automatic or manual. - - :ivar mode: Specifies the mode of an upgrade to virtual machines in the scale set.\\ :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Manual** - You - control the application of updates to virtual machines in the scale set. You do this by using - the manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - All virtual - machines in the scale set are automatically updated at the same time. Known values are: - "Automatic" and "Manual". - :vartype mode: str or ~azure.mgmt.compute.v2016_03_30.models.UpgradeMode - """ - - _attribute_map = { - "mode": {"key": "mode", "type": "str"}, - } - - def __init__(self, *, mode: Optional[Union[str, "_models.UpgradeMode"]] = None, **kwargs: Any) -> None: - """ - :keyword mode: Specifies the mode of an upgrade to virtual machines in the scale set.\\ - :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` - **Manual** - You control the application of updates to virtual machines in the scale set. You - do this by using the manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - - All virtual machines in the scale set are automatically updated at the same time. Known values - are: "Automatic" and "Manual". - :paramtype mode: str or ~azure.mgmt.compute.v2016_03_30.models.UpgradeMode - """ - super().__init__(**kwargs) - self.mode = mode - - -class Usage(_serialization.Model): - """Describes Compute Resource Usage. - - 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 unit: An enum describing the unit of usage measurement. Required. Default value is - "Count". - :vartype unit: str - :ivar current_value: The current usage of the resource. Required. - :vartype current_value: int - :ivar limit: The maximum permitted usage of the resource. Required. - :vartype limit: int - :ivar name: The name of the type of usage. Required. - :vartype name: ~azure.mgmt.compute.v2016_03_30.models.UsageName - """ - - _validation = { - "unit": {"required": True, "constant": True}, - "current_value": {"required": True}, - "limit": {"required": True}, - "name": {"required": True}, - } - - _attribute_map = { - "unit": {"key": "unit", "type": "str"}, - "current_value": {"key": "currentValue", "type": "int"}, - "limit": {"key": "limit", "type": "int"}, - "name": {"key": "name", "type": "UsageName"}, - } - - unit = "Count" - - def __init__(self, *, current_value: int, limit: int, name: "_models.UsageName", **kwargs: Any) -> None: - """ - :keyword current_value: The current usage of the resource. Required. - :paramtype current_value: int - :keyword limit: The maximum permitted usage of the resource. Required. - :paramtype limit: int - :keyword name: The name of the type of usage. Required. - :paramtype name: ~azure.mgmt.compute.v2016_03_30.models.UsageName - """ - super().__init__(**kwargs) - self.current_value = current_value - self.limit = limit - self.name = name - - -class UsageName(_serialization.Model): - """The Usage Names. - - :ivar value: The name of the resource. - :vartype value: str - :ivar localized_value: The localized name of the resource. - :vartype localized_value: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, - } - - def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The name of the resource. - :paramtype value: str - :keyword localized_value: The localized name of the resource. - :paramtype localized_value: str - """ - super().__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - -class VaultCertificate(_serialization.Model): - """Describes a single certificate reference in a Key Vault, and where the certificate should - reside on the VM. - - :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as - a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :vartype certificate_url: str - :ivar certificate_store: For Windows VMs, specifies the certificate store on the Virtual - Machine to which the certificate should be added. The specified certificate store is implicitly - in the LocalMachine account. :code:`
    `\\ :code:`
    `For Linux VMs, the certificate file is - placed under the /var/lib/waagent directory, with the file name <UppercaseThumbprint>.crt - for the X509 certificate file and <UppercaseThumbprint>.prv for private key. Both of - these files are .pem formatted. - :vartype certificate_store: str - """ - - _attribute_map = { - "certificate_url": {"key": "certificateUrl", "type": "str"}, - "certificate_store": {"key": "certificateStore", "type": "str"}, - } - - def __init__( - self, *, certificate_url: Optional[str] = None, certificate_store: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault - as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :paramtype certificate_url: str - :keyword certificate_store: For Windows VMs, specifies the certificate store on the Virtual - Machine to which the certificate should be added. The specified certificate store is implicitly - in the LocalMachine account. :code:`
    `\\ :code:`
    `For Linux VMs, the certificate file is - placed under the /var/lib/waagent directory, with the file name <UppercaseThumbprint>.crt - for the X509 certificate file and <UppercaseThumbprint>.prv for private key. Both of - these files are .pem formatted. - :paramtype certificate_store: str - """ - super().__init__(**kwargs) - self.certificate_url = certificate_url - self.certificate_store = certificate_store - - -class VaultSecretGroup(_serialization.Model): - """Describes a set of certificates which are all in the same Key Vault. - - :ivar source_vault: The relative URL of the Key Vault containing all of the certificates in - VaultCertificates. - :vartype source_vault: ~azure.mgmt.compute.v2016_03_30.models.SubResource - :ivar vault_certificates: The list of key vault references in SourceVault which contain - certificates. - :vartype vault_certificates: list[~azure.mgmt.compute.v2016_03_30.models.VaultCertificate] - """ - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - "vault_certificates": {"key": "vaultCertificates", "type": "[VaultCertificate]"}, - } - - def __init__( - self, - *, - source_vault: Optional["_models.SubResource"] = None, - vault_certificates: Optional[List["_models.VaultCertificate"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source_vault: The relative URL of the Key Vault containing all of the certificates in - VaultCertificates. - :paramtype source_vault: ~azure.mgmt.compute.v2016_03_30.models.SubResource - :keyword vault_certificates: The list of key vault references in SourceVault which contain - certificates. - :paramtype vault_certificates: list[~azure.mgmt.compute.v2016_03_30.models.VaultCertificate] - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.vault_certificates = vault_certificates - - -class VirtualHardDisk(_serialization.Model): - """Describes the uri of a disk. - - :ivar uri: Specifies the virtual hard disk's uri. - :vartype uri: str - """ - - _attribute_map = { - "uri": {"key": "uri", "type": "str"}, - } - - def __init__(self, *, uri: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword uri: Specifies the virtual hard disk's uri. - :paramtype uri: str - """ - super().__init__(**kwargs) - self.uri = uri - - -class VirtualMachine(Resource): - """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. - :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] - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2016_03_30.models.Plan - :ivar resources: The virtual machine child extension resources. - :vartype resources: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtension] - :ivar identity: The identity of the virtual machine, if configured. - :vartype identity: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineIdentity - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2016_03_30.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2016_03_30.models.StorageProfile - :ivar os_profile: Specifies the operating system settings for the virtual machine. - :vartype os_profile: ~azure.mgmt.compute.v2016_03_30.models.OSProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2016_03_30.models.NetworkProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2016_03_30.models.DiagnosticsProfile - :ivar availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :vartype availability_set: ~azure.mgmt.compute.v2016_03_30.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineInstanceView - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar vm_id: Specifies the VM unique ID which is a 128-bits identifier that is encoded and - stored in all Azure IaaS VMs SMBIOS and can be read using platform BIOS commands. - :vartype vm_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "resources": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - "vm_id": {"readonly": 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}"}, - "plan": {"key": "plan", "type": "Plan"}, - "resources": {"key": "resources", "type": "[VirtualMachineExtension]"}, - "identity": {"key": "identity", "type": "VirtualMachineIdentity"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineInstanceView"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineIdentity"] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - os_profile: Optional["_models.OSProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2016_03_30.models.Plan - :keyword identity: The identity of the virtual machine, if configured. - :paramtype identity: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineIdentity - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2016_03_30.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2016_03_30.models.StorageProfile - :keyword os_profile: Specifies the operating system settings for the virtual machine. - :paramtype os_profile: ~azure.mgmt.compute.v2016_03_30.models.OSProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2016_03_30.models.NetworkProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2016_03_30.models.DiagnosticsProfile - :keyword availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :paramtype availability_set: ~azure.mgmt.compute.v2016_03_30.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.plan = plan - self.resources: Optional[List["_models.VirtualMachineExtension"]] = None - self.identity = identity - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.os_profile = os_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineInstanceView"] = None - self.license_type = license_type - self.vm_id: Optional[str] = None - - -class VirtualMachineAgentInstanceView(_serialization.Model): - """The instance view of the VM Agent running on the virtual machine. - - :ivar vm_agent_version: The VM Agent full version. - :vartype vm_agent_version: str - :ivar extension_handlers: The virtual machine extension handler instance view. - :vartype extension_handlers: - list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtensionHandlerInstanceView] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2016_03_30.models.InstanceViewStatus] - """ - - _attribute_map = { - "vm_agent_version": {"key": "vmAgentVersion", "type": "str"}, - "extension_handlers": {"key": "extensionHandlers", "type": "[VirtualMachineExtensionHandlerInstanceView]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword vm_agent_version: The VM Agent full version. - :paramtype vm_agent_version: str - :keyword extension_handlers: The virtual machine extension handler instance view. - :paramtype extension_handlers: - list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtensionHandlerInstanceView] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2016_03_30.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.vm_agent_version = vm_agent_version - self.extension_handlers = extension_handlers - self.statuses = statuses - - -class VirtualMachineCaptureParameters(_serialization.Model): - """Capture Virtual Machine parameters. - - All required parameters must be populated in order to send to server. - - :ivar vhd_prefix: The captured virtual hard disk's name prefix. Required. - :vartype vhd_prefix: str - :ivar destination_container_name: The destination container name. Required. - :vartype destination_container_name: str - :ivar overwrite_vhds: Specifies whether to overwrite the destination virtual hard disk, in case - of conflict. Required. - :vartype overwrite_vhds: bool - """ - - _validation = { - "vhd_prefix": {"required": True}, - "destination_container_name": {"required": True}, - "overwrite_vhds": {"required": True}, - } - - _attribute_map = { - "vhd_prefix": {"key": "vhdPrefix", "type": "str"}, - "destination_container_name": {"key": "destinationContainerName", "type": "str"}, - "overwrite_vhds": {"key": "overwriteVhds", "type": "bool"}, - } - - def __init__( - self, *, vhd_prefix: str, destination_container_name: str, overwrite_vhds: bool, **kwargs: Any - ) -> None: - """ - :keyword vhd_prefix: The captured virtual hard disk's name prefix. Required. - :paramtype vhd_prefix: str - :keyword destination_container_name: The destination container name. Required. - :paramtype destination_container_name: str - :keyword overwrite_vhds: Specifies whether to overwrite the destination virtual hard disk, in - case of conflict. Required. - :paramtype overwrite_vhds: bool - """ - super().__init__(**kwargs) - self.vhd_prefix = vhd_prefix - self.destination_container_name = destination_container_name - self.overwrite_vhds = overwrite_vhds - - -class VirtualMachineCaptureResult(SubResource): - """Resource Id. - - :ivar id: Resource Id. - :vartype id: str - :ivar output: Operation output data (raw JSON). - :vartype output: JSON - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "output": {"key": "properties.output", "type": "object"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - output: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword output: Operation output data (raw JSON). - :paramtype output: JSON - """ - super().__init__(id=id, **kwargs) - self.output = output - - -class VirtualMachineExtension(Resource): - """Describes a Virtual Machine Extension. - - 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] - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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. - :vartype instance_view: - ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtensionInstanceView - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineExtensionInstanceView"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, 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, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :keyword instance_view: The virtual machine extension instance view. - :paramtype instance_view: - ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtensionInstanceView - """ - super().__init__(location=location, tags=tags, **kwargs) - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - self.instance_view = instance_view - - -class VirtualMachineExtensionHandlerInstanceView(_serialization.Model): # pylint: disable=name-too-long - """The instance view of a virtual machine extension handler. - - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar status: The extension handler status. - :vartype status: ~azure.mgmt.compute.v2016_03_30.models.InstanceViewStatus - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "status": {"key": "status", "type": "InstanceViewStatus"}, - } - - def __init__( - self, - *, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - status: Optional["_models.InstanceViewStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword status: The extension handler status. - :paramtype status: ~azure.mgmt.compute.v2016_03_30.models.InstanceViewStatus - """ - super().__init__(**kwargs) - self.type = type - self.type_handler_version = type_handler_version - self.status = status - - -class VirtualMachineExtensionImage(Resource): - """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. - :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] - :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. - :vartype compute_role: str - :ivar handler_schema: The schema defined by publisher, where extension consumers should provide - settings in a matching schema. - :vartype handler_schema: str - :ivar vm_scale_set_enabled: Whether the extension can be used on xRP VMScaleSets. By default - existing extensions are usable on scalesets, but there might be cases where a publisher wants - to explicitly indicate the extension is only enabled for CRP VMs but not VMSS. - :vartype vm_scale_set_enabled: bool - :ivar supports_multiple_extensions: Whether the handler can support multiple extensions. - :vartype supports_multiple_extensions: bool - """ - - _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}"}, - "operating_system": {"key": "properties.operatingSystem", "type": "str"}, - "compute_role": {"key": "properties.computeRole", "type": "str"}, - "handler_schema": {"key": "properties.handlerSchema", "type": "str"}, - "vm_scale_set_enabled": {"key": "properties.vmScaleSetEnabled", "type": "bool"}, - "supports_multiple_extensions": {"key": "properties.supportsMultipleExtensions", "type": "bool"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - operating_system: Optional[str] = None, - compute_role: Optional[str] = None, - handler_schema: Optional[str] = None, - vm_scale_set_enabled: Optional[bool] = None, - supports_multiple_extensions: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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. - :paramtype compute_role: str - :keyword handler_schema: The schema defined by publisher, where extension consumers should - provide settings in a matching schema. - :paramtype handler_schema: str - :keyword vm_scale_set_enabled: Whether the extension can be used on xRP VMScaleSets. By default - existing extensions are usable on scalesets, but there might be cases where a publisher wants - to explicitly indicate the extension is only enabled for CRP VMs but not VMSS. - :paramtype vm_scale_set_enabled: bool - :keyword supports_multiple_extensions: Whether the handler can support multiple extensions. - :paramtype supports_multiple_extensions: bool - """ - super().__init__(location=location, tags=tags, **kwargs) - self.operating_system = operating_system - self.compute_role = compute_role - self.handler_schema = handler_schema - self.vm_scale_set_enabled = vm_scale_set_enabled - self.supports_multiple_extensions = supports_multiple_extensions - - -class VirtualMachineExtensionInstanceView(_serialization.Model): - """The instance view of a virtual machine extension. - - :ivar name: The virtual machine extension name. - :vartype name: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar substatuses: The resource status information. - :vartype substatuses: list[~azure.mgmt.compute.v2016_03_30.models.InstanceViewStatus] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2016_03_30.models.InstanceViewStatus] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "substatuses": {"key": "substatuses", "type": "[InstanceViewStatus]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - substatuses: Optional[List["_models.InstanceViewStatus"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The virtual machine extension name. - :paramtype name: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword substatuses: The resource status information. - :paramtype substatuses: list[~azure.mgmt.compute.v2016_03_30.models.InstanceViewStatus] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2016_03_30.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.name = name - self.type = type - self.type_handler_version = type_handler_version - self.substatuses = substatuses - self.statuses = statuses - - -class VirtualMachineExtensionsListResult(_serialization.Model): - """The List Extension operation response. - - :ivar value: The list of extensions. - :vartype value: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtension] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineExtension]"}, - } - - def __init__(self, *, value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of extensions. - :paramtype value: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtension] - """ - super().__init__(**kwargs) - self.value = value - - -class VirtualMachineExtensionUpdate(UpdateResource): - """Describes a Virtual Machine Extension. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - force_update_tag: Optional[str] = None, - publisher: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - auto_upgrade_minor_version: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - """ - super().__init__(tags=tags, **kwargs) - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type = type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - - -class VirtualMachineIdentity(_serialization.Model): - """Identity for the virtual machine. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of virtual machine identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the virtual machine. - :vartype tenant_id: str - :ivar type: The type of identity used for the virtual machine. Currently, the only supported - type is 'SystemAssigned', which implicitly creates an identity. Default value is - "SystemAssigned". - :vartype type: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The type of identity used for the virtual machine. Currently, the only supported - type is 'SystemAssigned', which implicitly creates an identity. Default value is - "SystemAssigned". - :paramtype type: str - """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.type = type - - -class VirtualMachineImageResource(SubResource): - """Virtual machine image resource information. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar location: The supported Azure location of the resource. Required. - :vartype location: str - :ivar tags: Specifies the tags that are assigned to the virtual machine. For more information - about using tags, see `Using tags to organize your Azure resources - `_. - :vartype tags: dict[str, str] - """ - - _validation = { - "name": {"required": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__( - self, - *, - name: str, - location: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The name of the resource. Required. - :paramtype name: str - :keyword location: The supported Azure location of the resource. Required. - :paramtype location: str - :keyword tags: Specifies the tags that are assigned to the virtual machine. For more - information about using tags, see `Using tags to organize your Azure resources - `_. - :paramtype tags: dict[str, str] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.location = location - self.tags = tags - - -class VirtualMachineImage(VirtualMachineImageResource): - """Describes a Virtual Machine Image. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar location: The supported Azure location of the resource. Required. - :vartype location: str - :ivar tags: Specifies the tags that are assigned to the virtual machine. For more information - about using tags, see `Using tags to organize your Azure resources - `_. - :vartype tags: dict[str, str] - :ivar plan: Used for establishing the purchase context of any 3rd Party artifact through - MarketPlace. - :vartype plan: ~azure.mgmt.compute.v2016_03_30.models.PurchasePlan - :ivar os_disk_image: Contains the os disk image information. - :vartype os_disk_image: ~azure.mgmt.compute.v2016_03_30.models.OSDiskImage - :ivar data_disk_images: - :vartype data_disk_images: list[~azure.mgmt.compute.v2016_03_30.models.DataDiskImage] - """ - - _validation = { - "name": {"required": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "plan": {"key": "properties.plan", "type": "PurchasePlan"}, - "os_disk_image": {"key": "properties.osDiskImage", "type": "OSDiskImage"}, - "data_disk_images": {"key": "properties.dataDiskImages", "type": "[DataDiskImage]"}, - } - - def __init__( - self, - *, - name: str, - location: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.PurchasePlan"] = None, - os_disk_image: Optional["_models.OSDiskImage"] = None, - data_disk_images: Optional[List["_models.DataDiskImage"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The name of the resource. Required. - :paramtype name: str - :keyword location: The supported Azure location of the resource. Required. - :paramtype location: str - :keyword tags: Specifies the tags that are assigned to the virtual machine. For more - information about using tags, see `Using tags to organize your Azure resources - `_. - :paramtype tags: dict[str, str] - :keyword plan: Used for establishing the purchase context of any 3rd Party artifact through - MarketPlace. - :paramtype plan: ~azure.mgmt.compute.v2016_03_30.models.PurchasePlan - :keyword os_disk_image: Contains the os disk image information. - :paramtype os_disk_image: ~azure.mgmt.compute.v2016_03_30.models.OSDiskImage - :keyword data_disk_images: - :paramtype data_disk_images: list[~azure.mgmt.compute.v2016_03_30.models.DataDiskImage] - """ - super().__init__(id=id, name=name, location=location, tags=tags, **kwargs) - self.plan = plan - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - - -class VirtualMachineInstanceView(_serialization.Model): - """The instance view of a virtual machine. - - :ivar platform_update_domain: Specifies the update domain of the virtual machine. - :vartype platform_update_domain: int - :ivar platform_fault_domain: Specifies the fault domain of the virtual machine. - :vartype platform_fault_domain: int - :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. - :vartype rdp_thumb_print: str - :ivar vm_agent: The VM Agent running on the virtual machine. - :vartype vm_agent: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineAgentInstanceView - :ivar disks: The virtual machine disk information. - :vartype disks: list[~azure.mgmt.compute.v2016_03_30.models.DiskInstanceView] - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtensionInstanceView] - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2016_03_30.models.BootDiagnosticsInstanceView - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2016_03_30.models.InstanceViewStatus] - """ - - _attribute_map = { - "platform_update_domain": {"key": "platformUpdateDomain", "type": "int"}, - "platform_fault_domain": {"key": "platformFaultDomain", "type": "int"}, - "rdp_thumb_print": {"key": "rdpThumbPrint", "type": "str"}, - "vm_agent": {"key": "vmAgent", "type": "VirtualMachineAgentInstanceView"}, - "disks": {"key": "disks", "type": "[DiskInstanceView]"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineExtensionInstanceView]"}, - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnosticsInstanceView"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - platform_update_domain: Optional[int] = None, - platform_fault_domain: Optional[int] = None, - rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, - disks: Optional[List["_models.DiskInstanceView"]] = None, - extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword platform_update_domain: Specifies the update domain of the virtual machine. - :paramtype platform_update_domain: int - :keyword platform_fault_domain: Specifies the fault domain of the virtual machine. - :paramtype platform_fault_domain: int - :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. - :paramtype rdp_thumb_print: str - :keyword vm_agent: The VM Agent running on the virtual machine. - :paramtype vm_agent: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineAgentInstanceView - :keyword disks: The virtual machine disk information. - :paramtype disks: list[~azure.mgmt.compute.v2016_03_30.models.DiskInstanceView] - :keyword extensions: The extensions information. - :paramtype extensions: - list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtensionInstanceView] - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2016_03_30.models.BootDiagnosticsInstanceView - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2016_03_30.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.platform_update_domain = platform_update_domain - self.platform_fault_domain = platform_fault_domain - self.rdp_thumb_print = rdp_thumb_print - self.vm_agent = vm_agent - self.disks = disks - self.extensions = extensions - self.boot_diagnostics = boot_diagnostics - self.statuses = statuses - - -class VirtualMachineListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machines. Required. - :vartype value: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachine] - :ivar next_link: The URI to fetch the next page of VMs. Call ListNext() with this URI to fetch - the next page of Virtual Machines. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachine]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machines. Required. - :paramtype value: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachine] - :keyword next_link: The URI to fetch the next page of VMs. Call ListNext() with this URI to - fetch the next page of Virtual Machines. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSet(Resource): - """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. - :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] - :ivar sku: The virtual machine scale set sku. - :vartype sku: ~azure.mgmt.compute.v2016_03_30.models.Sku - :ivar identity: The identity of the virtual machine scale set, if configured. - :vartype identity: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetIdentity - :ivar upgrade_policy: The upgrade policy. - :vartype upgrade_policy: ~azure.mgmt.compute.v2016_03_30.models.UpgradePolicy - :ivar virtual_machine_profile: The virtual machine profile. - :vartype virtual_machine_profile: - ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetVMProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar over_provision: Specifies whether the Virtual Machine Scale Set should be - overprovisioned. - :vartype over_provision: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "identity": {"key": "identity", "type": "VirtualMachineScaleSetIdentity"}, - "upgrade_policy": {"key": "properties.upgradePolicy", "type": "UpgradePolicy"}, - "virtual_machine_profile": { - "key": "properties.virtualMachineProfile", - "type": "VirtualMachineScaleSetVMProfile", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "over_provision": {"key": "properties.overProvision", "type": "bool"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["_models.UpgradePolicy"] = None, - virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, - over_provision: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The virtual machine scale set sku. - :paramtype sku: ~azure.mgmt.compute.v2016_03_30.models.Sku - :keyword identity: The identity of the virtual machine scale set, if configured. - :paramtype identity: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetIdentity - :keyword upgrade_policy: The upgrade policy. - :paramtype upgrade_policy: ~azure.mgmt.compute.v2016_03_30.models.UpgradePolicy - :keyword virtual_machine_profile: The virtual machine profile. - :paramtype virtual_machine_profile: - ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetVMProfile - :keyword over_provision: Specifies whether the Virtual Machine Scale Set should be - overprovisioned. - :paramtype over_provision: bool - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.identity = identity - self.upgrade_policy = upgrade_policy - self.virtual_machine_profile = virtual_machine_profile - self.provisioning_state: Optional[str] = None - self.over_provision = over_provision - - -class VirtualMachineScaleSetExtension(SubResource): - """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. - :vartype id: str - :ivar name: The name of the extension. - :vartype name: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type: The type of the extension handler. - :vartype type: str - :ivar type_handler_version: The type version of the extension handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Whether the extension handler should be automatically - upgraded across minor versions. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: Json formatted protected settings for the extension. - :vartype protected_settings: JSON - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - publisher: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - auto_upgrade_minor_version: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The name of the extension. - :paramtype name: str - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type: The type of the extension handler. - :paramtype type: str - :keyword type_handler_version: The type version of the extension handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Whether the extension handler should be automatically - upgraded across minor versions. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: Json formatted protected settings for the extension. - :paramtype protected_settings: JSON - """ - super().__init__(id=id, **kwargs) - self.name = name - self.publisher = publisher - self.type = type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - - -class VirtualMachineScaleSetExtensionProfile(_serialization.Model): - """Describes a virtual machine scale set extension profile. - - :ivar extensions: The virtual machine scale set child extension resources. - :vartype extensions: - list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetExtension] - """ - - _attribute_map = { - "extensions": {"key": "extensions", "type": "[VirtualMachineScaleSetExtension]"}, - } - - def __init__( - self, *, extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, **kwargs: Any - ) -> None: - """ - :keyword extensions: The virtual machine scale set child extension resources. - :paramtype extensions: - list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetExtension] - """ - super().__init__(**kwargs) - self.extensions = extensions - - -class VirtualMachineScaleSetIdentity(_serialization.Model): - """Identity for the virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of virtual machine scale set identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the virtual machine scale set. - :vartype tenant_id: str - :ivar type: The type of identity used for the virtual machine scale set. Currently, the only - supported type is 'SystemAssigned', which implicitly creates an identity. Default value is - "SystemAssigned". - :vartype type: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The type of identity used for the virtual machine scale set. Currently, the only - supported type is 'SystemAssigned', which implicitly creates an identity. Default value is - "SystemAssigned". - :paramtype type: str - """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.type = type - - -class VirtualMachineScaleSetInstanceView(_serialization.Model): - """The instance view of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar virtual_machine: The instance view status summary for the virtual machine scale set. - :vartype virtual_machine: - ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetInstanceViewStatusesSummary - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetVMExtensionsSummary] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2016_03_30.models.InstanceViewStatus] - """ - - _validation = { - "virtual_machine": {"readonly": True}, - "extensions": {"readonly": True}, - } - - _attribute_map = { - "virtual_machine": {"key": "virtualMachine", "type": "VirtualMachineScaleSetInstanceViewStatusesSummary"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineScaleSetVMExtensionsSummary]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__(self, *, statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs: Any) -> None: - """ - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2016_03_30.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.virtual_machine: Optional["_models.VirtualMachineScaleSetInstanceViewStatusesSummary"] = None - self.extensions: Optional[List["_models.VirtualMachineScaleSetVMExtensionsSummary"]] = None - self.statuses = statuses - - -class VirtualMachineScaleSetInstanceViewStatusesSummary(_serialization.Model): # pylint: disable=name-too-long - """Instance view statuses summary for virtual machines of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar statuses_summary: The extensions information. - :vartype statuses_summary: - list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineStatusCodeCount] - """ - - _validation = { - "statuses_summary": {"readonly": True}, - } - - _attribute_map = { - "statuses_summary": {"key": "statusesSummary", "type": "[VirtualMachineStatusCodeCount]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.statuses_summary: Optional[List["_models.VirtualMachineStatusCodeCount"]] = None - - -class VirtualMachineScaleSetIPConfiguration(SubResource): - """Describes a virtual machine scale set network profile's IP configuration. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The IP configuration name. Required. - :vartype name: str - :ivar subnet: The subnet. - :vartype subnet: ~azure.mgmt.compute.v2016_03_30.models.ApiEntityReference - :ivar application_gateway_backend_address_pools: The application gateway backend address pools. - :vartype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2016_03_30.models.SubResource] - :ivar load_balancer_backend_address_pools: The load balancer backend address pools. - :vartype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2016_03_30.models.SubResource] - :ivar load_balancer_inbound_nat_pools: The load balancer inbound nat pools. - :vartype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2016_03_30.models.SubResource] - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subnet": {"key": "properties.subnet", "type": "ApiEntityReference"}, - "application_gateway_backend_address_pools": { - "key": "properties.applicationGatewayBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_backend_address_pools": { - "key": "properties.loadBalancerBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_inbound_nat_pools": {"key": "properties.loadBalancerInboundNatPools", "type": "[SubResource]"}, - } - - def __init__( - self, - *, - name: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - subnet: Optional["_models.ApiEntityReference"] = None, - application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The IP configuration name. Required. - :paramtype name: str - :keyword subnet: The subnet. - :paramtype subnet: ~azure.mgmt.compute.v2016_03_30.models.ApiEntityReference - :keyword application_gateway_backend_address_pools: The application gateway backend address - pools. - :paramtype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2016_03_30.models.SubResource] - :keyword load_balancer_backend_address_pools: The load balancer backend address pools. - :paramtype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2016_03_30.models.SubResource] - :keyword load_balancer_inbound_nat_pools: The load balancer inbound nat pools. - :paramtype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2016_03_30.models.SubResource] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.subnet = subnet - self.application_gateway_backend_address_pools = application_gateway_backend_address_pools - self.load_balancer_backend_address_pools = load_balancer_backend_address_pools - self.load_balancer_inbound_nat_pools = load_balancer_inbound_nat_pools - - -class VirtualMachineScaleSetListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets. Required. - :vartype value: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSet] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call ListNext() - with this to fetch the next page of VMSS. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSet] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call - ListNext() with this to fetch the next page of VMSS. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListSkusResult(_serialization.Model): - """The Virtual Machine Scale Set List Skus operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of skus available for the virtual machine scale set. Required. - :vartype value: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetSku] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Set Skus. Call - ListNext() with this to fetch the next page of VMSS Skus. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetSku]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of skus available for the virtual machine scale set. Required. - :paramtype value: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetSku] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Set Skus. Call - ListNext() with this to fetch the next page of VMSS Skus. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListWithLinkResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets. Required. - :vartype value: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSet] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call ListNext() - with this to fetch the next page of Virtual Machine Scale Sets. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSet] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call - ListNext() with this to fetch the next page of Virtual Machine Scale Sets. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetNetworkConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's network configurations. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The network configuration name. Required. - :vartype name: str - :ivar primary: Whether this is a primary NIC on a virtual machine. - :vartype primary: bool - :ivar ip_configurations: The virtual machine scale set IP Configuration. - :vartype ip_configurations: - list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetIPConfiguration] - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "ip_configurations": {"key": "properties.ipConfigurations", "type": "[VirtualMachineScaleSetIPConfiguration]"}, - } - - def __init__( - self, - *, - name: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - primary: Optional[bool] = None, - ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The network configuration name. Required. - :paramtype name: str - :keyword primary: Whether this is a primary NIC on a virtual machine. - :paramtype primary: bool - :keyword ip_configurations: The virtual machine scale set IP Configuration. - :paramtype ip_configurations: - list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetIPConfiguration] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.primary = primary - self.ip_configurations = ip_configurations - - -class VirtualMachineScaleSetNetworkProfile(_serialization.Model): - """Describes a virtual machine scale set network profile. - - :ivar network_interface_configurations: The list of network configurations. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetNetworkConfiguration] - """ - - _attribute_map = { - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineScaleSetNetworkConfiguration]", - }, - } - - def __init__( - self, - *, - network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword network_interface_configurations: The list of network configurations. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetNetworkConfiguration] - """ - super().__init__(**kwargs) - self.network_interface_configurations = network_interface_configurations - - -class VirtualMachineScaleSetOSDisk(_serialization.Model): - """Describes a virtual machine scale set operating system disk. - - All required parameters must be populated in order to send to server. - - :ivar name: The disk name. Required. - :vartype name: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2016_03_30.models.CachingTypes - :ivar create_option: Specifies how the virtual machines in the scale set should be created.\\ - :code:`
    `\\ :code:`
    ` The only allowed value is: **FromImage** \\u2013 This value is used - when you are using an image to create the virtual machine. If you are using a platform image, - you also use the imageReference element described above. If you are using a marketplace image, - you also use the plan element previously described. Required. Known values are: "FromImage", - "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2016_03_30.models.DiskCreateOptionTypes - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2016_03_30.models.OperatingSystemTypes - :ivar image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before - using it to attach to the Virtual Machine. If SourceImage is provided, the destination - VirtualHardDisk should not exist. - :vartype image: ~azure.mgmt.compute.v2016_03_30.models.VirtualHardDisk - :ivar vhd_containers: The list of virtual hard disk container uris. - :vartype vhd_containers: list[str] - """ - - _validation = { - "name": {"required": True}, - "create_option": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "create_option": {"key": "createOption", "type": "str"}, - "os_type": {"key": "osType", "type": "str"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "vhd_containers": {"key": "vhdContainers", "type": "[str]"}, - } - - def __init__( - self, - *, - name: str, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - image: Optional["_models.VirtualHardDisk"] = None, - vhd_containers: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. Required. - :paramtype name: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2016_03_30.models.CachingTypes - :keyword create_option: Specifies how the virtual machines in the scale set should be - created.\\ :code:`
    `\\ :code:`
    ` The only allowed value is: **FromImage** \\u2013 This - value is used when you are using an image to create the virtual machine. If you are using a - platform image, you also use the imageReference element described above. If you are using a - marketplace image, you also use the plan element previously described. Required. Known values - are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2016_03_30.models.DiskCreateOptionTypes - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2016_03_30.models.OperatingSystemTypes - :keyword image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied - before using it to attach to the Virtual Machine. If SourceImage is provided, the destination - VirtualHardDisk should not exist. - :paramtype image: ~azure.mgmt.compute.v2016_03_30.models.VirtualHardDisk - :keyword vhd_containers: The list of virtual hard disk container uris. - :paramtype vhd_containers: list[str] - """ - super().__init__(**kwargs) - self.name = name - self.caching = caching - self.create_option = create_option - self.os_type = os_type - self.image = image - self.vhd_containers = vhd_containers - - -class VirtualMachineScaleSetOSProfile(_serialization.Model): - """Describes a virtual machine scale set OS profile. - - :ivar computer_name_prefix: Specifies the computer name prefix for all of the virtual machines - in the scale set. Computer name prefixes must be 1 to 15 characters long. - :vartype computer_name_prefix: str - :ivar admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :vartype admin_username: str - :ivar admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :vartype admin_password: str - :ivar custom_data: A base-64 encoded string of custom data. - :vartype custom_data: str - :ivar windows_configuration: The Windows Configuration of the OS profile. - :vartype windows_configuration: ~azure.mgmt.compute.v2016_03_30.models.WindowsConfiguration - :ivar linux_configuration: The Linux Configuration of the OS profile. - :vartype linux_configuration: ~azure.mgmt.compute.v2016_03_30.models.LinuxConfiguration - :ivar secrets: The List of certificates for addition to the VM. - :vartype secrets: list[~azure.mgmt.compute.v2016_03_30.models.VaultSecretGroup] - """ - - _attribute_map = { - "computer_name_prefix": {"key": "computerNamePrefix", "type": "str"}, - "admin_username": {"key": "adminUsername", "type": "str"}, - "admin_password": {"key": "adminPassword", "type": "str"}, - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - } - - def __init__( - self, - *, - computer_name_prefix: Optional[str] = None, - admin_username: Optional[str] = None, - admin_password: Optional[str] = None, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword computer_name_prefix: Specifies the computer name prefix for all of the virtual - machines in the scale set. Computer name prefixes must be 1 to 15 characters long. - :paramtype computer_name_prefix: str - :keyword admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :paramtype admin_username: str - :keyword admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :paramtype admin_password: str - :keyword custom_data: A base-64 encoded string of custom data. - :paramtype custom_data: str - :keyword windows_configuration: The Windows Configuration of the OS profile. - :paramtype windows_configuration: ~azure.mgmt.compute.v2016_03_30.models.WindowsConfiguration - :keyword linux_configuration: The Linux Configuration of the OS profile. - :paramtype linux_configuration: ~azure.mgmt.compute.v2016_03_30.models.LinuxConfiguration - :keyword secrets: The List of certificates for addition to the VM. - :paramtype secrets: list[~azure.mgmt.compute.v2016_03_30.models.VaultSecretGroup] - """ - super().__init__(**kwargs) - self.computer_name_prefix = computer_name_prefix - self.admin_username = admin_username - self.admin_password = admin_password - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - - -class VirtualMachineScaleSetSku(_serialization.Model): - """Describes an available virtual machine scale set sku. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of resource the sku applies to. - :vartype resource_type: str - :ivar sku: The Sku. - :vartype sku: ~azure.mgmt.compute.v2016_03_30.models.Sku - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetSkuCapacity - """ - - _validation = { - "resource_type": {"readonly": True}, - "sku": {"readonly": True}, - "capacity": {"readonly": True}, - } - - _attribute_map = { - "resource_type": {"key": "resourceType", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "capacity": {"key": "capacity", "type": "VirtualMachineScaleSetSkuCapacity"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_type: Optional[str] = None - self.sku: Optional["_models.Sku"] = None - self.capacity: Optional["_models.VirtualMachineScaleSetSkuCapacity"] = None - - -class VirtualMachineScaleSetSkuCapacity(_serialization.Model): - """Describes scaling information of a sku. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar minimum: The minimum capacity. - :vartype minimum: int - :ivar maximum: The maximum capacity that can be set. - :vartype maximum: int - :ivar default_capacity: The default capacity. - :vartype default_capacity: int - :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic" and - "None". - :vartype scale_type: str or - ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetSkuScaleType - """ - - _validation = { - "minimum": {"readonly": True}, - "maximum": {"readonly": True}, - "default_capacity": {"readonly": True}, - "scale_type": {"readonly": True}, - } - - _attribute_map = { - "minimum": {"key": "minimum", "type": "int"}, - "maximum": {"key": "maximum", "type": "int"}, - "default_capacity": {"key": "defaultCapacity", "type": "int"}, - "scale_type": {"key": "scaleType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.minimum: Optional[int] = None - self.maximum: Optional[int] = None - self.default_capacity: Optional[int] = None - self.scale_type: Optional[Union[str, "_models.VirtualMachineScaleSetSkuScaleType"]] = None - - -class VirtualMachineScaleSetStorageProfile(_serialization.Model): - """Describes a virtual machine scale set storage profile. - - :ivar image_reference: The image reference. - :vartype image_reference: ~azure.mgmt.compute.v2016_03_30.models.ImageReference - :ivar os_disk: The OS disk. - :vartype os_disk: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetOSDisk - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "VirtualMachineScaleSetOSDisk"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: The image reference. - :paramtype image_reference: ~azure.mgmt.compute.v2016_03_30.models.ImageReference - :keyword os_disk: The OS disk. - :paramtype os_disk: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetOSDisk - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - - -class VirtualMachineScaleSetVM(Resource): - """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. - :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] - :ivar instance_id: The virtual machine instance ID. - :vartype instance_id: str - :ivar sku: The virtual machine SKU. - :vartype sku: ~azure.mgmt.compute.v2016_03_30.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2016_03_30.models.Plan - :ivar resources: The virtual machine child extension resources. - :vartype resources: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtension] - :ivar latest_model_applied: Specifies whether the latest model has been applied to the virtual - machine. - :vartype latest_model_applied: bool - :ivar vm_id: Azure VM unique ID. - :vartype vm_id: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: - ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetVMInstanceView - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2016_03_30.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2016_03_30.models.StorageProfile - :ivar os_profile: Specifies the operating system settings for the virtual machine. - :vartype os_profile: ~azure.mgmt.compute.v2016_03_30.models.OSProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2016_03_30.models.NetworkProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2016_03_30.models.DiagnosticsProfile - :ivar availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :vartype availability_set: ~azure.mgmt.compute.v2016_03_30.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "instance_id": {"readonly": True}, - "sku": {"readonly": True}, - "resources": {"readonly": True}, - "latest_model_applied": {"readonly": True}, - "vm_id": {"readonly": True}, - "instance_view": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "instance_id": {"key": "instanceId", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "resources": {"key": "resources", "type": "[VirtualMachineExtension]"}, - "latest_model_applied": {"key": "properties.latestModelApplied", "type": "bool"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineScaleSetVMInstanceView"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - os_profile: Optional["_models.OSProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2016_03_30.models.Plan - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2016_03_30.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2016_03_30.models.StorageProfile - :keyword os_profile: Specifies the operating system settings for the virtual machine. - :paramtype os_profile: ~azure.mgmt.compute.v2016_03_30.models.OSProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2016_03_30.models.NetworkProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2016_03_30.models.DiagnosticsProfile - :keyword availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :paramtype availability_set: ~azure.mgmt.compute.v2016_03_30.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.instance_id: Optional[str] = None - self.sku: Optional["_models.Sku"] = None - self.plan = plan - self.resources: Optional[List["_models.VirtualMachineExtension"]] = None - self.latest_model_applied: Optional[bool] = None - self.vm_id: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineScaleSetVMInstanceView"] = None - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.os_profile = os_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.provisioning_state: Optional[str] = None - self.license_type = license_type - - -class VirtualMachineScaleSetVMExtensionsSummary(_serialization.Model): # pylint: disable=name-too-long - """Extensions summary for virtual machines of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The extension name. - :vartype name: str - :ivar statuses_summary: The extensions information. - :vartype statuses_summary: - list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineStatusCodeCount] - """ - - _validation = { - "name": {"readonly": True}, - "statuses_summary": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "statuses_summary": {"key": "statusesSummary", "type": "[VirtualMachineStatusCodeCount]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.statuses_summary: Optional[List["_models.VirtualMachineStatusCodeCount"]] = None - - -class VirtualMachineScaleSetVMInstanceIDs(_serialization.Model): - """Specifies a list of virtual machine instance IDs from the VM scale set. - - :ivar instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :vartype instance_ids: list[str] - """ - - _attribute_map = { - "instance_ids": {"key": "instanceIds", "type": "[str]"}, - } - - def __init__(self, *, instance_ids: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :paramtype instance_ids: list[str] - """ - super().__init__(**kwargs) - self.instance_ids = instance_ids - - -class VirtualMachineScaleSetVMInstanceRequiredIDs(_serialization.Model): # pylint: disable=name-too-long - """Specifies a list of virtual machine instance IDs from the VM scale set. - - All required parameters must be populated in order to send to server. - - :ivar instance_ids: The virtual machine scale set instance ids. Required. - :vartype instance_ids: list[str] - """ - - _validation = { - "instance_ids": {"required": True}, - } - - _attribute_map = { - "instance_ids": {"key": "instanceIds", "type": "[str]"}, - } - - def __init__(self, *, instance_ids: List[str], **kwargs: Any) -> None: - """ - :keyword instance_ids: The virtual machine scale set instance ids. Required. - :paramtype instance_ids: list[str] - """ - super().__init__(**kwargs) - self.instance_ids = instance_ids - - -class VirtualMachineScaleSetVMInstanceView(_serialization.Model): - """The instance view of a virtual machine scale set VM. - - :ivar platform_update_domain: The Update Domain count. - :vartype platform_update_domain: int - :ivar platform_fault_domain: The Fault Domain count. - :vartype platform_fault_domain: int - :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. - :vartype rdp_thumb_print: str - :ivar vm_agent: The VM Agent running on the virtual machine. - :vartype vm_agent: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineAgentInstanceView - :ivar disks: The disks information. - :vartype disks: list[~azure.mgmt.compute.v2016_03_30.models.DiskInstanceView] - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtensionInstanceView] - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2016_03_30.models.BootDiagnosticsInstanceView - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2016_03_30.models.InstanceViewStatus] - """ - - _attribute_map = { - "platform_update_domain": {"key": "platformUpdateDomain", "type": "int"}, - "platform_fault_domain": {"key": "platformFaultDomain", "type": "int"}, - "rdp_thumb_print": {"key": "rdpThumbPrint", "type": "str"}, - "vm_agent": {"key": "vmAgent", "type": "VirtualMachineAgentInstanceView"}, - "disks": {"key": "disks", "type": "[DiskInstanceView]"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineExtensionInstanceView]"}, - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnosticsInstanceView"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - platform_update_domain: Optional[int] = None, - platform_fault_domain: Optional[int] = None, - rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, - disks: Optional[List["_models.DiskInstanceView"]] = None, - extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword platform_update_domain: The Update Domain count. - :paramtype platform_update_domain: int - :keyword platform_fault_domain: The Fault Domain count. - :paramtype platform_fault_domain: int - :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. - :paramtype rdp_thumb_print: str - :keyword vm_agent: The VM Agent running on the virtual machine. - :paramtype vm_agent: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineAgentInstanceView - :keyword disks: The disks information. - :paramtype disks: list[~azure.mgmt.compute.v2016_03_30.models.DiskInstanceView] - :keyword extensions: The extensions information. - :paramtype extensions: - list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtensionInstanceView] - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2016_03_30.models.BootDiagnosticsInstanceView - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2016_03_30.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.platform_update_domain = platform_update_domain - self.platform_fault_domain = platform_fault_domain - self.rdp_thumb_print = rdp_thumb_print - self.vm_agent = vm_agent - self.disks = disks - self.extensions = extensions - self.boot_diagnostics = boot_diagnostics - self.statuses = statuses - - -class VirtualMachineScaleSetVMListResult(_serialization.Model): - """The List Virtual Machine Scale Set VMs operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets VMs. Required. - :vartype value: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetVM] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Set VMs. Call - ListNext() with this to fetch the next page of VMSS VMs. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetVM]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets VMs. Required. - :paramtype value: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetVM] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Set VMs. Call - ListNext() with this to fetch the next page of VMSS VMs. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetVMProfile(_serialization.Model): - """Describes a virtual machine scale set virtual machine profile. - - :ivar os_profile: The virtual machine scale set OS profile. - :vartype os_profile: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetOSProfile - :ivar storage_profile: The virtual machine scale set storage profile. - :vartype storage_profile: - ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetStorageProfile - :ivar network_profile: The virtual machine scale set network profile. - :vartype network_profile: - ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetNetworkProfile - :ivar extension_profile: The virtual machine scale set extension profile. - :vartype extension_profile: - ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetExtensionProfile - """ - - _attribute_map = { - "os_profile": {"key": "osProfile", "type": "VirtualMachineScaleSetOSProfile"}, - "storage_profile": {"key": "storageProfile", "type": "VirtualMachineScaleSetStorageProfile"}, - "network_profile": {"key": "networkProfile", "type": "VirtualMachineScaleSetNetworkProfile"}, - "extension_profile": {"key": "extensionProfile", "type": "VirtualMachineScaleSetExtensionProfile"}, - } - - def __init__( - self, - *, - os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, - extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_profile: The virtual machine scale set OS profile. - :paramtype os_profile: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetOSProfile - :keyword storage_profile: The virtual machine scale set storage profile. - :paramtype storage_profile: - ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetStorageProfile - :keyword network_profile: The virtual machine scale set network profile. - :paramtype network_profile: - ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetNetworkProfile - :keyword extension_profile: The virtual machine scale set extension profile. - :paramtype extension_profile: - ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetExtensionProfile - """ - super().__init__(**kwargs) - self.os_profile = os_profile - self.storage_profile = storage_profile - self.network_profile = network_profile - self.extension_profile = extension_profile - - -class VirtualMachineSize(_serialization.Model): - """Describes the properties of a VM size. - - :ivar name: The name of the virtual machine size. - :vartype name: str - :ivar number_of_cores: The number of cores supported by the virtual machine size. - :vartype number_of_cores: int - :ivar os_disk_size_in_mb: The OS disk size, in MB, allowed by the virtual machine size. - :vartype os_disk_size_in_mb: int - :ivar resource_disk_size_in_mb: The resource disk size, in MB, allowed by the virtual machine - size. - :vartype resource_disk_size_in_mb: int - :ivar memory_in_mb: The amount of memory, in MB, supported by the virtual machine size. - :vartype memory_in_mb: int - :ivar max_data_disk_count: The maximum number of data disks that can be attached to the virtual - machine size. - :vartype max_data_disk_count: int - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "number_of_cores": {"key": "numberOfCores", "type": "int"}, - "os_disk_size_in_mb": {"key": "osDiskSizeInMB", "type": "int"}, - "resource_disk_size_in_mb": {"key": "resourceDiskSizeInMB", "type": "int"}, - "memory_in_mb": {"key": "memoryInMB", "type": "int"}, - "max_data_disk_count": {"key": "maxDataDiskCount", "type": "int"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - number_of_cores: Optional[int] = None, - os_disk_size_in_mb: Optional[int] = None, - resource_disk_size_in_mb: Optional[int] = None, - memory_in_mb: Optional[int] = None, - max_data_disk_count: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the virtual machine size. - :paramtype name: str - :keyword number_of_cores: The number of cores supported by the virtual machine size. - :paramtype number_of_cores: int - :keyword os_disk_size_in_mb: The OS disk size, in MB, allowed by the virtual machine size. - :paramtype os_disk_size_in_mb: int - :keyword resource_disk_size_in_mb: The resource disk size, in MB, allowed by the virtual - machine size. - :paramtype resource_disk_size_in_mb: int - :keyword memory_in_mb: The amount of memory, in MB, supported by the virtual machine size. - :paramtype memory_in_mb: int - :keyword max_data_disk_count: The maximum number of data disks that can be attached to the - virtual machine size. - :paramtype max_data_disk_count: int - """ - super().__init__(**kwargs) - self.name = name - self.number_of_cores = number_of_cores - self.os_disk_size_in_mb = os_disk_size_in_mb - self.resource_disk_size_in_mb = resource_disk_size_in_mb - self.memory_in_mb = memory_in_mb - self.max_data_disk_count = max_data_disk_count - - -class VirtualMachineSizeListResult(_serialization.Model): - """The List Virtual Machine operation response. - - :ivar value: The list of virtual machine sizes. - :vartype value: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineSize] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineSize]"}, - } - - def __init__(self, *, value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of virtual machine sizes. - :paramtype value: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineSize] - """ - super().__init__(**kwargs) - self.value = value - - -class VirtualMachineStatusCodeCount(_serialization.Model): - """The status code and count of the virtual machine scale set instance view status summary. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The instance view status code. - :vartype code: str - :ivar count: The number of instances having a particular status code. - :vartype count: int - """ - - _validation = { - "code": {"readonly": True}, - "count": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "count": {"key": "count", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.count: Optional[int] = None - - -class WindowsConfiguration(_serialization.Model): - """Specifies Windows operating system settings on the virtual machine. - - :ivar provision_vm_agent: Indicates whether virtual machine agent should be provisioned on the - virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the request - body, default behavior is to set it to true. This will ensure that VM Agent is installed on - the VM so that extensions can be added to the VM later. - :vartype provision_vm_agent: bool - :ivar enable_automatic_updates: Indicates whether virtual machine is enabled for automatic - updates. - :vartype enable_automatic_updates: bool - :ivar time_zone: Specifies the time zone of the virtual machine. e.g. "Pacific Standard Time". - :vartype time_zone: str - :ivar additional_unattend_content: Specifies additional base-64 encoded XML formatted - information that can be included in the Unattend.xml file, which is used by Windows Setup. - :vartype additional_unattend_content: - list[~azure.mgmt.compute.v2016_03_30.models.AdditionalUnattendContent] - :ivar win_rm: Specifies the Windows Remote Management listeners. This enables remote Windows - PowerShell. - :vartype win_rm: ~azure.mgmt.compute.v2016_03_30.models.WinRMConfiguration - """ - - _attribute_map = { - "provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"}, - "enable_automatic_updates": {"key": "enableAutomaticUpdates", "type": "bool"}, - "time_zone": {"key": "timeZone", "type": "str"}, - "additional_unattend_content": {"key": "additionalUnattendContent", "type": "[AdditionalUnattendContent]"}, - "win_rm": {"key": "winRM", "type": "WinRMConfiguration"}, - } - - def __init__( - self, - *, - provision_vm_agent: Optional[bool] = None, - enable_automatic_updates: Optional[bool] = None, - time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, - win_rm: Optional["_models.WinRMConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword provision_vm_agent: Indicates whether virtual machine agent should be provisioned on - the virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the - request body, default behavior is to set it to true. This will ensure that VM Agent is - installed on the VM so that extensions can be added to the VM later. - :paramtype provision_vm_agent: bool - :keyword enable_automatic_updates: Indicates whether virtual machine is enabled for automatic - updates. - :paramtype enable_automatic_updates: bool - :keyword time_zone: Specifies the time zone of the virtual machine. e.g. "Pacific Standard - Time". - :paramtype time_zone: str - :keyword additional_unattend_content: Specifies additional base-64 encoded XML formatted - information that can be included in the Unattend.xml file, which is used by Windows Setup. - :paramtype additional_unattend_content: - list[~azure.mgmt.compute.v2016_03_30.models.AdditionalUnattendContent] - :keyword win_rm: Specifies the Windows Remote Management listeners. This enables remote Windows - PowerShell. - :paramtype win_rm: ~azure.mgmt.compute.v2016_03_30.models.WinRMConfiguration - """ - super().__init__(**kwargs) - self.provision_vm_agent = provision_vm_agent - self.enable_automatic_updates = enable_automatic_updates - self.time_zone = time_zone - self.additional_unattend_content = additional_unattend_content - self.win_rm = win_rm - - -class WinRMConfiguration(_serialization.Model): - """Describes Windows Remote Management configuration of the VM. - - :ivar listeners: The list of Windows Remote Management listeners. - :vartype listeners: list[~azure.mgmt.compute.v2016_03_30.models.WinRMListener] - """ - - _attribute_map = { - "listeners": {"key": "listeners", "type": "[WinRMListener]"}, - } - - def __init__(self, *, listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs: Any) -> None: - """ - :keyword listeners: The list of Windows Remote Management listeners. - :paramtype listeners: list[~azure.mgmt.compute.v2016_03_30.models.WinRMListener] - """ - super().__init__(**kwargs) - self.listeners = listeners - - -class WinRMListener(_serialization.Model): - """Describes Protocol and thumbprint of Windows Remote Management listener. - - :ivar protocol: Specifies the protocol of listener. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. Known values are: "Http" - and "Https". - :vartype protocol: str or ~azure.mgmt.compute.v2016_03_30.models.ProtocolTypes - :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as - a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :vartype certificate_url: str - """ - - _attribute_map = { - "protocol": {"key": "protocol", "type": "str"}, - "certificate_url": {"key": "certificateUrl", "type": "str"}, - } - - def __init__( - self, - *, - protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, - certificate_url: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword protocol: Specifies the protocol of listener. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. Known values are: - "Http" and "Https". - :paramtype protocol: str or ~azure.mgmt.compute.v2016_03_30.models.ProtocolTypes - :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault - as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :paramtype certificate_url: str - """ - super().__init__(**kwargs) - self.protocol = protocol - self.certificate_url = certificate_url diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/__init__.py deleted file mode 100644 index c585bc95261e..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/__init__.py +++ /dev/null @@ -1,41 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import AvailabilitySetsOperations # type: ignore -from ._operations import VirtualMachineExtensionImagesOperations # type: ignore -from ._operations import VirtualMachineExtensionsOperations # type: ignore -from ._operations import VirtualMachinesOperations # type: ignore -from ._operations import VirtualMachineImagesOperations # type: ignore -from ._operations import UsageOperations # type: ignore -from ._operations import VirtualMachineSizesOperations # type: ignore -from ._operations import VirtualMachineScaleSetsOperations # type: ignore -from ._operations import VirtualMachineScaleSetVMsOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AvailabilitySetsOperations", - "VirtualMachineExtensionImagesOperations", - "VirtualMachineExtensionsOperations", - "VirtualMachinesOperations", - "VirtualMachineImagesOperations", - "UsageOperations", - "VirtualMachineSizesOperations", - "VirtualMachineScaleSetsOperations", - "VirtualMachineScaleSetVMsOperations", -] -__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/v2016_03_30/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_operations.py deleted file mode 100644 index 82da088ecb3e..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_operations.py +++ /dev/null @@ -1,8176 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterator, List, Literal, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import ComputeManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_availability_sets_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, 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", "2016-03-30")) - 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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "availabilitySetName": _SERIALIZER.url("name", name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_availability_sets_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes", - ) - 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"), - } - - _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_extension_images_get_request( # pylint: disable=name-too-long - location: str, publisher_name: str, type: str, version: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types", - ) - 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"), - } - - _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_extension_images_list_versions_request( # pylint: disable=name-too-long - location: str, - publisher_name: str, - type: str, - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - if orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2016-03-30")) - 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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-30")) - 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}", - ) - 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"), - } - - _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_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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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) - - -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 -) -> 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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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) - - -def build_virtual_machines_get_extensions_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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions", - ) - 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"), - } - - _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) - - -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", "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture", - ) - 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"), - } - - _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_machines_create_or_update_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", "2016-03-30")) - 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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_delete_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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", - ) - 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"), - } - - _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) - - -def build_virtual_machines_get_request( - resource_group_name: str, - vm_name: str, - subscription_id: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", - ) - 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"), - } - - _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) - - -def build_virtual_machines_deallocate_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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_generalize_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_list_all_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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes", - ) - 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"), - } - - _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_machines_power_off_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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_restart_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart", - ) - 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"), - } - - _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="POST", 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 -) -> 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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_redeploy_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy", - ) - 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"), - } - - _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="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 -) -> 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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", - ) - 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"), - } - - _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) - - -def build_virtual_machine_images_list_offers_request( # pylint: disable=name-too-long - location: str, publisher_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers" - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_images_list_skus_request( # pylint: disable=name-too-long - location: str, publisher_name: str, offer: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages" - ) - 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_sizes_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes" - ) - 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_scale_sets_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, 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", "2016-03-30")) - 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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("name", name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_delete_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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", - ) - 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"), - } - - _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) - - -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, **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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", - ) - 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"), - } - - _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_scale_sets_deallocate_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", "2016-03-30")) - 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", - ) - 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"), - } - - _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_scale_sets_delete_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", "2016-03-30")) - 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", - ) - 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"), - } - - _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_scale_sets_get_instance_view_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_list_all_request( # pylint: disable=name-too-long - subscription_id: str, **kwargs: Any -) -> 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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_list_skus_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus", - ) - 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"), - } - - _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_scale_sets_power_off_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", "2016-03-30")) - 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", - ) - 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"), - } - - _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_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", "2016-03-30")) - 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", - ) - 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"), - } - - _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_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", "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start", - ) - 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"), - } - - _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_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", "2016-03-30")) - 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", - ) - 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"), - } - - _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_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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage", - ) - 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"), - } - - _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="POST", 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 -) -> 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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage", - ) - 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"), - } - - _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="POST", 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 -) -> 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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate", - ) - 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"), - } - - _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="POST", 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, **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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", - ) - 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"), - } - - _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) - - -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, **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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView", - ) - 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"), - } - - _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_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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines", - ) - 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"), - } - - _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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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, **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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff", - ) - 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"), - } - - _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="POST", 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 -) -> 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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart", - ) - 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"), - } - - _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="POST", 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 -) -> 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", "2016-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class AvailabilitySetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2016_03_30.ComputeManagementClient`'s - :attr:`availability_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - name: str, - parameters: _models.AvailabilitySet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param name: The name of the availability set. Required. - :type name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2016_03_30.models.AvailabilitySet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2016_03_30.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param name: The name of the availability set. Required. - :type name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2016_03_30.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, resource_group_name: str, name: str, parameters: Union[_models.AvailabilitySet, IO[bytes]], **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param name: The name of the availability set. Required. - :type 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.v2016_03_30.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySet") - - _request = build_availability_sets_create_or_update_request( - resource_group_name=resource_group_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Optional[_models.OperationStatusResponse]: - """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: OperationStatusResponse or None or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse or 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 "2016-03-30")) - cls: ClsType[Optional[_models.OperationStatusResponse]] = 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) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("OperationStatusResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get(self, resource_group_name: str, 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.v2016_03_30.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", 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) - - _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("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription( - self, *, expand: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. - - :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.v2016_03_30.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 "2016-03-30")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets 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 AvailabilitySet or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - 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_available_sizes( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes that can be used to create a new virtual machine in - an existing availability set. - - :param resource_group_name: The name of the resource group. Required. - :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.v2016_03_30.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 "2016-03-30")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_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 - - if response.status_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 VirtualMachineExtensionImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2016_03_30.ComputeManagementClient`'s - :attr:`virtual_machine_extension_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, type: str, version: str, **kwargs: Any - ) -> _models.VirtualMachineExtensionImage: - """Gets a virtual machine extension image. - - :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.v2016_03_30.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 "2016-03-30")) - 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 - - @distributed_trace - def list_types( - self, location: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineExtensionImage]: - """Gets a list of virtual machine extension image types. - - :param location: The name of 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.v2016_03_30.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 "2016-03-30")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - - _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) - - _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 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 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.v2016_03_30.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 "2016-03-30")) - 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 - - -class VirtualMachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2016_03_30.ComputeManagementClient`'s - :attr:`virtual_machine_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, 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 "2016-03-30")) - 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, "VirtualMachineExtension") - - _request = build_virtual_machine_extensions_create_or_update_request( - resource_group_name=resource_group_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2016_03_30.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 VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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] - :keyword content_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.v2016_03_30.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2016_03_30.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.v2016_03_30.models.VirtualMachineExtension] - :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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - 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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineExtensionUpdate") - - _request = build_virtual_machine_extensions_update_request( - resource_group_name=resource_group_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, - 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]: - 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, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to update the extension. - - :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: - ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtensionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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 - ) -> 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_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 LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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.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.v2016_03_30.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.v2016_03_30.models.VirtualMachineExtension] - :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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2016-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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) - - _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, vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """The operation to delete 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 deleted. - 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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.v2016_03_30.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 "2016-03-30")) - 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) - - deserialized = self._deserialize("VirtualMachineExtension", 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.v2016_03_30.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_extensions( - 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.v2016_03_30.models.VirtualMachineExtensionsListResult - :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 "2016-03-30")) - cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machines_get_extensions_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineExtensionsListResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _capture_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2016-03-30")) - 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 - - 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_capture( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachineCaptureParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. - - :param resource_group_name: The name of the resource group. Required. - :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.v2016_03_30.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.v2016_03_30.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. - - :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.v2016_03_30.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_capture( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. - - :param resource_group_name: The name of the resource group. 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.v2016_03_30.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.v2016_03_30.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineCaptureResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._capture_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineCaptureResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # 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) - ) - 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 - ) - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, 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 "2016-03-30")) - 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, "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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachine, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or 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 Create Virtual Machine operation. Required. - :type parameters: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachine - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or 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 Create 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 VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or 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 Create Virtual Machine operation. Is either a - VirtualMachine type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachine or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - 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._create_or_update_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("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, **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 "2016-03-30")) - 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, - 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, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """The operation to delete 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 LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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: Literal["instanceView"] = "instanceView", **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - 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 - - def _deallocate_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[Iterator[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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_deallocate( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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_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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def generalize(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> _models.OperationStatusResponse: - """Sets the state of the virtual machine to generalized. - - :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: OperationStatusResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse - :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 "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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) - - deserialized = self._deserialize("OperationStatusResponse", 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) -> ItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - 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, - 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, **kwargs: Any) -> ItemPaged["_models.VirtualMachine"]: - """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. - - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - 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, - 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_available_sizes( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes to which the specified virtual machine can be - resized. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_available_sizes_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _power_off_initial(self, resource_group_name: str, vm_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 "2016-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_power_off_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_power_off( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - :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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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]: - 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 "2016-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_restart_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_restart( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """The operation to restart 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 LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._restart_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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]: - 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 "2016-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_start( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_redeploy_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_redeploy( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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.v2016_03_30.ComputeManagementClient`'s - :attr:`virtual_machine_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.v2016_03_30.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 "2016-03-30")) - 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.v2016_03_30.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 "2016-03-30")) - 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. - - :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.v2016_03_30.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 "2016-03-30")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_list_offers_request( - location=location, - publisher_name=publisher_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2016_03_30.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 "2016-03-30")) - 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 = 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_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 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.v2016_03_30.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 "2016-03-30")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _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) - - _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 - - -class UsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2016_03_30.ComputeManagementClient`'s - :attr:`usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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 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.v2016_03_30.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 "2016-03-30")) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - 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.v2016_03_30.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes for a subscription in a location. - - :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.v2016_03_30.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 "2016-03-30")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_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 - - 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 - - if response.status_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 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.v2016_03_30.ComputeManagementClient`'s - :attr:`virtual_machine_scale_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - name: str, - parameters: Union[_models.VirtualMachineScaleSet, 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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualMachineScaleSet") - - _request = build_virtual_machine_scale_sets_create_or_update_request( - resource_group_name=resource_group_name, - name=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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - name: str, - parameters: _models.VirtualMachineScaleSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param name: The name of the VM scale set to create or update. Required. - :type name: str - :param parameters: The scale set object. Required. - :type parameters: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSet - :keyword content_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.v2016_03_30.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param name: The name of the VM scale set to create or update. Required. - :type name: str - :param parameters: The scale set object. 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 VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param name: The name of the VM scale set to create or update. Required. - :type name: str - :param parameters: The scale set object. Is either a VirtualMachineScaleSet type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSet or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - 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, - name=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("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, **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 "2016-03-30")) - 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, - 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, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, **kwargs: Any) -> _models.VirtualMachineScaleSet: - """Display information about a 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 - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _deallocate_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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_deallocate( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - :type 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.v2016_03_30.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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - :type 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_deallocate( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - :type 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.v2016_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2016-03-30")) - 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") - - _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, - 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_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2016_03_30.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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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.v2016_03_30.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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. - - :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.v2016_03_30.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 "2016-03-30")) - 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 - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_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 - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - 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_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: - 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) -> ItemPaged["_models.VirtualMachineScaleSet"]: - """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource - group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this - till nextLink is null to fetch all the VM Scale Sets. - - :return: An iterator like instance of either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = 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_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("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) - - 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_skus( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineScaleSetSku"]: - """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM - instances allowed for each SKU. - - :param resource_group_name: The name of the resource group. Required. - :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.v2016_03_30.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 "2016-03-30")) - 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 _power_off_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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_power_off_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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.v2016_03_30.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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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, - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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.v2016_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, - 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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_restart_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2016_03_30.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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, - 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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_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 - 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_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[_models.OperationStatusResponse]: - """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.v2016_03_30.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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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.v2016_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2016-03-30")) - 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") - - _request = build_virtual_machine_scale_sets_update_instances_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2016_03_30.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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :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 "2016-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, **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 "2016-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_sets_reimage_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_reimage( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Reimages (upgrade the operating system) 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 - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineScaleSetVMsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2016_03_30.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _reimage_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 "2016-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_reimage_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - 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 - - return deserialized # type: ignore - - @distributed_trace - def begin_reimage( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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 "2016-03-30")) - 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) - - 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_deallocate( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and - releases the compute resources it uses. You are not billed for the compute resources of this - virtual machine once it is deallocated. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._deallocate_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, **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 "2016-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - 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, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Deletes 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: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, **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 - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - 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, - 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.v2016_03_30.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 "2016-03-30")) - 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 - ) -> ItemPaged["_models.VirtualMachineScaleSetVM"]: - """Gets a list of all virtual machines in a VM scale sets. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param virtual_machine_scale_set_name: The name of the VM scale set. Required. - :type virtual_machine_scale_set_name: str - :keyword filter: The filter to apply to the operation. Allowed values are - 'startswith(instanceView/statuses/code, 'PowerState') eq true', 'properties/latestModelApplied - eq true', 'properties/latestModelApplied eq false'. Default value is None. - :paramtype filter: str - :keyword select: The list parameters. Allowed values are 'instanceView', - 'instanceView/statuses'. Default value is None. - :paramtype select: str - :keyword expand: The expand expression to apply to the operation. Allowed values are - 'instanceView'. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.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 "2016-03-30")) - cls: ClsType[_models.VirtualMachineScaleSetVMListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_set_vms_list_request( - resource_group_name=resource_group_name, - virtual_machine_scale_set_name=virtual_machine_scale_set_name, - subscription_id=self._config.subscription_id, - filter=filter, - select=select, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVMListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _power_off_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **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 "2016-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_power_off_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_power_off( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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 "2016-03-30")) - 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 - - return deserialized # type: ignore - - @distributed_trace - def begin_restart( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Restarts a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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 - ) -> 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 "2016-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_start_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 - - return deserialized # type: ignore - - @distributed_trace - def begin_start( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 - :param vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2017_03_30/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_compute_management_client.py deleted file mode 100644 index 01ab17f83a47..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_compute_management_client.py +++ /dev/null @@ -1,216 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ( - AvailabilitySetsOperations, - DisksOperations, - ImagesOperations, - ResourceSkusOperations, - SnapshotsOperations, - UsageOperations, - VirtualMachineExtensionImagesOperations, - VirtualMachineExtensionsOperations, - VirtualMachineImagesOperations, - VirtualMachineRunCommandsOperations, - VirtualMachineScaleSetExtensionsOperations, - VirtualMachineScaleSetRollingUpgradesOperations, - VirtualMachineScaleSetVMsOperations, - VirtualMachineScaleSetsOperations, - VirtualMachineSizesOperations, - VirtualMachinesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2017_03_30.operations.AvailabilitySetsOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2017_03_30.operations.VirtualMachineExtensionImagesOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2017_03_30.operations.VirtualMachineExtensionsOperations - :ivar virtual_machines: VirtualMachinesOperations operations - :vartype virtual_machines: azure.mgmt.compute.v2017_03_30.operations.VirtualMachinesOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2017_03_30.operations.VirtualMachineImagesOperations - :ivar usage: UsageOperations operations - :vartype usage: azure.mgmt.compute.v2017_03_30.operations.UsageOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2017_03_30.operations.VirtualMachineSizesOperations - :ivar images: ImagesOperations operations - :vartype images: azure.mgmt.compute.v2017_03_30.operations.ImagesOperations - :ivar resource_skus: ResourceSkusOperations operations - :vartype resource_skus: azure.mgmt.compute.v2017_03_30.operations.ResourceSkusOperations - :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations - :vartype virtual_machine_scale_sets: - azure.mgmt.compute.v2017_03_30.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations - operations - :vartype virtual_machine_scale_set_extensions: - azure.mgmt.compute.v2017_03_30.operations.VirtualMachineScaleSetExtensionsOperations - :ivar virtual_machine_scale_set_rolling_upgrades: - VirtualMachineScaleSetRollingUpgradesOperations operations - :vartype virtual_machine_scale_set_rolling_upgrades: - azure.mgmt.compute.v2017_03_30.operations.VirtualMachineScaleSetRollingUpgradesOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2017_03_30.operations.VirtualMachineScaleSetVMsOperations - :ivar disks: DisksOperations operations - :vartype disks: azure.mgmt.compute.v2017_03_30.operations.DisksOperations - :ivar snapshots: SnapshotsOperations operations - :vartype snapshots: azure.mgmt.compute.v2017_03_30.operations.SnapshotsOperations - :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations - :vartype virtual_machine_run_commands: - azure.mgmt.compute.v2017_03_30.operations.VirtualMachineRunCommandsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2017-03-30". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.availability_sets = AvailabilitySetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.virtual_machine_images = VirtualMachineImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2017-03-30") - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2017-03-30") - self.resource_skus = ResourceSkusOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize, "2017-03-30") - self.snapshots = SnapshotsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_configuration.py deleted file mode 100644 index 3c64a9cb3602..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2017-03-30". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2017-03-30") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_metadata.json deleted file mode 100644 index a558c73591d9..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_metadata.json +++ /dev/null @@ -1,125 +0,0 @@ -{ - "chosen_version": "2017-03-30", - "total_api_version_list": ["2017-03-30"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "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.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "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.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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": { - "availability_sets": "AvailabilitySetsOperations", - "virtual_machine_extension_images": "VirtualMachineExtensionImagesOperations", - "virtual_machine_extensions": "VirtualMachineExtensionsOperations", - "virtual_machines": "VirtualMachinesOperations", - "virtual_machine_images": "VirtualMachineImagesOperations", - "usage": "UsageOperations", - "virtual_machine_sizes": "VirtualMachineSizesOperations", - "images": "ImagesOperations", - "resource_skus": "ResourceSkusOperations", - "virtual_machine_scale_sets": "VirtualMachineScaleSetsOperations", - "virtual_machine_scale_set_extensions": "VirtualMachineScaleSetExtensionsOperations", - "virtual_machine_scale_set_rolling_upgrades": "VirtualMachineScaleSetRollingUpgradesOperations", - "virtual_machine_scale_set_vms": "VirtualMachineScaleSetVMsOperations", - "disks": "DisksOperations", - "snapshots": "SnapshotsOperations", - "virtual_machine_run_commands": "VirtualMachineRunCommandsOperations" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node
    is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj 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 deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2017_03_30/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/_compute_management_client.py deleted file mode 100644 index 178d8ed48f20..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/_compute_management_client.py +++ /dev/null @@ -1,221 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ( - AvailabilitySetsOperations, - DisksOperations, - ImagesOperations, - ResourceSkusOperations, - SnapshotsOperations, - UsageOperations, - VirtualMachineExtensionImagesOperations, - VirtualMachineExtensionsOperations, - VirtualMachineImagesOperations, - VirtualMachineRunCommandsOperations, - VirtualMachineScaleSetExtensionsOperations, - VirtualMachineScaleSetRollingUpgradesOperations, - VirtualMachineScaleSetVMsOperations, - VirtualMachineScaleSetsOperations, - VirtualMachineSizesOperations, - VirtualMachinesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2017_03_30.aio.operations.AvailabilitySetsOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2017_03_30.aio.operations.VirtualMachineExtensionImagesOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2017_03_30.aio.operations.VirtualMachineExtensionsOperations - :ivar virtual_machines: VirtualMachinesOperations operations - :vartype virtual_machines: - azure.mgmt.compute.v2017_03_30.aio.operations.VirtualMachinesOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2017_03_30.aio.operations.VirtualMachineImagesOperations - :ivar usage: UsageOperations operations - :vartype usage: azure.mgmt.compute.v2017_03_30.aio.operations.UsageOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2017_03_30.aio.operations.VirtualMachineSizesOperations - :ivar images: ImagesOperations operations - :vartype images: azure.mgmt.compute.v2017_03_30.aio.operations.ImagesOperations - :ivar resource_skus: ResourceSkusOperations operations - :vartype resource_skus: azure.mgmt.compute.v2017_03_30.aio.operations.ResourceSkusOperations - :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations - :vartype virtual_machine_scale_sets: - azure.mgmt.compute.v2017_03_30.aio.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations - operations - :vartype virtual_machine_scale_set_extensions: - azure.mgmt.compute.v2017_03_30.aio.operations.VirtualMachineScaleSetExtensionsOperations - :ivar virtual_machine_scale_set_rolling_upgrades: - VirtualMachineScaleSetRollingUpgradesOperations operations - :vartype virtual_machine_scale_set_rolling_upgrades: - azure.mgmt.compute.v2017_03_30.aio.operations.VirtualMachineScaleSetRollingUpgradesOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2017_03_30.aio.operations.VirtualMachineScaleSetVMsOperations - :ivar disks: DisksOperations operations - :vartype disks: azure.mgmt.compute.v2017_03_30.aio.operations.DisksOperations - :ivar snapshots: SnapshotsOperations operations - :vartype snapshots: azure.mgmt.compute.v2017_03_30.aio.operations.SnapshotsOperations - :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations - :vartype virtual_machine_run_commands: - azure.mgmt.compute.v2017_03_30.aio.operations.VirtualMachineRunCommandsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2017-03-30". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.availability_sets = AvailabilitySetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.virtual_machine_images = VirtualMachineImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2017-03-30") - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2017-03-30") - self.resource_skus = ResourceSkusOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize, "2017-03-30") - self.snapshots = SnapshotsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-03-30" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/_configuration.py deleted file mode 100644 index 43d1f48aa114..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2017-03-30". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2017-03-30") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/__init__.py deleted file mode 100644 index 8e2dbe1731a1..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/__init__.py +++ /dev/null @@ -1,55 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import AvailabilitySetsOperations # type: ignore -from ._operations import VirtualMachineExtensionImagesOperations # type: ignore -from ._operations import VirtualMachineExtensionsOperations # type: ignore -from ._operations import VirtualMachinesOperations # type: ignore -from ._operations import VirtualMachineImagesOperations # type: ignore -from ._operations import UsageOperations # type: ignore -from ._operations import VirtualMachineSizesOperations # type: ignore -from ._operations import ImagesOperations # type: ignore -from ._operations import ResourceSkusOperations # type: ignore -from ._operations import VirtualMachineScaleSetsOperations # type: ignore -from ._operations import VirtualMachineScaleSetExtensionsOperations # type: ignore -from ._operations import VirtualMachineScaleSetRollingUpgradesOperations # type: ignore -from ._operations import VirtualMachineScaleSetVMsOperations # type: ignore -from ._operations import DisksOperations # type: ignore -from ._operations import SnapshotsOperations # type: ignore -from ._operations import VirtualMachineRunCommandsOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AvailabilitySetsOperations", - "VirtualMachineExtensionImagesOperations", - "VirtualMachineExtensionsOperations", - "VirtualMachinesOperations", - "VirtualMachineImagesOperations", - "UsageOperations", - "VirtualMachineSizesOperations", - "ImagesOperations", - "ResourceSkusOperations", - "VirtualMachineScaleSetsOperations", - "VirtualMachineScaleSetExtensionsOperations", - "VirtualMachineScaleSetRollingUpgradesOperations", - "VirtualMachineScaleSetVMsOperations", - "DisksOperations", - "SnapshotsOperations", - "VirtualMachineRunCommandsOperations", -] -__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/v2017_03_30/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_operations.py deleted file mode 100644 index daf9ed7bccca..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_operations.py +++ /dev/null @@ -1,11247 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, Dict, IO, List, Literal, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import ( - build_availability_sets_create_or_update_request, - build_availability_sets_delete_request, - build_availability_sets_get_request, - build_availability_sets_list_available_sizes_request, - build_availability_sets_list_by_subscription_request, - build_availability_sets_list_request, - build_disks_create_or_update_request, - build_disks_delete_request, - build_disks_get_request, - build_disks_grant_access_request, - build_disks_list_by_resource_group_request, - build_disks_list_request, - build_disks_revoke_access_request, - build_disks_update_request, - build_images_create_or_update_request, - build_images_delete_request, - build_images_get_request, - build_images_list_by_resource_group_request, - build_images_list_request, - build_resource_skus_list_request, - build_snapshots_create_or_update_request, - build_snapshots_delete_request, - build_snapshots_get_request, - build_snapshots_grant_access_request, - build_snapshots_list_by_resource_group_request, - build_snapshots_list_request, - build_snapshots_revoke_access_request, - build_snapshots_update_request, - build_usage_list_request, - build_virtual_machine_extension_images_get_request, - build_virtual_machine_extension_images_list_types_request, - build_virtual_machine_extension_images_list_versions_request, - build_virtual_machine_extensions_create_or_update_request, - build_virtual_machine_extensions_delete_request, - build_virtual_machine_extensions_get_request, - build_virtual_machine_extensions_update_request, - build_virtual_machine_images_get_request, - build_virtual_machine_images_list_offers_request, - build_virtual_machine_images_list_publishers_request, - build_virtual_machine_images_list_request, - build_virtual_machine_images_list_skus_request, - build_virtual_machine_run_commands_get_request, - build_virtual_machine_run_commands_list_request, - build_virtual_machine_scale_set_extensions_create_or_update_request, - build_virtual_machine_scale_set_extensions_delete_request, - build_virtual_machine_scale_set_extensions_get_request, - build_virtual_machine_scale_set_extensions_list_request, - build_virtual_machine_scale_set_rolling_upgrades_cancel_request, - build_virtual_machine_scale_set_rolling_upgrades_get_latest_request, - build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request, - build_virtual_machine_scale_set_vms_deallocate_request, - build_virtual_machine_scale_set_vms_delete_request, - build_virtual_machine_scale_set_vms_get_instance_view_request, - build_virtual_machine_scale_set_vms_get_request, - build_virtual_machine_scale_set_vms_list_request, - build_virtual_machine_scale_set_vms_power_off_request, - build_virtual_machine_scale_set_vms_reimage_all_request, - build_virtual_machine_scale_set_vms_reimage_request, - build_virtual_machine_scale_set_vms_restart_request, - build_virtual_machine_scale_set_vms_start_request, - build_virtual_machine_scale_sets_create_or_update_request, - build_virtual_machine_scale_sets_deallocate_request, - build_virtual_machine_scale_sets_delete_instances_request, - build_virtual_machine_scale_sets_delete_request, - build_virtual_machine_scale_sets_get_instance_view_request, - build_virtual_machine_scale_sets_get_request, - build_virtual_machine_scale_sets_list_all_request, - build_virtual_machine_scale_sets_list_request, - build_virtual_machine_scale_sets_list_skus_request, - build_virtual_machine_scale_sets_power_off_request, - build_virtual_machine_scale_sets_reimage_all_request, - build_virtual_machine_scale_sets_reimage_request, - build_virtual_machine_scale_sets_restart_request, - build_virtual_machine_scale_sets_start_request, - build_virtual_machine_scale_sets_update_instances_request, - build_virtual_machine_scale_sets_update_request, - build_virtual_machine_sizes_list_request, - build_virtual_machines_capture_request, - build_virtual_machines_convert_to_managed_disks_request, - build_virtual_machines_create_or_update_request, - build_virtual_machines_deallocate_request, - build_virtual_machines_delete_request, - build_virtual_machines_generalize_request, - build_virtual_machines_get_extensions_request, - build_virtual_machines_get_request, - build_virtual_machines_instance_view_request, - build_virtual_machines_list_all_request, - build_virtual_machines_list_available_sizes_request, - build_virtual_machines_list_by_location_request, - build_virtual_machines_list_request, - build_virtual_machines_perform_maintenance_request, - build_virtual_machines_power_off_request, - build_virtual_machines_redeploy_request, - build_virtual_machines_restart_request, - build_virtual_machines_run_command_request, - build_virtual_machines_start_request, -) -from .._configuration import ComputeManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AvailabilitySetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s - :attr:`availability_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2017_03_30.models.AvailabilitySet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_03_30.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_03_30.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySet, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Is either a - AvailabilitySet type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2017_03_30.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySet") - - _request = build_availability_sets_create_or_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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 - ) -> Optional[_models.OperationStatusResponse]: - """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: OperationStatusResponse or None or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse or 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 "2017-03-30")) - cls: ClsType[Optional[_models.OperationStatusResponse]] = kwargs.pop("cls", None) - - _request = build_availability_sets_delete_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("OperationStatusResponse", 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, 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.v2017_03_30.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", 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) - - _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("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription( - self, *, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. - - :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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, 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(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets 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 AvailabilitySet or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, 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_available_sizes( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes that can be used to create a new virtual machine in - an existing availability set. - - :param resource_group_name: The name of the resource group. Required. - :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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_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 - - if response.status_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 VirtualMachineExtensionImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s - :attr:`virtual_machine_extension_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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. - - :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.v2017_03_30.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 "2017-03-30")) - 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 = 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 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 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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - - _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) - - _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 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 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.v2017_03_30.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 "2017-03-30")) - 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 = 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 - - -class VirtualMachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s - :attr:`virtual_machine_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, 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 "2017-03-30")) - 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, "VirtualMachineExtension") - - _request = build_virtual_machine_extensions_create_or_update_request( - resource_group_name=resource_group_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, - 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) - - 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, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2017_03_30.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 VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_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 create or 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 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] - :keyword content_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.v2017_03_30.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2017_03_30.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.v2017_03_30.models.VirtualMachineExtension] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2017-03-30")) - 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( - resource_group_name=resource_group_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, - 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, - 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. - - :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: - ~azure.mgmt.compute.v2017_03_30.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.v2017_03_30.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.v2017_03_30.models.VirtualMachineExtension] - :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.v2017_03_30.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.v2017_03_30.models.VirtualMachineExtension] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2017-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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) - - _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, vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """The operation to delete 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 deleted. - 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - vm_extension_name=vm_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, - 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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_get_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -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.v2017_03_30.aio.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_extensions( - 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.v2017_03_30.models.VirtualMachineExtensionsListResult - :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 "2017-03-30")) - cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machines_get_extensions_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 - - @distributed_trace - def list_by_location(self, location: str, **kwargs: Any) -> AsyncItemPaged["_models.VirtualMachine"]: - """Gets all the virtual machines under the specified subscription for the specified location. - - :param location: The location for which virtual machines under the subscription are queried. - Required. - :type location: str - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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 - - 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) - - 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 _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, - 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 "2017-03-30")) - 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, "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 = 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_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. 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.v2017_03_30.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.v2017_03_30.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. 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.v2017_03_30.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. 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.v2017_03_30.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.v2017_03_30.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - 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 - ) - 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) - 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": "azure-async-operation"}, **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 _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, 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 "2017-03-30")) - 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, - 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) - - 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, - vm_name: str, - parameters: _models.VirtualMachine, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to create or 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 Create Virtual Machine operation. Required. - :type parameters: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachine - :keyword content_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.v2017_03_30.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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to create or 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 Create 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 VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to create or 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 Create Virtual Machine operation. Is either a - VirtualMachine type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachine or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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, - 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, **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, **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 "2017-03-30")) - 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, - 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, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """The operation to delete 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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: Literal["instanceView"] = "instanceView", **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) - - _request = build_virtual_machines_get_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def instance_view( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> _models.VirtualMachineInstanceView: - """Retrieves information about the run-time state of a virtual machine. - - :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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) - - _request = build_virtual_machines_instance_view_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineInstanceView", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _convert_to_managed_disks_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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_convert_to_managed_disks_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_convert_to_managed_disks( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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. - :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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _deallocate_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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - 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, - 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, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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 - ) -> _models.OperationStatusResponse: - """Sets the state of the virtual machine to generalized. - - :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: OperationStatusResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse - :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 "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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) - - deserialized = self._deserialize("OperationStatusResponse", 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) -> AsyncItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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, - 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("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) - - 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) -> AsyncItemPaged["_models.VirtualMachine"]: - """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. - - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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, - 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("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) - - 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_available_sizes( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes to which the specified virtual machine can be - resized. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_available_sizes_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 - - if response.status_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_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 "2017-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_power_off_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_power_off( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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. - :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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._power_off_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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]: - 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 "2017-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_restart_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - 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_restart( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """The operation to restart 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._restart_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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]: - 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 "2017-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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_start( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_redeploy_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_redeploy( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._redeploy_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _perform_maintenance_initial( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> 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 "2017-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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_perform_maintenance( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """The operation to perform maintenance on 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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_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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _run_command_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> 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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RunCommandInput") - - _request = build_virtual_machines_run_command_request( - 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) - - 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_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2017_03_30.models.RunCommandInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2017_03_30.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.v2017_03_30.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._run_command_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s - :attr:`virtual_machine_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.v2017_03_30.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 "2017-03-30")) - 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.v2017_03_30.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 "2017-03-30")) - 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.v2017_03_30.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 "2017-03-30")) - 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. - - :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.v2017_03_30.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 "2017-03-30")) - 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) - 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. - - :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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _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) - - _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 - - -class UsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s - :attr:`usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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 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.v2017_03_30.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 "2017-03-30")) - 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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ListUsagesResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class VirtualMachineSizesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes for a subscription in a location. - - :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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_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 - - 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 - - if response.status_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 ImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s - :attr:`images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> 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 "2017-03-30")) - 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) - - 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, - image_name: str, - parameters: _models.Image, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Create or update an image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param 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.v2017_03_30.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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Create or update an image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param 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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.Image] - :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. - - :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 - :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.v2017_03_30.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.v2017_03_30.models.Image] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._create_or_update_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Image]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial(self, resource_group_name: str, image_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_images_delete_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, image_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Deletes 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 - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - image_name=image_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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.v2017_03_30.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 "2017-03-30")) - 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 = 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("Image", 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) -> AsyncItemPaged["_models.Image"]: - """Gets the list of images 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 Image or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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(self, **kwargs: Any) -> AsyncItemPaged["_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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class ResourceSkusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s - :attr:`resource_skus` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.ResourceSku"]: - """Gets the list of Microsoft.Compute SKUs available for your Subscription. - - :return: An iterator like instance of either ResourceSku or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.ResourceSku] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.ResourceSkusResult] = 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_resource_skus_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("ResourceSkusResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - parameters: Union[_models.VirtualMachineScaleSet, 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 "2017-03-30")) - 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, - 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) - - 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, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. 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.v2017_03_30.models.VirtualMachineScaleSet - :keyword content_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.v2017_03_30.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. 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: IO[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 VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 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.v2017_03_30.models.VirtualMachineScaleSet or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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, - 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]], - **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 "2017-03-30")) - 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, "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, - 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, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSetUpdate, - *, - 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. 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.v2017_03_30.models.VirtualMachineScaleSetUpdate - :keyword content_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.v2017_03_30.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], - *, - 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. 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: IO[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 VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Update 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 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.v2017_03_30.models.VirtualMachineScaleSetUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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, - 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 _delete_initial( - self, resource_group_name: str, vm_scale_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 "2017-03-30")) - cls: ClsType[AsyncIterator[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, - 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, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, **kwargs: Any - ) -> _models.VirtualMachineScaleSet: - """Display information about a 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 - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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, - 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 _deallocate_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 "2017-03-30")) - 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_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_deallocate( - 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[_models.OperationStatusResponse]: - """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. - :type 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.v2017_03_30.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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_deallocate( - 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[_models.OperationStatusResponse]: - """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. - :type 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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, - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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. - :type 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.v2017_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-03-30")) - 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: - _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, - 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_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_03_30.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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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. - 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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.v2017_03_30.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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.v2017_03_30.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 "2017-03-30")) - 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) -> AsyncItemPaged["_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 - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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_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("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 - def list_all(self, **kwargs: Any) -> AsyncItemPaged["_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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = 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_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("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) - - 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_skus( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineScaleSetSku"]: - """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM - instances allowed for each SKU. - - :param resource_group_name: The name of the resource group. Required. - :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.v2017_03_30.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 "2017-03-30")) - 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 - - 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 _power_off_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 "2017-03-30")) - 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_power_off_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_power_off( - 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[_models.OperationStatusResponse]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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.v2017_03_30.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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_power_off( - 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[_models.OperationStatusResponse]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async 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, - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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.v2017_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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 "2017-03-30")) - 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_restart_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_03_30.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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, - 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 "2017-03-30")) - 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 - 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_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[_models.OperationStatusResponse]: - """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.v2017_03_30.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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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.v2017_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-03-30")) - 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: - _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, - 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_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_03_30.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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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_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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Reimages (upgrade the operating system) 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.v2017_03_30.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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_reimage( - 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[_models.OperationStatusResponse]: - """Reimages (upgrade the operating system) 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Reimages (upgrade the operating system) 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.v2017_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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_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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _reimage_all_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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.v2017_03_30.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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_all_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # 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.v2017_03_30.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2017-03-30")) - 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") - - _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, - 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) - - 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, - 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. - - :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.v2017_03_30.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.v2017_03_30.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2017_03_30.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtension, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to create or update an extension. - - :param resource_group_name: The name of the resource group. Required. - :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.v2017_03_30.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.v2017_03_30.models.VirtualMachineScaleSetExtension] - :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 "2017-03-30")) - 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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-03-30")) - cls: ClsType[AsyncIterator[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, - 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, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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.v2017_03_30.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 "2017-03-30")) - 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 - ) -> AsyncItemPaged["_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.v2017_03_30.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 "2017-03-30")) - 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. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> 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 "2017-03-30")) - 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, - 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 - - @distributed_trace_async - async def begin_cancel( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Cancels the current 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: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _start_os_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-03-30")) - 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, - 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 - - @distributed_trace_async - async def begin_start_os_upgrade( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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. Required. - :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.v2017_03_30.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 "2017-03-30")) - 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 = 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("RollingUpgradeStatusInfo", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class VirtualMachineScaleSetVMsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _reimage_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **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 "2017-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_reimage_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - 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 - - @distributed_trace_async - async def begin_reimage( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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 "2017-03-30")) - 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) - - 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_reimage_all( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. - This operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _deallocate_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_deallocate( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and - releases the compute resources it uses. You are not billed for the compute resources of this - virtual machine once it is deallocated. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, **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 "2017-03-30")) - 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, - 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, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Deletes 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: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, **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 - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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, - 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("VirtualMachineScaleSetVM", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_instance_view( - self, resource_group_name: str, vm_scale_set_name: str, 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.v2017_03_30.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 "2017-03-30")) - 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 - ) -> AsyncItemPaged["_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.v2017_03_30.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 "2017-03-30")) - 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, **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 "2017-03-30")) - 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, - 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, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, - 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 "2017-03-30")) - cls: ClsType[AsyncIterator[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 = 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_restart( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Restarts 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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 - ) -> 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 "2017-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_start_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - 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[_models.OperationStatusResponse]: - """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 - :param vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class DisksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s - :attr:`disks` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_name: str, disk: Union[_models.Disk, 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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk, (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_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) - - _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_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. 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.v2017_03_30.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.v2017_03_30.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. 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.v2017_03_30.models.Disk] - :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. - - :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 - :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.v2017_03_30.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.v2017_03_30.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 "2017-03-30")) - 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._create_or_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 - ) - await 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: 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.Disk].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Disk]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _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, - 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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk, (IOBase, bytes)): - _content = disk - else: - _json = self._serialize.body(disk, "DiskUpdate") - - _request = build_disks_update_request( - resource_group_name=resource_group_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) - - _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( - self, - resource_group_name: str, - disk_name: str, - disk: _models.DiskUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Updates (patches) a disk. - - :param resource_group_name: The name of the resource group. 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.v2017_03_30.models.DiskUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.Disk] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - disk_name: str, - disk: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Updates (patches) a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Patch disk operation. Required. - :type disk: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.Disk] - :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. - - :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 - :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.v2017_03_30.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.v2017_03_30.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 "2017-03-30")) - 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._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 - ) - await 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: 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.Disk].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Disk]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) - - _request = build_disks_get_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) - - _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("Disk", 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_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 "2017-03-30")) - 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[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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) -> AsyncItemPaged["_models.Disk"]: - """Lists all the disks 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 Disk or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disks_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _grant_access_initial( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, 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 "2017-03-30")) - 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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disks_grant_access_request( - resource_group_name=resource_group_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) - - _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_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2017_03_30.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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param grant_access_data: Access data object supplied in the body of the get disk access - operation. Required. - :type grant_access_data: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2017_03_30.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.v2017_03_30.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 "2017-03-30")) - 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, - disk_name=disk_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, **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, 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 "2017-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disks_revoke_access_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]: - 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_revoke_access( - self, resource_group_name: str, disk_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Revokes access to 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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.v2017_03_30.aio.ComputeManagementClient`'s - :attr:`snapshots` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, snapshot_name: str, snapshot: Union[_models.Snapshot, 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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "Snapshot") - - _request = build_snapshots_create_or_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.Snapshot, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: ~azure.mgmt.compute.v2017_03_30.models.Snapshot - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :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.v2017_03_30.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.v2017_03_30.models.Snapshot] - :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 "2017-03-30")) - 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._create_or_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, **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 _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, - 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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "SnapshotUpdate") - - _request = build_snapshots_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.SnapshotUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. 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.v2017_03_30.models.SnapshotUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. - Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. Is - either a SnapshotUpdate type or a IO[bytes] type. Required. - :type snapshot: ~azure.mgmt.compute.v2017_03_30.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.v2017_03_30.models.Snapshot] - :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 "2017-03-30")) - 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, **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 - ) - - @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.v2017_03_30.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 "2017-03-30")) - 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( - 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 "2017-03-30")) - 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) - - 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, snapshot_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Deletes 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: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - snapshot_name=snapshot_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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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) -> AsyncItemPaged["_models.Snapshot"]: - """Lists snapshots 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 Snapshot or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - 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(self, **kwargs: Any) -> AsyncItemPaged["_models.Snapshot"]: - """Lists snapshots under a subscription. - - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _grant_access_initial( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, 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 "2017-03-30")) - 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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_snapshots_grant_access_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param grant_access_data: Access data object supplied in the body of the get snapshot access - operation. Required. - :type grant_access_data: ~azure.mgmt.compute.v2017_03_30.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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param 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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param 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.v2017_03_30.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.v2017_03_30.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 "2017-03-30")) - 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, - snapshot_name=snapshot_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, **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, 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 "2017-03-30")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_snapshots_revoke_access_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]: - 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_revoke_access( - self, resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Revokes access to 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: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - snapshot_name=snapshot_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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineRunCommandsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s - :attr:`virtual_machine_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.RunCommandDocumentBase"]: - """Lists all available run commands for a subscription in a location. - - :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 - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_run_commands_list_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RunCommandListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, location: str, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: - """Gets specific run command for a subscription in a location. - - :param location: The 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.v2017_03_30.models.RunCommandDocument - :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 "2017-03-30")) - cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) - - _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, - 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("RunCommandDocument", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/__init__.py deleted file mode 100644 index 8cca6b7c8d49..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/__init__.py +++ /dev/null @@ -1,356 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - AccessUri, - AdditionalUnattendContent, - ApiEntityReference, - ApiError, - ApiErrorBase, - AvailabilitySet, - AvailabilitySetListResult, - BootDiagnostics, - BootDiagnosticsInstanceView, - ComputeLongRunningOperationProperties, - CreationData, - DataDisk, - DataDiskImage, - DiagnosticsProfile, - Disk, - DiskEncryptionSettings, - DiskInstanceView, - DiskList, - DiskSku, - DiskUpdate, - EncryptionSettings, - GrantAccessData, - HardwareProfile, - Image, - ImageDataDisk, - ImageDiskReference, - ImageListResult, - ImageOSDisk, - ImageReference, - ImageStorageProfile, - InnerError, - InstanceViewStatus, - KeyVaultAndKeyReference, - KeyVaultAndSecretReference, - KeyVaultKeyReference, - KeyVaultSecretReference, - LinuxConfiguration, - ListUsagesResult, - MaintenanceRedeployStatus, - ManagedDiskParameters, - NetworkInterfaceReference, - NetworkProfile, - OSDisk, - OSDiskImage, - OSProfile, - OperationStatusResponse, - Plan, - PurchasePlan, - Resource, - ResourceSku, - ResourceSkuCapabilities, - ResourceSkuCapacity, - ResourceSkuCosts, - ResourceSkuRestrictions, - ResourceSkusResult, - ResourceUpdate, - RollingUpgradePolicy, - RollingUpgradeProgressInfo, - RollingUpgradeRunningStatus, - RollingUpgradeStatusInfo, - RunCommandDocument, - RunCommandDocumentBase, - RunCommandInput, - RunCommandInputParameter, - RunCommandListResult, - RunCommandParameterDefinition, - RunCommandResult, - Sku, - Snapshot, - SnapshotList, - SnapshotUpdate, - SourceVault, - SshConfiguration, - SshPublicKey, - StorageProfile, - SubResource, - SubResourceReadOnly, - UpdateResource, - UpgradePolicy, - Usage, - UsageName, - VaultCertificate, - VaultSecretGroup, - VirtualHardDisk, - VirtualMachine, - VirtualMachineAgentInstanceView, - VirtualMachineCaptureParameters, - VirtualMachineCaptureResult, - VirtualMachineExtension, - VirtualMachineExtensionHandlerInstanceView, - VirtualMachineExtensionImage, - VirtualMachineExtensionInstanceView, - VirtualMachineExtensionUpdate, - VirtualMachineExtensionsListResult, - VirtualMachineHealthStatus, - VirtualMachineIdentity, - VirtualMachineImage, - VirtualMachineImageResource, - VirtualMachineInstanceView, - VirtualMachineListResult, - VirtualMachineScaleSet, - VirtualMachineScaleSetDataDisk, - VirtualMachineScaleSetExtension, - VirtualMachineScaleSetExtensionListResult, - VirtualMachineScaleSetExtensionProfile, - VirtualMachineScaleSetIPConfiguration, - VirtualMachineScaleSetIdentity, - VirtualMachineScaleSetInstanceView, - VirtualMachineScaleSetInstanceViewStatusesSummary, - VirtualMachineScaleSetListResult, - VirtualMachineScaleSetListSkusResult, - VirtualMachineScaleSetListWithLinkResult, - VirtualMachineScaleSetManagedDiskParameters, - VirtualMachineScaleSetNetworkConfiguration, - VirtualMachineScaleSetNetworkConfigurationDnsSettings, - VirtualMachineScaleSetNetworkProfile, - VirtualMachineScaleSetOSDisk, - VirtualMachineScaleSetOSProfile, - VirtualMachineScaleSetPublicIPAddressConfiguration, - VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings, - VirtualMachineScaleSetSku, - VirtualMachineScaleSetSkuCapacity, - VirtualMachineScaleSetStorageProfile, - VirtualMachineScaleSetUpdate, - VirtualMachineScaleSetUpdateIPConfiguration, - VirtualMachineScaleSetUpdateNetworkConfiguration, - VirtualMachineScaleSetUpdateNetworkProfile, - VirtualMachineScaleSetUpdateOSDisk, - VirtualMachineScaleSetUpdateOSProfile, - VirtualMachineScaleSetUpdatePublicIPAddressConfiguration, - VirtualMachineScaleSetUpdateStorageProfile, - VirtualMachineScaleSetUpdateVMProfile, - VirtualMachineScaleSetVM, - VirtualMachineScaleSetVMExtensionsSummary, - VirtualMachineScaleSetVMInstanceIDs, - VirtualMachineScaleSetVMInstanceRequiredIDs, - VirtualMachineScaleSetVMInstanceView, - VirtualMachineScaleSetVMListResult, - VirtualMachineScaleSetVMProfile, - VirtualMachineSize, - VirtualMachineSizeListResult, - VirtualMachineStatusCodeCount, - WinRMConfiguration, - WinRMListener, - WindowsConfiguration, -) - -from ._compute_management_client_enums import ( # type: ignore - AccessLevel, - CachingTypes, - DiskCreateOption, - DiskCreateOptionTypes, - IPVersion, - MaintenanceOperationResultCodeTypes, - OperatingSystemStateTypes, - OperatingSystemTypes, - ProtocolTypes, - ResourceSkuCapacityScaleType, - ResourceSkuRestrictionsReasonCode, - RollingUpgradeActionType, - RollingUpgradeStatusCode, - SettingNames, - StatusLevelTypes, - StorageAccountTypes, - UpgradeMode, - VirtualMachineScaleSetSkuScaleType, - VirtualMachineSizeTypes, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AccessUri", - "AdditionalUnattendContent", - "ApiEntityReference", - "ApiError", - "ApiErrorBase", - "AvailabilitySet", - "AvailabilitySetListResult", - "BootDiagnostics", - "BootDiagnosticsInstanceView", - "ComputeLongRunningOperationProperties", - "CreationData", - "DataDisk", - "DataDiskImage", - "DiagnosticsProfile", - "Disk", - "DiskEncryptionSettings", - "DiskInstanceView", - "DiskList", - "DiskSku", - "DiskUpdate", - "EncryptionSettings", - "GrantAccessData", - "HardwareProfile", - "Image", - "ImageDataDisk", - "ImageDiskReference", - "ImageListResult", - "ImageOSDisk", - "ImageReference", - "ImageStorageProfile", - "InnerError", - "InstanceViewStatus", - "KeyVaultAndKeyReference", - "KeyVaultAndSecretReference", - "KeyVaultKeyReference", - "KeyVaultSecretReference", - "LinuxConfiguration", - "ListUsagesResult", - "MaintenanceRedeployStatus", - "ManagedDiskParameters", - "NetworkInterfaceReference", - "NetworkProfile", - "OSDisk", - "OSDiskImage", - "OSProfile", - "OperationStatusResponse", - "Plan", - "PurchasePlan", - "Resource", - "ResourceSku", - "ResourceSkuCapabilities", - "ResourceSkuCapacity", - "ResourceSkuCosts", - "ResourceSkuRestrictions", - "ResourceSkusResult", - "ResourceUpdate", - "RollingUpgradePolicy", - "RollingUpgradeProgressInfo", - "RollingUpgradeRunningStatus", - "RollingUpgradeStatusInfo", - "RunCommandDocument", - "RunCommandDocumentBase", - "RunCommandInput", - "RunCommandInputParameter", - "RunCommandListResult", - "RunCommandParameterDefinition", - "RunCommandResult", - "Sku", - "Snapshot", - "SnapshotList", - "SnapshotUpdate", - "SourceVault", - "SshConfiguration", - "SshPublicKey", - "StorageProfile", - "SubResource", - "SubResourceReadOnly", - "UpdateResource", - "UpgradePolicy", - "Usage", - "UsageName", - "VaultCertificate", - "VaultSecretGroup", - "VirtualHardDisk", - "VirtualMachine", - "VirtualMachineAgentInstanceView", - "VirtualMachineCaptureParameters", - "VirtualMachineCaptureResult", - "VirtualMachineExtension", - "VirtualMachineExtensionHandlerInstanceView", - "VirtualMachineExtensionImage", - "VirtualMachineExtensionInstanceView", - "VirtualMachineExtensionUpdate", - "VirtualMachineExtensionsListResult", - "VirtualMachineHealthStatus", - "VirtualMachineIdentity", - "VirtualMachineImage", - "VirtualMachineImageResource", - "VirtualMachineInstanceView", - "VirtualMachineListResult", - "VirtualMachineScaleSet", - "VirtualMachineScaleSetDataDisk", - "VirtualMachineScaleSetExtension", - "VirtualMachineScaleSetExtensionListResult", - "VirtualMachineScaleSetExtensionProfile", - "VirtualMachineScaleSetIPConfiguration", - "VirtualMachineScaleSetIdentity", - "VirtualMachineScaleSetInstanceView", - "VirtualMachineScaleSetInstanceViewStatusesSummary", - "VirtualMachineScaleSetListResult", - "VirtualMachineScaleSetListSkusResult", - "VirtualMachineScaleSetListWithLinkResult", - "VirtualMachineScaleSetManagedDiskParameters", - "VirtualMachineScaleSetNetworkConfiguration", - "VirtualMachineScaleSetNetworkConfigurationDnsSettings", - "VirtualMachineScaleSetNetworkProfile", - "VirtualMachineScaleSetOSDisk", - "VirtualMachineScaleSetOSProfile", - "VirtualMachineScaleSetPublicIPAddressConfiguration", - "VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings", - "VirtualMachineScaleSetSku", - "VirtualMachineScaleSetSkuCapacity", - "VirtualMachineScaleSetStorageProfile", - "VirtualMachineScaleSetUpdate", - "VirtualMachineScaleSetUpdateIPConfiguration", - "VirtualMachineScaleSetUpdateNetworkConfiguration", - "VirtualMachineScaleSetUpdateNetworkProfile", - "VirtualMachineScaleSetUpdateOSDisk", - "VirtualMachineScaleSetUpdateOSProfile", - "VirtualMachineScaleSetUpdatePublicIPAddressConfiguration", - "VirtualMachineScaleSetUpdateStorageProfile", - "VirtualMachineScaleSetUpdateVMProfile", - "VirtualMachineScaleSetVM", - "VirtualMachineScaleSetVMExtensionsSummary", - "VirtualMachineScaleSetVMInstanceIDs", - "VirtualMachineScaleSetVMInstanceRequiredIDs", - "VirtualMachineScaleSetVMInstanceView", - "VirtualMachineScaleSetVMListResult", - "VirtualMachineScaleSetVMProfile", - "VirtualMachineSize", - "VirtualMachineSizeListResult", - "VirtualMachineStatusCodeCount", - "WinRMConfiguration", - "WinRMListener", - "WindowsConfiguration", - "AccessLevel", - "CachingTypes", - "DiskCreateOption", - "DiskCreateOptionTypes", - "IPVersion", - "MaintenanceOperationResultCodeTypes", - "OperatingSystemStateTypes", - "OperatingSystemTypes", - "ProtocolTypes", - "ResourceSkuCapacityScaleType", - "ResourceSkuRestrictionsReasonCode", - "RollingUpgradeActionType", - "RollingUpgradeStatusCode", - "SettingNames", - "StatusLevelTypes", - "StorageAccountTypes", - "UpgradeMode", - "VirtualMachineScaleSetSkuScaleType", - "VirtualMachineSizeTypes", -] -__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/v2017_03_30/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/_compute_management_client_enums.py deleted file mode 100644 index 239b67fad168..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/_compute_management_client_enums.py +++ /dev/null @@ -1,288 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AccessLevel.""" - - NONE = "None" - READ = "Read" - - -class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** :code:`
    `\\ - :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for Standard storage. - ReadOnly for Premium storage**. - """ - - NONE = "None" - READ_ONLY = "ReadOnly" - READ_WRITE = "ReadWrite" - - -class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This enumerates the possible sources of a disk's creation.""" - - EMPTY = "Empty" - ATTACH = "Attach" - FROM_IMAGE = "FromImage" - IMPORT = "Import" - COPY = "Copy" - IMPORT_ENUM = "Import" - - -class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies how the virtual machine should be created.\\ :code:`
    `\\ :code:`
    ` Possible - values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value is used when you are - using a specialized disk to create the virtual machine.\\ :code:`
    `\\ :code:`
    ` - **FromImage** \\u2013 This value is used when you are using an image to create the virtual - machine. If you are using a platform image, you also use the imageReference element described - above. If you are using a marketplace image, you also use the plan element previously - described. - """ - - FROM_IMAGE = "FromImage" - EMPTY = "Empty" - ATTACH = "Attach" - - -class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """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'. - """ - - I_PV4 = "IPv4" - I_PV6 = "IPv6" - - -class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The Last Maintenance Operation Result Code.""" - - NONE = "None" - RETRY_LATER = "RetryLater" - MAINTENANCE_ABORTED = "MaintenanceAborted" - MAINTENANCE_COMPLETED = "MaintenanceCompleted" - - -class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The OS State.""" - - GENERALIZED = "Generalized" - SPECIALIZED = "Specialized" - - -class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The operating system of the osDiskImage.""" - - WINDOWS = "Windows" - LINUX = "Linux" - - -class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the protocol of listener. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. - """ - - HTTP = "Http" - HTTPS = "Https" - - -class ResourceSkuCapacityScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scale type applicable to the sku.""" - - AUTOMATIC = "Automatic" - MANUAL = "Manual" - NONE = "None" - - -class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The reason for restriction.""" - - QUOTA_ID = "QuotaId" - NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" - - -class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The last action performed on the rolling upgrade.""" - - START = "Start" - CANCEL = "Cancel" - - -class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Code indicating the current status of the upgrade.""" - - ROLLING_FORWARD = "RollingForward" - CANCELLED = "Cancelled" - COMPLETED = "Completed" - FAULTED = "Faulted" - - -class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the name of the setting to which the content applies. Possible values are: - FirstLogonCommands and AutoLogon. - """ - - AUTO_LOGON = "AutoLogon" - FIRST_LOGON_COMMANDS = "FirstLogonCommands" - - -class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The level code.""" - - INFO = "Info" - WARNING = "Warning" - ERROR = "Error" - - -class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the storage account type for the managed disk. Possible values are: Standard_LRS or - Premium_LRS. - """ - - STANDARD_LRS = "Standard_LRS" - PREMIUM_LRS = "Premium_LRS" - - -class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the mode of an upgrade to virtual machines in the scale set.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Manual** - You control - the application of updates to virtual machines in the scale set. You do this by using the - manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - All virtual machines in - the scale set are automatically updated at the same time. - """ - - AUTOMATIC = "Automatic" - MANUAL = "Manual" - ROLLING = "Rolling" - - -class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scale type applicable to the sku.""" - - AUTOMATIC = "Automatic" - NONE = "None" - - -class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the size of the virtual machine. For more information about virtual machine sizes, - see `Sizes for virtual machines - `_. - :code:`
    `\\ :code:`
    ` The available VM sizes depend on region and availability set. For a - list of available sizes use these APIs: :code:`
    `\\ :code:`
    ` `List all available - virtual machine sizes in an availability set - `_ - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in a region - `_ :code:`
    `\\ - :code:`
    ` `List all available virtual machine sizes for resizing - `_. - """ - - BASIC_A0 = "Basic_A0" - BASIC_A1 = "Basic_A1" - BASIC_A2 = "Basic_A2" - BASIC_A3 = "Basic_A3" - BASIC_A4 = "Basic_A4" - STANDARD_A0 = "Standard_A0" - STANDARD_A1 = "Standard_A1" - STANDARD_A2 = "Standard_A2" - STANDARD_A3 = "Standard_A3" - STANDARD_A4 = "Standard_A4" - STANDARD_A5 = "Standard_A5" - STANDARD_A6 = "Standard_A6" - STANDARD_A7 = "Standard_A7" - STANDARD_A8 = "Standard_A8" - STANDARD_A9 = "Standard_A9" - STANDARD_A10 = "Standard_A10" - STANDARD_A11 = "Standard_A11" - STANDARD_A1_V2 = "Standard_A1_v2" - STANDARD_A2_V2 = "Standard_A2_v2" - STANDARD_A4_V2 = "Standard_A4_v2" - STANDARD_A8_V2 = "Standard_A8_v2" - STANDARD_A2_M_V2 = "Standard_A2m_v2" - STANDARD_A4_M_V2 = "Standard_A4m_v2" - STANDARD_A8_M_V2 = "Standard_A8m_v2" - STANDARD_D1 = "Standard_D1" - STANDARD_D2 = "Standard_D2" - STANDARD_D3 = "Standard_D3" - STANDARD_D4 = "Standard_D4" - STANDARD_D11 = "Standard_D11" - STANDARD_D12 = "Standard_D12" - STANDARD_D13 = "Standard_D13" - STANDARD_D14 = "Standard_D14" - STANDARD_D1_V2 = "Standard_D1_v2" - STANDARD_D2_V2 = "Standard_D2_v2" - STANDARD_D3_V2 = "Standard_D3_v2" - STANDARD_D4_V2 = "Standard_D4_v2" - STANDARD_D5_V2 = "Standard_D5_v2" - STANDARD_D11_V2 = "Standard_D11_v2" - STANDARD_D12_V2 = "Standard_D12_v2" - STANDARD_D13_V2 = "Standard_D13_v2" - STANDARD_D14_V2 = "Standard_D14_v2" - STANDARD_D15_V2 = "Standard_D15_v2" - STANDARD_DS1 = "Standard_DS1" - STANDARD_DS2 = "Standard_DS2" - STANDARD_DS3 = "Standard_DS3" - STANDARD_DS4 = "Standard_DS4" - STANDARD_DS11 = "Standard_DS11" - STANDARD_DS12 = "Standard_DS12" - STANDARD_DS13 = "Standard_DS13" - STANDARD_DS14 = "Standard_DS14" - STANDARD_DS1_V2 = "Standard_DS1_v2" - STANDARD_DS2_V2 = "Standard_DS2_v2" - STANDARD_DS3_V2 = "Standard_DS3_v2" - STANDARD_DS4_V2 = "Standard_DS4_v2" - STANDARD_DS5_V2 = "Standard_DS5_v2" - STANDARD_DS11_V2 = "Standard_DS11_v2" - STANDARD_DS12_V2 = "Standard_DS12_v2" - STANDARD_DS13_V2 = "Standard_DS13_v2" - STANDARD_DS14_V2 = "Standard_DS14_v2" - STANDARD_DS15_V2 = "Standard_DS15_v2" - STANDARD_F1 = "Standard_F1" - STANDARD_F2 = "Standard_F2" - STANDARD_F4 = "Standard_F4" - STANDARD_F8 = "Standard_F8" - STANDARD_F16 = "Standard_F16" - STANDARD_F1_S = "Standard_F1s" - STANDARD_F2_S = "Standard_F2s" - STANDARD_F4_S = "Standard_F4s" - STANDARD_F8_S = "Standard_F8s" - STANDARD_F16_S = "Standard_F16s" - STANDARD_G1 = "Standard_G1" - STANDARD_G2 = "Standard_G2" - STANDARD_G3 = "Standard_G3" - STANDARD_G4 = "Standard_G4" - STANDARD_G5 = "Standard_G5" - STANDARD_GS1 = "Standard_GS1" - STANDARD_GS2 = "Standard_GS2" - STANDARD_GS3 = "Standard_GS3" - STANDARD_GS4 = "Standard_GS4" - STANDARD_GS5 = "Standard_GS5" - STANDARD_H8 = "Standard_H8" - STANDARD_H16 = "Standard_H16" - STANDARD_H8_M = "Standard_H8m" - STANDARD_H16_M = "Standard_H16m" - STANDARD_H16_R = "Standard_H16r" - STANDARD_H16_MR = "Standard_H16mr" - STANDARD_L4_S = "Standard_L4s" - STANDARD_L8_S = "Standard_L8s" - STANDARD_L16_S = "Standard_L16s" - STANDARD_L32_S = "Standard_L32s" - STANDARD_NC6 = "Standard_NC6" - STANDARD_NC12 = "Standard_NC12" - STANDARD_NC24 = "Standard_NC24" - STANDARD_NC24_R = "Standard_NC24r" - STANDARD_NV6 = "Standard_NV6" - STANDARD_NV12 = "Standard_NV12" - STANDARD_NV24 = "Standard_NV24" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/_models_py3.py deleted file mode 100644 index 7b303bf883ab..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/_models_py3.py +++ /dev/null @@ -1,7720 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from collections.abc import MutableMapping -import datetime -from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models -JSON = MutableMapping[str, Any] - - -class AccessUri(_serialization.Model): - """A disk access SAS uri. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar access_sas: A SAS uri for accessing a disk. - :vartype access_sas: str - """ - - _validation = { - "access_sas": {"readonly": True}, - } - - _attribute_map = { - "access_sas": {"key": "properties.output.accessSAS", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.access_sas: Optional[str] = None - - -class AdditionalUnattendContent(_serialization.Model): - """Specifies additional XML formatted information that can be included in the Unattend.xml file, - which is used by Windows Setup. Contents are defined by setting name, component name, and the - pass in which the content is applied. - - :ivar pass_name: The pass name. Currently, the only allowable value is OobeSystem. Default - value is "OobeSystem". - :vartype pass_name: str - :ivar component_name: The component name. Currently, the only allowable value is - Microsoft-Windows-Shell-Setup. Default value is "Microsoft-Windows-Shell-Setup". - :vartype component_name: str - :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon" and - "FirstLogonCommands". - :vartype setting_name: str or ~azure.mgmt.compute.v2017_03_30.models.SettingNames - :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for - the specified path and component. The XML must be less than 4KB and must include the root - element for the setting or feature that is being inserted. - :vartype content: str - """ - - _attribute_map = { - "pass_name": {"key": "passName", "type": "str"}, - "component_name": {"key": "componentName", "type": "str"}, - "setting_name": {"key": "settingName", "type": "str"}, - "content": {"key": "content", "type": "str"}, - } - - def __init__( - self, - *, - pass_name: Optional[Literal["OobeSystem"]] = None, - component_name: Optional[Literal["Microsoft-Windows-Shell-Setup"]] = None, - setting_name: Optional[Union[str, "_models.SettingNames"]] = None, - content: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword pass_name: The pass name. Currently, the only allowable value is OobeSystem. Default - value is "OobeSystem". - :paramtype pass_name: str - :keyword component_name: The component name. Currently, the only allowable value is - Microsoft-Windows-Shell-Setup. Default value is "Microsoft-Windows-Shell-Setup". - :paramtype component_name: str - :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon" and - "FirstLogonCommands". - :paramtype setting_name: str or ~azure.mgmt.compute.v2017_03_30.models.SettingNames - :keyword content: Specifies the XML formatted content that is added to the unattend.xml file - for the specified path and component. The XML must be less than 4KB and must include the root - element for the setting or feature that is being inserted. - :paramtype content: str - """ - super().__init__(**kwargs) - self.pass_name = pass_name - self.component_name = component_name - self.setting_name = setting_name - self.content = content - - -class ApiEntityReference(_serialization.Model): - """The API entity reference. - - :ivar id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class ApiError(_serialization.Model): - """Api error. - - :ivar details: The Api error details. - :vartype details: list[~azure.mgmt.compute.v2017_03_30.models.ApiErrorBase] - :ivar innererror: The Api inner error. - :vartype innererror: ~azure.mgmt.compute.v2017_03_30.models.InnerError - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "details": {"key": "details", "type": "[ApiErrorBase]"}, - "innererror": {"key": "innererror", "type": "InnerError"}, - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - details: Optional[List["_models.ApiErrorBase"]] = None, - innererror: Optional["_models.InnerError"] = None, - code: Optional[str] = None, - target: Optional[str] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword details: The Api error details. - :paramtype details: list[~azure.mgmt.compute.v2017_03_30.models.ApiErrorBase] - :keyword innererror: The Api inner error. - :paramtype innererror: ~azure.mgmt.compute.v2017_03_30.models.InnerError - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.details = details - self.innererror = innererror - self.code = code - self.target = target - self.message = message - - -class ApiErrorBase(_serialization.Model): - """Api error base. - - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.target = target - self.message = message - - -class Resource(_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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - - -class AvailabilitySet(Resource): - """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 `Manage the - availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability 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. - :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] - :ivar sku: Sku of the availability set. - :vartype sku: ~azure.mgmt.compute.v2017_03_30.models.Sku - :ivar platform_update_domain_count: Update Domain count. - :vartype platform_update_domain_count: int - :ivar platform_fault_domain_count: Fault Domain count. - :vartype platform_fault_domain_count: int - :ivar virtual_machines: A list of references to all virtual machines in the availability set. - :vartype virtual_machines: list[~azure.mgmt.compute.v2017_03_30.models.SubResource] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2017_03_30.models.InstanceViewStatus] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "statuses": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "Sku"}, - "platform_update_domain_count": {"key": "properties.platformUpdateDomainCount", "type": "int"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResource]"}, - "statuses": {"key": "properties.statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - platform_update_domain_count: Optional[int] = None, - platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["_models.SubResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: Sku of the availability set. - :paramtype sku: ~azure.mgmt.compute.v2017_03_30.models.Sku - :keyword platform_update_domain_count: Update Domain count. - :paramtype platform_update_domain_count: int - :keyword platform_fault_domain_count: Fault Domain count. - :paramtype platform_fault_domain_count: int - :keyword virtual_machines: A list of references to all virtual machines in the availability - set. - :paramtype virtual_machines: list[~azure.mgmt.compute.v2017_03_30.models.SubResource] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.platform_update_domain_count = platform_update_domain_count - self.platform_fault_domain_count = platform_fault_domain_count - self.virtual_machines = virtual_machines - self.statuses: Optional[List["_models.InstanceViewStatus"]] = None - - -class AvailabilitySetListResult(_serialization.Model): - """The List Availability Set operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of availability sets. Required. - :vartype value: list[~azure.mgmt.compute.v2017_03_30.models.AvailabilitySet] - :ivar next_link: The URI to fetch the next page of AvailabilitySets. Call ListNext() with this - URI to fetch the next page of AvailabilitySets. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AvailabilitySet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of availability sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_03_30.models.AvailabilitySet] - :keyword next_link: The URI to fetch the next page of AvailabilitySets. Call ListNext() with - this URI to fetch the next page of AvailabilitySets. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class BootDiagnostics(_serialization.Model): - """Boot Diagnostics is a debugging feature which allows you to view Console Output and Screenshot - to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily view the output of your - console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see a screenshot of the VM - from the hypervisor. - - :ivar enabled: Whether boot diagnostics should be enabled on the Virtual Machine. - :vartype enabled: bool - :ivar storage_uri: Uri of the storage account to use for placing the console output and - screenshot. - :vartype storage_uri: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "storage_uri": {"key": "storageUri", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, storage_uri: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Whether boot diagnostics should be enabled on the Virtual Machine. - :paramtype enabled: bool - :keyword storage_uri: Uri of the storage account to use for placing the console output and - screenshot. - :paramtype storage_uri: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.storage_uri = storage_uri - - -class BootDiagnosticsInstanceView(_serialization.Model): - """The instance view of a virtual machine boot diagnostics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar console_screenshot_blob_uri: The console screenshot blob URI. - :vartype console_screenshot_blob_uri: str - :ivar serial_console_log_blob_uri: The Linux serial console log blob Uri. - :vartype serial_console_log_blob_uri: str - """ - - _validation = { - "console_screenshot_blob_uri": {"readonly": True}, - "serial_console_log_blob_uri": {"readonly": True}, - } - - _attribute_map = { - "console_screenshot_blob_uri": {"key": "consoleScreenshotBlobUri", "type": "str"}, - "serial_console_log_blob_uri": {"key": "serialConsoleLogBlobUri", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.console_screenshot_blob_uri: Optional[str] = None - self.serial_console_log_blob_uri: Optional[str] = None - - -class ComputeLongRunningOperationProperties(_serialization.Model): - """Compute-specific operation properties, including output. - - :ivar output: Operation output data (raw JSON). - :vartype output: JSON - """ - - _attribute_map = { - "output": {"key": "output", "type": "object"}, - } - - def __init__(self, *, output: Optional[JSON] = None, **kwargs: Any) -> None: - """ - :keyword output: Operation output data (raw JSON). - :paramtype output: JSON - """ - super().__init__(**kwargs) - self.output = output - - -class CreationData(_serialization.Model): - """Data used when creating a disk. - - All required parameters must be populated in order to send to server. - - :ivar create_option: This enumerates the possible sources of a disk's creation. Required. Known - values are: "Empty", "Attach", "FromImage", "Import", "Copy", and "Import". - :vartype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOption - :ivar storage_account_id: If createOption is Import, the Azure Resource Manager identifier of - the storage account containing the blob to import as a disk. Required only if the blob is in a - different subscription. - :vartype storage_account_id: str - :ivar image_reference: Disk source information. - :vartype image_reference: ~azure.mgmt.compute.v2017_03_30.models.ImageDiskReference - :ivar source_uri: If createOption is Import, this is the URI of a blob to be imported into a - managed disk. - :vartype source_uri: str - :ivar source_resource_id: If createOption is Copy, this is the ARM id of the source snapshot or - disk. - :vartype source_resource_id: str - """ - - _validation = { - "create_option": {"required": True}, - } - - _attribute_map = { - "create_option": {"key": "createOption", "type": "str"}, - "storage_account_id": {"key": "storageAccountId", "type": "str"}, - "image_reference": {"key": "imageReference", "type": "ImageDiskReference"}, - "source_uri": {"key": "sourceUri", "type": "str"}, - "source_resource_id": {"key": "sourceResourceId", "type": "str"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOption"], - storage_account_id: Optional[str] = None, - image_reference: Optional["_models.ImageDiskReference"] = None, - source_uri: Optional[str] = None, - source_resource_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword create_option: This enumerates the possible sources of a disk's creation. Required. - Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", and "Import". - :paramtype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOption - :keyword storage_account_id: If createOption is Import, the Azure Resource Manager identifier - of the storage account containing the blob to import as a disk. Required only if the blob is in - a different subscription. - :paramtype storage_account_id: str - :keyword image_reference: Disk source information. - :paramtype image_reference: ~azure.mgmt.compute.v2017_03_30.models.ImageDiskReference - :keyword source_uri: If createOption is Import, this is the URI of a blob to be imported into a - managed disk. - :paramtype source_uri: str - :keyword source_resource_id: If createOption is Copy, this is the ARM id of the source snapshot - or disk. - :paramtype source_resource_id: str - """ - super().__init__(**kwargs) - self.create_option = create_option - self.storage_account_id = storage_account_id - self.image_reference = image_reference - self.source_uri = source_uri - self.source_resource_id = source_resource_id - - -class DataDisk(_serialization.Model): - """Describes a data disk. - - All required parameters must be populated in order to send to server. - - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - :ivar name: The disk name. - :vartype name: str - :ivar vhd: The virtual hard disk. - :vartype vhd: ~azure.mgmt.compute.v2017_03_30.models.VirtualHardDisk - :ivar image: 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. - :vartype image: ~azure.mgmt.compute.v2017_03_30.models.VirtualHardDisk - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes - :ivar create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: ~azure.mgmt.compute.v2017_03_30.models.ManagedDiskParameters - """ - - _validation = { - "lun": {"required": True}, - "create_option": {"required": True}, - } - - _attribute_map = { - "lun": {"key": "lun", "type": "int"}, - "name": {"key": "name", "type": "str"}, - "vhd": {"key": "vhd", "type": "VirtualHardDisk"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "caching": {"key": "caching", "type": "str"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, - } - - def __init__( - self, - *, - lun: int, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - vhd: Optional["_models.VirtualHardDisk"] = None, - image: Optional["_models.VirtualHardDisk"] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.ManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - :keyword name: The disk name. - :paramtype name: str - :keyword vhd: The virtual hard disk. - :paramtype vhd: ~azure.mgmt.compute.v2017_03_30.models.VirtualHardDisk - :keyword image: 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. - :paramtype image: ~azure.mgmt.compute.v2017_03_30.models.VirtualHardDisk - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes - :keyword create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: ~azure.mgmt.compute.v2017_03_30.models.ManagedDiskParameters - """ - super().__init__(**kwargs) - self.lun = lun - self.name = name - self.vhd = vhd - self.image = image - self.caching = caching - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - - -class DataDiskImage(_serialization.Model): - """Contains the data disk images information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - :vartype lun: int - """ - - _validation = { - "lun": {"readonly": True}, - } - - _attribute_map = { - "lun": {"key": "lun", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.lun: Optional[int] = None - - -class DiagnosticsProfile(_serialization.Model): - """Specifies the boot diagnostic settings state. :code:`
    `\\ :code:`
    `Minimum api-version: - 2015-06-15. - - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2017_03_30.models.BootDiagnostics - """ - - _attribute_map = { - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnostics"}, - } - - def __init__(self, *, boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs: Any) -> None: - """ - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2017_03_30.models.BootDiagnostics - """ - super().__init__(**kwargs) - self.boot_diagnostics = boot_diagnostics - - -class Disk(Resource): - """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. - :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] - :ivar managed_by: A relative URI containing the ID of the VM that has the disk attached. - :vartype managed_by: str - :ivar sku: The disks and snapshots sku name. Can be Standard_LRS or Premium_LRS. - :vartype sku: ~azure.mgmt.compute.v2017_03_30.models.DiskSku - :ivar zones: The Logical zone list for Disk. - :vartype zones: list[str] - :ivar time_created: The time when the disk was created. - :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :ivar creation_data: Disk source information. CreationData information cannot be changed after - the disk has been created. - :vartype creation_data: ~azure.mgmt.compute.v2017_03_30.models.CreationData - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the VHD to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar encryption_settings: Encryption settings for disk or snapshot. - :vartype encryption_settings: ~azure.mgmt.compute.v2017_03_30.models.EncryptionSettings - :ivar provisioning_state: The disk provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "managed_by": {"readonly": True}, - "time_created": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "sku": {"key": "sku", "type": "DiskSku"}, - "zones": {"key": "zones", "type": "[str]"}, - "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "creation_data": {"key": "properties.creationData", "type": "CreationData"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "encryption_settings": {"key": "properties.encryptionSettings", "type": "EncryptionSettings"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.DiskSku"] = None, - zones: Optional[List[str]] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - creation_data: Optional["_models.CreationData"] = None, - disk_size_gb: Optional[int] = None, - encryption_settings: Optional["_models.EncryptionSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The disks and snapshots sku name. Can be Standard_LRS or Premium_LRS. - :paramtype sku: ~azure.mgmt.compute.v2017_03_30.models.DiskSku - :keyword zones: The Logical zone list for Disk. - :paramtype zones: list[str] - :keyword os_type: The Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :keyword creation_data: Disk source information. CreationData information cannot be changed - after the disk has been created. - :paramtype creation_data: ~azure.mgmt.compute.v2017_03_30.models.CreationData - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the VHD to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings: Encryption settings for disk or snapshot. - :paramtype encryption_settings: ~azure.mgmt.compute.v2017_03_30.models.EncryptionSettings - """ - super().__init__(location=location, tags=tags, **kwargs) - self.managed_by: Optional[str] = None - self.sku = sku - self.zones = zones - self.time_created: Optional[datetime.datetime] = None - self.os_type = os_type - self.creation_data = creation_data - self.disk_size_gb = disk_size_gb - self.encryption_settings = encryption_settings - self.provisioning_state: Optional[str] = None - - -class DiskEncryptionSettings(_serialization.Model): - """Describes a Encryption Settings for a Disk. - - :ivar disk_encryption_key: Specifies the location of the disk encryption key, which is a Key - Vault Secret. - :vartype disk_encryption_key: ~azure.mgmt.compute.v2017_03_30.models.KeyVaultSecretReference - :ivar key_encryption_key: Specifies the location of the key encryption key in Key Vault. - :vartype key_encryption_key: ~azure.mgmt.compute.v2017_03_30.models.KeyVaultKeyReference - :ivar enabled: Specifies whether disk encryption should be enabled on the virtual machine. - :vartype enabled: bool - """ - - _attribute_map = { - "disk_encryption_key": {"key": "diskEncryptionKey", "type": "KeyVaultSecretReference"}, - "key_encryption_key": {"key": "keyEncryptionKey", "type": "KeyVaultKeyReference"}, - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__( - self, - *, - disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, - key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, - enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_key: Specifies the location of the disk encryption key, which is a Key - Vault Secret. - :paramtype disk_encryption_key: ~azure.mgmt.compute.v2017_03_30.models.KeyVaultSecretReference - :keyword key_encryption_key: Specifies the location of the key encryption key in Key Vault. - :paramtype key_encryption_key: ~azure.mgmt.compute.v2017_03_30.models.KeyVaultKeyReference - :keyword enabled: Specifies whether disk encryption should be enabled on the virtual machine. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.disk_encryption_key = disk_encryption_key - self.key_encryption_key = key_encryption_key - self.enabled = enabled - - -class DiskInstanceView(_serialization.Model): - """The instance view of the disk. - - :ivar name: The disk name. - :vartype name: str - :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :vartype encryption_settings: - list[~azure.mgmt.compute.v2017_03_30.models.DiskEncryptionSettings] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2017_03_30.models.InstanceViewStatus] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "encryption_settings": {"key": "encryptionSettings", "type": "[DiskEncryptionSettings]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype encryption_settings: - list[~azure.mgmt.compute.v2017_03_30.models.DiskEncryptionSettings] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2017_03_30.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.name = name - self.encryption_settings = encryption_settings - self.statuses = statuses - - -class DiskList(_serialization.Model): - """The List Disks operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of disks. Required. - :vartype value: list[~azure.mgmt.compute.v2017_03_30.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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Disk]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of disks. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_03_30.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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DiskSku(_serialization.Model): - """The disks and snapshots sku name. Can be Standard_LRS or Premium_LRS. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. Known values are: "Standard_LRS" and "Premium_LRS". - :vartype name: str or ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes - :ivar tier: The sku tier. - :vartype tier: str - """ - - _validation = { - "tier": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__(self, *, name: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs: Any) -> None: - """ - :keyword name: The sku name. Known values are: "Standard_LRS" and "Premium_LRS". - :paramtype name: str or ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes - """ - super().__init__(**kwargs) - self.name = name - self.tier: Optional[str] = None - - -class ResourceUpdate(_serialization.Model): - """The Resource model definition. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The disks and snapshots sku name. Can be Standard_LRS or Premium_LRS. - :vartype sku: ~azure.mgmt.compute.v2017_03_30.models.DiskSku - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "DiskSku"}, - } - - def __init__( - self, *, tags: Optional[Dict[str, str]] = None, sku: Optional["_models.DiskSku"] = None, **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The disks and snapshots sku name. Can be Standard_LRS or Premium_LRS. - :paramtype sku: ~azure.mgmt.compute.v2017_03_30.models.DiskSku - """ - super().__init__(**kwargs) - self.tags = tags - self.sku = sku - - -class DiskUpdate(ResourceUpdate): - """Disk update resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The disks and snapshots sku name. Can be Standard_LRS or Premium_LRS. - :vartype sku: ~azure.mgmt.compute.v2017_03_30.models.DiskSku - :ivar os_type: the Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the VHD to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar encryption_settings: Encryption settings for disk or snapshot. - :vartype encryption_settings: ~azure.mgmt.compute.v2017_03_30.models.EncryptionSettings - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "DiskSku"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "encryption_settings": {"key": "properties.encryptionSettings", "type": "EncryptionSettings"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.DiskSku"] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - disk_size_gb: Optional[int] = None, - encryption_settings: Optional["_models.EncryptionSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The disks and snapshots sku name. Can be Standard_LRS or Premium_LRS. - :paramtype sku: ~azure.mgmt.compute.v2017_03_30.models.DiskSku - :keyword os_type: the Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the VHD to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings: Encryption settings for disk or snapshot. - :paramtype encryption_settings: ~azure.mgmt.compute.v2017_03_30.models.EncryptionSettings - """ - super().__init__(tags=tags, sku=sku, **kwargs) - self.os_type = os_type - self.disk_size_gb = disk_size_gb - self.encryption_settings = encryption_settings - - -class EncryptionSettings(_serialization.Model): - """Encryption settings for disk or snapshot. - - :ivar enabled: Set this flag to true and provide DiskEncryptionKey and optional - KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and - KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, - the existing settings remain unchanged. - :vartype enabled: bool - :ivar disk_encryption_key: Key Vault Secret Url and vault id of the disk encryption key. - :vartype disk_encryption_key: ~azure.mgmt.compute.v2017_03_30.models.KeyVaultAndSecretReference - :ivar key_encryption_key: Key Vault Key Url and vault id of the key encryption key. - :vartype key_encryption_key: ~azure.mgmt.compute.v2017_03_30.models.KeyVaultAndKeyReference - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "disk_encryption_key": {"key": "diskEncryptionKey", "type": "KeyVaultAndSecretReference"}, - "key_encryption_key": {"key": "keyEncryptionKey", "type": "KeyVaultAndKeyReference"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Set this flag to true and provide DiskEncryptionKey and optional - KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and - KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, - the existing settings remain unchanged. - :paramtype enabled: bool - :keyword disk_encryption_key: Key Vault Secret Url and vault id of the disk encryption key. - :paramtype disk_encryption_key: - ~azure.mgmt.compute.v2017_03_30.models.KeyVaultAndSecretReference - :keyword key_encryption_key: Key Vault Key Url and vault id of the key encryption key. - :paramtype key_encryption_key: ~azure.mgmt.compute.v2017_03_30.models.KeyVaultAndKeyReference - """ - super().__init__(**kwargs) - self.enabled = enabled - self.disk_encryption_key = disk_encryption_key - self.key_encryption_key = key_encryption_key - - -class GrantAccessData(_serialization.Model): - """Data used for requesting a SAS. - - All required parameters must be populated in order to send to server. - - :ivar access: Required. Known values are: "None" and "Read". - :vartype access: str or ~azure.mgmt.compute.v2017_03_30.models.AccessLevel - :ivar duration_in_seconds: Time duration in seconds until the SAS access expires. Required. - :vartype duration_in_seconds: int - """ - - _validation = { - "access": {"required": True}, - "duration_in_seconds": {"required": True}, - } - - _attribute_map = { - "access": {"key": "access", "type": "str"}, - "duration_in_seconds": {"key": "durationInSeconds", "type": "int"}, - } - - def __init__(self, *, access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, **kwargs: Any) -> None: - """ - :keyword access: Required. Known values are: "None" and "Read". - :paramtype access: str or ~azure.mgmt.compute.v2017_03_30.models.AccessLevel - :keyword duration_in_seconds: Time duration in seconds until the SAS access expires. Required. - :paramtype duration_in_seconds: int - """ - super().__init__(**kwargs) - self.access = access - self.duration_in_seconds = duration_in_seconds - - -class HardwareProfile(_serialization.Model): - """Specifies the hardware settings for the virtual machine. - - :ivar vm_size: Specifies the size of the virtual machine. For more information about virtual - machine sizes, see `Sizes for virtual machines - `_. - :code:`
    `\\ :code:`
    ` The available VM sizes depend on region and availability set. For a - list of available sizes use these APIs: :code:`
    `\\ :code:`
    ` `List all available - virtual machine sizes in an availability set - `_ - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in a region - `_ :code:`
    `\\ - :code:`
    ` `List all available virtual machine sizes for resizing - `_. Known - values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", - "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", - "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", - "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", - "Standard_A8m_v2", "Standard_D1", "Standard_D2", "Standard_D3", "Standard_D4", "Standard_D11", - "Standard_D12", "Standard_D13", "Standard_D14", "Standard_D1_v2", "Standard_D2_v2", - "Standard_D3_v2", "Standard_D4_v2", "Standard_D5_v2", "Standard_D11_v2", "Standard_D12_v2", - "Standard_D13_v2", "Standard_D14_v2", "Standard_D15_v2", "Standard_DS1", "Standard_DS2", - "Standard_DS3", "Standard_DS4", "Standard_DS11", "Standard_DS12", "Standard_DS13", - "Standard_DS14", "Standard_DS1_v2", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", - "Standard_DS5_v2", "Standard_DS11_v2", "Standard_DS12_v2", "Standard_DS13_v2", - "Standard_DS14_v2", "Standard_DS15_v2", "Standard_F1", "Standard_F2", "Standard_F4", - "Standard_F8", "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", - "Standard_F16s", "Standard_G1", "Standard_G2", "Standard_G3", "Standard_G4", "Standard_G5", - "Standard_GS1", "Standard_GS2", "Standard_GS3", "Standard_GS4", "Standard_GS5", "Standard_H8", - "Standard_H16", "Standard_H8m", "Standard_H16m", "Standard_H16r", "Standard_H16mr", - "Standard_L4s", "Standard_L8s", "Standard_L16s", "Standard_L32s", "Standard_NC6", - "Standard_NC12", "Standard_NC24", "Standard_NC24r", "Standard_NV6", "Standard_NV12", and - "Standard_NV24". - :vartype vm_size: str or ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineSizeTypes - """ - - _attribute_map = { - "vm_size": {"key": "vmSize", "type": "str"}, - } - - def __init__( - self, *, vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs: Any - ) -> None: - """ - :keyword vm_size: Specifies the size of the virtual machine. For more information about virtual - machine sizes, see `Sizes for virtual machines - `_. - :code:`
    `\\ :code:`
    ` The available VM sizes depend on region and availability set. For a - list of available sizes use these APIs: :code:`
    `\\ :code:`
    ` `List all available - virtual machine sizes in an availability set - `_ - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in a region - `_ :code:`
    `\\ - :code:`
    ` `List all available virtual machine sizes for resizing - `_. Known - values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", - "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", - "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", - "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", - "Standard_A8m_v2", "Standard_D1", "Standard_D2", "Standard_D3", "Standard_D4", "Standard_D11", - "Standard_D12", "Standard_D13", "Standard_D14", "Standard_D1_v2", "Standard_D2_v2", - "Standard_D3_v2", "Standard_D4_v2", "Standard_D5_v2", "Standard_D11_v2", "Standard_D12_v2", - "Standard_D13_v2", "Standard_D14_v2", "Standard_D15_v2", "Standard_DS1", "Standard_DS2", - "Standard_DS3", "Standard_DS4", "Standard_DS11", "Standard_DS12", "Standard_DS13", - "Standard_DS14", "Standard_DS1_v2", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", - "Standard_DS5_v2", "Standard_DS11_v2", "Standard_DS12_v2", "Standard_DS13_v2", - "Standard_DS14_v2", "Standard_DS15_v2", "Standard_F1", "Standard_F2", "Standard_F4", - "Standard_F8", "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", - "Standard_F16s", "Standard_G1", "Standard_G2", "Standard_G3", "Standard_G4", "Standard_G5", - "Standard_GS1", "Standard_GS2", "Standard_GS3", "Standard_GS4", "Standard_GS5", "Standard_H8", - "Standard_H16", "Standard_H8m", "Standard_H16m", "Standard_H16r", "Standard_H16mr", - "Standard_L4s", "Standard_L8s", "Standard_L16s", "Standard_L32s", "Standard_NC6", - "Standard_NC12", "Standard_NC24", "Standard_NC24r", "Standard_NV6", "Standard_NV12", and - "Standard_NV24". - :paramtype vm_size: str or ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineSizeTypes - """ - super().__init__(**kwargs) - self.vm_size = vm_size - - -class Image(Resource): - """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. - - 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] - :ivar source_virtual_machine: The source virtual machine from which Image is created. - :vartype source_virtual_machine: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2017_03_30.models.ImageStorageProfile - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "source_virtual_machine": {"key": "properties.sourceVirtualMachine", "type": "SubResource"}, - "storage_profile": {"key": "properties.storageProfile", "type": "ImageStorageProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["_models.SubResource"] = None, - storage_profile: Optional["_models.ImageStorageProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword source_virtual_machine: The source virtual machine from which Image is created. - :paramtype source_virtual_machine: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2017_03_30.models.ImageStorageProfile - """ - super().__init__(location=location, tags=tags, **kwargs) - self.source_virtual_machine = source_virtual_machine - self.storage_profile = storage_profile - self.provisioning_state: Optional[str] = None - - -class ImageDataDisk(_serialization.Model): - """Describes a data disk. - - All required parameters must be populated in order to send to server. - - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - :ivar snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. Possible - values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS" and "Premium_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes - """ - - _validation = { - "lun": {"required": True}, - } - - _attribute_map = { - "lun": {"key": "lun", "type": "int"}, - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - } - - def __init__( - self, - *, - lun: int, - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. - Possible values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS" and - "Premium_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes - """ - super().__init__(**kwargs) - self.lun = lun - self.snapshot = snapshot - self.managed_disk = managed_disk - self.blob_uri = blob_uri - self.caching = caching - self.disk_size_gb = disk_size_gb - self.storage_account_type = storage_account_type - - -class ImageDiskReference(_serialization.Model): - """The source image used for creating the disk. - - All required parameters must be populated in order to send to server. - - :ivar id: A relative uri containing either a Platform Image Repository or user image reference. - Required. - :vartype id: str - :ivar lun: If the disk is created from an image's data disk, this is an index that indicates - which of the data disks in the image to use. For OS disks, this field is null. - :vartype lun: int - """ - - _validation = { - "id": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__( - self, *, id: str, lun: Optional[int] = None, **kwargs: Any # pylint: disable=redefined-builtin - ) -> None: - """ - :keyword id: A relative uri containing either a Platform Image Repository or user image - reference. Required. - :paramtype id: str - :keyword lun: If the disk is created from an image's data disk, this is an index that indicates - which of the data disks in the image to use. For OS disks, this field is null. - :paramtype lun: int - """ - super().__init__(**kwargs) - self.id = id - self.lun = lun - - -class ImageListResult(_serialization.Model): - """The List Image operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of Images. Required. - :vartype value: list[~azure.mgmt.compute.v2017_03_30.models.Image] - :ivar next_link: The uri to fetch the next page of Images. Call ListNext() with this to fetch - the next page of Images. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Image]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Image"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of Images. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_03_30.models.Image] - :keyword next_link: The uri to fetch the next page of Images. Call ListNext() with this to - fetch the next page of Images. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ImageOSDisk(_serialization.Model): - """Describes an Operating System disk. - - All required parameters must be populated in order to send to server. - - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from a custom image. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Required. Known - values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :ivar os_state: The OS State. Required. Known values are: "Generalized" and "Specialized". - :vartype os_state: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemStateTypes - :ivar snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. Possible - values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS" and "Premium_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes - """ - - _validation = { - "os_type": {"required": True}, - "os_state": {"required": True}, - } - - _attribute_map = { - "os_type": {"key": "osType", "type": "str"}, - "os_state": {"key": "osState", "type": "str"}, - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - } - - def __init__( - self, - *, - os_type: Union[str, "_models.OperatingSystemTypes"], - os_state: Union[str, "_models.OperatingSystemStateTypes"], - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from a custom image. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Required. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :keyword os_state: The OS State. Required. Known values are: "Generalized" and "Specialized". - :paramtype os_state: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemStateTypes - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. - Possible values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS" and - "Premium_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes - """ - super().__init__(**kwargs) - self.os_type = os_type - self.os_state = os_state - self.snapshot = snapshot - self.managed_disk = managed_disk - self.blob_uri = blob_uri - self.caching = caching - self.disk_size_gb = disk_size_gb - self.storage_account_type = storage_account_type - - -class SubResource(_serialization.Model): - """SubResource. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class ImageReference(SubResource): - """Specifies information about the image to use. You can specify information about platform - images, marketplace images, or virtual machine images. This element is required when you want - to use a platform image, marketplace image, or virtual machine image, but is not used in other - creation operations. NOTE: Image reference publisher and offer can only be set when you create - the scale set. - - :ivar id: Resource Id. - :vartype id: str - :ivar publisher: The image publisher. - :vartype publisher: str - :ivar offer: Specifies the offer of the platform image or marketplace image used to create the - virtual machine. - :vartype offer: str - :ivar sku: The image SKU. - :vartype sku: str - :ivar version: Specifies the version of the platform image or marketplace image used to create - the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and - Build are decimal numbers. Specify 'latest' to use the latest version of an image available at - deploy time. Even if you use 'latest', the VM image will not automatically update after deploy - time even if a new version becomes available. - :vartype version: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "offer": {"key": "offer", "type": "str"}, - "sku": {"key": "sku", "type": "str"}, - "version": {"key": "version", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - publisher: Optional[str] = None, - offer: Optional[str] = None, - sku: Optional[str] = None, - version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword publisher: The image publisher. - :paramtype publisher: str - :keyword offer: Specifies the offer of the platform image or marketplace image used to create - the virtual machine. - :paramtype offer: str - :keyword sku: The image SKU. - :paramtype sku: str - :keyword version: Specifies the version of the platform image or marketplace image used to - create the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, - Minor, and Build are decimal numbers. Specify 'latest' to use the latest version of an image - available at deploy time. Even if you use 'latest', the VM image will not automatically update - after deploy time even if a new version becomes available. - :paramtype version: str - """ - super().__init__(id=id, **kwargs) - self.publisher = publisher - self.offer = offer - self.sku = sku - self.version = version - - -class ImageStorageProfile(_serialization.Model): - """Describes a storage profile. - - All required parameters must be populated in order to send to server. - - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - Required. - :vartype os_disk: ~azure.mgmt.compute.v2017_03_30.models.ImageOSDisk - :ivar data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype data_disks: list[~azure.mgmt.compute.v2017_03_30.models.ImageDataDisk] - """ - - _validation = { - "os_disk": {"required": True}, - } - - _attribute_map = { - "os_disk": {"key": "osDisk", "type": "ImageOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[ImageDataDisk]"}, - } - - def __init__( - self, - *, - os_disk: "_models.ImageOSDisk", - data_disks: Optional[List["_models.ImageDataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - Required. - :paramtype os_disk: ~azure.mgmt.compute.v2017_03_30.models.ImageOSDisk - :keyword data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype data_disks: list[~azure.mgmt.compute.v2017_03_30.models.ImageDataDisk] - """ - super().__init__(**kwargs) - self.os_disk = os_disk - self.data_disks = data_disks - - -class InnerError(_serialization.Model): - """Inner error details. - - :ivar exceptiontype: The exception type. - :vartype exceptiontype: str - :ivar errordetail: The internal error message or exception dump. - :vartype errordetail: str - """ - - _attribute_map = { - "exceptiontype": {"key": "exceptiontype", "type": "str"}, - "errordetail": {"key": "errordetail", "type": "str"}, - } - - def __init__( - self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword exceptiontype: The exception type. - :paramtype exceptiontype: str - :keyword errordetail: The internal error message or exception dump. - :paramtype errordetail: str - """ - super().__init__(**kwargs) - self.exceptiontype = exceptiontype - self.errordetail = errordetail - - -class InstanceViewStatus(_serialization.Model): - """Instance view status. - - :ivar code: The status code. - :vartype code: str - :ivar level: The level code. Known values are: "Info", "Warning", and "Error". - :vartype level: str or ~azure.mgmt.compute.v2017_03_30.models.StatusLevelTypes - :ivar display_status: The short localizable label for the status. - :vartype display_status: str - :ivar message: The detailed status message, including for alerts and error messages. - :vartype message: str - :ivar time: The time of the status. - :vartype time: ~datetime.datetime - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "level": {"key": "level", "type": "str"}, - "display_status": {"key": "displayStatus", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "time": {"key": "time", "type": "iso-8601"}, - } - - def __init__( - self, - *, - code: Optional[str] = None, - level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, - display_status: Optional[str] = None, - message: Optional[str] = None, - time: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword code: The status code. - :paramtype code: str - :keyword level: The level code. Known values are: "Info", "Warning", and "Error". - :paramtype level: str or ~azure.mgmt.compute.v2017_03_30.models.StatusLevelTypes - :keyword display_status: The short localizable label for the status. - :paramtype display_status: str - :keyword message: The detailed status message, including for alerts and error messages. - :paramtype message: str - :keyword time: The time of the status. - :paramtype time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.code = code - self.level = level - self.display_status = display_status - self.message = message - self.time = time - - -class KeyVaultAndKeyReference(_serialization.Model): - """Key Vault Key Url and vault id of KeK, KeK is optional and when provided is used to unwrap the - encryptionKey. - - All required parameters must be populated in order to send to server. - - :ivar source_vault: Resource id of the KeyVault containing the key or secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2017_03_30.models.SourceVault - :ivar key_url: Url pointing to a key or secret in KeyVault. Required. - :vartype key_url: str - """ - - _validation = { - "source_vault": {"required": True}, - "key_url": {"required": True}, - } - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SourceVault"}, - "key_url": {"key": "keyUrl", "type": "str"}, - } - - def __init__(self, *, source_vault: "_models.SourceVault", key_url: str, **kwargs: Any) -> None: - """ - :keyword source_vault: Resource id of the KeyVault containing the key or secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2017_03_30.models.SourceVault - :keyword key_url: Url pointing to a key or secret in KeyVault. Required. - :paramtype key_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.key_url = key_url - - -class KeyVaultAndSecretReference(_serialization.Model): - """Key Vault Secret Url and vault id of the encryption key. - - All required parameters must be populated in order to send to server. - - :ivar source_vault: Resource id of the KeyVault containing the key or secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2017_03_30.models.SourceVault - :ivar secret_url: Url pointing to a key or secret in KeyVault. Required. - :vartype secret_url: str - """ - - _validation = { - "source_vault": {"required": True}, - "secret_url": {"required": True}, - } - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SourceVault"}, - "secret_url": {"key": "secretUrl", "type": "str"}, - } - - def __init__(self, *, source_vault: "_models.SourceVault", secret_url: str, **kwargs: Any) -> None: - """ - :keyword source_vault: Resource id of the KeyVault containing the key or secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2017_03_30.models.SourceVault - :keyword secret_url: Url pointing to a key or secret in KeyVault. Required. - :paramtype secret_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.secret_url = secret_url - - -class KeyVaultKeyReference(_serialization.Model): - """Describes a reference to Key Vault Key. - - All required parameters must be populated in order to send to server. - - :ivar key_url: The URL referencing a key encryption key in Key Vault. Required. - :vartype key_url: str - :ivar source_vault: The relative URL of the Key Vault containing the key. Required. - :vartype source_vault: ~azure.mgmt.compute.v2017_03_30.models.SubResource - """ - - _validation = { - "key_url": {"required": True}, - "source_vault": {"required": True}, - } - - _attribute_map = { - "key_url": {"key": "keyUrl", "type": "str"}, - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - } - - def __init__(self, *, key_url: str, source_vault: "_models.SubResource", **kwargs: Any) -> None: - """ - :keyword key_url: The URL referencing a key encryption key in Key Vault. Required. - :paramtype key_url: str - :keyword source_vault: The relative URL of the Key Vault containing the key. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2017_03_30.models.SubResource - """ - super().__init__(**kwargs) - self.key_url = key_url - self.source_vault = source_vault - - -class KeyVaultSecretReference(_serialization.Model): - """Describes a reference to Key Vault Secret. - - All required parameters must be populated in order to send to server. - - :ivar secret_url: The URL referencing a secret in a Key Vault. Required. - :vartype secret_url: str - :ivar source_vault: The relative URL of the Key Vault containing the secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2017_03_30.models.SubResource - """ - - _validation = { - "secret_url": {"required": True}, - "source_vault": {"required": True}, - } - - _attribute_map = { - "secret_url": {"key": "secretUrl", "type": "str"}, - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - } - - def __init__(self, *, secret_url: str, source_vault: "_models.SubResource", **kwargs: Any) -> None: - """ - :keyword secret_url: The URL referencing a secret in a Key Vault. Required. - :paramtype secret_url: str - :keyword source_vault: The relative URL of the Key Vault containing the secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2017_03_30.models.SubResource - """ - super().__init__(**kwargs) - self.secret_url = secret_url - self.source_vault = source_vault - - -class LinuxConfiguration(_serialization.Model): - """Specifies the Linux operating system settings on the virtual machine. :code:`
    `\\ - :code:`
    `For a list of supported Linux distributions, see `Linux on Azure-Endorsed - Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - - :ivar disable_password_authentication: Specifies whether password authentication should be - disabled. - :vartype disable_password_authentication: bool - :ivar ssh: Specifies the ssh key configuration for a Linux OS. - :vartype ssh: ~azure.mgmt.compute.v2017_03_30.models.SshConfiguration - """ - - _attribute_map = { - "disable_password_authentication": {"key": "disablePasswordAuthentication", "type": "bool"}, - "ssh": {"key": "ssh", "type": "SshConfiguration"}, - } - - def __init__( - self, - *, - disable_password_authentication: Optional[bool] = None, - ssh: Optional["_models.SshConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword disable_password_authentication: Specifies whether password authentication should be - disabled. - :paramtype disable_password_authentication: bool - :keyword ssh: Specifies the ssh key configuration for a Linux OS. - :paramtype ssh: ~azure.mgmt.compute.v2017_03_30.models.SshConfiguration - """ - super().__init__(**kwargs) - self.disable_password_authentication = disable_password_authentication - self.ssh = ssh - - -class ListUsagesResult(_serialization.Model): - """The List Usages operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of compute resource usages. Required. - :vartype value: list[~azure.mgmt.compute.v2017_03_30.models.Usage] - :ivar next_link: The URI to fetch the next page of compute resource usage information. Call - ListNext() with this to fetch the next page of compute resource usage information. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Usage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of compute resource usages. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_03_30.models.Usage] - :keyword next_link: The URI to fetch the next page of compute resource usage information. Call - ListNext() with this to fetch the next page of compute resource usage information. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class MaintenanceRedeployStatus(_serialization.Model): - """Maintenance Operation Status. - - :ivar is_customer_initiated_maintenance_allowed: True, if customer is allowed to perform - Maintenance. - :vartype is_customer_initiated_maintenance_allowed: bool - :ivar pre_maintenance_window_start_time: Start Time for the Pre Maintenance Window. - :vartype pre_maintenance_window_start_time: ~datetime.datetime - :ivar pre_maintenance_window_end_time: End Time for the Pre Maintenance Window. - :vartype pre_maintenance_window_end_time: ~datetime.datetime - :ivar maintenance_window_start_time: Start Time for the Maintenance Window. - :vartype maintenance_window_start_time: ~datetime.datetime - :ivar maintenance_window_end_time: End Time for the Maintenance Window. - :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: - "None", "RetryLater", "MaintenanceAborted", and "MaintenanceCompleted". - :vartype last_operation_result_code: str or - ~azure.mgmt.compute.v2017_03_30.models.MaintenanceOperationResultCodeTypes - :ivar last_operation_message: Message returned for the last Maintenance Operation. - :vartype last_operation_message: str - """ - - _attribute_map = { - "is_customer_initiated_maintenance_allowed": {"key": "isCustomerInitiatedMaintenanceAllowed", "type": "bool"}, - "pre_maintenance_window_start_time": {"key": "preMaintenanceWindowStartTime", "type": "iso-8601"}, - "pre_maintenance_window_end_time": {"key": "preMaintenanceWindowEndTime", "type": "iso-8601"}, - "maintenance_window_start_time": {"key": "maintenanceWindowStartTime", "type": "iso-8601"}, - "maintenance_window_end_time": {"key": "maintenanceWindowEndTime", "type": "iso-8601"}, - "last_operation_result_code": {"key": "lastOperationResultCode", "type": "str"}, - "last_operation_message": {"key": "lastOperationMessage", "type": "str"}, - } - - def __init__( - self, - *, - is_customer_initiated_maintenance_allowed: Optional[bool] = None, - pre_maintenance_window_start_time: Optional[datetime.datetime] = None, - pre_maintenance_window_end_time: Optional[datetime.datetime] = None, - maintenance_window_start_time: Optional[datetime.datetime] = None, - maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, - last_operation_message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_customer_initiated_maintenance_allowed: True, if customer is allowed to perform - Maintenance. - :paramtype is_customer_initiated_maintenance_allowed: bool - :keyword pre_maintenance_window_start_time: Start Time for the Pre Maintenance Window. - :paramtype pre_maintenance_window_start_time: ~datetime.datetime - :keyword pre_maintenance_window_end_time: End Time for the Pre Maintenance Window. - :paramtype pre_maintenance_window_end_time: ~datetime.datetime - :keyword maintenance_window_start_time: Start Time for the Maintenance Window. - :paramtype maintenance_window_start_time: ~datetime.datetime - :keyword maintenance_window_end_time: End Time for the Maintenance Window. - :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values - are: "None", "RetryLater", "MaintenanceAborted", and "MaintenanceCompleted". - :paramtype last_operation_result_code: str or - ~azure.mgmt.compute.v2017_03_30.models.MaintenanceOperationResultCodeTypes - :keyword last_operation_message: Message returned for the last Maintenance Operation. - :paramtype last_operation_message: str - """ - super().__init__(**kwargs) - self.is_customer_initiated_maintenance_allowed = is_customer_initiated_maintenance_allowed - self.pre_maintenance_window_start_time = pre_maintenance_window_start_time - self.pre_maintenance_window_end_time = pre_maintenance_window_end_time - self.maintenance_window_start_time = maintenance_window_start_time - self.maintenance_window_end_time = maintenance_window_end_time - self.last_operation_result_code = last_operation_result_code - self.last_operation_message = last_operation_message - - -class ManagedDiskParameters(SubResource): - """The parameters of a managed disk. - - :ivar id: Resource Id. - :vartype id: str - :ivar storage_account_type: Specifies the storage account type for the managed disk. Possible - values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS" and "Premium_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword storage_account_type: Specifies the storage account type for the managed disk. - Possible values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS" and - "Premium_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes - """ - super().__init__(id=id, **kwargs) - self.storage_account_type = storage_account_type - - -class NetworkInterfaceReference(SubResource): - """Describes a network interface reference. - - :ivar id: Resource Id. - :vartype id: str - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - primary: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - """ - super().__init__(id=id, **kwargs) - self.primary = primary - - -class NetworkProfile(_serialization.Model): - """Specifies the network interfaces of the virtual machine. - - :ivar network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the virtual machine. - :vartype network_interfaces: - list[~azure.mgmt.compute.v2017_03_30.models.NetworkInterfaceReference] - """ - - _attribute_map = { - "network_interfaces": {"key": "networkInterfaces", "type": "[NetworkInterfaceReference]"}, - } - - def __init__( - self, *, network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs: Any - ) -> None: - """ - :keyword network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the virtual machine. - :paramtype network_interfaces: - list[~azure.mgmt.compute.v2017_03_30.models.NetworkInterfaceReference] - """ - super().__init__(**kwargs) - self.network_interfaces = network_interfaces - - -class OperationStatusResponse(_serialization.Model): - """Operation status response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation ID. - :vartype name: str - :ivar status: Operation status. - :vartype status: str - :ivar start_time: Start time of the operation. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the operation. - :vartype end_time: ~datetime.datetime - :ivar error: Api error. - :vartype error: ~azure.mgmt.compute.v2017_03_30.models.ApiError - """ - - _validation = { - "name": {"readonly": True}, - "status": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - "error": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "error": {"key": "error", "type": "ApiError"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.status: Optional[str] = None - self.start_time: Optional[datetime.datetime] = None - self.end_time: Optional[datetime.datetime] = None - self.error: Optional["_models.ApiError"] = None - - -class OSDisk(_serialization.Model): - """Specifies information about the operating system disk used by the virtual machine. - :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and VHDs for - Azure virtual machines - `_. - - All required parameters must be populated in order to send to server. - - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :vartype encryption_settings: ~azure.mgmt.compute.v2017_03_30.models.DiskEncryptionSettings - :ivar name: The disk name. - :vartype name: str - :ivar vhd: The virtual hard disk. - :vartype vhd: ~azure.mgmt.compute.v2017_03_30.models.VirtualHardDisk - :ivar image: 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. - :vartype image: ~azure.mgmt.compute.v2017_03_30.models.VirtualHardDisk - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes - :ivar create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: ~azure.mgmt.compute.v2017_03_30.models.ManagedDiskParameters - """ - - _validation = { - "create_option": {"required": True}, - } - - _attribute_map = { - "os_type": {"key": "osType", "type": "str"}, - "encryption_settings": {"key": "encryptionSettings", "type": "DiskEncryptionSettings"}, - "name": {"key": "name", "type": "str"}, - "vhd": {"key": "vhd", "type": "VirtualHardDisk"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "caching": {"key": "caching", "type": "str"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, - name: Optional[str] = None, - vhd: Optional["_models.VirtualHardDisk"] = None, - image: Optional["_models.VirtualHardDisk"] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.ManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype encryption_settings: ~azure.mgmt.compute.v2017_03_30.models.DiskEncryptionSettings - :keyword name: The disk name. - :paramtype name: str - :keyword vhd: The virtual hard disk. - :paramtype vhd: ~azure.mgmt.compute.v2017_03_30.models.VirtualHardDisk - :keyword image: 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. - :paramtype image: ~azure.mgmt.compute.v2017_03_30.models.VirtualHardDisk - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes - :keyword create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: ~azure.mgmt.compute.v2017_03_30.models.ManagedDiskParameters - """ - super().__init__(**kwargs) - self.os_type = os_type - self.encryption_settings = encryption_settings - self.name = name - self.vhd = vhd - self.image = image - self.caching = caching - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - - -class OSDiskImage(_serialization.Model): - """Contains the os disk image information. - - All required parameters must be populated in order to send to server. - - :ivar operating_system: The operating system of the osDiskImage. Required. Known values are: - "Windows" and "Linux". - :vartype operating_system: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - """ - - _validation = { - "operating_system": {"required": True}, - } - - _attribute_map = { - "operating_system": {"key": "operatingSystem", "type": "str"}, - } - - def __init__(self, *, operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs: Any) -> None: - """ - :keyword operating_system: The operating system of the osDiskImage. Required. Known values are: - "Windows" and "Linux". - :paramtype operating_system: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - """ - super().__init__(**kwargs) - self.operating_system = operating_system - - -class OSProfile(_serialization.Model): - """Specifies the operating system settings for the virtual machine. - - :ivar computer_name: Specifies the host OS name of the virtual machine. :code:`
    `\\ - :code:`
    ` This name cannot be updated after the VM is created. :code:`
    `\\ :code:`
    ` - **Max-length (Windows):** 15 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 - characters. :code:`
    `\\ :code:`
    ` For naming conventions and restrictions see `Azure - infrastructure services implementation guidelines - `_. - :vartype computer_name: str - :ivar admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :vartype admin_username: str - :ivar admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :vartype admin_password: str - :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` For using cloud-init for - your VM, see `Using cloud-init to customize a Linux VM during creation - `_. - :vartype custom_data: str - :ivar windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :vartype windows_configuration: ~azure.mgmt.compute.v2017_03_30.models.WindowsConfiguration - :ivar linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :vartype linux_configuration: ~azure.mgmt.compute.v2017_03_30.models.LinuxConfiguration - :ivar secrets: Specifies set of certificates that should be installed onto the virtual machine. - :vartype secrets: list[~azure.mgmt.compute.v2017_03_30.models.VaultSecretGroup] - """ - - _attribute_map = { - "computer_name": {"key": "computerName", "type": "str"}, - "admin_username": {"key": "adminUsername", "type": "str"}, - "admin_password": {"key": "adminPassword", "type": "str"}, - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - } - - def __init__( - self, - *, - computer_name: Optional[str] = None, - admin_username: Optional[str] = None, - admin_password: Optional[str] = None, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword computer_name: Specifies the host OS name of the virtual machine. :code:`
    `\\ - :code:`
    ` This name cannot be updated after the VM is created. :code:`
    `\\ :code:`
    ` - **Max-length (Windows):** 15 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 - characters. :code:`
    `\\ :code:`
    ` For naming conventions and restrictions see `Azure - infrastructure services implementation guidelines - `_. - :paramtype computer_name: str - :keyword admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :paramtype admin_username: str - :keyword admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :paramtype admin_password: str - :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` For using cloud-init for - your VM, see `Using cloud-init to customize a Linux VM during creation - `_. - :paramtype custom_data: str - :keyword windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :paramtype windows_configuration: ~azure.mgmt.compute.v2017_03_30.models.WindowsConfiguration - :keyword linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :paramtype linux_configuration: ~azure.mgmt.compute.v2017_03_30.models.LinuxConfiguration - :keyword secrets: Specifies set of certificates that should be installed onto the virtual - machine. - :paramtype secrets: list[~azure.mgmt.compute.v2017_03_30.models.VaultSecretGroup] - """ - super().__init__(**kwargs) - self.computer_name = computer_name - self.admin_username = admin_username - self.admin_password = admin_password - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - - -class Plan(_serialization.Model): - """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 the marketplace - image that you want to use and then click **Want to deploy programmatically, Get Started ->**. - Enter any required information and then click **Save**. - - :ivar name: The plan ID. - :vartype name: str - :ivar publisher: The publisher ID. - :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. - :vartype product: str - :ivar promotion_code: The promotion code. - :vartype promotion_code: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - "promotion_code": {"key": "promotionCode", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - publisher: Optional[str] = None, - product: Optional[str] = None, - promotion_code: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The plan ID. - :paramtype name: str - :keyword publisher: The publisher ID. - :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. - :paramtype product: str - :keyword promotion_code: The promotion code. - :paramtype promotion_code: str - """ - super().__init__(**kwargs) - self.name = name - self.publisher = publisher - self.product = product - self.promotion_code = promotion_code - - -class PurchasePlan(_serialization.Model): - """Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. - - All required parameters must be populated in order to send to server. - - :ivar publisher: The publisher ID. Required. - :vartype publisher: str - :ivar name: The plan ID. Required. - :vartype name: 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 - """ - - _validation = { - "publisher": {"required": True}, - "name": {"required": True}, - "product": {"required": True}, - } - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "product": {"key": "product", "type": "str"}, - } - - def __init__(self, *, publisher: str, name: str, product: str, **kwargs: Any) -> None: - """ - :keyword publisher: The publisher ID. Required. - :paramtype publisher: str - :keyword name: The plan ID. Required. - :paramtype name: 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 - """ - super().__init__(**kwargs) - self.publisher = publisher - self.name = name - self.product = product - - -class ResourceSku(_serialization.Model): - """Describes an available Compute SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of resource the SKU applies to. - :vartype resource_type: str - :ivar name: The name of SKU. - :vartype name: str - :ivar tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
    `\\ - :code:`
    ` Possible Values:\\ :code:`
    `\\ :code:`
    ` **Standard**\\ :code:`
    `\\ :code:`
    ` **Basic**. - :vartype tier: str - :ivar size: The Size of the SKU. - :vartype size: str - :ivar family: The Family of this particular SKU. - :vartype family: str - :ivar kind: The Kind of resources that are supported in this SKU. - :vartype kind: str - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: ~azure.mgmt.compute.v2017_03_30.models.ResourceSkuCapacity - :ivar locations: The set of locations that the SKU is available. - :vartype locations: list[str] - :ivar api_versions: The api versions that support this SKU. - :vartype api_versions: list[str] - :ivar costs: Metadata for retrieving price info. - :vartype costs: list[~azure.mgmt.compute.v2017_03_30.models.ResourceSkuCosts] - :ivar capabilities: A name value pair to describe the capability. - :vartype capabilities: list[~azure.mgmt.compute.v2017_03_30.models.ResourceSkuCapabilities] - :ivar restrictions: The restrictions because of which SKU cannot be used. This is empty if - there are no restrictions. - :vartype restrictions: list[~azure.mgmt.compute.v2017_03_30.models.ResourceSkuRestrictions] - """ - - _validation = { - "resource_type": {"readonly": True}, - "name": {"readonly": True}, - "tier": {"readonly": True}, - "size": {"readonly": True}, - "family": {"readonly": True}, - "kind": {"readonly": True}, - "capacity": {"readonly": True}, - "locations": {"readonly": True}, - "api_versions": {"readonly": True}, - "costs": {"readonly": True}, - "capabilities": {"readonly": True}, - "restrictions": {"readonly": True}, - } - - _attribute_map = { - "resource_type": {"key": "resourceType", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "size": {"key": "size", "type": "str"}, - "family": {"key": "family", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "capacity": {"key": "capacity", "type": "ResourceSkuCapacity"}, - "locations": {"key": "locations", "type": "[str]"}, - "api_versions": {"key": "apiVersions", "type": "[str]"}, - "costs": {"key": "costs", "type": "[ResourceSkuCosts]"}, - "capabilities": {"key": "capabilities", "type": "[ResourceSkuCapabilities]"}, - "restrictions": {"key": "restrictions", "type": "[ResourceSkuRestrictions]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_type: Optional[str] = None - self.name: Optional[str] = None - self.tier: Optional[str] = None - self.size: Optional[str] = None - self.family: Optional[str] = None - self.kind: Optional[str] = None - self.capacity: Optional["_models.ResourceSkuCapacity"] = None - self.locations: Optional[List[str]] = None - self.api_versions: Optional[List[str]] = None - self.costs: Optional[List["_models.ResourceSkuCosts"]] = None - self.capabilities: Optional[List["_models.ResourceSkuCapabilities"]] = None - self.restrictions: Optional[List["_models.ResourceSkuRestrictions"]] = None - - -class ResourceSkuCapabilities(_serialization.Model): - """Describes The SKU capabilities object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: An invariant to describe the feature. - :vartype name: str - :ivar value: An invariant if the feature is measured by quantity. - :vartype value: str - """ - - _validation = { - "name": {"readonly": True}, - "value": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.value: Optional[str] = None - - -class ResourceSkuCapacity(_serialization.Model): - """Describes scaling information of a SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar minimum: The minimum capacity. - :vartype minimum: int - :ivar maximum: The maximum capacity that can be set. - :vartype maximum: int - :ivar default: The default capacity. - :vartype default: int - :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", - "Manual", and "None". - :vartype scale_type: str or ~azure.mgmt.compute.v2017_03_30.models.ResourceSkuCapacityScaleType - """ - - _validation = { - "minimum": {"readonly": True}, - "maximum": {"readonly": True}, - "default": {"readonly": True}, - "scale_type": {"readonly": True}, - } - - _attribute_map = { - "minimum": {"key": "minimum", "type": "int"}, - "maximum": {"key": "maximum", "type": "int"}, - "default": {"key": "default", "type": "int"}, - "scale_type": {"key": "scaleType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.minimum: Optional[int] = None - self.maximum: Optional[int] = None - self.default: Optional[int] = None - self.scale_type: Optional[Union[str, "_models.ResourceSkuCapacityScaleType"]] = None - - -class ResourceSkuCosts(_serialization.Model): - """Describes metadata for retrieving price info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar meter_id: Used for querying price from commerce. - :vartype meter_id: str - :ivar quantity: The multiplier is needed to extend the base metered cost. - :vartype quantity: int - :ivar extended_unit: An invariant to show the extended unit. - :vartype extended_unit: str - """ - - _validation = { - "meter_id": {"readonly": True}, - "quantity": {"readonly": True}, - "extended_unit": {"readonly": True}, - } - - _attribute_map = { - "meter_id": {"key": "meterID", "type": "str"}, - "quantity": {"key": "quantity", "type": "int"}, - "extended_unit": {"key": "extendedUnit", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.meter_id: Optional[str] = None - self.quantity: Optional[int] = None - self.extended_unit: Optional[str] = None - - -class ResourceSkuRestrictions(_serialization.Model): - """Describes scaling information of a SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of restrictions. Default value is "Location". - :vartype type: str - :ivar values: The value of restrictions. If the restriction type is set to location. This would - be different locations where the SKU is restricted. - :vartype values: list[str] - :ivar reason_code: The reason for restriction. Known values are: "QuotaId" and - "NotAvailableForSubscription". - :vartype reason_code: str or - ~azure.mgmt.compute.v2017_03_30.models.ResourceSkuRestrictionsReasonCode - """ - - _validation = { - "type": {"readonly": True}, - "values": {"readonly": True}, - "reason_code": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "values": {"key": "values", "type": "[str]"}, - "reason_code": {"key": "reasonCode", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[Literal["Location"]] = None - self.values: Optional[List[str]] = None - self.reason_code: Optional[Union[str, "_models.ResourceSkuRestrictionsReasonCode"]] = None - - -class ResourceSkusResult(_serialization.Model): - """The Compute List Skus operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of skus available for the subscription. Required. - :vartype value: list[~azure.mgmt.compute.v2017_03_30.models.ResourceSku] - :ivar next_link: The uri to fetch the next page of Compute Skus. Call ListNext() with this to - fetch the next page of VMSS Skus. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ResourceSku]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - 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. - :paramtype value: list[~azure.mgmt.compute.v2017_03_30.models.ResourceSku] - :keyword next_link: The uri to fetch the next page of Compute Skus. Call ListNext() with this - to fetch the next page of VMSS Skus. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RollingUpgradePolicy(_serialization.Model): - """The configuration parameters used while performing a rolling upgrade. - - :ivar max_batch_instance_percent: The maximum percent of total virtual machine instances that - will be upgraded simultaneously by the rolling upgrade in one batch. As this is a maximum, - unhealthy instances in previous or future batches can cause the percentage of instances in a - batch to decrease to ensure higher reliability. The default value for this parameter is 20%. - :vartype max_batch_instance_percent: int - :ivar max_unhealthy_instance_percent: The maximum percentage of the total virtual machine - instances in the scale set that can be simultaneously unhealthy, either as a result of being - upgraded, or by being found in an unhealthy state by the virtual machine health checks before - the rolling upgrade aborts. This constraint will be checked prior to starting any batch. The - default value for this parameter is 20%. - :vartype max_unhealthy_instance_percent: int - :ivar max_unhealthy_upgraded_instance_percent: The maximum percentage of upgraded virtual - machine instances that can be found to be in an unhealthy state. This check will happen after - each batch is upgraded. If this percentage is ever exceeded, the rolling update aborts. The - default value for this parameter is 20%. - :vartype max_unhealthy_upgraded_instance_percent: int - :ivar pause_time_between_batches: The wait time between completing the update for all virtual - machines in one batch and starting the next batch. The time duration should be specified in ISO - 8601 format. The default value is 0 seconds (PT0S). - :vartype pause_time_between_batches: str - """ - - _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}, - } - - _attribute_map = { - "max_batch_instance_percent": {"key": "maxBatchInstancePercent", "type": "int"}, - "max_unhealthy_instance_percent": {"key": "maxUnhealthyInstancePercent", "type": "int"}, - "max_unhealthy_upgraded_instance_percent": {"key": "maxUnhealthyUpgradedInstancePercent", "type": "int"}, - "pause_time_between_batches": {"key": "pauseTimeBetweenBatches", "type": "str"}, - } - - def __init__( - self, - *, - max_batch_instance_percent: Optional[int] = None, - max_unhealthy_instance_percent: Optional[int] = None, - max_unhealthy_upgraded_instance_percent: Optional[int] = None, - pause_time_between_batches: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword max_batch_instance_percent: The maximum percent of total virtual machine instances - that will be upgraded simultaneously by the rolling upgrade in one batch. As this is a maximum, - unhealthy instances in previous or future batches can cause the percentage of instances in a - batch to decrease to ensure higher reliability. The default value for this parameter is 20%. - :paramtype max_batch_instance_percent: int - :keyword max_unhealthy_instance_percent: The maximum percentage of the total virtual machine - instances in the scale set that can be simultaneously unhealthy, either as a result of being - upgraded, or by being found in an unhealthy state by the virtual machine health checks before - the rolling upgrade aborts. This constraint will be checked prior to starting any batch. The - default value for this parameter is 20%. - :paramtype max_unhealthy_instance_percent: int - :keyword max_unhealthy_upgraded_instance_percent: The maximum percentage of upgraded virtual - machine instances that can be found to be in an unhealthy state. This check will happen after - each batch is upgraded. If this percentage is ever exceeded, the rolling update aborts. The - default value for this parameter is 20%. - :paramtype max_unhealthy_upgraded_instance_percent: int - :keyword pause_time_between_batches: The wait time between completing the update for all - virtual machines in one batch and starting the next batch. The time duration should be - specified in ISO 8601 format. The default value is 0 seconds (PT0S). - :paramtype pause_time_between_batches: str - """ - super().__init__(**kwargs) - self.max_batch_instance_percent = max_batch_instance_percent - self.max_unhealthy_instance_percent = max_unhealthy_instance_percent - self.max_unhealthy_upgraded_instance_percent = max_unhealthy_upgraded_instance_percent - self.pause_time_between_batches = pause_time_between_batches - - -class RollingUpgradeProgressInfo(_serialization.Model): - """Information about the number of virtual machine instances in each upgrade state. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar successful_instance_count: The number of instances that have been successfully upgraded. - :vartype successful_instance_count: int - :ivar failed_instance_count: The number of instances that have failed to be upgraded - successfully. - :vartype failed_instance_count: int - :ivar in_progress_instance_count: The number of instances that are currently being upgraded. - :vartype in_progress_instance_count: int - :ivar pending_instance_count: The number of instances that have not yet begun to be upgraded. - :vartype pending_instance_count: int - """ - - _validation = { - "successful_instance_count": {"readonly": True}, - "failed_instance_count": {"readonly": True}, - "in_progress_instance_count": {"readonly": True}, - "pending_instance_count": {"readonly": True}, - } - - _attribute_map = { - "successful_instance_count": {"key": "successfulInstanceCount", "type": "int"}, - "failed_instance_count": {"key": "failedInstanceCount", "type": "int"}, - "in_progress_instance_count": {"key": "inProgressInstanceCount", "type": "int"}, - "pending_instance_count": {"key": "pendingInstanceCount", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.successful_instance_count: Optional[int] = None - self.failed_instance_count: Optional[int] = None - self.in_progress_instance_count: Optional[int] = None - self.pending_instance_count: Optional[int] = None - - -class RollingUpgradeRunningStatus(_serialization.Model): - """Information about the current running state of the overall upgrade. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Code indicating the current status of the upgrade. Known values are: - "RollingForward", "Cancelled", "Completed", and "Faulted". - :vartype code: str or ~azure.mgmt.compute.v2017_03_30.models.RollingUpgradeStatusCode - :ivar start_time: Start time of the upgrade. - :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start" - and "Cancel". - :vartype last_action: str or ~azure.mgmt.compute.v2017_03_30.models.RollingUpgradeActionType - :ivar last_action_time: Last action time of the upgrade. - :vartype last_action_time: ~datetime.datetime - """ - - _validation = { - "code": {"readonly": True}, - "start_time": {"readonly": True}, - "last_action": {"readonly": True}, - "last_action_time": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "last_action": {"key": "lastAction", "type": "str"}, - "last_action_time": {"key": "lastActionTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[Union[str, "_models.RollingUpgradeStatusCode"]] = None - self.start_time: Optional[datetime.datetime] = None - self.last_action: Optional[Union[str, "_models.RollingUpgradeActionType"]] = None - self.last_action_time: Optional[datetime.datetime] = None - - -class RollingUpgradeStatusInfo(Resource): - """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. - :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] - :ivar policy: The rolling upgrade policies applied for this upgrade. - :vartype policy: ~azure.mgmt.compute.v2017_03_30.models.RollingUpgradePolicy - :ivar running_status: Information about the current running state of the overall upgrade. - :vartype running_status: ~azure.mgmt.compute.v2017_03_30.models.RollingUpgradeRunningStatus - :ivar progress: Information about the number of virtual machine instances in each upgrade - state. - :vartype progress: ~azure.mgmt.compute.v2017_03_30.models.RollingUpgradeProgressInfo - :ivar error: Error details for this upgrade, if there are any. - :vartype error: ~azure.mgmt.compute.v2017_03_30.models.ApiError - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "policy": {"readonly": True}, - "running_status": {"readonly": True}, - "progress": {"readonly": True}, - "error": {"readonly": 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}"}, - "policy": {"key": "properties.policy", "type": "RollingUpgradePolicy"}, - "running_status": {"key": "properties.runningStatus", "type": "RollingUpgradeRunningStatus"}, - "progress": {"key": "properties.progress", "type": "RollingUpgradeProgressInfo"}, - "error": {"key": "properties.error", "type": "ApiError"}, - } - - 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__(location=location, tags=tags, **kwargs) - self.policy: Optional["_models.RollingUpgradePolicy"] = None - self.running_status: Optional["_models.RollingUpgradeRunningStatus"] = None - self.progress: Optional["_models.RollingUpgradeProgressInfo"] = None - self.error: Optional["_models.ApiError"] = None - - -class RunCommandDocumentBase(_serialization.Model): - """Describes the properties of a Run Command metadata. - - All required parameters must be populated in order to send to server. - - :ivar schema: The VM run command schema. Required. - :vartype schema: str - :ivar id: The VM run command id. Required. - :vartype id: str - :ivar os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :ivar label: The VM run command label. Required. - :vartype label: str - :ivar description: The VM run command description. Required. - :vartype description: str - """ - - _validation = { - "schema": {"required": True}, - "id": {"required": True}, - "os_type": {"required": True}, - "label": {"required": True}, - "description": {"required": True}, - } - - _attribute_map = { - "schema": {"key": "$schema", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "os_type": {"key": "osType", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - schema: str, - id: str, # pylint: disable=redefined-builtin - os_type: Union[str, "_models.OperatingSystemTypes"], - label: str, - description: str, - **kwargs: Any - ) -> None: - """ - :keyword schema: The VM run command schema. Required. - :paramtype schema: str - :keyword id: The VM run command id. Required. - :paramtype id: str - :keyword os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :keyword label: The VM run command label. Required. - :paramtype label: str - :keyword description: The VM run command description. Required. - :paramtype description: str - """ - super().__init__(**kwargs) - self.schema = schema - self.id = id - self.os_type = os_type - self.label = label - self.description = description - - -class RunCommandDocument(RunCommandDocumentBase): - """Describes the properties of a Run Command. - - All required parameters must be populated in order to send to server. - - :ivar schema: The VM run command schema. Required. - :vartype schema: str - :ivar id: The VM run command id. Required. - :vartype id: str - :ivar os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :ivar label: The VM run command label. Required. - :vartype label: str - :ivar description: The VM run command description. Required. - :vartype description: str - :ivar script: The script to be executed. Required. - :vartype script: list[str] - :ivar parameters: The parameters used by the script. - :vartype parameters: list[~azure.mgmt.compute.v2017_03_30.models.RunCommandParameterDefinition] - """ - - _validation = { - "schema": {"required": True}, - "id": {"required": True}, - "os_type": {"required": True}, - "label": {"required": True}, - "description": {"required": True}, - "script": {"required": True}, - } - - _attribute_map = { - "schema": {"key": "$schema", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "os_type": {"key": "osType", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "script": {"key": "script", "type": "[str]"}, - "parameters": {"key": "parameters", "type": "[RunCommandParameterDefinition]"}, - } - - def __init__( - self, - *, - schema: str, - id: str, # pylint: disable=redefined-builtin - os_type: Union[str, "_models.OperatingSystemTypes"], - label: str, - description: str, - script: List[str], - parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword schema: The VM run command schema. Required. - :paramtype schema: str - :keyword id: The VM run command id. Required. - :paramtype id: str - :keyword os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :keyword label: The VM run command label. Required. - :paramtype label: str - :keyword description: The VM run command description. Required. - :paramtype description: str - :keyword script: The script to be executed. Required. - :paramtype script: list[str] - :keyword parameters: The parameters used by the script. - :paramtype parameters: - list[~azure.mgmt.compute.v2017_03_30.models.RunCommandParameterDefinition] - """ - super().__init__(schema=schema, id=id, os_type=os_type, label=label, description=description, **kwargs) - self.script = script - self.parameters = parameters - - -class RunCommandInput(_serialization.Model): - """Capture Virtual Machine parameters. - - All required parameters must be populated in order to send to server. - - :ivar command_id: The run command id. Required. - :vartype command_id: str - :ivar script: Optional. The script to be executed. When this value is given, the given script - will override the default script of the command. - :vartype script: list[str] - :ivar parameters: The run command parameters. - :vartype parameters: list[~azure.mgmt.compute.v2017_03_30.models.RunCommandInputParameter] - """ - - _validation = { - "command_id": {"required": True}, - } - - _attribute_map = { - "command_id": {"key": "commandId", "type": "str"}, - "script": {"key": "script", "type": "[str]"}, - "parameters": {"key": "parameters", "type": "[RunCommandInputParameter]"}, - } - - def __init__( - self, - *, - command_id: str, - script: Optional[List[str]] = None, - parameters: Optional[List["_models.RunCommandInputParameter"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword command_id: The run command id. Required. - :paramtype command_id: str - :keyword script: Optional. The script to be executed. When this value is given, the given - script will override the default script of the command. - :paramtype script: list[str] - :keyword parameters: The run command parameters. - :paramtype parameters: list[~azure.mgmt.compute.v2017_03_30.models.RunCommandInputParameter] - """ - super().__init__(**kwargs) - self.command_id = command_id - self.script = script - self.parameters = parameters - - -class RunCommandInputParameter(_serialization.Model): - """Describes the properties of a run command parameter. - - All required parameters must be populated in order to send to server. - - :ivar name: The run command parameter name. Required. - :vartype name: str - :ivar value: The run command parameter value. Required. - :vartype value: str - """ - - _validation = { - "name": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: - """ - :keyword name: The run command parameter name. Required. - :paramtype name: str - :keyword value: The run command parameter value. Required. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class RunCommandListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine run commands. Required. - :vartype value: list[~azure.mgmt.compute.v2017_03_30.models.RunCommandDocumentBase] - :ivar next_link: The uri to fetch the next page of run commands. Call ListNext() with this to - fetch the next page of run commands. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RunCommandDocumentBase]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine run commands. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_03_30.models.RunCommandDocumentBase] - :keyword next_link: The uri to fetch the next page of run commands. Call ListNext() with this - to fetch the next page of run commands. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RunCommandParameterDefinition(_serialization.Model): - """Describes the properties of a run command parameter. - - All required parameters must be populated in order to send to server. - - :ivar name: The run command parameter name. Required. - :vartype name: str - :ivar type: The run command parameter type. Required. - :vartype type: str - :ivar default_value: The run command parameter default value. - :vartype default_value: str - :ivar required: The run command parameter required. - :vartype required: bool - """ - - _validation = { - "name": {"required": True}, - "type": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "default_value": {"key": "defaultValue", "type": "str"}, - "required": {"key": "required", "type": "bool"}, - } - - def __init__( - self, *, name: str, type: str, default_value: Optional[str] = None, required: bool = False, **kwargs: Any - ) -> None: - """ - :keyword name: The run command parameter name. Required. - :paramtype name: str - :keyword type: The run command parameter type. Required. - :paramtype type: str - :keyword default_value: The run command parameter default value. - :paramtype default_value: str - :keyword required: The run command parameter required. - :paramtype required: bool - """ - super().__init__(**kwargs) - self.name = name - self.type = type - self.default_value = default_value - self.required = required - - -class RunCommandResult(OperationStatusResponse): - """Run command operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation ID. - :vartype name: str - :ivar status: Operation status. - :vartype status: str - :ivar start_time: Start time of the operation. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the operation. - :vartype end_time: ~datetime.datetime - :ivar error: Api error. - :vartype error: ~azure.mgmt.compute.v2017_03_30.models.ApiError - :ivar output: Operation output data (raw JSON). - :vartype output: JSON - """ - - _validation = { - "name": {"readonly": True}, - "status": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - "error": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "error": {"key": "error", "type": "ApiError"}, - "output": {"key": "properties.output", "type": "object"}, - } - - def __init__(self, *, output: Optional[JSON] = None, **kwargs: Any) -> None: - """ - :keyword output: Operation output data (raw JSON). - :paramtype output: JSON - """ - super().__init__(**kwargs) - self.output = output - - -class Sku(_serialization.Model): - """Describes a virtual machine scale set sku. - - :ivar name: The sku name. - :vartype name: str - :ivar tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
    `\\ - :code:`
    ` Possible Values:\\ :code:`
    `\\ :code:`
    ` **Standard**\\ :code:`
    `\\ :code:`
    ` **Basic**. - :vartype tier: str - :ivar capacity: Specifies the number of virtual machines in the scale set. NOTE: If the new VM - SKU is not supported on the hardware the scale set is currently on, you need to deallocate the - VMs in the scale set before you modify the SKU name. - :vartype capacity: int - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "capacity": {"key": "capacity", "type": "int"}, - } - - def __init__( - self, *, name: Optional[str] = None, tier: Optional[str] = None, capacity: Optional[int] = None, **kwargs: Any - ) -> None: - """ - :keyword name: The sku name. - :paramtype name: str - :keyword tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
    `\\ - :code:`
    ` Possible Values:\\ :code:`
    `\\ :code:`
    ` **Standard**\\ :code:`
    `\\ :code:`
    ` **Basic**. - :paramtype tier: str - :keyword capacity: Specifies the number of virtual machines in the scale set. NOTE: If the new - VM SKU is not supported on the hardware the scale set is currently on, you need to deallocate - the VMs in the scale set before you modify the SKU name. - :paramtype capacity: int - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - self.capacity = capacity - - -class Snapshot(Resource): - """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. - :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] - :ivar managed_by: Unused. Always Null. - :vartype managed_by: str - :ivar sku: The disks and snapshots sku name. Can be Standard_LRS or Premium_LRS. - :vartype sku: ~azure.mgmt.compute.v2017_03_30.models.DiskSku - :ivar time_created: The time when the disk was created. - :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :ivar creation_data: Disk source information. CreationData information cannot be changed after - the disk has been created. - :vartype creation_data: ~azure.mgmt.compute.v2017_03_30.models.CreationData - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the VHD to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar encryption_settings: Encryption settings for disk or snapshot. - :vartype encryption_settings: ~azure.mgmt.compute.v2017_03_30.models.EncryptionSettings - :ivar provisioning_state: The disk provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "managed_by": {"readonly": True}, - "time_created": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "sku": {"key": "sku", "type": "DiskSku"}, - "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "creation_data": {"key": "properties.creationData", "type": "CreationData"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "encryption_settings": {"key": "properties.encryptionSettings", "type": "EncryptionSettings"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.DiskSku"] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - creation_data: Optional["_models.CreationData"] = None, - disk_size_gb: Optional[int] = None, - encryption_settings: Optional["_models.EncryptionSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The disks and snapshots sku name. Can be Standard_LRS or Premium_LRS. - :paramtype sku: ~azure.mgmt.compute.v2017_03_30.models.DiskSku - :keyword os_type: The Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :keyword creation_data: Disk source information. CreationData information cannot be changed - after the disk has been created. - :paramtype creation_data: ~azure.mgmt.compute.v2017_03_30.models.CreationData - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the VHD to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings: Encryption settings for disk or snapshot. - :paramtype encryption_settings: ~azure.mgmt.compute.v2017_03_30.models.EncryptionSettings - """ - super().__init__(location=location, tags=tags, **kwargs) - self.managed_by: Optional[str] = None - self.sku = sku - self.time_created: Optional[datetime.datetime] = None - self.os_type = os_type - self.creation_data = creation_data - self.disk_size_gb = disk_size_gb - self.encryption_settings = encryption_settings - self.provisioning_state: Optional[str] = None - - -class SnapshotList(_serialization.Model): - """The List Snapshots operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of snapshots. Required. - :vartype value: list[~azure.mgmt.compute.v2017_03_30.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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Snapshot]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of snapshots. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_03_30.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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SnapshotUpdate(ResourceUpdate): - """Snapshot update resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The disks and snapshots sku name. Can be Standard_LRS or Premium_LRS. - :vartype sku: ~azure.mgmt.compute.v2017_03_30.models.DiskSku - :ivar os_type: the Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the VHD to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar encryption_settings: Encryption settings for disk or snapshot. - :vartype encryption_settings: ~azure.mgmt.compute.v2017_03_30.models.EncryptionSettings - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "DiskSku"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "encryption_settings": {"key": "properties.encryptionSettings", "type": "EncryptionSettings"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.DiskSku"] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - disk_size_gb: Optional[int] = None, - encryption_settings: Optional["_models.EncryptionSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The disks and snapshots sku name. Can be Standard_LRS or Premium_LRS. - :paramtype sku: ~azure.mgmt.compute.v2017_03_30.models.DiskSku - :keyword os_type: the Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the VHD to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings: Encryption settings for disk or snapshot. - :paramtype encryption_settings: ~azure.mgmt.compute.v2017_03_30.models.EncryptionSettings - """ - super().__init__(tags=tags, sku=sku, **kwargs) - self.os_type = os_type - self.disk_size_gb = disk_size_gb - self.encryption_settings = encryption_settings - - -class SourceVault(_serialization.Model): - """The vault id is an Azure Resource Manager Resource id in the form - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class SshConfiguration(_serialization.Model): - """SSH configuration for Linux based VMs running on Azure. - - :ivar public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :vartype public_keys: list[~azure.mgmt.compute.v2017_03_30.models.SshPublicKey] - """ - - _attribute_map = { - "public_keys": {"key": "publicKeys", "type": "[SshPublicKey]"}, - } - - def __init__(self, *, public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs: Any) -> None: - """ - :keyword public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :paramtype public_keys: list[~azure.mgmt.compute.v2017_03_30.models.SshPublicKey] - """ - super().__init__(**kwargs) - self.public_keys = public_keys - - -class SshPublicKey(_serialization.Model): - """Contains information about SSH certificate public key and the path on the Linux VM where the - public key is placed. - - :ivar path: Specifies the full path on the created VM where ssh public key is stored. If the - file already exists, the specified key is appended to the file. Example: - /home/user/.ssh/authorized_keys. - :vartype path: str - :ivar key_data: SSH public key certificate used to authenticate with the VM through ssh. The - key needs to be at least 2048-bit and in ssh-rsa format. :code:`
    `\\ :code:`
    ` For - creating ssh keys, see `Create SSH keys on Linux and Mac for Linux VMs in Azure - `_. - :vartype key_data: str - """ - - _attribute_map = { - "path": {"key": "path", "type": "str"}, - "key_data": {"key": "keyData", "type": "str"}, - } - - def __init__(self, *, path: Optional[str] = None, key_data: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword path: Specifies the full path on the created VM where ssh public key is stored. If the - file already exists, the specified key is appended to the file. Example: - /home/user/.ssh/authorized_keys. - :paramtype path: str - :keyword key_data: SSH public key certificate used to authenticate with the VM through ssh. The - key needs to be at least 2048-bit and in ssh-rsa format. :code:`
    `\\ :code:`
    ` For - creating ssh keys, see `Create SSH keys on Linux and Mac for Linux VMs in Azure - `_. - :paramtype key_data: str - """ - super().__init__(**kwargs) - self.path = path - self.key_data = key_data - - -class StorageProfile(_serialization.Model): - """Specifies the storage settings for the virtual machine disks. - - :ivar image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :vartype image_reference: ~azure.mgmt.compute.v2017_03_30.models.ImageReference - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2017_03_30.models.OSDisk - :ivar data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype data_disks: list[~azure.mgmt.compute.v2017_03_30.models.DataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "OSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[DataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.OSDisk"] = None, - data_disks: Optional[List["_models.DataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :paramtype image_reference: ~azure.mgmt.compute.v2017_03_30.models.ImageReference - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2017_03_30.models.OSDisk - :keyword data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype data_disks: list[~azure.mgmt.compute.v2017_03_30.models.DataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class SubResourceReadOnly(_serialization.Model): - """SubResourceReadOnly. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class UpdateResource(_serialization.Model): - """The Update Resource model definition. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class UpgradePolicy(_serialization.Model): - """Describes an upgrade policy - automatic, manual, or rolling. - - :ivar mode: Specifies the mode of an upgrade to virtual machines in the scale set.\\ :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Manual** - You - control the application of updates to virtual machines in the scale set. You do this by using - the manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - All virtual - machines in the scale set are automatically updated at the same time. Known values are: - "Automatic", "Manual", and "Rolling". - :vartype mode: str or ~azure.mgmt.compute.v2017_03_30.models.UpgradeMode - :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling - upgrade. - :vartype rolling_upgrade_policy: ~azure.mgmt.compute.v2017_03_30.models.RollingUpgradePolicy - :ivar automatic_os_upgrade: Whether OS upgrades should automatically be applied to scale set - instances in a rolling fashion when a newer version of the image becomes available. - :vartype automatic_os_upgrade: bool - """ - - _attribute_map = { - "mode": {"key": "mode", "type": "str"}, - "rolling_upgrade_policy": {"key": "rollingUpgradePolicy", "type": "RollingUpgradePolicy"}, - "automatic_os_upgrade": {"key": "automaticOSUpgrade", "type": "bool"}, - } - - def __init__( - self, - *, - mode: Optional[Union[str, "_models.UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, - automatic_os_upgrade: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword mode: Specifies the mode of an upgrade to virtual machines in the scale set.\\ - :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` - **Manual** - You control the application of updates to virtual machines in the scale set. You - do this by using the manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - - All virtual machines in the scale set are automatically updated at the same time. Known values - are: "Automatic", "Manual", and "Rolling". - :paramtype mode: str or ~azure.mgmt.compute.v2017_03_30.models.UpgradeMode - :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling - upgrade. - :paramtype rolling_upgrade_policy: ~azure.mgmt.compute.v2017_03_30.models.RollingUpgradePolicy - :keyword automatic_os_upgrade: Whether OS upgrades should automatically be applied to scale set - instances in a rolling fashion when a newer version of the image becomes available. - :paramtype automatic_os_upgrade: bool - """ - super().__init__(**kwargs) - self.mode = mode - self.rolling_upgrade_policy = rolling_upgrade_policy - self.automatic_os_upgrade = automatic_os_upgrade - - -class Usage(_serialization.Model): - """Describes Compute Resource Usage. - - 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 unit: An enum describing the unit of usage measurement. Required. Default value is - "Count". - :vartype unit: str - :ivar current_value: The current usage of the resource. Required. - :vartype current_value: int - :ivar limit: The maximum permitted usage of the resource. Required. - :vartype limit: int - :ivar name: The name of the type of usage. Required. - :vartype name: ~azure.mgmt.compute.v2017_03_30.models.UsageName - """ - - _validation = { - "unit": {"required": True, "constant": True}, - "current_value": {"required": True}, - "limit": {"required": True}, - "name": {"required": True}, - } - - _attribute_map = { - "unit": {"key": "unit", "type": "str"}, - "current_value": {"key": "currentValue", "type": "int"}, - "limit": {"key": "limit", "type": "int"}, - "name": {"key": "name", "type": "UsageName"}, - } - - unit = "Count" - - def __init__(self, *, current_value: int, limit: int, name: "_models.UsageName", **kwargs: Any) -> None: - """ - :keyword current_value: The current usage of the resource. Required. - :paramtype current_value: int - :keyword limit: The maximum permitted usage of the resource. Required. - :paramtype limit: int - :keyword name: The name of the type of usage. Required. - :paramtype name: ~azure.mgmt.compute.v2017_03_30.models.UsageName - """ - super().__init__(**kwargs) - self.current_value = current_value - self.limit = limit - self.name = name - - -class UsageName(_serialization.Model): - """The Usage Names. - - :ivar value: The name of the resource. - :vartype value: str - :ivar localized_value: The localized name of the resource. - :vartype localized_value: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, - } - - def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The name of the resource. - :paramtype value: str - :keyword localized_value: The localized name of the resource. - :paramtype localized_value: str - """ - super().__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - -class VaultCertificate(_serialization.Model): - """Describes a single certificate reference in a Key Vault, and where the certificate should - reside on the VM. - - :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as - a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :vartype certificate_url: str - :ivar certificate_store: For Windows VMs, specifies the certificate store on the Virtual - Machine to which the certificate should be added. The specified certificate store is implicitly - in the LocalMachine account. :code:`
    `\\ :code:`
    `For Linux VMs, the certificate file is - placed under the /var/lib/waagent directory, with the file name <UppercaseThumbprint>.crt - for the X509 certificate file and <UppercaseThumbprint>.prv for private key. Both of - these files are .pem formatted. - :vartype certificate_store: str - """ - - _attribute_map = { - "certificate_url": {"key": "certificateUrl", "type": "str"}, - "certificate_store": {"key": "certificateStore", "type": "str"}, - } - - def __init__( - self, *, certificate_url: Optional[str] = None, certificate_store: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault - as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :paramtype certificate_url: str - :keyword certificate_store: For Windows VMs, specifies the certificate store on the Virtual - Machine to which the certificate should be added. The specified certificate store is implicitly - in the LocalMachine account. :code:`
    `\\ :code:`
    `For Linux VMs, the certificate file is - placed under the /var/lib/waagent directory, with the file name <UppercaseThumbprint>.crt - for the X509 certificate file and <UppercaseThumbprint>.prv for private key. Both of - these files are .pem formatted. - :paramtype certificate_store: str - """ - super().__init__(**kwargs) - self.certificate_url = certificate_url - self.certificate_store = certificate_store - - -class VaultSecretGroup(_serialization.Model): - """Describes a set of certificates which are all in the same Key Vault. - - :ivar source_vault: The relative URL of the Key Vault containing all of the certificates in - VaultCertificates. - :vartype source_vault: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :ivar vault_certificates: The list of key vault references in SourceVault which contain - certificates. - :vartype vault_certificates: list[~azure.mgmt.compute.v2017_03_30.models.VaultCertificate] - """ - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - "vault_certificates": {"key": "vaultCertificates", "type": "[VaultCertificate]"}, - } - - def __init__( - self, - *, - source_vault: Optional["_models.SubResource"] = None, - vault_certificates: Optional[List["_models.VaultCertificate"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source_vault: The relative URL of the Key Vault containing all of the certificates in - VaultCertificates. - :paramtype source_vault: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :keyword vault_certificates: The list of key vault references in SourceVault which contain - certificates. - :paramtype vault_certificates: list[~azure.mgmt.compute.v2017_03_30.models.VaultCertificate] - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.vault_certificates = vault_certificates - - -class VirtualHardDisk(_serialization.Model): - """Describes the uri of a disk. - - :ivar uri: Specifies the virtual hard disk's uri. - :vartype uri: str - """ - - _attribute_map = { - "uri": {"key": "uri", "type": "str"}, - } - - def __init__(self, *, uri: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword uri: Specifies the virtual hard disk's uri. - :paramtype uri: str - """ - super().__init__(**kwargs) - self.uri = uri - - -class VirtualMachine(Resource): - """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. - :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] - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2017_03_30.models.Plan - :ivar resources: The virtual machine child extension resources. - :vartype resources: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtension] - :ivar identity: The identity of the virtual machine, if configured. - :vartype identity: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineIdentity - :ivar zones: The virtual machine zones. - :vartype zones: list[str] - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2017_03_30.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2017_03_30.models.StorageProfile - :ivar os_profile: Specifies the operating system settings for the virtual machine. - :vartype os_profile: ~azure.mgmt.compute.v2017_03_30.models.OSProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2017_03_30.models.NetworkProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2017_03_30.models.DiagnosticsProfile - :ivar availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :vartype availability_set: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineInstanceView - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar vm_id: Specifies the VM unique ID which is a 128-bits identifier that is encoded and - stored in all Azure IaaS VMs SMBIOS and can be read using platform BIOS commands. - :vartype vm_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "resources": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - "vm_id": {"readonly": 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}"}, - "plan": {"key": "plan", "type": "Plan"}, - "resources": {"key": "resources", "type": "[VirtualMachineExtension]"}, - "identity": {"key": "identity", "type": "VirtualMachineIdentity"}, - "zones": {"key": "zones", "type": "[str]"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineInstanceView"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineIdentity"] = None, - zones: Optional[List[str]] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - os_profile: Optional["_models.OSProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2017_03_30.models.Plan - :keyword identity: The identity of the virtual machine, if configured. - :paramtype identity: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineIdentity - :keyword zones: The virtual machine zones. - :paramtype zones: list[str] - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2017_03_30.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2017_03_30.models.StorageProfile - :keyword os_profile: Specifies the operating system settings for the virtual machine. - :paramtype os_profile: ~azure.mgmt.compute.v2017_03_30.models.OSProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2017_03_30.models.NetworkProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2017_03_30.models.DiagnosticsProfile - :keyword availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :paramtype availability_set: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.plan = plan - self.resources: Optional[List["_models.VirtualMachineExtension"]] = None - self.identity = identity - self.zones = zones - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.os_profile = os_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineInstanceView"] = None - self.license_type = license_type - self.vm_id: Optional[str] = None - - -class VirtualMachineAgentInstanceView(_serialization.Model): - """The instance view of the VM Agent running on the virtual machine. - - :ivar vm_agent_version: The VM Agent full version. - :vartype vm_agent_version: str - :ivar extension_handlers: The virtual machine extension handler instance view. - :vartype extension_handlers: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtensionHandlerInstanceView] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2017_03_30.models.InstanceViewStatus] - """ - - _attribute_map = { - "vm_agent_version": {"key": "vmAgentVersion", "type": "str"}, - "extension_handlers": {"key": "extensionHandlers", "type": "[VirtualMachineExtensionHandlerInstanceView]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword vm_agent_version: The VM Agent full version. - :paramtype vm_agent_version: str - :keyword extension_handlers: The virtual machine extension handler instance view. - :paramtype extension_handlers: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtensionHandlerInstanceView] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2017_03_30.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.vm_agent_version = vm_agent_version - self.extension_handlers = extension_handlers - self.statuses = statuses - - -class VirtualMachineCaptureParameters(_serialization.Model): - """Capture Virtual Machine parameters. - - All required parameters must be populated in order to send to server. - - :ivar vhd_prefix: The captured virtual hard disk's name prefix. Required. - :vartype vhd_prefix: str - :ivar destination_container_name: The destination container name. Required. - :vartype destination_container_name: str - :ivar overwrite_vhds: Specifies whether to overwrite the destination virtual hard disk, in case - of conflict. Required. - :vartype overwrite_vhds: bool - """ - - _validation = { - "vhd_prefix": {"required": True}, - "destination_container_name": {"required": True}, - "overwrite_vhds": {"required": True}, - } - - _attribute_map = { - "vhd_prefix": {"key": "vhdPrefix", "type": "str"}, - "destination_container_name": {"key": "destinationContainerName", "type": "str"}, - "overwrite_vhds": {"key": "overwriteVhds", "type": "bool"}, - } - - def __init__( - self, *, vhd_prefix: str, destination_container_name: str, overwrite_vhds: bool, **kwargs: Any - ) -> None: - """ - :keyword vhd_prefix: The captured virtual hard disk's name prefix. Required. - :paramtype vhd_prefix: str - :keyword destination_container_name: The destination container name. Required. - :paramtype destination_container_name: str - :keyword overwrite_vhds: Specifies whether to overwrite the destination virtual hard disk, in - case of conflict. Required. - :paramtype overwrite_vhds: bool - """ - super().__init__(**kwargs) - self.vhd_prefix = vhd_prefix - self.destination_container_name = destination_container_name - self.overwrite_vhds = overwrite_vhds - - -class VirtualMachineCaptureResult(SubResource): - """Resource Id. - - :ivar id: Resource Id. - :vartype id: str - :ivar output: Operation output data (raw JSON). - :vartype output: JSON - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "output": {"key": "properties.output", "type": "object"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - output: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword output: Operation output data (raw JSON). - :paramtype output: JSON - """ - super().__init__(id=id, **kwargs) - self.output = output - - -class VirtualMachineExtension(Resource): - """Describes a Virtual Machine Extension. - - 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] - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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. - :vartype instance_view: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtensionInstanceView - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineExtensionInstanceView"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, 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, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :keyword instance_view: The virtual machine extension instance view. - :paramtype instance_view: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtensionInstanceView - """ - super().__init__(location=location, tags=tags, **kwargs) - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - self.instance_view = instance_view - - -class VirtualMachineExtensionHandlerInstanceView(_serialization.Model): # pylint: disable=name-too-long - """The instance view of a virtual machine extension handler. - - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar status: The extension handler status. - :vartype status: ~azure.mgmt.compute.v2017_03_30.models.InstanceViewStatus - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "status": {"key": "status", "type": "InstanceViewStatus"}, - } - - def __init__( - self, - *, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - status: Optional["_models.InstanceViewStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword status: The extension handler status. - :paramtype status: ~azure.mgmt.compute.v2017_03_30.models.InstanceViewStatus - """ - super().__init__(**kwargs) - self.type = type - self.type_handler_version = type_handler_version - self.status = status - - -class VirtualMachineExtensionImage(Resource): - """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. - :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] - :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. - :vartype compute_role: str - :ivar handler_schema: The schema defined by publisher, where extension consumers should provide - settings in a matching schema. - :vartype handler_schema: str - :ivar vm_scale_set_enabled: Whether the extension can be used on xRP VMScaleSets. By default - existing extensions are usable on scalesets, but there might be cases where a publisher wants - to explicitly indicate the extension is only enabled for CRP VMs but not VMSS. - :vartype vm_scale_set_enabled: bool - :ivar supports_multiple_extensions: Whether the handler can support multiple extensions. - :vartype supports_multiple_extensions: bool - """ - - _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}"}, - "operating_system": {"key": "properties.operatingSystem", "type": "str"}, - "compute_role": {"key": "properties.computeRole", "type": "str"}, - "handler_schema": {"key": "properties.handlerSchema", "type": "str"}, - "vm_scale_set_enabled": {"key": "properties.vmScaleSetEnabled", "type": "bool"}, - "supports_multiple_extensions": {"key": "properties.supportsMultipleExtensions", "type": "bool"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - operating_system: Optional[str] = None, - compute_role: Optional[str] = None, - handler_schema: Optional[str] = None, - vm_scale_set_enabled: Optional[bool] = None, - supports_multiple_extensions: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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. - :paramtype compute_role: str - :keyword handler_schema: The schema defined by publisher, where extension consumers should - provide settings in a matching schema. - :paramtype handler_schema: str - :keyword vm_scale_set_enabled: Whether the extension can be used on xRP VMScaleSets. By default - existing extensions are usable on scalesets, but there might be cases where a publisher wants - to explicitly indicate the extension is only enabled for CRP VMs but not VMSS. - :paramtype vm_scale_set_enabled: bool - :keyword supports_multiple_extensions: Whether the handler can support multiple extensions. - :paramtype supports_multiple_extensions: bool - """ - super().__init__(location=location, tags=tags, **kwargs) - self.operating_system = operating_system - self.compute_role = compute_role - self.handler_schema = handler_schema - self.vm_scale_set_enabled = vm_scale_set_enabled - self.supports_multiple_extensions = supports_multiple_extensions - - -class VirtualMachineExtensionInstanceView(_serialization.Model): - """The instance view of a virtual machine extension. - - :ivar name: The virtual machine extension name. - :vartype name: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar substatuses: The resource status information. - :vartype substatuses: list[~azure.mgmt.compute.v2017_03_30.models.InstanceViewStatus] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2017_03_30.models.InstanceViewStatus] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "substatuses": {"key": "substatuses", "type": "[InstanceViewStatus]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - substatuses: Optional[List["_models.InstanceViewStatus"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The virtual machine extension name. - :paramtype name: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword substatuses: The resource status information. - :paramtype substatuses: list[~azure.mgmt.compute.v2017_03_30.models.InstanceViewStatus] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2017_03_30.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.name = name - self.type = type - self.type_handler_version = type_handler_version - self.substatuses = substatuses - self.statuses = statuses - - -class VirtualMachineExtensionsListResult(_serialization.Model): - """The List Extension operation response. - - :ivar value: The list of extensions. - :vartype value: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtension] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineExtension]"}, - } - - def __init__(self, *, value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of extensions. - :paramtype value: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtension] - """ - super().__init__(**kwargs) - self.value = value - - -class VirtualMachineExtensionUpdate(UpdateResource): - """Describes a Virtual Machine Extension. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - force_update_tag: Optional[str] = None, - publisher: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - auto_upgrade_minor_version: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - """ - super().__init__(tags=tags, **kwargs) - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type = type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - - -class VirtualMachineHealthStatus(_serialization.Model): - """The health status of the VM. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The health status information for the VM. - :vartype status: ~azure.mgmt.compute.v2017_03_30.models.InstanceViewStatus - """ - - _validation = { - "status": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "InstanceViewStatus"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional["_models.InstanceViewStatus"] = None - - -class VirtualMachineIdentity(_serialization.Model): - """Identity for the virtual machine. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of virtual machine identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the virtual machine. - :vartype tenant_id: str - :ivar type: The type of identity used for the virtual machine. Currently, the only supported - type is 'SystemAssigned', which implicitly creates an identity. Default value is - "SystemAssigned". - :vartype type: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The type of identity used for the virtual machine. Currently, the only supported - type is 'SystemAssigned', which implicitly creates an identity. Default value is - "SystemAssigned". - :paramtype type: str - """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.type = type - - -class VirtualMachineImageResource(SubResource): - """Virtual machine image resource information. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar location: The supported Azure location of the resource. Required. - :vartype location: str - :ivar tags: Specifies the tags that are assigned to the virtual machine. For more information - about using tags, see `Using tags to organize your Azure resources - `_. - :vartype tags: dict[str, str] - """ - - _validation = { - "name": {"required": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__( - self, - *, - name: str, - location: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The name of the resource. Required. - :paramtype name: str - :keyword location: The supported Azure location of the resource. Required. - :paramtype location: str - :keyword tags: Specifies the tags that are assigned to the virtual machine. For more - information about using tags, see `Using tags to organize your Azure resources - `_. - :paramtype tags: dict[str, str] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.location = location - self.tags = tags - - -class VirtualMachineImage(VirtualMachineImageResource): - """Describes a Virtual Machine Image. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar location: The supported Azure location of the resource. Required. - :vartype location: str - :ivar tags: Specifies the tags that are assigned to the virtual machine. For more information - about using tags, see `Using tags to organize your Azure resources - `_. - :vartype tags: dict[str, str] - :ivar plan: Used for establishing the purchase context of any 3rd Party artifact through - MarketPlace. - :vartype plan: ~azure.mgmt.compute.v2017_03_30.models.PurchasePlan - :ivar os_disk_image: Contains the os disk image information. - :vartype os_disk_image: ~azure.mgmt.compute.v2017_03_30.models.OSDiskImage - :ivar data_disk_images: - :vartype data_disk_images: list[~azure.mgmt.compute.v2017_03_30.models.DataDiskImage] - """ - - _validation = { - "name": {"required": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "plan": {"key": "properties.plan", "type": "PurchasePlan"}, - "os_disk_image": {"key": "properties.osDiskImage", "type": "OSDiskImage"}, - "data_disk_images": {"key": "properties.dataDiskImages", "type": "[DataDiskImage]"}, - } - - def __init__( - self, - *, - name: str, - location: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.PurchasePlan"] = None, - os_disk_image: Optional["_models.OSDiskImage"] = None, - data_disk_images: Optional[List["_models.DataDiskImage"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The name of the resource. Required. - :paramtype name: str - :keyword location: The supported Azure location of the resource. Required. - :paramtype location: str - :keyword tags: Specifies the tags that are assigned to the virtual machine. For more - information about using tags, see `Using tags to organize your Azure resources - `_. - :paramtype tags: dict[str, str] - :keyword plan: Used for establishing the purchase context of any 3rd Party artifact through - MarketPlace. - :paramtype plan: ~azure.mgmt.compute.v2017_03_30.models.PurchasePlan - :keyword os_disk_image: Contains the os disk image information. - :paramtype os_disk_image: ~azure.mgmt.compute.v2017_03_30.models.OSDiskImage - :keyword data_disk_images: - :paramtype data_disk_images: list[~azure.mgmt.compute.v2017_03_30.models.DataDiskImage] - """ - super().__init__(id=id, name=name, location=location, tags=tags, **kwargs) - self.plan = plan - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - - -class VirtualMachineInstanceView(_serialization.Model): - """The instance view of a virtual machine. - - :ivar platform_update_domain: Specifies the update domain of the virtual machine. - :vartype platform_update_domain: int - :ivar platform_fault_domain: Specifies the fault domain of the virtual machine. - :vartype platform_fault_domain: int - :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. - :vartype rdp_thumb_print: str - :ivar vm_agent: The VM Agent running on the virtual machine. - :vartype vm_agent: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineAgentInstanceView - :ivar maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :vartype maintenance_redeploy_status: - ~azure.mgmt.compute.v2017_03_30.models.MaintenanceRedeployStatus - :ivar disks: The virtual machine disk information. - :vartype disks: list[~azure.mgmt.compute.v2017_03_30.models.DiskInstanceView] - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtensionInstanceView] - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2017_03_30.models.BootDiagnosticsInstanceView - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2017_03_30.models.InstanceViewStatus] - """ - - _attribute_map = { - "platform_update_domain": {"key": "platformUpdateDomain", "type": "int"}, - "platform_fault_domain": {"key": "platformFaultDomain", "type": "int"}, - "rdp_thumb_print": {"key": "rdpThumbPrint", "type": "str"}, - "vm_agent": {"key": "vmAgent", "type": "VirtualMachineAgentInstanceView"}, - "maintenance_redeploy_status": {"key": "maintenanceRedeployStatus", "type": "MaintenanceRedeployStatus"}, - "disks": {"key": "disks", "type": "[DiskInstanceView]"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineExtensionInstanceView]"}, - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnosticsInstanceView"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - platform_update_domain: Optional[int] = None, - platform_fault_domain: Optional[int] = None, - rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, - disks: Optional[List["_models.DiskInstanceView"]] = None, - extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword platform_update_domain: Specifies the update domain of the virtual machine. - :paramtype platform_update_domain: int - :keyword platform_fault_domain: Specifies the fault domain of the virtual machine. - :paramtype platform_fault_domain: int - :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. - :paramtype rdp_thumb_print: str - :keyword vm_agent: The VM Agent running on the virtual machine. - :paramtype vm_agent: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineAgentInstanceView - :keyword maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :paramtype maintenance_redeploy_status: - ~azure.mgmt.compute.v2017_03_30.models.MaintenanceRedeployStatus - :keyword disks: The virtual machine disk information. - :paramtype disks: list[~azure.mgmt.compute.v2017_03_30.models.DiskInstanceView] - :keyword extensions: The extensions information. - :paramtype extensions: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtensionInstanceView] - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2017_03_30.models.BootDiagnosticsInstanceView - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2017_03_30.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.platform_update_domain = platform_update_domain - self.platform_fault_domain = platform_fault_domain - self.rdp_thumb_print = rdp_thumb_print - self.vm_agent = vm_agent - self.maintenance_redeploy_status = maintenance_redeploy_status - self.disks = disks - self.extensions = extensions - self.boot_diagnostics = boot_diagnostics - self.statuses = statuses - - -class VirtualMachineListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machines. Required. - :vartype value: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachine] - :ivar next_link: The URI to fetch the next page of VMs. Call ListNext() with this URI to fetch - the next page of Virtual Machines. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachine]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machines. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachine] - :keyword next_link: The URI to fetch the next page of VMs. Call ListNext() with this URI to - fetch the next page of Virtual Machines. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSet(Resource): - """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. - :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] - :ivar sku: The virtual machine scale set sku. - :vartype sku: ~azure.mgmt.compute.v2017_03_30.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2017_03_30.models.Plan - :ivar identity: The identity of the virtual machine scale set, if configured. - :vartype identity: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetIdentity - :ivar zones: The virtual machine scale set zones. NOTE: Availability zones can only be set when - you create the scale set. - :vartype zones: list[str] - :ivar upgrade_policy: The upgrade policy. - :vartype upgrade_policy: ~azure.mgmt.compute.v2017_03_30.models.UpgradePolicy - :ivar virtual_machine_profile: The virtual machine profile. - :vartype virtual_machine_profile: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetVMProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar overprovision: Specifies whether the Virtual Machine Scale Set should be overprovisioned. - :vartype overprovision: bool - :ivar unique_id: Specifies the ID which uniquely identifies a Virtual Machine Scale Set. - :vartype unique_id: str - :ivar single_placement_group: When true this limits the scale set to a single placement group, - of max size 100 virtual machines. - :vartype single_placement_group: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "unique_id": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "identity": {"key": "identity", "type": "VirtualMachineScaleSetIdentity"}, - "zones": {"key": "zones", "type": "[str]"}, - "upgrade_policy": {"key": "properties.upgradePolicy", "type": "UpgradePolicy"}, - "virtual_machine_profile": { - "key": "properties.virtualMachineProfile", - "type": "VirtualMachineScaleSetVMProfile", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "overprovision": {"key": "properties.overprovision", "type": "bool"}, - "unique_id": {"key": "properties.uniqueId", "type": "str"}, - "single_placement_group": {"key": "properties.singlePlacementGroup", "type": "bool"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, - zones: Optional[List[str]] = None, - upgrade_policy: Optional["_models.UpgradePolicy"] = None, - virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, - overprovision: Optional[bool] = None, - single_placement_group: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The virtual machine scale set sku. - :paramtype sku: ~azure.mgmt.compute.v2017_03_30.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2017_03_30.models.Plan - :keyword identity: The identity of the virtual machine scale set, if configured. - :paramtype identity: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetIdentity - :keyword zones: The virtual machine scale set zones. NOTE: Availability zones can only be set - when you create the scale set. - :paramtype zones: list[str] - :keyword upgrade_policy: The upgrade policy. - :paramtype upgrade_policy: ~azure.mgmt.compute.v2017_03_30.models.UpgradePolicy - :keyword virtual_machine_profile: The virtual machine profile. - :paramtype virtual_machine_profile: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetVMProfile - :keyword overprovision: Specifies whether the Virtual Machine Scale Set should be - overprovisioned. - :paramtype overprovision: bool - :keyword single_placement_group: When true this limits the scale set to a single placement - group, of max size 100 virtual machines. - :paramtype single_placement_group: bool - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.plan = plan - self.identity = identity - self.zones = zones - self.upgrade_policy = upgrade_policy - self.virtual_machine_profile = virtual_machine_profile - self.provisioning_state: Optional[str] = None - self.overprovision = overprovision - self.unique_id: Optional[str] = None - self.single_placement_group = single_placement_group - - -class VirtualMachineScaleSetDataDisk(_serialization.Model): - """Describes a virtual machine scale set data disk. - - All required parameters must be populated in order to send to server. - - :ivar name: The disk name. - :vartype name: str - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes - :ivar create_option: The create option. Required. Known values are: "FromImage", "Empty", and - "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetManagedDiskParameters - """ - - _validation = { - "lun": {"required": True}, - "create_option": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - "caching": {"key": "caching", "type": "str"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "VirtualMachineScaleSetManagedDiskParameters"}, - } - - def __init__( - self, - *, - lun: int, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes - :keyword create_option: The create option. Required. Known values are: "FromImage", "Empty", - and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetManagedDiskParameters - """ - super().__init__(**kwargs) - self.name = name - self.lun = lun - self.caching = caching - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - - -class VirtualMachineScaleSetExtension(SubResourceReadOnly): - """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. - :vartype id: str - :ivar name: The name of the extension. - :vartype name: str - :ivar force_update_tag: If a value is provided and is different from the previous value, the - extension handler will be forced to update even if the extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - """ - - _validation = { - "id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - force_update_tag: Optional[str] = None, - publisher: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - auto_upgrade_minor_version: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - """ - super().__init__(**kwargs) - self.name = name - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type = type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - - -class VirtualMachineScaleSetExtensionListResult(_serialization.Model): # pylint: disable=name-too-long - """The List VM scale set extension operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of VM scale set extensions. Required. - :vartype value: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetExtension] - :ivar next_link: The uri to fetch the next page of VM scale set extensions. Call ListNext() - with this to fetch the next page of VM scale set extensions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetExtension]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of VM scale set extensions. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetExtension] - :keyword next_link: The uri to fetch the next page of VM scale set extensions. Call ListNext() - with this to fetch the next page of VM scale set extensions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetExtensionProfile(_serialization.Model): - """Describes a virtual machine scale set extension profile. - - :ivar extensions: The virtual machine scale set child extension resources. - :vartype extensions: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetExtension] - """ - - _attribute_map = { - "extensions": {"key": "extensions", "type": "[VirtualMachineScaleSetExtension]"}, - } - - def __init__( - self, *, extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, **kwargs: Any - ) -> None: - """ - :keyword extensions: The virtual machine scale set child extension resources. - :paramtype extensions: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetExtension] - """ - super().__init__(**kwargs) - self.extensions = extensions - - -class VirtualMachineScaleSetIdentity(_serialization.Model): - """Identity for the virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of virtual machine scale set identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the virtual machine scale set. - :vartype tenant_id: str - :ivar type: The type of identity used for the virtual machine scale set. Currently, the only - supported type is 'SystemAssigned', which implicitly creates an identity. Default value is - "SystemAssigned". - :vartype type: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The type of identity used for the virtual machine scale set. Currently, the only - supported type is 'SystemAssigned', which implicitly creates an identity. Default value is - "SystemAssigned". - :paramtype type: str - """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.type = type - - -class VirtualMachineScaleSetInstanceView(_serialization.Model): - """The instance view of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar virtual_machine: The instance view status summary for the virtual machine scale set. - :vartype virtual_machine: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetInstanceViewStatusesSummary - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetVMExtensionsSummary] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2017_03_30.models.InstanceViewStatus] - """ - - _validation = { - "virtual_machine": {"readonly": True}, - "extensions": {"readonly": True}, - } - - _attribute_map = { - "virtual_machine": {"key": "virtualMachine", "type": "VirtualMachineScaleSetInstanceViewStatusesSummary"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineScaleSetVMExtensionsSummary]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__(self, *, statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs: Any) -> None: - """ - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2017_03_30.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.virtual_machine: Optional["_models.VirtualMachineScaleSetInstanceViewStatusesSummary"] = None - self.extensions: Optional[List["_models.VirtualMachineScaleSetVMExtensionsSummary"]] = None - self.statuses = statuses - - -class VirtualMachineScaleSetInstanceViewStatusesSummary(_serialization.Model): # pylint: disable=name-too-long - """Instance view statuses summary for virtual machines of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar statuses_summary: The extensions information. - :vartype statuses_summary: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineStatusCodeCount] - """ - - _validation = { - "statuses_summary": {"readonly": True}, - } - - _attribute_map = { - "statuses_summary": {"key": "statusesSummary", "type": "[VirtualMachineStatusCodeCount]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.statuses_summary: Optional[List["_models.VirtualMachineStatusCodeCount"]] = None - - -class VirtualMachineScaleSetIPConfiguration(SubResource): - """Describes a virtual machine scale set network profile's IP configuration. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The IP configuration name. Required. - :vartype name: str - :ivar subnet: Specifies the identifier of the subnet. - :vartype subnet: ~azure.mgmt.compute.v2017_03_30.models.ApiEntityReference - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - :ivar public_ip_address_configuration: The publicIPAddressConfiguration. - :vartype public_ip_address_configuration: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetPublicIPAddressConfiguration - :ivar private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2017_03_30.models.IPVersion - :ivar application_gateway_backend_address_pools: Specifies an array of references to backend - address pools of application gateways. A scale set can reference backend address pools of - multiple application gateways. Multiple scale sets cannot use the same application gateway. - :vartype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2017_03_30.models.SubResource] - :ivar load_balancer_backend_address_pools: Specifies an array of references to backend address - pools of load balancers. A scale set can reference backend address pools of one public and one - internal load balancer. Multiple scale sets cannot use the same load balancer. - :vartype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2017_03_30.models.SubResource] - :ivar load_balancer_inbound_nat_pools: Specifies an array of references to inbound Nat pools of - the load balancers. A scale set can reference inbound nat pools of one public and one internal - load balancer. Multiple scale sets cannot use the same load balancer. - :vartype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2017_03_30.models.SubResource] - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subnet": {"key": "properties.subnet", "type": "ApiEntityReference"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "public_ip_address_configuration": { - "key": "properties.publicIPAddressConfiguration", - "type": "VirtualMachineScaleSetPublicIPAddressConfiguration", - }, - "private_ip_address_version": {"key": "properties.privateIPAddressVersion", "type": "str"}, - "application_gateway_backend_address_pools": { - "key": "properties.applicationGatewayBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_backend_address_pools": { - "key": "properties.loadBalancerBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_inbound_nat_pools": {"key": "properties.loadBalancerInboundNatPools", "type": "[SubResource]"}, - } - - def __init__( - self, - *, - name: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - subnet: Optional["_models.ApiEntityReference"] = None, - primary: Optional[bool] = None, - public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The IP configuration name. Required. - :paramtype name: str - :keyword subnet: Specifies the identifier of the subnet. - :paramtype subnet: ~azure.mgmt.compute.v2017_03_30.models.ApiEntityReference - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - :keyword public_ip_address_configuration: The publicIPAddressConfiguration. - :paramtype public_ip_address_configuration: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetPublicIPAddressConfiguration - :keyword private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2017_03_30.models.IPVersion - :keyword application_gateway_backend_address_pools: Specifies an array of references to backend - address pools of application gateways. A scale set can reference backend address pools of - multiple application gateways. Multiple scale sets cannot use the same application gateway. - :paramtype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2017_03_30.models.SubResource] - :keyword load_balancer_backend_address_pools: Specifies an array of references to backend - address pools of load balancers. A scale set can reference backend address pools of one public - and one internal load balancer. Multiple scale sets cannot use the same load balancer. - :paramtype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2017_03_30.models.SubResource] - :keyword load_balancer_inbound_nat_pools: Specifies an array of references to inbound Nat pools - of the load balancers. A scale set can reference inbound nat pools of one public and one - internal load balancer. Multiple scale sets cannot use the same load balancer. - :paramtype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2017_03_30.models.SubResource] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.subnet = subnet - self.primary = primary - self.public_ip_address_configuration = public_ip_address_configuration - self.private_ip_address_version = private_ip_address_version - self.application_gateway_backend_address_pools = application_gateway_backend_address_pools - self.load_balancer_backend_address_pools = load_balancer_backend_address_pools - self.load_balancer_inbound_nat_pools = load_balancer_inbound_nat_pools - - -class VirtualMachineScaleSetListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets. Required. - :vartype value: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSet] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call ListNext() - with this to fetch the next page of VMSS. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSet] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call - ListNext() with this to fetch the next page of VMSS. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListSkusResult(_serialization.Model): - """The Virtual Machine Scale Set List Skus operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of skus available for the virtual machine scale set. Required. - :vartype value: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetSku] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Set Skus. Call - ListNext() with this to fetch the next page of VMSS Skus. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetSku]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of skus available for the virtual machine scale set. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetSku] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Set Skus. Call - ListNext() with this to fetch the next page of VMSS Skus. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListWithLinkResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets. Required. - :vartype value: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSet] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call ListNext() - with this to fetch the next page of Virtual Machine Scale Sets. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSet] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call - ListNext() with this to fetch the next page of Virtual Machine Scale Sets. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetManagedDiskParameters(_serialization.Model): # pylint: disable=name-too-long - """Describes the parameters of a ScaleSet managed disk. - - :ivar storage_account_type: Specifies the storage account type for the managed disk. Managed OS - disk storage account type can only be set when you create the scale set. Possible values are: - Standard_LRS or Premium_LRS. Known values are: "Standard_LRS" and "Premium_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes - """ - - _attribute_map = { - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - } - - def __init__( - self, *, storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs: Any - ) -> None: - """ - :keyword storage_account_type: Specifies the storage account type for the managed disk. Managed - OS disk storage account type can only be set when you create the scale set. Possible values - are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS" and "Premium_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes - """ - super().__init__(**kwargs) - self.storage_account_type = storage_account_type - - -class VirtualMachineScaleSetNetworkConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's network configurations. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The network configuration name. Required. - :vartype name: str - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :vartype enable_accelerated_networking: bool - :ivar network_security_group: The network security group. - :vartype network_security_group: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :ivar dns_settings: The dns settings to be applied on the network interfaces. - :vartype dns_settings: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :ivar ip_configurations: Specifies the IP configurations of the network interface. - :vartype ip_configurations: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetIPConfiguration] - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "enable_accelerated_networking": {"key": "properties.enableAcceleratedNetworking", "type": "bool"}, - "network_security_group": {"key": "properties.networkSecurityGroup", "type": "SubResource"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetNetworkConfigurationDnsSettings", - }, - "ip_configurations": {"key": "properties.ipConfigurations", "type": "[VirtualMachineScaleSetIPConfiguration]"}, - } - - def __init__( - self, - *, - name: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - primary: Optional[bool] = None, - enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["_models.SubResource"] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The network configuration name. Required. - :paramtype name: str - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :paramtype enable_accelerated_networking: bool - :keyword network_security_group: The network security group. - :paramtype network_security_group: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :keyword dns_settings: The dns settings to be applied on the network interfaces. - :paramtype dns_settings: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :keyword ip_configurations: Specifies the IP configurations of the network interface. - :paramtype ip_configurations: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetIPConfiguration] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.primary = primary - self.enable_accelerated_networking = enable_accelerated_networking - self.network_security_group = network_security_group - self.dns_settings = dns_settings - self.ip_configurations = ip_configurations - - -class VirtualMachineScaleSetNetworkConfigurationDnsSettings(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines scale sets network configuration's DNS settings. - - :ivar dns_servers: List of DNS servers IP addresses. - :vartype dns_servers: list[str] - """ - - _attribute_map = { - "dns_servers": {"key": "dnsServers", "type": "[str]"}, - } - - def __init__(self, *, dns_servers: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword dns_servers: List of DNS servers IP addresses. - :paramtype dns_servers: list[str] - """ - super().__init__(**kwargs) - self.dns_servers = dns_servers - - -class VirtualMachineScaleSetNetworkProfile(_serialization.Model): - """Describes a virtual machine scale set network profile. - - :ivar health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :vartype health_probe: ~azure.mgmt.compute.v2017_03_30.models.ApiEntityReference - :ivar network_interface_configurations: The list of network configurations. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetNetworkConfiguration] - """ - - _attribute_map = { - "health_probe": {"key": "healthProbe", "type": "ApiEntityReference"}, - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineScaleSetNetworkConfiguration]", - }, - } - - def __init__( - self, - *, - health_probe: Optional["_models.ApiEntityReference"] = None, - network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :paramtype health_probe: ~azure.mgmt.compute.v2017_03_30.models.ApiEntityReference - :keyword network_interface_configurations: The list of network configurations. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetNetworkConfiguration] - """ - super().__init__(**kwargs) - self.health_probe = health_probe - self.network_interface_configurations = network_interface_configurations - - -class VirtualMachineScaleSetOSDisk(_serialization.Model): - """Describes a virtual machine scale set operating system disk. - - All required parameters must be populated in order to send to server. - - :ivar name: The disk name. - :vartype name: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes - :ivar create_option: Specifies how the virtual machines in the scale set should be created.\\ - :code:`
    `\\ :code:`
    ` The only allowed value is: **FromImage** \\u2013 This value is used - when you are using an image to create the virtual machine. If you are using a platform image, - you also use the imageReference element described above. If you are using a marketplace image, - you also use the plan element previously described. Required. Known values are: "FromImage", - "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOptionTypes - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :ivar image: Specifies information about the unmanaged user image to base the scale set on. - :vartype image: ~azure.mgmt.compute.v2017_03_30.models.VirtualHardDisk - :ivar vhd_containers: Specifies the container urls that are used to store operating system - disks for the scale set. - :vartype vhd_containers: list[str] - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetManagedDiskParameters - """ - - _validation = { - "create_option": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "create_option": {"key": "createOption", "type": "str"}, - "os_type": {"key": "osType", "type": "str"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "vhd_containers": {"key": "vhdContainers", "type": "[str]"}, - "managed_disk": {"key": "managedDisk", "type": "VirtualMachineScaleSetManagedDiskParameters"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - image: Optional["_models.VirtualHardDisk"] = None, - vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes - :keyword create_option: Specifies how the virtual machines in the scale set should be - created.\\ :code:`
    `\\ :code:`
    ` The only allowed value is: **FromImage** \\u2013 This - value is used when you are using an image to create the virtual machine. If you are using a - platform image, you also use the imageReference element described above. If you are using a - marketplace image, you also use the plan element previously described. Required. Known values - are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOptionTypes - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :keyword image: Specifies information about the unmanaged user image to base the scale set on. - :paramtype image: ~azure.mgmt.compute.v2017_03_30.models.VirtualHardDisk - :keyword vhd_containers: Specifies the container urls that are used to store operating system - disks for the scale set. - :paramtype vhd_containers: list[str] - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetManagedDiskParameters - """ - super().__init__(**kwargs) - self.name = name - self.caching = caching - self.create_option = create_option - self.os_type = os_type - self.image = image - self.vhd_containers = vhd_containers - self.managed_disk = managed_disk - - -class VirtualMachineScaleSetOSProfile(_serialization.Model): - """Describes a virtual machine scale set OS profile. - - :ivar computer_name_prefix: Specifies the computer name prefix for all of the virtual machines - in the scale set. Computer name prefixes must be 1 to 15 characters long. - :vartype computer_name_prefix: str - :ivar admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :vartype admin_username: str - :ivar admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :vartype admin_password: str - :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` For using cloud-init for - your VM, see `Using cloud-init to customize a Linux VM during creation - `_. - :vartype custom_data: str - :ivar windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :vartype windows_configuration: ~azure.mgmt.compute.v2017_03_30.models.WindowsConfiguration - :ivar linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :vartype linux_configuration: ~azure.mgmt.compute.v2017_03_30.models.LinuxConfiguration - :ivar secrets: Specifies set of certificates that should be installed onto the virtual machines - in the scale set. - :vartype secrets: list[~azure.mgmt.compute.v2017_03_30.models.VaultSecretGroup] - """ - - _attribute_map = { - "computer_name_prefix": {"key": "computerNamePrefix", "type": "str"}, - "admin_username": {"key": "adminUsername", "type": "str"}, - "admin_password": {"key": "adminPassword", "type": "str"}, - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - } - - def __init__( - self, - *, - computer_name_prefix: Optional[str] = None, - admin_username: Optional[str] = None, - admin_password: Optional[str] = None, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword computer_name_prefix: Specifies the computer name prefix for all of the virtual - machines in the scale set. Computer name prefixes must be 1 to 15 characters long. - :paramtype computer_name_prefix: str - :keyword admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :paramtype admin_username: str - :keyword admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :paramtype admin_password: str - :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` For using cloud-init for - your VM, see `Using cloud-init to customize a Linux VM during creation - `_. - :paramtype custom_data: str - :keyword windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :paramtype windows_configuration: ~azure.mgmt.compute.v2017_03_30.models.WindowsConfiguration - :keyword linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :paramtype linux_configuration: ~azure.mgmt.compute.v2017_03_30.models.LinuxConfiguration - :keyword secrets: Specifies set of certificates that should be installed onto the virtual - machines in the scale set. - :paramtype secrets: list[~azure.mgmt.compute.v2017_03_30.models.VaultSecretGroup] - """ - super().__init__(**kwargs) - self.computer_name_prefix = computer_name_prefix - self.admin_username = admin_username - self.admin_password = admin_password - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - - -class VirtualMachineScaleSetPublicIPAddressConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines scale set IP Configuration's PublicIPAddress configuration. - - All required parameters must be populated in order to send to server. - - :ivar name: The publicIP address configuration name. Required. - :vartype name: str - :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. - :vartype idle_timeout_in_minutes: int - :ivar dns_settings: The dns settings to be applied on the publicIP addresses . - :vartype dns_settings: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "idle_timeout_in_minutes": {"key": "properties.idleTimeoutInMinutes", "type": "int"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings", - }, - } - - def __init__( - self, - *, - name: str, - idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The publicIP address configuration name. Required. - :paramtype name: str - :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. - :paramtype idle_timeout_in_minutes: int - :keyword dns_settings: The dns settings to be applied on the publicIP addresses . - :paramtype dns_settings: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - """ - super().__init__(**kwargs) - self.name = name - self.idle_timeout_in_minutes = idle_timeout_in_minutes - self.dns_settings = dns_settings - - -class VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings( - _serialization.Model -): # pylint: disable=name-too-long - """Describes a virtual machines scale sets network configuration's DNS settings. - - All required parameters must be populated in order to send to server. - - :ivar domain_name_label: The Domain name label.The concatenation of the domain name label and - vm index will be the domain name labels of the PublicIPAddress resources that will be created. - Required. - :vartype domain_name_label: str - """ - - _validation = { - "domain_name_label": {"required": True}, - } - - _attribute_map = { - "domain_name_label": {"key": "domainNameLabel", "type": "str"}, - } - - def __init__(self, *, domain_name_label: str, **kwargs: Any) -> None: - """ - :keyword domain_name_label: The Domain name label.The concatenation of the domain name label - and vm index will be the domain name labels of the PublicIPAddress resources that will be - created. Required. - :paramtype domain_name_label: str - """ - super().__init__(**kwargs) - self.domain_name_label = domain_name_label - - -class VirtualMachineScaleSetSku(_serialization.Model): - """Describes an available virtual machine scale set sku. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of resource the sku applies to. - :vartype resource_type: str - :ivar sku: The Sku. - :vartype sku: ~azure.mgmt.compute.v2017_03_30.models.Sku - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetSkuCapacity - """ - - _validation = { - "resource_type": {"readonly": True}, - "sku": {"readonly": True}, - "capacity": {"readonly": True}, - } - - _attribute_map = { - "resource_type": {"key": "resourceType", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "capacity": {"key": "capacity", "type": "VirtualMachineScaleSetSkuCapacity"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_type: Optional[str] = None - self.sku: Optional["_models.Sku"] = None - self.capacity: Optional["_models.VirtualMachineScaleSetSkuCapacity"] = None - - -class VirtualMachineScaleSetSkuCapacity(_serialization.Model): - """Describes scaling information of a sku. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar minimum: The minimum capacity. - :vartype minimum: int - :ivar maximum: The maximum capacity that can be set. - :vartype maximum: int - :ivar default_capacity: The default capacity. - :vartype default_capacity: int - :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic" and - "None". - :vartype scale_type: str or - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetSkuScaleType - """ - - _validation = { - "minimum": {"readonly": True}, - "maximum": {"readonly": True}, - "default_capacity": {"readonly": True}, - "scale_type": {"readonly": True}, - } - - _attribute_map = { - "minimum": {"key": "minimum", "type": "int"}, - "maximum": {"key": "maximum", "type": "int"}, - "default_capacity": {"key": "defaultCapacity", "type": "int"}, - "scale_type": {"key": "scaleType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.minimum: Optional[int] = None - self.maximum: Optional[int] = None - self.default_capacity: Optional[int] = None - self.scale_type: Optional[Union[str, "_models.VirtualMachineScaleSetSkuScaleType"]] = None - - -class VirtualMachineScaleSetStorageProfile(_serialization.Model): - """Describes a virtual machine scale set storage profile. - - :ivar image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :vartype image_reference: ~azure.mgmt.compute.v2017_03_30.models.ImageReference - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetOSDisk - :ivar data_disks: Specifies the parameters that are used to add data disks to the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :vartype data_disks: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetDataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "VirtualMachineScaleSetOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[VirtualMachineScaleSetDataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :paramtype image_reference: ~azure.mgmt.compute.v2017_03_30.models.ImageReference - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetOSDisk - :keyword data_disks: Specifies the parameters that are used to add data disks to the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :paramtype data_disks: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetDataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class VirtualMachineScaleSetUpdate(UpdateResource): - """Describes a Virtual Machine Scale Set. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The virtual machine scale set sku. - :vartype sku: ~azure.mgmt.compute.v2017_03_30.models.Sku - :ivar plan: The purchase plan when deploying a virtual machine scale set from VM Marketplace - images. - :vartype plan: ~azure.mgmt.compute.v2017_03_30.models.Plan - :ivar identity: The identity of the virtual machine scale set, if configured. - :vartype identity: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetIdentity - :ivar upgrade_policy: The upgrade policy. - :vartype upgrade_policy: ~azure.mgmt.compute.v2017_03_30.models.UpgradePolicy - :ivar virtual_machine_profile: The virtual machine profile. - :vartype virtual_machine_profile: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetUpdateVMProfile - :ivar overprovision: Specifies whether the Virtual Machine Scale Set should be overprovisioned. - :vartype overprovision: bool - :ivar single_placement_group: When true this limits the scale set to a single placement group, - of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be modified to - false. However, if singlePlacementGroup is false, it may not be modified to true. - :vartype single_placement_group: bool - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "identity": {"key": "identity", "type": "VirtualMachineScaleSetIdentity"}, - "upgrade_policy": {"key": "properties.upgradePolicy", "type": "UpgradePolicy"}, - "virtual_machine_profile": { - "key": "properties.virtualMachineProfile", - "type": "VirtualMachineScaleSetUpdateVMProfile", - }, - "overprovision": {"key": "properties.overprovision", "type": "bool"}, - "single_placement_group": {"key": "properties.singlePlacementGroup", "type": "bool"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["_models.UpgradePolicy"] = None, - virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, - overprovision: Optional[bool] = None, - single_placement_group: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The virtual machine scale set sku. - :paramtype sku: ~azure.mgmt.compute.v2017_03_30.models.Sku - :keyword plan: The purchase plan when deploying a virtual machine scale set from VM Marketplace - images. - :paramtype plan: ~azure.mgmt.compute.v2017_03_30.models.Plan - :keyword identity: The identity of the virtual machine scale set, if configured. - :paramtype identity: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetIdentity - :keyword upgrade_policy: The upgrade policy. - :paramtype upgrade_policy: ~azure.mgmt.compute.v2017_03_30.models.UpgradePolicy - :keyword virtual_machine_profile: The virtual machine profile. - :paramtype virtual_machine_profile: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetUpdateVMProfile - :keyword overprovision: Specifies whether the Virtual Machine Scale Set should be - overprovisioned. - :paramtype overprovision: bool - :keyword single_placement_group: When true this limits the scale set to a single placement - group, of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be - modified to false. However, if singlePlacementGroup is false, it may not be modified to true. - :paramtype single_placement_group: bool - """ - super().__init__(tags=tags, **kwargs) - self.sku = sku - self.plan = plan - self.identity = identity - self.upgrade_policy = upgrade_policy - self.virtual_machine_profile = virtual_machine_profile - self.overprovision = overprovision - self.single_placement_group = single_placement_group - - -class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's IP configuration. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The IP configuration name. - :vartype name: str - :ivar subnet: The subnet. - :vartype subnet: ~azure.mgmt.compute.v2017_03_30.models.ApiEntityReference - :ivar primary: Specifies the primary IP Configuration in case the network interface has more - than one IP Configuration. - :vartype primary: bool - :ivar public_ip_address_configuration: The publicIPAddressConfiguration. - :vartype public_ip_address_configuration: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration - :ivar private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2017_03_30.models.IPVersion - :ivar application_gateway_backend_address_pools: The application gateway backend address pools. - :vartype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2017_03_30.models.SubResource] - :ivar load_balancer_backend_address_pools: The load balancer backend address pools. - :vartype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2017_03_30.models.SubResource] - :ivar load_balancer_inbound_nat_pools: The load balancer inbound nat pools. - :vartype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2017_03_30.models.SubResource] - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subnet": {"key": "properties.subnet", "type": "ApiEntityReference"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "public_ip_address_configuration": { - "key": "properties.publicIPAddressConfiguration", - "type": "VirtualMachineScaleSetUpdatePublicIPAddressConfiguration", - }, - "private_ip_address_version": {"key": "properties.privateIPAddressVersion", "type": "str"}, - "application_gateway_backend_address_pools": { - "key": "properties.applicationGatewayBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_backend_address_pools": { - "key": "properties.loadBalancerBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_inbound_nat_pools": {"key": "properties.loadBalancerInboundNatPools", "type": "[SubResource]"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - subnet: Optional["_models.ApiEntityReference"] = None, - primary: Optional[bool] = None, - public_ip_address_configuration: Optional[ - "_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration" - ] = None, - private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The IP configuration name. - :paramtype name: str - :keyword subnet: The subnet. - :paramtype subnet: ~azure.mgmt.compute.v2017_03_30.models.ApiEntityReference - :keyword primary: Specifies the primary IP Configuration in case the network interface has more - than one IP Configuration. - :paramtype primary: bool - :keyword public_ip_address_configuration: The publicIPAddressConfiguration. - :paramtype public_ip_address_configuration: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration - :keyword private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2017_03_30.models.IPVersion - :keyword application_gateway_backend_address_pools: The application gateway backend address - pools. - :paramtype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2017_03_30.models.SubResource] - :keyword load_balancer_backend_address_pools: The load balancer backend address pools. - :paramtype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2017_03_30.models.SubResource] - :keyword load_balancer_inbound_nat_pools: The load balancer inbound nat pools. - :paramtype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2017_03_30.models.SubResource] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.subnet = subnet - self.primary = primary - self.public_ip_address_configuration = public_ip_address_configuration - self.private_ip_address_version = private_ip_address_version - self.application_gateway_backend_address_pools = application_gateway_backend_address_pools - self.load_balancer_backend_address_pools = load_balancer_backend_address_pools - self.load_balancer_inbound_nat_pools = load_balancer_inbound_nat_pools - - -class VirtualMachineScaleSetUpdateNetworkConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's network configurations. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The network configuration name. - :vartype name: str - :ivar primary: Whether this is a primary NIC on a virtual machine. - :vartype primary: bool - :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :vartype enable_accelerated_networking: bool - :ivar network_security_group: The network security group. - :vartype network_security_group: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :ivar dns_settings: The dns settings to be applied on the network interfaces. - :vartype dns_settings: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :ivar ip_configurations: The virtual machine scale set IP Configuration. - :vartype ip_configurations: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetUpdateIPConfiguration] - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "enable_accelerated_networking": {"key": "properties.enableAcceleratedNetworking", "type": "bool"}, - "network_security_group": {"key": "properties.networkSecurityGroup", "type": "SubResource"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetNetworkConfigurationDnsSettings", - }, - "ip_configurations": { - "key": "properties.ipConfigurations", - "type": "[VirtualMachineScaleSetUpdateIPConfiguration]", - }, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - primary: Optional[bool] = None, - enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["_models.SubResource"] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The network configuration name. - :paramtype name: str - :keyword primary: Whether this is a primary NIC on a virtual machine. - :paramtype primary: bool - :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :paramtype enable_accelerated_networking: bool - :keyword network_security_group: The network security group. - :paramtype network_security_group: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :keyword dns_settings: The dns settings to be applied on the network interfaces. - :paramtype dns_settings: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :keyword ip_configurations: The virtual machine scale set IP Configuration. - :paramtype ip_configurations: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetUpdateIPConfiguration] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.primary = primary - self.enable_accelerated_networking = enable_accelerated_networking - self.network_security_group = network_security_group - self.dns_settings = dns_settings - self.ip_configurations = ip_configurations - - -class VirtualMachineScaleSetUpdateNetworkProfile(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile. - - :ivar network_interface_configurations: The list of network configurations. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetUpdateNetworkConfiguration] - """ - - _attribute_map = { - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineScaleSetUpdateNetworkConfiguration]", - }, - } - - def __init__( - self, - *, - network_interface_configurations: Optional[ - List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword network_interface_configurations: The list of network configurations. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetUpdateNetworkConfiguration] - """ - super().__init__(**kwargs) - self.network_interface_configurations = network_interface_configurations - - -class VirtualMachineScaleSetUpdateOSDisk(_serialization.Model): - """Describes virtual machine scale set operating system disk Update Object. This should be used - for Updating VMSS OS Disk. - - :ivar caching: The caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes - :ivar image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before - using it to attach to the Virtual Machine. If SourceImage is provided, the destination - VirtualHardDisk should not exist. - :vartype image: ~azure.mgmt.compute.v2017_03_30.models.VirtualHardDisk - :ivar vhd_containers: The list of virtual hard disk container uris. - :vartype vhd_containers: list[str] - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetManagedDiskParameters - """ - - _attribute_map = { - "caching": {"key": "caching", "type": "str"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "vhd_containers": {"key": "vhdContainers", "type": "[str]"}, - "managed_disk": {"key": "managedDisk", "type": "VirtualMachineScaleSetManagedDiskParameters"}, - } - - def __init__( - self, - *, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - image: Optional["_models.VirtualHardDisk"] = None, - vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword caching: The caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes - :keyword image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied - before using it to attach to the Virtual Machine. If SourceImage is provided, the destination - VirtualHardDisk should not exist. - :paramtype image: ~azure.mgmt.compute.v2017_03_30.models.VirtualHardDisk - :keyword vhd_containers: The list of virtual hard disk container uris. - :paramtype vhd_containers: list[str] - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetManagedDiskParameters - """ - super().__init__(**kwargs) - self.caching = caching - self.image = image - self.vhd_containers = vhd_containers - self.managed_disk = managed_disk - - -class VirtualMachineScaleSetUpdateOSProfile(_serialization.Model): - """Describes a virtual machine scale set OS profile. - - :ivar custom_data: A base-64 encoded string of custom data. - :vartype custom_data: str - :ivar windows_configuration: The Windows Configuration of the OS profile. - :vartype windows_configuration: ~azure.mgmt.compute.v2017_03_30.models.WindowsConfiguration - :ivar linux_configuration: The Linux Configuration of the OS profile. - :vartype linux_configuration: ~azure.mgmt.compute.v2017_03_30.models.LinuxConfiguration - :ivar secrets: The List of certificates for addition to the VM. - :vartype secrets: list[~azure.mgmt.compute.v2017_03_30.models.VaultSecretGroup] - """ - - _attribute_map = { - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - } - - def __init__( - self, - *, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword custom_data: A base-64 encoded string of custom data. - :paramtype custom_data: str - :keyword windows_configuration: The Windows Configuration of the OS profile. - :paramtype windows_configuration: ~azure.mgmt.compute.v2017_03_30.models.WindowsConfiguration - :keyword linux_configuration: The Linux Configuration of the OS profile. - :paramtype linux_configuration: ~azure.mgmt.compute.v2017_03_30.models.LinuxConfiguration - :keyword secrets: The List of certificates for addition to the VM. - :paramtype secrets: list[~azure.mgmt.compute.v2017_03_30.models.VaultSecretGroup] - """ - super().__init__(**kwargs) - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - - -class VirtualMachineScaleSetUpdatePublicIPAddressConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines scale set IP Configuration's PublicIPAddress configuration. - - :ivar name: The publicIP address configuration name. - :vartype name: str - :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. - :vartype idle_timeout_in_minutes: int - :ivar dns_settings: The dns settings to be applied on the publicIP addresses . - :vartype dns_settings: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "idle_timeout_in_minutes": {"key": "properties.idleTimeoutInMinutes", "type": "int"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings", - }, - } - - def __init__( - self, - *, - name: Optional[str] = None, - idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The publicIP address configuration name. - :paramtype name: str - :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. - :paramtype idle_timeout_in_minutes: int - :keyword dns_settings: The dns settings to be applied on the publicIP addresses . - :paramtype dns_settings: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - """ - super().__init__(**kwargs) - self.name = name - self.idle_timeout_in_minutes = idle_timeout_in_minutes - self.dns_settings = dns_settings - - -class VirtualMachineScaleSetUpdateStorageProfile(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machine scale set storage profile. - - :ivar image_reference: The image reference. - :vartype image_reference: ~azure.mgmt.compute.v2017_03_30.models.ImageReference - :ivar os_disk: The OS disk. - :vartype os_disk: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetUpdateOSDisk - :ivar data_disks: The data disks. - :vartype data_disks: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetDataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "VirtualMachineScaleSetUpdateOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[VirtualMachineScaleSetDataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: The image reference. - :paramtype image_reference: ~azure.mgmt.compute.v2017_03_30.models.ImageReference - :keyword os_disk: The OS disk. - :paramtype os_disk: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetUpdateOSDisk - :keyword data_disks: The data disks. - :paramtype data_disks: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetDataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class VirtualMachineScaleSetUpdateVMProfile(_serialization.Model): - """Describes a virtual machine scale set virtual machine profile. - - :ivar os_profile: The virtual machine scale set OS profile. - :vartype os_profile: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetUpdateOSProfile - :ivar storage_profile: The virtual machine scale set storage profile. - :vartype storage_profile: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetUpdateStorageProfile - :ivar network_profile: The virtual machine scale set network profile. - :vartype network_profile: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetUpdateNetworkProfile - :ivar diagnostics_profile: The virtual machine scale set diagnostics profile. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2017_03_30.models.DiagnosticsProfile - :ivar extension_profile: The virtual machine scale set extension profile. - :vartype extension_profile: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetExtensionProfile - :ivar license_type: The license type, which is for bring your own license scenario. - :vartype license_type: str - """ - - _attribute_map = { - "os_profile": {"key": "osProfile", "type": "VirtualMachineScaleSetUpdateOSProfile"}, - "storage_profile": {"key": "storageProfile", "type": "VirtualMachineScaleSetUpdateStorageProfile"}, - "network_profile": {"key": "networkProfile", "type": "VirtualMachineScaleSetUpdateNetworkProfile"}, - "diagnostics_profile": {"key": "diagnosticsProfile", "type": "DiagnosticsProfile"}, - "extension_profile": {"key": "extensionProfile", "type": "VirtualMachineScaleSetExtensionProfile"}, - "license_type": {"key": "licenseType", "type": "str"}, - } - - def __init__( - self, - *, - os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, - license_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_profile: The virtual machine scale set OS profile. - :paramtype os_profile: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetUpdateOSProfile - :keyword storage_profile: The virtual machine scale set storage profile. - :paramtype storage_profile: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetUpdateStorageProfile - :keyword network_profile: The virtual machine scale set network profile. - :paramtype network_profile: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetUpdateNetworkProfile - :keyword diagnostics_profile: The virtual machine scale set diagnostics profile. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2017_03_30.models.DiagnosticsProfile - :keyword extension_profile: The virtual machine scale set extension profile. - :paramtype extension_profile: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetExtensionProfile - :keyword license_type: The license type, which is for bring your own license scenario. - :paramtype license_type: str - """ - super().__init__(**kwargs) - self.os_profile = os_profile - self.storage_profile = storage_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.extension_profile = extension_profile - self.license_type = license_type - - -class VirtualMachineScaleSetVM(Resource): - """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. - :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] - :ivar instance_id: The virtual machine instance ID. - :vartype instance_id: str - :ivar sku: The virtual machine SKU. - :vartype sku: ~azure.mgmt.compute.v2017_03_30.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2017_03_30.models.Plan - :ivar resources: The virtual machine child extension resources. - :vartype resources: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtension] - :ivar latest_model_applied: Specifies whether the latest model has been applied to the virtual - machine. - :vartype latest_model_applied: bool - :ivar vm_id: Azure VM unique ID. - :vartype vm_id: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetVMInstanceView - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2017_03_30.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2017_03_30.models.StorageProfile - :ivar os_profile: Specifies the operating system settings for the virtual machine. - :vartype os_profile: ~azure.mgmt.compute.v2017_03_30.models.OSProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2017_03_30.models.NetworkProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2017_03_30.models.DiagnosticsProfile - :ivar availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :vartype availability_set: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "instance_id": {"readonly": True}, - "sku": {"readonly": True}, - "resources": {"readonly": True}, - "latest_model_applied": {"readonly": True}, - "vm_id": {"readonly": True}, - "instance_view": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "instance_id": {"key": "instanceId", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "resources": {"key": "resources", "type": "[VirtualMachineExtension]"}, - "latest_model_applied": {"key": "properties.latestModelApplied", "type": "bool"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineScaleSetVMInstanceView"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - os_profile: Optional["_models.OSProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2017_03_30.models.Plan - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2017_03_30.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2017_03_30.models.StorageProfile - :keyword os_profile: Specifies the operating system settings for the virtual machine. - :paramtype os_profile: ~azure.mgmt.compute.v2017_03_30.models.OSProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2017_03_30.models.NetworkProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2017_03_30.models.DiagnosticsProfile - :keyword availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :paramtype availability_set: ~azure.mgmt.compute.v2017_03_30.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.instance_id: Optional[str] = None - self.sku: Optional["_models.Sku"] = None - self.plan = plan - self.resources: Optional[List["_models.VirtualMachineExtension"]] = None - self.latest_model_applied: Optional[bool] = None - self.vm_id: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineScaleSetVMInstanceView"] = None - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.os_profile = os_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.provisioning_state: Optional[str] = None - self.license_type = license_type - - -class VirtualMachineScaleSetVMExtensionsSummary(_serialization.Model): # pylint: disable=name-too-long - """Extensions summary for virtual machines of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The extension name. - :vartype name: str - :ivar statuses_summary: The extensions information. - :vartype statuses_summary: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineStatusCodeCount] - """ - - _validation = { - "name": {"readonly": True}, - "statuses_summary": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "statuses_summary": {"key": "statusesSummary", "type": "[VirtualMachineStatusCodeCount]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.statuses_summary: Optional[List["_models.VirtualMachineStatusCodeCount"]] = None - - -class VirtualMachineScaleSetVMInstanceIDs(_serialization.Model): - """Specifies a list of virtual machine instance IDs from the VM scale set. - - :ivar instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :vartype instance_ids: list[str] - """ - - _attribute_map = { - "instance_ids": {"key": "instanceIds", "type": "[str]"}, - } - - def __init__(self, *, instance_ids: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :paramtype instance_ids: list[str] - """ - super().__init__(**kwargs) - self.instance_ids = instance_ids - - -class VirtualMachineScaleSetVMInstanceRequiredIDs(_serialization.Model): # pylint: disable=name-too-long - """Specifies a list of virtual machine instance IDs from the VM scale set. - - All required parameters must be populated in order to send to server. - - :ivar instance_ids: The virtual machine scale set instance ids. Required. - :vartype instance_ids: list[str] - """ - - _validation = { - "instance_ids": {"required": True}, - } - - _attribute_map = { - "instance_ids": {"key": "instanceIds", "type": "[str]"}, - } - - def __init__(self, *, instance_ids: List[str], **kwargs: Any) -> None: - """ - :keyword instance_ids: The virtual machine scale set instance ids. Required. - :paramtype instance_ids: list[str] - """ - super().__init__(**kwargs) - self.instance_ids = instance_ids - - -class VirtualMachineScaleSetVMInstanceView(_serialization.Model): - """The instance view of a virtual machine scale set VM. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar platform_update_domain: The Update Domain count. - :vartype platform_update_domain: int - :ivar platform_fault_domain: The Fault Domain count. - :vartype platform_fault_domain: int - :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. - :vartype rdp_thumb_print: str - :ivar vm_agent: The VM Agent running on the virtual machine. - :vartype vm_agent: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineAgentInstanceView - :ivar disks: The disks information. - :vartype disks: list[~azure.mgmt.compute.v2017_03_30.models.DiskInstanceView] - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtensionInstanceView] - :ivar vm_health: The health status for the VM. - :vartype vm_health: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineHealthStatus - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2017_03_30.models.BootDiagnosticsInstanceView - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2017_03_30.models.InstanceViewStatus] - :ivar placement_group_id: The placement group in which the VM is running. If the VM is - deallocated it will not have a placementGroupId. - :vartype placement_group_id: str - """ - - _validation = { - "vm_health": {"readonly": True}, - } - - _attribute_map = { - "platform_update_domain": {"key": "platformUpdateDomain", "type": "int"}, - "platform_fault_domain": {"key": "platformFaultDomain", "type": "int"}, - "rdp_thumb_print": {"key": "rdpThumbPrint", "type": "str"}, - "vm_agent": {"key": "vmAgent", "type": "VirtualMachineAgentInstanceView"}, - "disks": {"key": "disks", "type": "[DiskInstanceView]"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineExtensionInstanceView]"}, - "vm_health": {"key": "vmHealth", "type": "VirtualMachineHealthStatus"}, - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnosticsInstanceView"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - "placement_group_id": {"key": "placementGroupId", "type": "str"}, - } - - def __init__( - self, - *, - platform_update_domain: Optional[int] = None, - platform_fault_domain: Optional[int] = None, - rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, - disks: Optional[List["_models.DiskInstanceView"]] = None, - extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - placement_group_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword platform_update_domain: The Update Domain count. - :paramtype platform_update_domain: int - :keyword platform_fault_domain: The Fault Domain count. - :paramtype platform_fault_domain: int - :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. - :paramtype rdp_thumb_print: str - :keyword vm_agent: The VM Agent running on the virtual machine. - :paramtype vm_agent: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineAgentInstanceView - :keyword disks: The disks information. - :paramtype disks: list[~azure.mgmt.compute.v2017_03_30.models.DiskInstanceView] - :keyword extensions: The extensions information. - :paramtype extensions: - list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtensionInstanceView] - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2017_03_30.models.BootDiagnosticsInstanceView - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2017_03_30.models.InstanceViewStatus] - :keyword placement_group_id: The placement group in which the VM is running. If the VM is - deallocated it will not have a placementGroupId. - :paramtype placement_group_id: str - """ - super().__init__(**kwargs) - self.platform_update_domain = platform_update_domain - self.platform_fault_domain = platform_fault_domain - self.rdp_thumb_print = rdp_thumb_print - self.vm_agent = vm_agent - self.disks = disks - self.extensions = extensions - self.vm_health: Optional["_models.VirtualMachineHealthStatus"] = None - self.boot_diagnostics = boot_diagnostics - self.statuses = statuses - self.placement_group_id = placement_group_id - - -class VirtualMachineScaleSetVMListResult(_serialization.Model): - """The List Virtual Machine Scale Set VMs operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets VMs. Required. - :vartype value: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetVM] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Set VMs. Call - ListNext() with this to fetch the next page of VMSS VMs. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetVM]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets VMs. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetVM] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Set VMs. Call - ListNext() with this to fetch the next page of VMSS VMs. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetVMProfile(_serialization.Model): - """Describes a virtual machine scale set virtual machine profile. - - :ivar os_profile: Specifies the operating system settings for the virtual machines in the scale - set. - :vartype os_profile: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetOSProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetStorageProfile - :ivar network_profile: Specifies properties of the network interfaces of the virtual machines - in the scale set. - :vartype network_profile: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetNetworkProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2017_03_30.models.DiagnosticsProfile - :ivar extension_profile: Specifies a collection of settings for extensions installed on virtual - machines in the scale set. - :vartype extension_profile: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetExtensionProfile - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - """ - - _attribute_map = { - "os_profile": {"key": "osProfile", "type": "VirtualMachineScaleSetOSProfile"}, - "storage_profile": {"key": "storageProfile", "type": "VirtualMachineScaleSetStorageProfile"}, - "network_profile": {"key": "networkProfile", "type": "VirtualMachineScaleSetNetworkProfile"}, - "diagnostics_profile": {"key": "diagnosticsProfile", "type": "DiagnosticsProfile"}, - "extension_profile": {"key": "extensionProfile", "type": "VirtualMachineScaleSetExtensionProfile"}, - "license_type": {"key": "licenseType", "type": "str"}, - } - - def __init__( - self, - *, - os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, - license_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_profile: Specifies the operating system settings for the virtual machines in the - scale set. - :paramtype os_profile: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetOSProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetStorageProfile - :keyword network_profile: Specifies properties of the network interfaces of the virtual - machines in the scale set. - :paramtype network_profile: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetNetworkProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2017_03_30.models.DiagnosticsProfile - :keyword extension_profile: Specifies a collection of settings for extensions installed on - virtual machines in the scale set. - :paramtype extension_profile: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetExtensionProfile - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - """ - super().__init__(**kwargs) - self.os_profile = os_profile - self.storage_profile = storage_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.extension_profile = extension_profile - self.license_type = license_type - - -class VirtualMachineSize(_serialization.Model): - """Describes the properties of a VM size. - - :ivar name: The name of the virtual machine size. - :vartype name: str - :ivar number_of_cores: The number of cores supported by the virtual machine size. - :vartype number_of_cores: int - :ivar os_disk_size_in_mb: The OS disk size, in MB, allowed by the virtual machine size. - :vartype os_disk_size_in_mb: int - :ivar resource_disk_size_in_mb: The resource disk size, in MB, allowed by the virtual machine - size. - :vartype resource_disk_size_in_mb: int - :ivar memory_in_mb: The amount of memory, in MB, supported by the virtual machine size. - :vartype memory_in_mb: int - :ivar max_data_disk_count: The maximum number of data disks that can be attached to the virtual - machine size. - :vartype max_data_disk_count: int - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "number_of_cores": {"key": "numberOfCores", "type": "int"}, - "os_disk_size_in_mb": {"key": "osDiskSizeInMB", "type": "int"}, - "resource_disk_size_in_mb": {"key": "resourceDiskSizeInMB", "type": "int"}, - "memory_in_mb": {"key": "memoryInMB", "type": "int"}, - "max_data_disk_count": {"key": "maxDataDiskCount", "type": "int"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - number_of_cores: Optional[int] = None, - os_disk_size_in_mb: Optional[int] = None, - resource_disk_size_in_mb: Optional[int] = None, - memory_in_mb: Optional[int] = None, - max_data_disk_count: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the virtual machine size. - :paramtype name: str - :keyword number_of_cores: The number of cores supported by the virtual machine size. - :paramtype number_of_cores: int - :keyword os_disk_size_in_mb: The OS disk size, in MB, allowed by the virtual machine size. - :paramtype os_disk_size_in_mb: int - :keyword resource_disk_size_in_mb: The resource disk size, in MB, allowed by the virtual - machine size. - :paramtype resource_disk_size_in_mb: int - :keyword memory_in_mb: The amount of memory, in MB, supported by the virtual machine size. - :paramtype memory_in_mb: int - :keyword max_data_disk_count: The maximum number of data disks that can be attached to the - virtual machine size. - :paramtype max_data_disk_count: int - """ - super().__init__(**kwargs) - self.name = name - self.number_of_cores = number_of_cores - self.os_disk_size_in_mb = os_disk_size_in_mb - self.resource_disk_size_in_mb = resource_disk_size_in_mb - self.memory_in_mb = memory_in_mb - self.max_data_disk_count = max_data_disk_count - - -class VirtualMachineSizeListResult(_serialization.Model): - """The List Virtual Machine operation response. - - :ivar value: The list of virtual machine sizes. - :vartype value: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineSize] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineSize]"}, - } - - def __init__(self, *, value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of virtual machine sizes. - :paramtype value: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineSize] - """ - super().__init__(**kwargs) - self.value = value - - -class VirtualMachineStatusCodeCount(_serialization.Model): - """The status code and count of the virtual machine scale set instance view status summary. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The instance view status code. - :vartype code: str - :ivar count: The number of instances having a particular status code. - :vartype count: int - """ - - _validation = { - "code": {"readonly": True}, - "count": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "count": {"key": "count", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.count: Optional[int] = None - - -class WindowsConfiguration(_serialization.Model): - """Specifies Windows operating system settings on the virtual machine. - - :ivar provision_vm_agent: Indicates whether virtual machine agent should be provisioned on the - virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the request - body, default behavior is to set it to true. This will ensure that VM Agent is installed on - the VM so that extensions can be added to the VM later. - :vartype provision_vm_agent: bool - :ivar enable_automatic_updates: Indicates whether virtual machine is enabled for automatic - updates. - :vartype enable_automatic_updates: bool - :ivar time_zone: Specifies the time zone of the virtual machine. e.g. "Pacific Standard Time". - :vartype time_zone: str - :ivar additional_unattend_content: Specifies additional base-64 encoded XML formatted - information that can be included in the Unattend.xml file, which is used by Windows Setup. - :vartype additional_unattend_content: - list[~azure.mgmt.compute.v2017_03_30.models.AdditionalUnattendContent] - :ivar win_rm: Specifies the Windows Remote Management listeners. This enables remote Windows - PowerShell. - :vartype win_rm: ~azure.mgmt.compute.v2017_03_30.models.WinRMConfiguration - """ - - _attribute_map = { - "provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"}, - "enable_automatic_updates": {"key": "enableAutomaticUpdates", "type": "bool"}, - "time_zone": {"key": "timeZone", "type": "str"}, - "additional_unattend_content": {"key": "additionalUnattendContent", "type": "[AdditionalUnattendContent]"}, - "win_rm": {"key": "winRM", "type": "WinRMConfiguration"}, - } - - def __init__( - self, - *, - provision_vm_agent: Optional[bool] = None, - enable_automatic_updates: Optional[bool] = None, - time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, - win_rm: Optional["_models.WinRMConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword provision_vm_agent: Indicates whether virtual machine agent should be provisioned on - the virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the - request body, default behavior is to set it to true. This will ensure that VM Agent is - installed on the VM so that extensions can be added to the VM later. - :paramtype provision_vm_agent: bool - :keyword enable_automatic_updates: Indicates whether virtual machine is enabled for automatic - updates. - :paramtype enable_automatic_updates: bool - :keyword time_zone: Specifies the time zone of the virtual machine. e.g. "Pacific Standard - Time". - :paramtype time_zone: str - :keyword additional_unattend_content: Specifies additional base-64 encoded XML formatted - information that can be included in the Unattend.xml file, which is used by Windows Setup. - :paramtype additional_unattend_content: - list[~azure.mgmt.compute.v2017_03_30.models.AdditionalUnattendContent] - :keyword win_rm: Specifies the Windows Remote Management listeners. This enables remote Windows - PowerShell. - :paramtype win_rm: ~azure.mgmt.compute.v2017_03_30.models.WinRMConfiguration - """ - super().__init__(**kwargs) - self.provision_vm_agent = provision_vm_agent - self.enable_automatic_updates = enable_automatic_updates - self.time_zone = time_zone - self.additional_unattend_content = additional_unattend_content - self.win_rm = win_rm - - -class WinRMConfiguration(_serialization.Model): - """Describes Windows Remote Management configuration of the VM. - - :ivar listeners: The list of Windows Remote Management listeners. - :vartype listeners: list[~azure.mgmt.compute.v2017_03_30.models.WinRMListener] - """ - - _attribute_map = { - "listeners": {"key": "listeners", "type": "[WinRMListener]"}, - } - - def __init__(self, *, listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs: Any) -> None: - """ - :keyword listeners: The list of Windows Remote Management listeners. - :paramtype listeners: list[~azure.mgmt.compute.v2017_03_30.models.WinRMListener] - """ - super().__init__(**kwargs) - self.listeners = listeners - - -class WinRMListener(_serialization.Model): - """Describes Protocol and thumbprint of Windows Remote Management listener. - - :ivar protocol: Specifies the protocol of listener. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. Known values are: "Http" - and "Https". - :vartype protocol: str or ~azure.mgmt.compute.v2017_03_30.models.ProtocolTypes - :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as - a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :vartype certificate_url: str - """ - - _attribute_map = { - "protocol": {"key": "protocol", "type": "str"}, - "certificate_url": {"key": "certificateUrl", "type": "str"}, - } - - def __init__( - self, - *, - protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, - certificate_url: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword protocol: Specifies the protocol of listener. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. Known values are: - "Http" and "Https". - :paramtype protocol: str or ~azure.mgmt.compute.v2017_03_30.models.ProtocolTypes - :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault - as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :paramtype certificate_url: str - """ - super().__init__(**kwargs) - self.protocol = protocol - self.certificate_url = certificate_url diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/__init__.py deleted file mode 100644 index 8e2dbe1731a1..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/__init__.py +++ /dev/null @@ -1,55 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import AvailabilitySetsOperations # type: ignore -from ._operations import VirtualMachineExtensionImagesOperations # type: ignore -from ._operations import VirtualMachineExtensionsOperations # type: ignore -from ._operations import VirtualMachinesOperations # type: ignore -from ._operations import VirtualMachineImagesOperations # type: ignore -from ._operations import UsageOperations # type: ignore -from ._operations import VirtualMachineSizesOperations # type: ignore -from ._operations import ImagesOperations # type: ignore -from ._operations import ResourceSkusOperations # type: ignore -from ._operations import VirtualMachineScaleSetsOperations # type: ignore -from ._operations import VirtualMachineScaleSetExtensionsOperations # type: ignore -from ._operations import VirtualMachineScaleSetRollingUpgradesOperations # type: ignore -from ._operations import VirtualMachineScaleSetVMsOperations # type: ignore -from ._operations import DisksOperations # type: ignore -from ._operations import SnapshotsOperations # type: ignore -from ._operations import VirtualMachineRunCommandsOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AvailabilitySetsOperations", - "VirtualMachineExtensionImagesOperations", - "VirtualMachineExtensionsOperations", - "VirtualMachinesOperations", - "VirtualMachineImagesOperations", - "UsageOperations", - "VirtualMachineSizesOperations", - "ImagesOperations", - "ResourceSkusOperations", - "VirtualMachineScaleSetsOperations", - "VirtualMachineScaleSetExtensionsOperations", - "VirtualMachineScaleSetRollingUpgradesOperations", - "VirtualMachineScaleSetVMsOperations", - "DisksOperations", - "SnapshotsOperations", - "VirtualMachineRunCommandsOperations", -] -__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/v2017_03_30/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_operations.py deleted file mode 100644 index 1552cbb0d5ce..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_operations.py +++ /dev/null @@ -1,14159 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterator, List, Literal, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import ComputeManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - 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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_availability_sets_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes", - ) - 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"), - } - - _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_extension_images_get_request( # pylint: disable=name-too-long - location: str, publisher_name: str, type: str, version: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types", - ) - 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"), - } - - _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_extension_images_list_versions_request( # pylint: disable=name-too-long - location: str, - publisher_name: str, - type: str, - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - if orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2017-03-30")) - 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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - 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}", - ) - 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"), - } - - _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_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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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) - - -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 -) -> 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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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) - - -def build_virtual_machines_get_extensions_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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines", - ) - 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_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", "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture", - ) - 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"), - } - - _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_machines_create_or_update_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", "2017-03-30")) - 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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_delete_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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", - ) - 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"), - } - - _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) - - -def build_virtual_machines_get_request( - resource_group_name: str, - vm_name: str, - subscription_id: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", - ) - 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"), - } - - _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) - - -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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView", - ) - 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"), - } - - _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_machines_convert_to_managed_disks_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks", - ) - 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"), - } - - _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="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, **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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_generalize_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_list_all_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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes", - ) - 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"), - } - - _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_machines_power_off_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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_restart_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart", - ) - 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"), - } - - _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="POST", 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 -) -> 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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_redeploy_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_perform_maintenance_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_run_command_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", - ) - 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"), - } - - _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) - - -def build_virtual_machine_images_list_offers_request( # pylint: disable=name-too-long - location: str, publisher_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers" - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_images_list_skus_request( # pylint: disable=name-too-long - location: str, publisher_name: str, offer: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages" - ) - 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_sizes_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes" - ) - 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - 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}", - ) - 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"), - } - - _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_images_delete_request( - resource_group_name: str, image_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", - ) - 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"), - } - - _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) - - -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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", - ) - 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"), - } - - _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) - - -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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_resource_skus_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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/skus") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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, **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", "2017-03-30")) - 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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_update_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", "2017-03-30")) - 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}", - ) - 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"), - } - - _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_virtual_machine_scale_sets_delete_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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", - ) - 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"), - } - - _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) - - -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, **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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", - ) - 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"), - } - - _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_scale_sets_deallocate_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", "2017-03-30")) - 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", - ) - 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"), - } - - _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_scale_sets_delete_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", "2017-03-30")) - 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", - ) - 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"), - } - - _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_scale_sets_get_instance_view_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_list_all_request( # pylint: disable=name-too-long - subscription_id: str, **kwargs: Any -) -> 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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_list_skus_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus", - ) - 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"), - } - - _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_scale_sets_power_off_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", "2017-03-30")) - 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", - ) - 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"), - } - - _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_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", "2017-03-30")) - 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", - ) - 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"), - } - - _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_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", "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start", - ) - 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"), - } - - _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_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", "2017-03-30")) - 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", - ) - 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"), - } - - _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_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", "2017-03-30")) - 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", - ) - 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"), - } - - _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_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", "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall", - ) - 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"), - } - - _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_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", "2017-03-30")) - 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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions", - ) - 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"), - } - - _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_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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel", - ) - 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"), - } - - _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="POST", 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 -) -> 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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade", - ) - 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"), - } - - _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="POST", 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 -) -> 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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest", - ) - 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"), - } - - _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_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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_set_vms_reimage_all_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any -) -> 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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall", - ) - 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"), - } - - _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="POST", 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 -) -> 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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate", - ) - 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"), - } - - _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="POST", 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, **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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", - ) - 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"), - } - - _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) - - -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, **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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView", - ) - 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"), - } - - _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_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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines", - ) - 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"), - } - - _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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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, **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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff", - ) - 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"), - } - - _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="POST", 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 -) -> 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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart", - ) - 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"), - } - - _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="POST", 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 -) -> 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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2017-03-30")) - 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}", - ) - 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"), - } - - _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_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", "2017-03-30")) - 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}", - ) - 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"), - } - - _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_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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", - ) - 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"), - } - - _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) - - -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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2017-03-30")) - 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", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2017-03-30")) - 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}", - ) - 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"), - } - - _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_snapshots_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", "2017-03-30")) - 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}", - ) - 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"), - } - - _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_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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", - ) - 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"), - } - - _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_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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2017-03-30")) - 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}/beginGetAccess", - ) - 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"), - } - - _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_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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess", - ) - 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"), - } - - _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="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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands" - ) - 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", "2017-03-30")) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}", - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"), - "commandId": _SERIALIZER.url("command_id", command_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AvailabilitySetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s - :attr:`availability_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: _models.AvailabilitySet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2017_03_30.models.AvailabilitySet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_03_30.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_03_30.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySet, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Is either a - AvailabilitySet type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2017_03_30.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySet") - - _request = build_availability_sets_create_or_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Optional[_models.OperationStatusResponse]: - """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: OperationStatusResponse or None or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse or 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 "2017-03-30")) - cls: ClsType[Optional[_models.OperationStatusResponse]] = 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) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("OperationStatusResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get(self, resource_group_name: str, 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.v2017_03_30.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", 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) - - _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("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription( - self, *, expand: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. - - :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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets 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 AvailabilitySet or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - 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_available_sizes( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes that can be used to create a new virtual machine in - an existing availability set. - - :param resource_group_name: The name of the resource group. Required. - :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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_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 - - if response.status_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 VirtualMachineExtensionImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s - :attr:`virtual_machine_extension_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, type: str, version: str, **kwargs: Any - ) -> _models.VirtualMachineExtensionImage: - """Gets a virtual machine extension image. - - :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.v2017_03_30.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 "2017-03-30")) - 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 - - @distributed_trace - def list_types( - self, location: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineExtensionImage]: - """Gets a list of virtual machine extension image types. - - :param location: The name of 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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - - _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) - - _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 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 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.v2017_03_30.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 "2017-03-30")) - 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 - - -class VirtualMachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s - :attr:`virtual_machine_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, 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 "2017-03-30")) - 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, "VirtualMachineExtension") - - _request = build_virtual_machine_extensions_create_or_update_request( - resource_group_name=resource_group_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2017_03_30.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 VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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] - :keyword content_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.v2017_03_30.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2017_03_30.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.v2017_03_30.models.VirtualMachineExtension] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - 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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineExtensionUpdate") - - _request = build_virtual_machine_extensions_update_request( - resource_group_name=resource_group_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, - 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]: - 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, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to update the extension. - - :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: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtensionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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 - ) -> 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_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 LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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.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.v2017_03_30.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.v2017_03_30.models.VirtualMachineExtension] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2017-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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) - - _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, vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """The operation to delete 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 deleted. - 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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.v2017_03_30.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 "2017-03-30")) - 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) - - deserialized = self._deserialize("VirtualMachineExtension", 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.v2017_03_30.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_extensions( - 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.v2017_03_30.models.VirtualMachineExtensionsListResult - :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 "2017-03-30")) - cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machines_get_extensions_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineExtensionsListResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_location(self, location: str, **kwargs: Any) -> ItemPaged["_models.VirtualMachine"]: - """Gets all the virtual machines under the specified subscription for the specified location. - - :param location: The location for which virtual machines under the subscription are queried. - Required. - :type location: str - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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 - - 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) - - def _capture_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-03-30")) - 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 - - 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_capture( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachineCaptureParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. - - :param resource_group_name: The name of the resource group. Required. - :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.v2017_03_30.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.v2017_03_30.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. - - :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.v2017_03_30.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_capture( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. - - :param resource_group_name: The name of the resource group. 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.v2017_03_30.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.v2017_03_30.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineCaptureResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._capture_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineCaptureResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # 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) - ) - 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 - ) - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, 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 "2017-03-30")) - 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, "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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachine, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or 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 Create Virtual Machine operation. Required. - :type parameters: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachine - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or 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 Create 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 VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or 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 Create Virtual Machine operation. Is either a - VirtualMachine type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachine or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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._create_or_update_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("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, **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 "2017-03-30")) - 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, - 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, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """The operation to delete 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 LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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: Literal["instanceView"] = "instanceView", **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) - - _request = build_virtual_machines_instance_view_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineInstanceView", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _convert_to_managed_disks_initial( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> 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 "2017-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_convert_to_managed_disks_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_convert_to_managed_disks( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - :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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._convert_to_managed_disks_initial( - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _deallocate_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[Iterator[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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_deallocate( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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_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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def generalize(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> _models.OperationStatusResponse: - """Sets the state of the virtual machine to generalized. - - :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: OperationStatusResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse - :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 "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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) - - deserialized = self._deserialize("OperationStatusResponse", 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) -> ItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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, - 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, **kwargs: Any) -> ItemPaged["_models.VirtualMachine"]: - """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. - - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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, - 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_available_sizes( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes to which the specified virtual machine can be - resized. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_available_sizes_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _power_off_initial(self, resource_group_name: str, vm_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 "2017-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_power_off_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_power_off( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - :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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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]: - 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 "2017-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_restart_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_restart( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """The operation to restart 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 LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._restart_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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]: - 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 "2017-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_start( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_redeploy_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_redeploy( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _perform_maintenance_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_perform_maintenance( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """The operation to perform maintenance on 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 LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _run_command_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - 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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RunCommandInput") - - _request = build_virtual_machines_run_command_request( - 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 - - 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_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2017_03_30.models.RunCommandInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2017_03_30.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.v2017_03_30.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._run_command_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: 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.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s - :attr:`virtual_machine_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.v2017_03_30.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 "2017-03-30")) - 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.v2017_03_30.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 "2017-03-30")) - 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. - - :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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_list_offers_request( - location=location, - publisher_name=publisher_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2017_03_30.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 "2017-03-30")) - 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 = 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_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 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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _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) - - _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 - - -class UsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s - :attr:`usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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 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.v2017_03_30.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 "2017-03-30")) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - 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.v2017_03_30.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes for a subscription in a location. - - :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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_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 - - 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 - - if response.status_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 ImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s - :attr:`images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any - ) -> 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 "2017-03-30")) - 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, "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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: _models.Image, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2017_03_30.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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Create or update 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 - :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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.Image] - :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. - - :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 - :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.v2017_03_30.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.v2017_03_30.models.Image] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._create_or_update_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: 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.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Image]( - 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]: - 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 "2017-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_images_delete_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, image_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Deletes 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 - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - image_name=image_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.Image] = kwargs.pop("cls", None) - - _request = build_images_get_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Image", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Image"]: - """Gets the list of images 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 Image or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class ResourceSkusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s - :attr:`resource_skus` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.ResourceSku"]: - """Gets the list of Microsoft.Compute SKUs available for your Subscription. - - :return: An iterator like instance of either ResourceSku or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.ResourceSku] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.ResourceSkusResult] = 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_resource_skus_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("ResourceSkusResult", 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 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.v2017_03_30.ComputeManagementClient`'s - :attr:`virtual_machine_scale_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, 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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualMachineScaleSet") - - _request = build_virtual_machine_scale_sets_create_or_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. - :type parameters: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSet - :keyword content_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.v2017_03_30.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. 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 VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 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.v2017_03_30.models.VirtualMachineScaleSet or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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, - 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]], - **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 "2017-03-30")) - 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, "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, - 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]: - 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, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. - - :param resource_group_name: The name of the resource group. 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.v2017_03_30.models.VirtualMachineScaleSetUpdate - :keyword content_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.v2017_03_30.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. - - :param resource_group_name: The name of the resource group. 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: IO[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 VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.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]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update 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 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.v2017_03_30.models.VirtualMachineScaleSetUpdate or - IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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, - 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, **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 "2017-03-30")) - 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, - 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, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, **kwargs: Any) -> _models.VirtualMachineScaleSet: - """Display information about a 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 - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _deallocate_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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_deallocate( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - :type 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.v2017_03_30.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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - :type 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_deallocate( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - :type 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.v2017_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-03-30")) - 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") - - _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, - 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_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_03_30.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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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.v2017_03_30.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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. - - :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.v2017_03_30.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 "2017-03-30")) - 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 - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_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 - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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_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: - 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) -> ItemPaged["_models.VirtualMachineScaleSet"]: - """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource - group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this - till nextLink is null to fetch all the VM Scale Sets. - - :return: An iterator like instance of either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = 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_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("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) - - 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_skus( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineScaleSetSku"]: - """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM - instances allowed for each SKU. - - :param resource_group_name: The name of the resource group. Required. - :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.v2017_03_30.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 "2017-03-30")) - 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 _power_off_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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_power_off_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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.v2017_03_30.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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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, - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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.v2017_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, - 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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_restart_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_03_30.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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, - 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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_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 - 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_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[_models.OperationStatusResponse]: - """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.v2017_03_30.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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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.v2017_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-03-30")) - 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") - - _request = build_virtual_machine_scale_sets_update_instances_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_03_30.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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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_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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Reimages (upgrade the operating system) 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.v2017_03_30.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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_reimage( - 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[_models.OperationStatusResponse]: - """Reimages (upgrade the operating system) 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Reimages (upgrade the operating system) 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.v2017_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reimage_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_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[_models.OperationStatusResponse]: - """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.v2017_03_30.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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # 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.v2017_03_30.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtension, 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 "2017-03-30")) - 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") - - _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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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. - - :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.v2017_03_30.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.v2017_03_30.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.v2017_03_30.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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.v2017_03_30.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.v2017_03_30.models.VirtualMachineScaleSetExtension] - :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 "2017-03-30")) - 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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-03-30")) - 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, - 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, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """The operation to delete the extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be deleted. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def get( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSetExtension: - """The operation to get the extension. - - :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.v2017_03_30.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 "2017-03-30")) - 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 - - @distributed_trace - def list( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_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.v2017_03_30.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 "2017-03-30")) - 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) - - -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.v2017_03_30.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2017-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_rolling_upgrades_cancel_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - 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 - - return deserialized # type: ignore - - @distributed_trace - def begin_cancel( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Cancels the current 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: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, - 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 "2017-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - 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 - - return deserialized # type: ignore - - @distributed_trace - def begin_start_os_upgrade( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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.v2017_03_30.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 "2017-03-30")) - 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 - ) - - response = pipeline_response.http_response - - if response.status_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 VirtualMachineScaleSetVMsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _reimage_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 "2017-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_reimage_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - 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 - - return deserialized # type: ignore - - @distributed_trace - def begin_reimage( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _reimage_all_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_reimage_all( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. - This operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reimage_all_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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 "2017-03-30")) - 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) - - 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_deallocate( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and - releases the compute resources it uses. You are not billed for the compute resources of this - virtual machine once it is deallocated. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._deallocate_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, **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 "2017-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - 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, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Deletes 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: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, **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 - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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, - 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.v2017_03_30.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 "2017-03-30")) - 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 - ) -> ItemPaged["_models.VirtualMachineScaleSetVM"]: - """Gets a list of all virtual machines in a VM scale sets. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param virtual_machine_scale_set_name: The name of the VM scale set. Required. - :type virtual_machine_scale_set_name: str - :keyword filter: The filter to apply to the operation. Allowed values are - 'startswith(instanceView/statuses/code, 'PowerState') eq true', 'properties/latestModelApplied - eq true', 'properties/latestModelApplied eq false'. Default value is None. - :paramtype filter: str - :keyword select: The list parameters. Allowed values are 'instanceView', - 'instanceView/statuses'. Default value is None. - :paramtype select: str - :keyword expand: The expand expression to apply to the operation. Allowed values are - 'instanceView'. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.VirtualMachineScaleSetVMListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_set_vms_list_request( - resource_group_name=resource_group_name, - virtual_machine_scale_set_name=virtual_machine_scale_set_name, - subscription_id=self._config.subscription_id, - filter=filter, - select=select, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVMListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _power_off_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **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 "2017-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_power_off_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_power_off( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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 "2017-03-30")) - 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 - - return deserialized # type: ignore - - @distributed_trace - def begin_restart( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Restarts a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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 - ) -> 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 "2017-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_start_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 - - return deserialized # type: ignore - - @distributed_trace - def begin_start( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 - :param vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class DisksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s - :attr:`disks` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_name: str, disk: Union[_models.Disk, 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 "2017-03-30")) - 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, (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_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) - - _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_create_or_update( - self, - resource_group_name: str, - disk_name: str, - disk: _models.Disk, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Creates or updates 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 - :param disk: Disk object supplied in the body of the Put disk operation. Required. - :type disk: ~azure.mgmt.compute.v2017_03_30.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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.Disk] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_name: str, - disk: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Creates or updates 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 - :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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.Disk] - :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. - - :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 - :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.v2017_03_30.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.v2017_03_30.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 "2017-03-30")) - 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._create_or_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, **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 _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, - 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 "2017-03-30")) - 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, (IOBase, bytes)): - _content = disk - else: - _json = self._serialize.body(disk, "DiskUpdate") - - _request = build_disks_update_request( - resource_group_name=resource_group_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) - - _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, - disk_name: str, - disk: _models.DiskUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Updates (patches) a disk. - - :param resource_group_name: The name of the resource group. Required. - :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.v2017_03_30.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.v2017_03_30.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. 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.v2017_03_30.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. 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.v2017_03_30.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.v2017_03_30.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 "2017-03-30")) - 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, **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 - ) - - @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.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) - - _request = build_disks_get_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) - - _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("Disk", 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_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 "2017-03-30")) - 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[_models.OperationStatusResponse]: - """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 LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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_name=disk_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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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) -> ItemPaged["_models.Disk"]: - """Lists all the disks 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 Disk or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - 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 list(self, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disks_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) - - 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, - 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 "2017-03-30")) - 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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disks_grant_access_request( - resource_group_name=resource_group_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) - - _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_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_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.v2017_03_30.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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_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.v2017_03_30.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.v2017_03_30.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 "2017-03-30")) - 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, - disk_name=disk_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, **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, 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disks_revoke_access_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]: - 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_revoke_access( - self, resource_group_name: str, disk_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Revokes access to 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 LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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.v2017_03_30.ComputeManagementClient`'s - :attr:`snapshots` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, snapshot_name: str, snapshot: Union[_models.Snapshot, 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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "Snapshot") - - _request = build_snapshots_create_or_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.Snapshot, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: ~azure.mgmt.compute.v2017_03_30.models.Snapshot - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :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.v2017_03_30.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.v2017_03_30.models.Snapshot] - :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 "2017-03-30")) - 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._create_or_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, **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 _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, - 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 "2017-03-30")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "SnapshotUpdate") - - _request = build_snapshots_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, - snapshot_name: str, - snapshot: _models.SnapshotUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. 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.v2017_03_30.models.SnapshotUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. - Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. Is - either a SnapshotUpdate type or a IO[bytes] type. Required. - :type snapshot: ~azure.mgmt.compute.v2017_03_30.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.v2017_03_30.models.Snapshot] - :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 "2017-03-30")) - 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, **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 - ) - - @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.v2017_03_30.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 "2017-03-30")) - 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]: - 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 "2017-03-30")) - 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) - - 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, snapshot_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Deletes 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: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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, - snapshot_name=snapshot_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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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) -> ItemPaged["_models.Snapshot"]: - """Lists snapshots 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 Snapshot or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.Snapshot"]: - """Lists snapshots under a subscription. - - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _grant_access_initial( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, 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 "2017-03-30")) - 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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_snapshots_grant_access_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param grant_access_data: Access data object supplied in the body of the get snapshot access - operation. Required. - :type grant_access_data: ~azure.mgmt.compute.v2017_03_30.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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param 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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param 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.v2017_03_30.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.v2017_03_30.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 "2017-03-30")) - 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, - snapshot_name=snapshot_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, **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, 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 "2017-03-30")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_snapshots_revoke_access_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]: - 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_revoke_access( - self, resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Revokes access to 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: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-30")) - cls: ClsType[_models.OperationStatusResponse] = 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( - resource_group_name=resource_group_name, - snapshot_name=snapshot_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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineRunCommandsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s - :attr:`virtual_machine_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.RunCommandDocumentBase"]: - """Lists all available run commands for a subscription in a location. - - :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 - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.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 "2017-03-30")) - cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_run_commands_list_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RunCommandListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - 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, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: - """Gets specific run command for a subscription in a location. - - :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.v2017_03_30.models.RunCommandDocument - :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 "2017-03-30")) - cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) - - _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, - 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("RunCommandDocument", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2017_09_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_compute_management_client.py deleted file mode 100644 index 71ebb25d01c8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_compute_management_client.py +++ /dev/null @@ -1,116 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ResourceSkusOperations - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar resource_skus: ResourceSkusOperations operations - :vartype resource_skus: azure.mgmt.compute.v2017_09_01.operations.ResourceSkusOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2017-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.resource_skus = ResourceSkusOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-09-01" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_configuration.py deleted file mode 100644 index 3e9f61bd7768..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2017-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2017-09-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_metadata.json deleted file mode 100644 index 60feb47df5a2..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2017-09-01", - "total_api_version_list": ["2017-09-01"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "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.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "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.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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": { - "resource_skus": "ResourceSkusOperations" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node
    is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj 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 deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2017_09_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/_compute_management_client.py deleted file mode 100644 index 05ac4e04584f..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/_compute_management_client.py +++ /dev/null @@ -1,120 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ResourceSkusOperations - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar resource_skus: ResourceSkusOperations operations - :vartype resource_skus: azure.mgmt.compute.v2017_09_01.aio.operations.ResourceSkusOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2017-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.resource_skus = ResourceSkusOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-09-01" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/_configuration.py deleted file mode 100644 index 9b0e6a194d11..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2017-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2017-09-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/__init__.py deleted file mode 100644 index a17cbc8abb0e..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import ResourceSkusOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ResourceSkusOperations", -] -__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/v2017_09_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/__init__.py deleted file mode 100644 index 152fce99ac51..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/__init__.py +++ /dev/null @@ -1,50 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - ResourceSku, - ResourceSkuCapabilities, - ResourceSkuCapacity, - ResourceSkuCosts, - ResourceSkuLocationInfo, - ResourceSkuRestrictionInfo, - ResourceSkuRestrictions, - ResourceSkusResult, -) - -from ._compute_management_client_enums import ( # type: ignore - ResourceSkuCapacityScaleType, - ResourceSkuRestrictionsReasonCode, - ResourceSkuRestrictionsType, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ResourceSku", - "ResourceSkuCapabilities", - "ResourceSkuCapacity", - "ResourceSkuCosts", - "ResourceSkuLocationInfo", - "ResourceSkuRestrictionInfo", - "ResourceSkuRestrictions", - "ResourceSkusResult", - "ResourceSkuCapacityScaleType", - "ResourceSkuRestrictionsReasonCode", - "ResourceSkuRestrictionsType", -] -__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/v2017_09_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_compute_management_client_enums.py deleted file mode 100644 index 6a772bbc0075..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_compute_management_client_enums.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class ResourceSkuCapacityScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scale type applicable to the sku.""" - - AUTOMATIC = "Automatic" - MANUAL = "Manual" - NONE = "None" - - -class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The reason for restriction.""" - - QUOTA_ID = "QuotaId" - NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" - - -class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of restrictions.""" - - LOCATION = "Location" - ZONE = "Zone" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_models_py3.py deleted file mode 100644 index 6e4e9f6b9bf7..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_models_py3.py +++ /dev/null @@ -1,332 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -class ResourceSku(_serialization.Model): - """Describes an available Compute SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of resource the SKU applies to. - :vartype resource_type: str - :ivar name: The name of SKU. - :vartype name: str - :ivar tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
    `\\ - :code:`
    ` Possible Values:\\ :code:`
    `\\ :code:`
    ` **Standard**\\ :code:`
    `\\ :code:`
    ` **Basic**. - :vartype tier: str - :ivar size: The Size of the SKU. - :vartype size: str - :ivar family: The Family of this particular SKU. - :vartype family: str - :ivar kind: The Kind of resources that are supported in this SKU. - :vartype kind: str - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: ~azure.mgmt.compute.v2017_09_01.models.ResourceSkuCapacity - :ivar locations: The set of locations that the SKU is available. - :vartype locations: list[str] - :ivar location_info: A list of locations and availability zones in those locations where the - SKU is available. - :vartype location_info: list[~azure.mgmt.compute.v2017_09_01.models.ResourceSkuLocationInfo] - :ivar api_versions: The api versions that support this SKU. - :vartype api_versions: list[str] - :ivar costs: Metadata for retrieving price info. - :vartype costs: list[~azure.mgmt.compute.v2017_09_01.models.ResourceSkuCosts] - :ivar capabilities: A name value pair to describe the capability. - :vartype capabilities: list[~azure.mgmt.compute.v2017_09_01.models.ResourceSkuCapabilities] - :ivar restrictions: The restrictions because of which SKU cannot be used. This is empty if - there are no restrictions. - :vartype restrictions: list[~azure.mgmt.compute.v2017_09_01.models.ResourceSkuRestrictions] - """ - - _validation = { - "resource_type": {"readonly": True}, - "name": {"readonly": True}, - "tier": {"readonly": True}, - "size": {"readonly": True}, - "family": {"readonly": True}, - "kind": {"readonly": True}, - "capacity": {"readonly": True}, - "locations": {"readonly": True}, - "location_info": {"readonly": True}, - "api_versions": {"readonly": True}, - "costs": {"readonly": True}, - "capabilities": {"readonly": True}, - "restrictions": {"readonly": True}, - } - - _attribute_map = { - "resource_type": {"key": "resourceType", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "size": {"key": "size", "type": "str"}, - "family": {"key": "family", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "capacity": {"key": "capacity", "type": "ResourceSkuCapacity"}, - "locations": {"key": "locations", "type": "[str]"}, - "location_info": {"key": "locationInfo", "type": "[ResourceSkuLocationInfo]"}, - "api_versions": {"key": "apiVersions", "type": "[str]"}, - "costs": {"key": "costs", "type": "[ResourceSkuCosts]"}, - "capabilities": {"key": "capabilities", "type": "[ResourceSkuCapabilities]"}, - "restrictions": {"key": "restrictions", "type": "[ResourceSkuRestrictions]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_type: Optional[str] = None - self.name: Optional[str] = None - self.tier: Optional[str] = None - self.size: Optional[str] = None - self.family: Optional[str] = None - self.kind: Optional[str] = None - self.capacity: Optional["_models.ResourceSkuCapacity"] = None - self.locations: Optional[List[str]] = None - self.location_info: Optional[List["_models.ResourceSkuLocationInfo"]] = None - self.api_versions: Optional[List[str]] = None - self.costs: Optional[List["_models.ResourceSkuCosts"]] = None - self.capabilities: Optional[List["_models.ResourceSkuCapabilities"]] = None - self.restrictions: Optional[List["_models.ResourceSkuRestrictions"]] = None - - -class ResourceSkuCapabilities(_serialization.Model): - """Describes The SKU capabilities object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: An invariant to describe the feature. - :vartype name: str - :ivar value: An invariant if the feature is measured by quantity. - :vartype value: str - """ - - _validation = { - "name": {"readonly": True}, - "value": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.value: Optional[str] = None - - -class ResourceSkuCapacity(_serialization.Model): - """Describes scaling information of a SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar minimum: The minimum capacity. - :vartype minimum: int - :ivar maximum: The maximum capacity that can be set. - :vartype maximum: int - :ivar default: The default capacity. - :vartype default: int - :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", - "Manual", and "None". - :vartype scale_type: str or ~azure.mgmt.compute.v2017_09_01.models.ResourceSkuCapacityScaleType - """ - - _validation = { - "minimum": {"readonly": True}, - "maximum": {"readonly": True}, - "default": {"readonly": True}, - "scale_type": {"readonly": True}, - } - - _attribute_map = { - "minimum": {"key": "minimum", "type": "int"}, - "maximum": {"key": "maximum", "type": "int"}, - "default": {"key": "default", "type": "int"}, - "scale_type": {"key": "scaleType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.minimum: Optional[int] = None - self.maximum: Optional[int] = None - self.default: Optional[int] = None - self.scale_type: Optional[Union[str, "_models.ResourceSkuCapacityScaleType"]] = None - - -class ResourceSkuCosts(_serialization.Model): - """Describes metadata for retrieving price info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar meter_id: Used for querying price from commerce. - :vartype meter_id: str - :ivar quantity: The multiplier is needed to extend the base metered cost. - :vartype quantity: int - :ivar extended_unit: An invariant to show the extended unit. - :vartype extended_unit: str - """ - - _validation = { - "meter_id": {"readonly": True}, - "quantity": {"readonly": True}, - "extended_unit": {"readonly": True}, - } - - _attribute_map = { - "meter_id": {"key": "meterID", "type": "str"}, - "quantity": {"key": "quantity", "type": "int"}, - "extended_unit": {"key": "extendedUnit", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.meter_id: Optional[str] = None - self.quantity: Optional[int] = None - self.extended_unit: Optional[str] = None - - -class ResourceSkuLocationInfo(_serialization.Model): - """ResourceSkuLocationInfo. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: Location of the SKU. - :vartype location: str - :ivar zones: List of availability zones where the SKU is supported. - :vartype zones: list[str] - """ - - _validation = { - "location": {"readonly": True}, - "zones": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "zones": {"key": "zones", "type": "[str]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.location: Optional[str] = None - self.zones: Optional[List[str]] = None - - -class ResourceSkuRestrictionInfo(_serialization.Model): - """ResourceSkuRestrictionInfo. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar locations: Locations where the SKU is restricted. - :vartype locations: list[str] - :ivar zones: List of availability zones where the SKU is restricted. - :vartype zones: list[str] - """ - - _validation = { - "locations": {"readonly": True}, - "zones": {"readonly": True}, - } - - _attribute_map = { - "locations": {"key": "locations", "type": "[str]"}, - "zones": {"key": "zones", "type": "[str]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.locations: Optional[List[str]] = None - self.zones: Optional[List[str]] = None - - -class ResourceSkuRestrictions(_serialization.Model): - """Describes scaling information of a SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of restrictions. Known values are: "Location" and "Zone". - :vartype type: str or ~azure.mgmt.compute.v2017_09_01.models.ResourceSkuRestrictionsType - :ivar values: The value of restrictions. If the restriction type is set to location. This would - be different locations where the SKU is restricted. - :vartype values: list[str] - :ivar restriction_info: The information about the restriction where the SKU cannot be used. - :vartype restriction_info: ~azure.mgmt.compute.v2017_09_01.models.ResourceSkuRestrictionInfo - :ivar reason_code: The reason for restriction. Known values are: "QuotaId" and - "NotAvailableForSubscription". - :vartype reason_code: str or - ~azure.mgmt.compute.v2017_09_01.models.ResourceSkuRestrictionsReasonCode - """ - - _validation = { - "type": {"readonly": True}, - "values": {"readonly": True}, - "restriction_info": {"readonly": True}, - "reason_code": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "values": {"key": "values", "type": "[str]"}, - "restriction_info": {"key": "restrictionInfo", "type": "ResourceSkuRestrictionInfo"}, - "reason_code": {"key": "reasonCode", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[Union[str, "_models.ResourceSkuRestrictionsType"]] = None - self.values: Optional[List[str]] = None - self.restriction_info: Optional["_models.ResourceSkuRestrictionInfo"] = None - self.reason_code: Optional[Union[str, "_models.ResourceSkuRestrictionsReasonCode"]] = None - - -class ResourceSkusResult(_serialization.Model): - """The List Resource Skus operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of skus available for the subscription. Required. - :vartype value: list[~azure.mgmt.compute.v2017_09_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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ResourceSku]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - 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. - :paramtype value: list[~azure.mgmt.compute.v2017_09_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/__init__.py deleted file mode 100644 index a17cbc8abb0e..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import ResourceSkusOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ResourceSkusOperations", -] -__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/v2017_09_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2017_12_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_compute_management_client.py deleted file mode 100644 index de985dec2abd..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_compute_management_client.py +++ /dev/null @@ -1,210 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ( - AvailabilitySetsOperations, - ImagesOperations, - LogAnalyticsOperations, - Operations, - UsageOperations, - VirtualMachineExtensionImagesOperations, - VirtualMachineExtensionsOperations, - VirtualMachineImagesOperations, - VirtualMachineRunCommandsOperations, - VirtualMachineScaleSetExtensionsOperations, - VirtualMachineScaleSetRollingUpgradesOperations, - VirtualMachineScaleSetVMsOperations, - VirtualMachineScaleSetsOperations, - VirtualMachineSizesOperations, - VirtualMachinesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.compute.v2017_12_01.operations.Operations - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2017_12_01.operations.AvailabilitySetsOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2017_12_01.operations.VirtualMachineExtensionImagesOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2017_12_01.operations.VirtualMachineExtensionsOperations - :ivar virtual_machines: VirtualMachinesOperations operations - :vartype virtual_machines: azure.mgmt.compute.v2017_12_01.operations.VirtualMachinesOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2017_12_01.operations.VirtualMachineImagesOperations - :ivar usage: UsageOperations operations - :vartype usage: azure.mgmt.compute.v2017_12_01.operations.UsageOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2017_12_01.operations.VirtualMachineSizesOperations - :ivar images: ImagesOperations operations - :vartype images: azure.mgmt.compute.v2017_12_01.operations.ImagesOperations - :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations - :vartype virtual_machine_scale_sets: - azure.mgmt.compute.v2017_12_01.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations - operations - :vartype virtual_machine_scale_set_extensions: - azure.mgmt.compute.v2017_12_01.operations.VirtualMachineScaleSetExtensionsOperations - :ivar virtual_machine_scale_set_rolling_upgrades: - VirtualMachineScaleSetRollingUpgradesOperations operations - :vartype virtual_machine_scale_set_rolling_upgrades: - azure.mgmt.compute.v2017_12_01.operations.VirtualMachineScaleSetRollingUpgradesOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2017_12_01.operations.VirtualMachineScaleSetVMsOperations - :ivar log_analytics: LogAnalyticsOperations operations - :vartype log_analytics: azure.mgmt.compute.v2017_12_01.operations.LogAnalyticsOperations - :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations - :vartype virtual_machine_run_commands: - azure.mgmt.compute.v2017_12_01.operations.VirtualMachineRunCommandsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2017-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2017-12-01") - self.availability_sets = AvailabilitySetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.virtual_machine_images = VirtualMachineImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2017-12-01") - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2017-12-01") - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.log_analytics = LogAnalyticsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_configuration.py deleted file mode 100644 index 0c3b149bbbca..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2017-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2017-12-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_metadata.json deleted file mode 100644 index 5944975cfcc3..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_metadata.json +++ /dev/null @@ -1,124 +0,0 @@ -{ - "chosen_version": "2017-12-01", - "total_api_version_list": ["2017-12-01"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "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.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "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.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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": { - "operations": "Operations", - "availability_sets": "AvailabilitySetsOperations", - "virtual_machine_extension_images": "VirtualMachineExtensionImagesOperations", - "virtual_machine_extensions": "VirtualMachineExtensionsOperations", - "virtual_machines": "VirtualMachinesOperations", - "virtual_machine_images": "VirtualMachineImagesOperations", - "usage": "UsageOperations", - "virtual_machine_sizes": "VirtualMachineSizesOperations", - "images": "ImagesOperations", - "virtual_machine_scale_sets": "VirtualMachineScaleSetsOperations", - "virtual_machine_scale_set_extensions": "VirtualMachineScaleSetExtensionsOperations", - "virtual_machine_scale_set_rolling_upgrades": "VirtualMachineScaleSetRollingUpgradesOperations", - "virtual_machine_scale_set_vms": "VirtualMachineScaleSetVMsOperations", - "log_analytics": "LogAnalyticsOperations", - "virtual_machine_run_commands": "VirtualMachineRunCommandsOperations" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node
    is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj 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 deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2017_12_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/_compute_management_client.py deleted file mode 100644 index dd42c886e130..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/_compute_management_client.py +++ /dev/null @@ -1,215 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ( - AvailabilitySetsOperations, - ImagesOperations, - LogAnalyticsOperations, - Operations, - UsageOperations, - VirtualMachineExtensionImagesOperations, - VirtualMachineExtensionsOperations, - VirtualMachineImagesOperations, - VirtualMachineRunCommandsOperations, - VirtualMachineScaleSetExtensionsOperations, - VirtualMachineScaleSetRollingUpgradesOperations, - VirtualMachineScaleSetVMsOperations, - VirtualMachineScaleSetsOperations, - VirtualMachineSizesOperations, - VirtualMachinesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.compute.v2017_12_01.aio.operations.Operations - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2017_12_01.aio.operations.AvailabilitySetsOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2017_12_01.aio.operations.VirtualMachineExtensionImagesOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2017_12_01.aio.operations.VirtualMachineExtensionsOperations - :ivar virtual_machines: VirtualMachinesOperations operations - :vartype virtual_machines: - azure.mgmt.compute.v2017_12_01.aio.operations.VirtualMachinesOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2017_12_01.aio.operations.VirtualMachineImagesOperations - :ivar usage: UsageOperations operations - :vartype usage: azure.mgmt.compute.v2017_12_01.aio.operations.UsageOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2017_12_01.aio.operations.VirtualMachineSizesOperations - :ivar images: ImagesOperations operations - :vartype images: azure.mgmt.compute.v2017_12_01.aio.operations.ImagesOperations - :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations - :vartype virtual_machine_scale_sets: - azure.mgmt.compute.v2017_12_01.aio.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations - operations - :vartype virtual_machine_scale_set_extensions: - azure.mgmt.compute.v2017_12_01.aio.operations.VirtualMachineScaleSetExtensionsOperations - :ivar virtual_machine_scale_set_rolling_upgrades: - VirtualMachineScaleSetRollingUpgradesOperations operations - :vartype virtual_machine_scale_set_rolling_upgrades: - azure.mgmt.compute.v2017_12_01.aio.operations.VirtualMachineScaleSetRollingUpgradesOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2017_12_01.aio.operations.VirtualMachineScaleSetVMsOperations - :ivar log_analytics: LogAnalyticsOperations operations - :vartype log_analytics: azure.mgmt.compute.v2017_12_01.aio.operations.LogAnalyticsOperations - :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations - :vartype virtual_machine_run_commands: - azure.mgmt.compute.v2017_12_01.aio.operations.VirtualMachineRunCommandsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2017-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2017-12-01") - self.availability_sets = AvailabilitySetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.virtual_machine_images = VirtualMachineImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2017-12-01") - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2017-12-01") - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.log_analytics = LogAnalyticsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-12-01" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/_configuration.py deleted file mode 100644 index 54732e987592..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2017-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2017-12-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/__init__.py deleted file mode 100644 index 120054eeda4f..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/__init__.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import Operations # type: ignore -from ._operations import AvailabilitySetsOperations # type: ignore -from ._operations import VirtualMachineExtensionImagesOperations # type: ignore -from ._operations import VirtualMachineExtensionsOperations # type: ignore -from ._operations import VirtualMachinesOperations # type: ignore -from ._operations import VirtualMachineImagesOperations # type: ignore -from ._operations import UsageOperations # type: ignore -from ._operations import VirtualMachineSizesOperations # type: ignore -from ._operations import ImagesOperations # type: ignore -from ._operations import VirtualMachineScaleSetsOperations # type: ignore -from ._operations import VirtualMachineScaleSetExtensionsOperations # type: ignore -from ._operations import VirtualMachineScaleSetRollingUpgradesOperations # type: ignore -from ._operations import VirtualMachineScaleSetVMsOperations # type: ignore -from ._operations import LogAnalyticsOperations # type: ignore -from ._operations import VirtualMachineRunCommandsOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AvailabilitySetsOperations", - "VirtualMachineExtensionImagesOperations", - "VirtualMachineExtensionsOperations", - "VirtualMachinesOperations", - "VirtualMachineImagesOperations", - "UsageOperations", - "VirtualMachineSizesOperations", - "ImagesOperations", - "VirtualMachineScaleSetsOperations", - "VirtualMachineScaleSetExtensionsOperations", - "VirtualMachineScaleSetRollingUpgradesOperations", - "VirtualMachineScaleSetVMsOperations", - "LogAnalyticsOperations", - "VirtualMachineRunCommandsOperations", -] -__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/v2017_12_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_operations.py deleted file mode 100644 index 2072880c8dee..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_operations.py +++ /dev/null @@ -1,11071 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, Dict, IO, List, Literal, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import ( - build_availability_sets_create_or_update_request, - build_availability_sets_delete_request, - build_availability_sets_get_request, - build_availability_sets_list_available_sizes_request, - build_availability_sets_list_by_subscription_request, - build_availability_sets_list_request, - build_availability_sets_update_request, - build_images_create_or_update_request, - build_images_delete_request, - build_images_get_request, - build_images_list_by_resource_group_request, - build_images_list_request, - build_images_update_request, - build_log_analytics_export_request_rate_by_interval_request, - build_log_analytics_export_throttled_requests_request, - build_operations_list_request, - build_usage_list_request, - build_virtual_machine_extension_images_get_request, - build_virtual_machine_extension_images_list_types_request, - build_virtual_machine_extension_images_list_versions_request, - build_virtual_machine_extensions_create_or_update_request, - build_virtual_machine_extensions_delete_request, - build_virtual_machine_extensions_get_request, - build_virtual_machine_extensions_update_request, - build_virtual_machine_images_get_request, - build_virtual_machine_images_list_offers_request, - build_virtual_machine_images_list_publishers_request, - build_virtual_machine_images_list_request, - build_virtual_machine_images_list_skus_request, - build_virtual_machine_run_commands_get_request, - build_virtual_machine_run_commands_list_request, - build_virtual_machine_scale_set_extensions_create_or_update_request, - build_virtual_machine_scale_set_extensions_delete_request, - build_virtual_machine_scale_set_extensions_get_request, - build_virtual_machine_scale_set_extensions_list_request, - build_virtual_machine_scale_set_rolling_upgrades_cancel_request, - build_virtual_machine_scale_set_rolling_upgrades_get_latest_request, - build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request, - build_virtual_machine_scale_set_vms_deallocate_request, - build_virtual_machine_scale_set_vms_delete_request, - build_virtual_machine_scale_set_vms_get_instance_view_request, - build_virtual_machine_scale_set_vms_get_request, - build_virtual_machine_scale_set_vms_list_request, - build_virtual_machine_scale_set_vms_perform_maintenance_request, - build_virtual_machine_scale_set_vms_power_off_request, - build_virtual_machine_scale_set_vms_redeploy_request, - build_virtual_machine_scale_set_vms_reimage_all_request, - build_virtual_machine_scale_set_vms_reimage_request, - build_virtual_machine_scale_set_vms_restart_request, - build_virtual_machine_scale_set_vms_start_request, - build_virtual_machine_scale_set_vms_update_request, - build_virtual_machine_scale_sets_create_or_update_request, - build_virtual_machine_scale_sets_deallocate_request, - build_virtual_machine_scale_sets_delete_instances_request, - build_virtual_machine_scale_sets_delete_request, - build_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk_request, - build_virtual_machine_scale_sets_get_instance_view_request, - build_virtual_machine_scale_sets_get_os_upgrade_history_request, - build_virtual_machine_scale_sets_get_request, - build_virtual_machine_scale_sets_list_all_request, - build_virtual_machine_scale_sets_list_request, - build_virtual_machine_scale_sets_list_skus_request, - build_virtual_machine_scale_sets_perform_maintenance_request, - build_virtual_machine_scale_sets_power_off_request, - build_virtual_machine_scale_sets_redeploy_request, - build_virtual_machine_scale_sets_reimage_all_request, - build_virtual_machine_scale_sets_reimage_request, - build_virtual_machine_scale_sets_restart_request, - build_virtual_machine_scale_sets_start_request, - build_virtual_machine_scale_sets_update_instances_request, - build_virtual_machine_scale_sets_update_request, - build_virtual_machine_sizes_list_request, - build_virtual_machines_capture_request, - build_virtual_machines_convert_to_managed_disks_request, - build_virtual_machines_create_or_update_request, - build_virtual_machines_deallocate_request, - build_virtual_machines_delete_request, - build_virtual_machines_generalize_request, - build_virtual_machines_get_extensions_request, - build_virtual_machines_get_request, - build_virtual_machines_instance_view_request, - build_virtual_machines_list_all_request, - build_virtual_machines_list_available_sizes_request, - build_virtual_machines_list_by_location_request, - build_virtual_machines_list_request, - build_virtual_machines_perform_maintenance_request, - build_virtual_machines_power_off_request, - build_virtual_machines_redeploy_request, - build_virtual_machines_restart_request, - build_virtual_machines_run_command_request, - build_virtual_machines_start_request, - build_virtual_machines_update_request, -) -from .._configuration import ComputeManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.aio.ComputeManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.ComputeOperationValue"]: - """Gets a list of compute operations. - - :return: An iterator like instance of either ComputeOperationValue or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.ComputeOperationValue] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.ComputeOperationListResult] = 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_operations_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async 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, 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 AvailabilitySetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.aio.ComputeManagementClient`'s - :attr:`availability_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySet, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Is either a - AvailabilitySet type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySet") - - _request = build_availability_sets_create_or_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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, - availability_set_name: str, - parameters: _models.AvailabilitySetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySetUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Is either a - AvailabilitySetUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySetUpdate or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySetUpdate") - - _request = build_availability_sets_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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 - ) -> Optional[_models.OperationStatusResponse]: - """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: OperationStatusResponse or None or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse or 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 "2017-12-01")) - cls: ClsType[Optional[_models.OperationStatusResponse]] = kwargs.pop("cls", None) - - _request = build_availability_sets_delete_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("OperationStatusResponse", 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, 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.v2017_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", 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) - - _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("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription( - self, *, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. - - :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.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, 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(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets 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 AvailabilitySet or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, 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_available_sizes( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes that can be used to create a new virtual machine in - an existing availability set. - - :param resource_group_name: The name of the resource group. Required. - :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.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_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 - - if response.status_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 VirtualMachineExtensionImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_extension_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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. - - :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.v2017_12_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 "2017-12-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 = 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 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 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.v2017_12_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 "2017-12-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - - _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) - - _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 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 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.v2017_12_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 "2017-12-01")) - 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 = 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 - - -class VirtualMachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, 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 "2017-12-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, "VirtualMachineExtension") - - _request = build_virtual_machine_extensions_create_or_update_request( - resource_group_name=resource_group_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, - 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) - - 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, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2017_12_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 VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_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 create or 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 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] - :keyword content_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.v2017_12_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2017_12_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.v2017_12_01.models.VirtualMachineExtension] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2017-12-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( - resource_group_name=resource_group_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, - 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, - 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. - - :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: - ~azure.mgmt.compute.v2017_12_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.v2017_12_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.v2017_12_01.models.VirtualMachineExtension] - :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.v2017_12_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.v2017_12_01.models.VirtualMachineExtension] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2017-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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) - - _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, vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """The operation to delete 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 deleted. - 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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, - vm_extension_name=vm_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, - 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.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_get_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -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.v2017_12_01.aio.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_extensions( - 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.v2017_12_01.models.VirtualMachineExtensionsListResult - :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 "2017-12-01")) - cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machines_get_extensions_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 - - @distributed_trace - def list_by_location(self, location: str, **kwargs: Any) -> AsyncItemPaged["_models.VirtualMachine"]: - """Gets all the virtual machines under the specified subscription for the specified location. - - :param location: The location for which virtual machines under the subscription are queried. - Required. - :type location: str - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-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 - - 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) - - 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 _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, - 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 "2017-12-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, "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 = 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_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. 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.v2017_12_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.v2017_12_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. 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.v2017_12_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. 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.v2017_12_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.v2017_12_01.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-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 - ) - 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) - 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": "azure-async-operation"}, **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 _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, 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 "2017-12-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, - 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) - - 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, - vm_name: str, - parameters: _models.VirtualMachine, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to create or 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 Create Virtual Machine operation. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachine - :keyword content_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.v2017_12_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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to create or 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 Create 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 VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to create or 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 Create Virtual Machine operation. Is either a - VirtualMachine type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachine or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_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 "2017-12-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, - 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, **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]], - **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 "2017-12-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, - 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) - - 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, - vm_name: str, - parameters: _models.VirtualMachineUpdate, - *, - 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. 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.v2017_12_01.models.VirtualMachineUpdate - :keyword content_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.v2017_12_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - 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. 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 content_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.v2017_12_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]], - **kwargs: Any - ) -> AsyncLROPoller[_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.v2017_12_01.models.VirtualMachineUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_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 "2017-12-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, - 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, **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, **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 "2017-12-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, - 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, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """The operation to delete 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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: Literal["instanceView"] = "instanceView", **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) - - _request = build_virtual_machines_get_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def instance_view( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> _models.VirtualMachineInstanceView: - """Retrieves information about the run-time state of a virtual machine. - - :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.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) - - _request = build_virtual_machines_instance_view_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineInstanceView", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _convert_to_managed_disks_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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_convert_to_managed_disks_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_convert_to_managed_disks( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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. - :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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _deallocate_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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-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, - 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, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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 - ) -> _models.OperationStatusResponse: - """Sets the state of the virtual machine to generalized. - - :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: OperationStatusResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse - :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 "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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) - - deserialized = self._deserialize("OperationStatusResponse", 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) -> AsyncItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-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, - 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("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) - - 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) -> AsyncItemPaged["_models.VirtualMachine"]: - """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. - - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-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, - 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("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) - - 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_available_sizes( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes to which the specified virtual machine can be - resized. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_available_sizes_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 - - if response.status_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_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 "2017-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_power_off_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_power_off( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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. - :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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._power_off_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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]: - 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 "2017-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_restart_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - 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_restart( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """The operation to restart 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._restart_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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]: - 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 "2017-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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_start( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_redeploy_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_redeploy( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._redeploy_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _perform_maintenance_initial( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> 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 "2017-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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_perform_maintenance( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """The operation to perform maintenance on 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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_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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _run_command_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> 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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RunCommandInput") - - _request = build_virtual_machines_run_command_request( - 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) - - 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_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.RunCommandInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_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.v2017_12_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._run_command_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.v2017_12_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 "2017-12-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.v2017_12_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 "2017-12-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.v2017_12_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 "2017-12-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. - - :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.v2017_12_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 "2017-12-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) - 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. - - :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.v2017_12_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 "2017-12-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _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) - - _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 - - -class UsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.aio.ComputeManagementClient`'s - :attr:`usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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 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.v2017_12_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 "2017-12-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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ListUsagesResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class VirtualMachineSizesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes for a subscription in a location. - - :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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_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 - - 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 - - if response.status_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 ImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.aio.ComputeManagementClient`'s - :attr:`images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> 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 "2017-12-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) - - 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, - image_name: str, - parameters: _models.Image, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Create or update an image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param 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.v2017_12_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Create or update an image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param 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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.Image] - :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. - - :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 - :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.v2017_12_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.v2017_12_01.models.Image] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._create_or_update_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Image]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, 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 "2017-12-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, "ImageUpdate") - - _request = build_images_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) - - 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, - image_name: str, - parameters: _models.ImageUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Update 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 - :param parameters: Parameters supplied to the Update Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Update 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 - :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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Update 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 - :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.v2017_12_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.v2017_12_01.models.Image] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Image]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial(self, resource_group_name: str, image_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_images_delete_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, image_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Deletes 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 - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - image_name=image_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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.v2017_12_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 "2017-12-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 = 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("Image", 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) -> AsyncItemPaged["_models.Image"]: - """Gets the list of images 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 Image or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-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 - - 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) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - parameters: Union[_models.VirtualMachineScaleSet, 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 "2017-12-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, - 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) - - 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, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. 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.v2017_12_01.models.VirtualMachineScaleSet - :keyword content_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.v2017_12_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. 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: IO[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 VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 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.v2017_12_01.models.VirtualMachineScaleSet or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_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 "2017-12-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, - 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]], - **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 "2017-12-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, "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, - 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, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSetUpdate, - *, - 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. 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.v2017_12_01.models.VirtualMachineScaleSetUpdate - :keyword content_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.v2017_12_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], - *, - 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. 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: IO[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 VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Update 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 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.v2017_12_01.models.VirtualMachineScaleSetUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_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 "2017-12-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, - 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 _delete_initial( - self, resource_group_name: str, vm_scale_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 "2017-12-01")) - cls: ClsType[AsyncIterator[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, - 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, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, **kwargs: Any - ) -> _models.VirtualMachineScaleSet: - """Display information about a 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 - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_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 "2017-12-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, - 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 _deallocate_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 "2017-12-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_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_deallocate( - 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[_models.OperationStatusResponse]: - """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. - :type 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.v2017_12_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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_deallocate( - 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[_models.OperationStatusResponse]: - """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. - :type 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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, - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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. - :type 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.v2017_12_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-12-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: - _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, - 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_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_12_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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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. - 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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.v2017_12_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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.v2017_12_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 "2017-12-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) -> AsyncItemPaged["_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 - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-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_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("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 - def list_all(self, **kwargs: Any) -> AsyncItemPaged["_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.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = 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_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("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) - - 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_skus( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineScaleSetSku"]: - """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM - instances allowed for each SKU. - - :param resource_group_name: The name of the resource group. Required. - :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.v2017_12_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 "2017-12-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 - - 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) - - @distributed_trace - def get_os_upgrade_history( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.UpgradeOperationHistoricalStatusInfo"]: - """Gets list of OS upgrades 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 - :return: An iterator like instance of either UpgradeOperationHistoricalStatusInfo or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-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 _power_off_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 "2017-12-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_power_off_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_power_off( - 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[_models.OperationStatusResponse]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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.v2017_12_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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_power_off( - 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[_models.OperationStatusResponse]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async 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, - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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.v2017_12_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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 "2017-12-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_restart_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_12_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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, - 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 "2017-12-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 - 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_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[_models.OperationStatusResponse]: - """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.v2017_12_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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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.v2017_12_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, - 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 "2017-12-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_redeploy_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_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[_models.OperationStatusResponse]: - """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.v2017_12_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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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 AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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.v2017_12_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._redeploy_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _perform_maintenance_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-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_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_perform_maintenance( - 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[_models.OperationStatusResponse]: - """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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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.v2017_12_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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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 - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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.v2017_12_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-12-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: - _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, - 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_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_12_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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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_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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Reimages (upgrade the operating system) 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.v2017_12_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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_reimage( - 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[_models.OperationStatusResponse]: - """Reimages (upgrade the operating system) 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Reimages (upgrade the operating system) 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.v2017_12_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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_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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _reimage_all_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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.v2017_12_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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_all_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, **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 - :return: RecoveryWalkResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_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 "2017-12-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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RecoveryWalkResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -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.v2017_12_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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2017-12-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") - - _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, - 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) - - 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, - 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. - - :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.v2017_12_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.v2017_12_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2017_12_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtension, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to create or update an extension. - - :param resource_group_name: The name of the resource group. Required. - :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.v2017_12_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.v2017_12_01.models.VirtualMachineScaleSetExtension] - :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 "2017-12-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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-12-01")) - cls: ClsType[AsyncIterator[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, - 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, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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.v2017_12_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 "2017-12-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 - ) -> AsyncItemPaged["_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.v2017_12_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 "2017-12-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. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> 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 "2017-12-01")) - 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, - 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 - - @distributed_trace_async - async def begin_cancel( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Cancels the current 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: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _start_os_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-12-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, - 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) - - _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_start_os_upgrade( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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. Required. - :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.v2017_12_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 "2017-12-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 = 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("RollingUpgradeStatusInfo", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class VirtualMachineScaleSetVMsOperations: # 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.v2017_12_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _reimage_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **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 "2017-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_reimage_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - 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 - - @distributed_trace_async - async def begin_reimage( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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 "2017-12-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) - - 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_reimage_all( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. - This operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _deallocate_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_deallocate( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and - releases the compute resources it uses. You are not billed for the compute resources of this - virtual machine once it is deallocated. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], - **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 "2017-12-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, "VirtualMachineScaleSetVM") - - _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, - 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( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.VirtualMachineScaleSetVM, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVM - :keyword content_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) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - 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 VirtualMachineScaleSetVM or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVM] - :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, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. - Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVM or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVM or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVM] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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, - 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("VirtualMachineScaleSetVM", 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.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 - ) - - async def _delete_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 "2017-12-01")) - 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, - 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, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Deletes 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: An instance of AsyncLROPoller that returns either OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, **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 - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_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 "2017-12-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, - 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("VirtualMachineScaleSetVM", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_instance_view( - self, resource_group_name: str, vm_scale_set_name: str, 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.v2017_12_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 "2017-12-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 - ) -> AsyncItemPaged["_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.v2017_12_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 "2017-12-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, **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 "2017-12-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, - 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, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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, - 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 "2017-12-01")) - cls: ClsType[AsyncIterator[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 = 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_restart( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """Restarts 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - 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 - ) -> 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 "2017-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_start_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - 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[_models.OperationStatusResponse]: - """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 - :param vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _redeploy_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_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, - 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_redeploy( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._redeploy_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _perform_maintenance_initial( - self, resource_group_name: str, vm_scale_set_name: str, 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 "2017-12-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) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_perform_maintenance( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class LogAnalyticsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.aio.ComputeManagementClient`'s - :attr:`log_analytics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _export_request_rate_by_interval_initial( - self, location: str, parameters: Union[_models.RequestRateByIntervalInput, 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 "2017-12-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, "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, - ) - _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_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 location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. - Required. - :type parameters: ~azure.mgmt.compute.v2017_12_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.v2017_12_01.models.LogAnalyticsOperationResult] - :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. - - :param location: The location upon which virtual-machine-sizes is queried. 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.v2017_12_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 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.v2017_12_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.v2017_12_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 "2017-12-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._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, - **kwargs - ) - 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) - 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LogAnalyticsOperationResult]( - 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 - ) -> 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 "2017-12-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, - 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_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.v2017_12_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.v2017_12_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.v2017_12_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. - - :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.v2017_12_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.v2017_12_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 "2017-12-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._export_throttled_requests_initial( - location=location, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - 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) - 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LogAnalyticsOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineRunCommandsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.RunCommandDocumentBase"]: - """Lists all available run commands for a subscription in a location. - - :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 - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_run_commands_list_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RunCommandListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, location: str, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: - """Gets specific run command for a subscription in a location. - - :param location: The 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.v2017_12_01.models.RunCommandDocument - :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 "2017-12-01")) - cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) - - _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, - 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("RunCommandDocument", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/__init__.py deleted file mode 100644 index da880cc1d752..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/__init__.py +++ /dev/null @@ -1,350 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - AdditionalUnattendContent, - ApiEntityReference, - ApiError, - ApiErrorBase, - AutoOSUpgradePolicy, - AvailabilitySet, - AvailabilitySetListResult, - AvailabilitySetUpdate, - BootDiagnostics, - BootDiagnosticsInstanceView, - ComputeLongRunningOperationProperties, - ComputeOperationListResult, - ComputeOperationValue, - DataDisk, - DataDiskImage, - DiagnosticsProfile, - DiskEncryptionSettings, - DiskInstanceView, - HardwareProfile, - Image, - ImageDataDisk, - ImageListResult, - ImageOSDisk, - ImageReference, - ImageStorageProfile, - ImageUpdate, - InnerError, - InstanceViewStatus, - KeyVaultKeyReference, - KeyVaultSecretReference, - LinuxConfiguration, - ListUsagesResult, - LogAnalyticsInputBase, - LogAnalyticsOperationResult, - LogAnalyticsOutput, - MaintenanceRedeployStatus, - ManagedDiskParameters, - NetworkInterfaceReference, - NetworkProfile, - OSDisk, - OSDiskImage, - OSProfile, - OperationStatusResponse, - Plan, - PurchasePlan, - RecoveryWalkResponse, - RequestRateByIntervalInput, - Resource, - RollbackStatusInfo, - RollingUpgradePolicy, - RollingUpgradeProgressInfo, - RollingUpgradeRunningStatus, - RollingUpgradeStatusInfo, - RunCommandDocument, - RunCommandDocumentBase, - RunCommandInput, - RunCommandInputParameter, - RunCommandListResult, - RunCommandParameterDefinition, - RunCommandResult, - Sku, - SshConfiguration, - SshPublicKey, - StorageProfile, - SubResource, - SubResourceReadOnly, - ThrottledRequestsInput, - UpdateResource, - UpgradeOperationHistoricalStatusInfo, - UpgradeOperationHistoricalStatusInfoProperties, - UpgradeOperationHistoryStatus, - UpgradePolicy, - Usage, - UsageName, - VaultCertificate, - VaultSecretGroup, - VirtualHardDisk, - VirtualMachine, - VirtualMachineAgentInstanceView, - VirtualMachineCaptureParameters, - VirtualMachineCaptureResult, - VirtualMachineExtension, - VirtualMachineExtensionHandlerInstanceView, - VirtualMachineExtensionImage, - VirtualMachineExtensionInstanceView, - VirtualMachineExtensionUpdate, - VirtualMachineExtensionsListResult, - VirtualMachineHealthStatus, - VirtualMachineIdentity, - VirtualMachineImage, - VirtualMachineImageResource, - VirtualMachineInstanceView, - VirtualMachineListResult, - VirtualMachineScaleSet, - VirtualMachineScaleSetDataDisk, - VirtualMachineScaleSetExtension, - VirtualMachineScaleSetExtensionListResult, - VirtualMachineScaleSetExtensionProfile, - VirtualMachineScaleSetIPConfiguration, - VirtualMachineScaleSetIdentity, - VirtualMachineScaleSetInstanceView, - VirtualMachineScaleSetInstanceViewStatusesSummary, - VirtualMachineScaleSetListOSUpgradeHistory, - VirtualMachineScaleSetListResult, - VirtualMachineScaleSetListSkusResult, - VirtualMachineScaleSetListWithLinkResult, - VirtualMachineScaleSetManagedDiskParameters, - VirtualMachineScaleSetNetworkConfiguration, - VirtualMachineScaleSetNetworkConfigurationDnsSettings, - VirtualMachineScaleSetNetworkProfile, - VirtualMachineScaleSetOSDisk, - VirtualMachineScaleSetOSProfile, - VirtualMachineScaleSetPublicIPAddressConfiguration, - VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings, - VirtualMachineScaleSetSku, - VirtualMachineScaleSetSkuCapacity, - VirtualMachineScaleSetStorageProfile, - VirtualMachineScaleSetUpdate, - VirtualMachineScaleSetUpdateIPConfiguration, - VirtualMachineScaleSetUpdateNetworkConfiguration, - VirtualMachineScaleSetUpdateNetworkProfile, - VirtualMachineScaleSetUpdateOSDisk, - VirtualMachineScaleSetUpdateOSProfile, - VirtualMachineScaleSetUpdatePublicIPAddressConfiguration, - VirtualMachineScaleSetUpdateStorageProfile, - VirtualMachineScaleSetUpdateVMProfile, - VirtualMachineScaleSetVM, - VirtualMachineScaleSetVMExtensionsSummary, - VirtualMachineScaleSetVMInstanceIDs, - VirtualMachineScaleSetVMInstanceRequiredIDs, - VirtualMachineScaleSetVMInstanceView, - VirtualMachineScaleSetVMListResult, - VirtualMachineScaleSetVMProfile, - VirtualMachineSize, - VirtualMachineSizeListResult, - VirtualMachineStatusCodeCount, - VirtualMachineUpdate, - WinRMConfiguration, - WinRMListener, - WindowsConfiguration, -) - -from ._compute_management_client_enums import ( # type: ignore - CachingTypes, - DiskCreateOptionTypes, - IPVersion, - IntervalInMins, - MaintenanceOperationResultCodeTypes, - OperatingSystemStateTypes, - OperatingSystemTypes, - ProtocolTypes, - ResourceIdentityType, - RollingUpgradeActionType, - RollingUpgradeStatusCode, - SettingNames, - StatusLevelTypes, - StorageAccountTypes, - UpgradeMode, - UpgradeOperationInvoker, - UpgradeState, - VirtualMachineEvictionPolicyTypes, - VirtualMachinePriorityTypes, - VirtualMachineScaleSetSkuScaleType, - VirtualMachineSizeTypes, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AdditionalUnattendContent", - "ApiEntityReference", - "ApiError", - "ApiErrorBase", - "AutoOSUpgradePolicy", - "AvailabilitySet", - "AvailabilitySetListResult", - "AvailabilitySetUpdate", - "BootDiagnostics", - "BootDiagnosticsInstanceView", - "ComputeLongRunningOperationProperties", - "ComputeOperationListResult", - "ComputeOperationValue", - "DataDisk", - "DataDiskImage", - "DiagnosticsProfile", - "DiskEncryptionSettings", - "DiskInstanceView", - "HardwareProfile", - "Image", - "ImageDataDisk", - "ImageListResult", - "ImageOSDisk", - "ImageReference", - "ImageStorageProfile", - "ImageUpdate", - "InnerError", - "InstanceViewStatus", - "KeyVaultKeyReference", - "KeyVaultSecretReference", - "LinuxConfiguration", - "ListUsagesResult", - "LogAnalyticsInputBase", - "LogAnalyticsOperationResult", - "LogAnalyticsOutput", - "MaintenanceRedeployStatus", - "ManagedDiskParameters", - "NetworkInterfaceReference", - "NetworkProfile", - "OSDisk", - "OSDiskImage", - "OSProfile", - "OperationStatusResponse", - "Plan", - "PurchasePlan", - "RecoveryWalkResponse", - "RequestRateByIntervalInput", - "Resource", - "RollbackStatusInfo", - "RollingUpgradePolicy", - "RollingUpgradeProgressInfo", - "RollingUpgradeRunningStatus", - "RollingUpgradeStatusInfo", - "RunCommandDocument", - "RunCommandDocumentBase", - "RunCommandInput", - "RunCommandInputParameter", - "RunCommandListResult", - "RunCommandParameterDefinition", - "RunCommandResult", - "Sku", - "SshConfiguration", - "SshPublicKey", - "StorageProfile", - "SubResource", - "SubResourceReadOnly", - "ThrottledRequestsInput", - "UpdateResource", - "UpgradeOperationHistoricalStatusInfo", - "UpgradeOperationHistoricalStatusInfoProperties", - "UpgradeOperationHistoryStatus", - "UpgradePolicy", - "Usage", - "UsageName", - "VaultCertificate", - "VaultSecretGroup", - "VirtualHardDisk", - "VirtualMachine", - "VirtualMachineAgentInstanceView", - "VirtualMachineCaptureParameters", - "VirtualMachineCaptureResult", - "VirtualMachineExtension", - "VirtualMachineExtensionHandlerInstanceView", - "VirtualMachineExtensionImage", - "VirtualMachineExtensionInstanceView", - "VirtualMachineExtensionUpdate", - "VirtualMachineExtensionsListResult", - "VirtualMachineHealthStatus", - "VirtualMachineIdentity", - "VirtualMachineImage", - "VirtualMachineImageResource", - "VirtualMachineInstanceView", - "VirtualMachineListResult", - "VirtualMachineScaleSet", - "VirtualMachineScaleSetDataDisk", - "VirtualMachineScaleSetExtension", - "VirtualMachineScaleSetExtensionListResult", - "VirtualMachineScaleSetExtensionProfile", - "VirtualMachineScaleSetIPConfiguration", - "VirtualMachineScaleSetIdentity", - "VirtualMachineScaleSetInstanceView", - "VirtualMachineScaleSetInstanceViewStatusesSummary", - "VirtualMachineScaleSetListOSUpgradeHistory", - "VirtualMachineScaleSetListResult", - "VirtualMachineScaleSetListSkusResult", - "VirtualMachineScaleSetListWithLinkResult", - "VirtualMachineScaleSetManagedDiskParameters", - "VirtualMachineScaleSetNetworkConfiguration", - "VirtualMachineScaleSetNetworkConfigurationDnsSettings", - "VirtualMachineScaleSetNetworkProfile", - "VirtualMachineScaleSetOSDisk", - "VirtualMachineScaleSetOSProfile", - "VirtualMachineScaleSetPublicIPAddressConfiguration", - "VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings", - "VirtualMachineScaleSetSku", - "VirtualMachineScaleSetSkuCapacity", - "VirtualMachineScaleSetStorageProfile", - "VirtualMachineScaleSetUpdate", - "VirtualMachineScaleSetUpdateIPConfiguration", - "VirtualMachineScaleSetUpdateNetworkConfiguration", - "VirtualMachineScaleSetUpdateNetworkProfile", - "VirtualMachineScaleSetUpdateOSDisk", - "VirtualMachineScaleSetUpdateOSProfile", - "VirtualMachineScaleSetUpdatePublicIPAddressConfiguration", - "VirtualMachineScaleSetUpdateStorageProfile", - "VirtualMachineScaleSetUpdateVMProfile", - "VirtualMachineScaleSetVM", - "VirtualMachineScaleSetVMExtensionsSummary", - "VirtualMachineScaleSetVMInstanceIDs", - "VirtualMachineScaleSetVMInstanceRequiredIDs", - "VirtualMachineScaleSetVMInstanceView", - "VirtualMachineScaleSetVMListResult", - "VirtualMachineScaleSetVMProfile", - "VirtualMachineSize", - "VirtualMachineSizeListResult", - "VirtualMachineStatusCodeCount", - "VirtualMachineUpdate", - "WinRMConfiguration", - "WinRMListener", - "WindowsConfiguration", - "CachingTypes", - "DiskCreateOptionTypes", - "IPVersion", - "IntervalInMins", - "MaintenanceOperationResultCodeTypes", - "OperatingSystemStateTypes", - "OperatingSystemTypes", - "ProtocolTypes", - "ResourceIdentityType", - "RollingUpgradeActionType", - "RollingUpgradeStatusCode", - "SettingNames", - "StatusLevelTypes", - "StorageAccountTypes", - "UpgradeMode", - "UpgradeOperationInvoker", - "UpgradeState", - "VirtualMachineEvictionPolicyTypes", - "VirtualMachinePriorityTypes", - "VirtualMachineScaleSetSkuScaleType", - "VirtualMachineSizeTypes", -] -__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/v2017_12_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/_compute_management_client_enums.py deleted file mode 100644 index 16a7ce23d0b3..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/_compute_management_client_enums.py +++ /dev/null @@ -1,380 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** :code:`
    `\\ - :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for Standard storage. - ReadOnly for Premium storage**. - """ - - NONE = "None" - READ_ONLY = "ReadOnly" - READ_WRITE = "ReadWrite" - - -class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies how the virtual machine should be created.\\ :code:`
    `\\ :code:`
    ` Possible - values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value is used when you are - using a specialized disk to create the virtual machine.\\ :code:`
    `\\ :code:`
    ` - **FromImage** \\u2013 This value is used when you are using an image to create the virtual - machine. If you are using a platform image, you also use the imageReference element described - above. If you are using a marketplace image, you also use the plan element previously - described. - """ - - FROM_IMAGE = "FromImage" - EMPTY = "Empty" - ATTACH = "Attach" - - -class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Interval value in minutes used to create LogAnalytics call rate logs.""" - - THREE_MINS = "ThreeMins" - FIVE_MINS = "FiveMins" - THIRTY_MINS = "ThirtyMins" - SIXTY_MINS = "SixtyMins" - - -class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """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'. - """ - - I_PV4 = "IPv4" - I_PV6 = "IPv6" - - -class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The Last Maintenance Operation Result Code.""" - - NONE = "None" - RETRY_LATER = "RetryLater" - MAINTENANCE_ABORTED = "MaintenanceAborted" - MAINTENANCE_COMPLETED = "MaintenanceCompleted" - - -class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The OS State.""" - - GENERALIZED = "Generalized" - SPECIALIZED = "Specialized" - - -class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The operating system of the osDiskImage.""" - - WINDOWS = "Windows" - LINUX = "Linux" - - -class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the protocol of listener. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. - """ - - HTTP = "Http" - HTTPS = "Https" - - -class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' - includes both an implicitly created identity and a set of user assigned identities. The type - 'None' will remove any identities from the virtual machine. - """ - - SYSTEM_ASSIGNED = "SystemAssigned" - USER_ASSIGNED = "UserAssigned" - SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" - NONE = "None" - - -class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The last action performed on the rolling upgrade.""" - - START = "Start" - CANCEL = "Cancel" - - -class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Code indicating the current status of the upgrade.""" - - ROLLING_FORWARD = "RollingForward" - CANCELLED = "Cancelled" - COMPLETED = "Completed" - FAULTED = "Faulted" - - -class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the name of the setting to which the content applies. Possible values are: - FirstLogonCommands and AutoLogon. - """ - - AUTO_LOGON = "AutoLogon" - FIRST_LOGON_COMMANDS = "FirstLogonCommands" - - -class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The level code.""" - - INFO = "Info" - WARNING = "Warning" - ERROR = "Error" - - -class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the storage account type for the managed disk. Possible values are: Standard_LRS or - Premium_LRS. - """ - - STANDARD_LRS = "Standard_LRS" - PREMIUM_LRS = "Premium_LRS" - - -class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the mode of an upgrade to virtual machines in the scale set.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Manual** - You control - the application of updates to virtual machines in the scale set. You do this by using the - manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - All virtual machines in - the scale set are automatically updated at the same time. - """ - - AUTOMATIC = "Automatic" - MANUAL = "Manual" - ROLLING = "Rolling" - - -class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Invoker of the Upgrade Operation.""" - - UNKNOWN = "Unknown" - USER = "User" - PLATFORM = "Platform" - - -class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Code indicating the current status of the upgrade.""" - - ROLLING_FORWARD = "RollingForward" - CANCELLED = "Cancelled" - COMPLETED = "Completed" - FAULTED = "Faulted" - - -class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the eviction policy for virtual machines in a low priority scale set. :code:`
    `\\ - :code:`
    `Minimum api-version: 2017-10-30-preview. - """ - - DEALLOCATE = "Deallocate" - DELETE = "Delete" - - -class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the priority for the virtual machines in the scale set. :code:`
    `\\ - :code:`
    `Minimum api-version: 2017-10-30-preview. - """ - - REGULAR = "Regular" - LOW = "Low" - - -class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scale type applicable to the sku.""" - - AUTOMATIC = "Automatic" - NONE = "None" - - -class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the size of the virtual machine. For more information about virtual machine sizes, - see `Sizes for virtual machines - `_. - :code:`
    `\\ :code:`
    ` The available VM sizes depend on region and availability set. For a - list of available sizes use these APIs: :code:`
    `\\ :code:`
    ` `List all available - virtual machine sizes in an availability set - `_ - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in a region - `_ :code:`
    `\\ - :code:`
    ` `List all available virtual machine sizes for resizing - `_. - """ - - BASIC_A0 = "Basic_A0" - BASIC_A1 = "Basic_A1" - BASIC_A2 = "Basic_A2" - BASIC_A3 = "Basic_A3" - BASIC_A4 = "Basic_A4" - STANDARD_A0 = "Standard_A0" - STANDARD_A1 = "Standard_A1" - STANDARD_A2 = "Standard_A2" - STANDARD_A3 = "Standard_A3" - STANDARD_A4 = "Standard_A4" - STANDARD_A5 = "Standard_A5" - STANDARD_A6 = "Standard_A6" - STANDARD_A7 = "Standard_A7" - STANDARD_A8 = "Standard_A8" - STANDARD_A9 = "Standard_A9" - STANDARD_A10 = "Standard_A10" - STANDARD_A11 = "Standard_A11" - STANDARD_A1_V2 = "Standard_A1_v2" - STANDARD_A2_V2 = "Standard_A2_v2" - STANDARD_A4_V2 = "Standard_A4_v2" - STANDARD_A8_V2 = "Standard_A8_v2" - STANDARD_A2_M_V2 = "Standard_A2m_v2" - STANDARD_A4_M_V2 = "Standard_A4m_v2" - STANDARD_A8_M_V2 = "Standard_A8m_v2" - STANDARD_B1_S = "Standard_B1s" - STANDARD_B1_MS = "Standard_B1ms" - STANDARD_B2_S = "Standard_B2s" - STANDARD_B2_MS = "Standard_B2ms" - STANDARD_B4_MS = "Standard_B4ms" - STANDARD_B8_MS = "Standard_B8ms" - STANDARD_D1 = "Standard_D1" - STANDARD_D2 = "Standard_D2" - STANDARD_D3 = "Standard_D3" - STANDARD_D4 = "Standard_D4" - STANDARD_D11 = "Standard_D11" - STANDARD_D12 = "Standard_D12" - STANDARD_D13 = "Standard_D13" - STANDARD_D14 = "Standard_D14" - STANDARD_D1_V2 = "Standard_D1_v2" - STANDARD_D2_V2 = "Standard_D2_v2" - STANDARD_D3_V2 = "Standard_D3_v2" - STANDARD_D4_V2 = "Standard_D4_v2" - STANDARD_D5_V2 = "Standard_D5_v2" - STANDARD_D2_V3 = "Standard_D2_v3" - STANDARD_D4_V3 = "Standard_D4_v3" - STANDARD_D8_V3 = "Standard_D8_v3" - STANDARD_D16_V3 = "Standard_D16_v3" - STANDARD_D32_V3 = "Standard_D32_v3" - STANDARD_D64_V3 = "Standard_D64_v3" - STANDARD_D2_S_V3 = "Standard_D2s_v3" - STANDARD_D4_S_V3 = "Standard_D4s_v3" - STANDARD_D8_S_V3 = "Standard_D8s_v3" - STANDARD_D16_S_V3 = "Standard_D16s_v3" - STANDARD_D32_S_V3 = "Standard_D32s_v3" - STANDARD_D64_S_V3 = "Standard_D64s_v3" - STANDARD_D11_V2 = "Standard_D11_v2" - STANDARD_D12_V2 = "Standard_D12_v2" - STANDARD_D13_V2 = "Standard_D13_v2" - STANDARD_D14_V2 = "Standard_D14_v2" - STANDARD_D15_V2 = "Standard_D15_v2" - STANDARD_DS1 = "Standard_DS1" - STANDARD_DS2 = "Standard_DS2" - STANDARD_DS3 = "Standard_DS3" - STANDARD_DS4 = "Standard_DS4" - STANDARD_DS11 = "Standard_DS11" - STANDARD_DS12 = "Standard_DS12" - STANDARD_DS13 = "Standard_DS13" - STANDARD_DS14 = "Standard_DS14" - STANDARD_DS1_V2 = "Standard_DS1_v2" - STANDARD_DS2_V2 = "Standard_DS2_v2" - STANDARD_DS3_V2 = "Standard_DS3_v2" - STANDARD_DS4_V2 = "Standard_DS4_v2" - STANDARD_DS5_V2 = "Standard_DS5_v2" - STANDARD_DS11_V2 = "Standard_DS11_v2" - STANDARD_DS12_V2 = "Standard_DS12_v2" - STANDARD_DS13_V2 = "Standard_DS13_v2" - STANDARD_DS14_V2 = "Standard_DS14_v2" - STANDARD_DS15_V2 = "Standard_DS15_v2" - STANDARD_DS13_4_V2 = "Standard_DS13-4_v2" - STANDARD_DS13_2_V2 = "Standard_DS13-2_v2" - STANDARD_DS14_8_V2 = "Standard_DS14-8_v2" - STANDARD_DS14_4_V2 = "Standard_DS14-4_v2" - STANDARD_E2_V3 = "Standard_E2_v3" - STANDARD_E4_V3 = "Standard_E4_v3" - STANDARD_E8_V3 = "Standard_E8_v3" - STANDARD_E16_V3 = "Standard_E16_v3" - STANDARD_E32_V3 = "Standard_E32_v3" - STANDARD_E64_V3 = "Standard_E64_v3" - STANDARD_E2_S_V3 = "Standard_E2s_v3" - STANDARD_E4_S_V3 = "Standard_E4s_v3" - STANDARD_E8_S_V3 = "Standard_E8s_v3" - STANDARD_E16_S_V3 = "Standard_E16s_v3" - STANDARD_E32_S_V3 = "Standard_E32s_v3" - STANDARD_E64_S_V3 = "Standard_E64s_v3" - STANDARD_E32_16_V3 = "Standard_E32-16_v3" - STANDARD_E32_8_S_V3 = "Standard_E32-8s_v3" - STANDARD_E64_32_S_V3 = "Standard_E64-32s_v3" - STANDARD_E64_16_S_V3 = "Standard_E64-16s_v3" - STANDARD_F1 = "Standard_F1" - STANDARD_F2 = "Standard_F2" - STANDARD_F4 = "Standard_F4" - STANDARD_F8 = "Standard_F8" - STANDARD_F16 = "Standard_F16" - STANDARD_F1_S = "Standard_F1s" - STANDARD_F2_S = "Standard_F2s" - STANDARD_F4_S = "Standard_F4s" - STANDARD_F8_S = "Standard_F8s" - STANDARD_F16_S = "Standard_F16s" - STANDARD_F2_S_V2 = "Standard_F2s_v2" - STANDARD_F4_S_V2 = "Standard_F4s_v2" - STANDARD_F8_S_V2 = "Standard_F8s_v2" - STANDARD_F16_S_V2 = "Standard_F16s_v2" - STANDARD_F32_S_V2 = "Standard_F32s_v2" - STANDARD_F64_S_V2 = "Standard_F64s_v2" - STANDARD_F72_S_V2 = "Standard_F72s_v2" - STANDARD_G1 = "Standard_G1" - STANDARD_G2 = "Standard_G2" - STANDARD_G3 = "Standard_G3" - STANDARD_G4 = "Standard_G4" - STANDARD_G5 = "Standard_G5" - STANDARD_GS1 = "Standard_GS1" - STANDARD_GS2 = "Standard_GS2" - STANDARD_GS3 = "Standard_GS3" - STANDARD_GS4 = "Standard_GS4" - STANDARD_GS5 = "Standard_GS5" - STANDARD_GS4_8 = "Standard_GS4-8" - STANDARD_GS4_4 = "Standard_GS4-4" - STANDARD_GS5_16 = "Standard_GS5-16" - STANDARD_GS5_8 = "Standard_GS5-8" - STANDARD_H8 = "Standard_H8" - STANDARD_H16 = "Standard_H16" - STANDARD_H8_M = "Standard_H8m" - STANDARD_H16_M = "Standard_H16m" - STANDARD_H16_R = "Standard_H16r" - STANDARD_H16_MR = "Standard_H16mr" - STANDARD_L4_S = "Standard_L4s" - STANDARD_L8_S = "Standard_L8s" - STANDARD_L16_S = "Standard_L16s" - STANDARD_L32_S = "Standard_L32s" - STANDARD_M64_S = "Standard_M64s" - STANDARD_M64_MS = "Standard_M64ms" - STANDARD_M128_S = "Standard_M128s" - STANDARD_M128_MS = "Standard_M128ms" - STANDARD_M64_32_MS = "Standard_M64-32ms" - STANDARD_M64_16_MS = "Standard_M64-16ms" - STANDARD_M128_64_MS = "Standard_M128-64ms" - STANDARD_M128_32_MS = "Standard_M128-32ms" - STANDARD_NC6 = "Standard_NC6" - STANDARD_NC12 = "Standard_NC12" - STANDARD_NC24 = "Standard_NC24" - STANDARD_NC24_R = "Standard_NC24r" - STANDARD_NC6_S_V2 = "Standard_NC6s_v2" - STANDARD_NC12_S_V2 = "Standard_NC12s_v2" - STANDARD_NC24_S_V2 = "Standard_NC24s_v2" - STANDARD_NC24_RS_V2 = "Standard_NC24rs_v2" - STANDARD_NC6_S_V3 = "Standard_NC6s_v3" - STANDARD_NC12_S_V3 = "Standard_NC12s_v3" - STANDARD_NC24_S_V3 = "Standard_NC24s_v3" - STANDARD_NC24_RS_V3 = "Standard_NC24rs_v3" - STANDARD_ND6_S = "Standard_ND6s" - STANDARD_ND12_S = "Standard_ND12s" - STANDARD_ND24_S = "Standard_ND24s" - STANDARD_ND24_RS = "Standard_ND24rs" - STANDARD_NV6 = "Standard_NV6" - STANDARD_NV12 = "Standard_NV12" - STANDARD_NV24 = "Standard_NV24" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/_models_py3.py deleted file mode 100644 index 9c90715db427..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/_models_py3.py +++ /dev/null @@ -1,7745 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from collections.abc import MutableMapping -import datetime -from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models -JSON = MutableMapping[str, Any] - - -class AdditionalUnattendContent(_serialization.Model): - """Specifies additional XML formatted information that can be included in the Unattend.xml file, - which is used by Windows Setup. Contents are defined by setting name, component name, and the - pass in which the content is applied. - - :ivar pass_name: The pass name. Currently, the only allowable value is OobeSystem. Default - value is "OobeSystem". - :vartype pass_name: str - :ivar component_name: The component name. Currently, the only allowable value is - Microsoft-Windows-Shell-Setup. Default value is "Microsoft-Windows-Shell-Setup". - :vartype component_name: str - :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon" and - "FirstLogonCommands". - :vartype setting_name: str or ~azure.mgmt.compute.v2017_12_01.models.SettingNames - :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for - the specified path and component. The XML must be less than 4KB and must include the root - element for the setting or feature that is being inserted. - :vartype content: str - """ - - _attribute_map = { - "pass_name": {"key": "passName", "type": "str"}, - "component_name": {"key": "componentName", "type": "str"}, - "setting_name": {"key": "settingName", "type": "str"}, - "content": {"key": "content", "type": "str"}, - } - - def __init__( - self, - *, - pass_name: Optional[Literal["OobeSystem"]] = None, - component_name: Optional[Literal["Microsoft-Windows-Shell-Setup"]] = None, - setting_name: Optional[Union[str, "_models.SettingNames"]] = None, - content: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword pass_name: The pass name. Currently, the only allowable value is OobeSystem. Default - value is "OobeSystem". - :paramtype pass_name: str - :keyword component_name: The component name. Currently, the only allowable value is - Microsoft-Windows-Shell-Setup. Default value is "Microsoft-Windows-Shell-Setup". - :paramtype component_name: str - :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon" and - "FirstLogonCommands". - :paramtype setting_name: str or ~azure.mgmt.compute.v2017_12_01.models.SettingNames - :keyword content: Specifies the XML formatted content that is added to the unattend.xml file - for the specified path and component. The XML must be less than 4KB and must include the root - element for the setting or feature that is being inserted. - :paramtype content: str - """ - super().__init__(**kwargs) - self.pass_name = pass_name - self.component_name = component_name - self.setting_name = setting_name - self.content = content - - -class ApiEntityReference(_serialization.Model): - """The API entity reference. - - :ivar id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class ApiError(_serialization.Model): - """Api error. - - :ivar details: The Api error details. - :vartype details: list[~azure.mgmt.compute.v2017_12_01.models.ApiErrorBase] - :ivar innererror: The Api inner error. - :vartype innererror: ~azure.mgmt.compute.v2017_12_01.models.InnerError - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "details": {"key": "details", "type": "[ApiErrorBase]"}, - "innererror": {"key": "innererror", "type": "InnerError"}, - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - details: Optional[List["_models.ApiErrorBase"]] = None, - innererror: Optional["_models.InnerError"] = None, - code: Optional[str] = None, - target: Optional[str] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword details: The Api error details. - :paramtype details: list[~azure.mgmt.compute.v2017_12_01.models.ApiErrorBase] - :keyword innererror: The Api inner error. - :paramtype innererror: ~azure.mgmt.compute.v2017_12_01.models.InnerError - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.details = details - self.innererror = innererror - self.code = code - self.target = target - self.message = message - - -class ApiErrorBase(_serialization.Model): - """Api error base. - - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.target = target - self.message = message - - -class AutoOSUpgradePolicy(_serialization.Model): - """The configuration parameters used for performing automatic OS upgrade. - - :ivar disable_auto_rollback: Whether OS image rollback feature should be disabled. Default - value is false. - :vartype disable_auto_rollback: bool - """ - - _attribute_map = { - "disable_auto_rollback": {"key": "disableAutoRollback", "type": "bool"}, - } - - def __init__(self, *, disable_auto_rollback: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword disable_auto_rollback: Whether OS image rollback feature should be disabled. Default - value is false. - :paramtype disable_auto_rollback: bool - """ - super().__init__(**kwargs) - self.disable_auto_rollback = disable_auto_rollback - - -class Resource(_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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - - -class AvailabilitySet(Resource): - """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 `Manage the - availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability 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. - :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] - :ivar sku: Sku of the availability set. - :vartype sku: ~azure.mgmt.compute.v2017_12_01.models.Sku - :ivar platform_update_domain_count: Update Domain count. - :vartype platform_update_domain_count: int - :ivar platform_fault_domain_count: Fault Domain count. - :vartype platform_fault_domain_count: int - :ivar virtual_machines: A list of references to all virtual machines in the availability set. - :vartype virtual_machines: list[~azure.mgmt.compute.v2017_12_01.models.SubResource] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "statuses": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "Sku"}, - "platform_update_domain_count": {"key": "properties.platformUpdateDomainCount", "type": "int"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResource]"}, - "statuses": {"key": "properties.statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - platform_update_domain_count: Optional[int] = None, - platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["_models.SubResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: Sku of the availability set. - :paramtype sku: ~azure.mgmt.compute.v2017_12_01.models.Sku - :keyword platform_update_domain_count: Update Domain count. - :paramtype platform_update_domain_count: int - :keyword platform_fault_domain_count: Fault Domain count. - :paramtype platform_fault_domain_count: int - :keyword virtual_machines: A list of references to all virtual machines in the availability - set. - :paramtype virtual_machines: list[~azure.mgmt.compute.v2017_12_01.models.SubResource] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.platform_update_domain_count = platform_update_domain_count - self.platform_fault_domain_count = platform_fault_domain_count - self.virtual_machines = virtual_machines - self.statuses: Optional[List["_models.InstanceViewStatus"]] = None - - -class AvailabilitySetListResult(_serialization.Model): - """The List Availability Set operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of availability sets. Required. - :vartype value: list[~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet] - :ivar next_link: The URI to fetch the next page of AvailabilitySets. Call ListNext() with this - URI to fetch the next page of AvailabilitySets. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AvailabilitySet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of availability sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet] - :keyword next_link: The URI to fetch the next page of AvailabilitySets. Call ListNext() with - this URI to fetch the next page of AvailabilitySets. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class UpdateResource(_serialization.Model): - """The Update Resource model definition. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class AvailabilitySetUpdate(UpdateResource): - """Specifies information about the availability set that the virtual machine should be assigned - to. Only tags may be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: Sku of the availability set. - :vartype sku: ~azure.mgmt.compute.v2017_12_01.models.Sku - :ivar platform_update_domain_count: Update Domain count. - :vartype platform_update_domain_count: int - :ivar platform_fault_domain_count: Fault Domain count. - :vartype platform_fault_domain_count: int - :ivar virtual_machines: A list of references to all virtual machines in the availability set. - :vartype virtual_machines: list[~azure.mgmt.compute.v2017_12_01.models.SubResource] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus] - """ - - _validation = { - "statuses": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "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"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResource]"}, - "statuses": {"key": "properties.statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - platform_update_domain_count: Optional[int] = None, - platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["_models.SubResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: Sku of the availability set. - :paramtype sku: ~azure.mgmt.compute.v2017_12_01.models.Sku - :keyword platform_update_domain_count: Update Domain count. - :paramtype platform_update_domain_count: int - :keyword platform_fault_domain_count: Fault Domain count. - :paramtype platform_fault_domain_count: int - :keyword virtual_machines: A list of references to all virtual machines in the availability - set. - :paramtype virtual_machines: list[~azure.mgmt.compute.v2017_12_01.models.SubResource] - """ - super().__init__(tags=tags, **kwargs) - self.sku = sku - self.platform_update_domain_count = platform_update_domain_count - self.platform_fault_domain_count = platform_fault_domain_count - self.virtual_machines = virtual_machines - self.statuses: Optional[List["_models.InstanceViewStatus"]] = None - - -class BootDiagnostics(_serialization.Model): - """Boot Diagnostics is a debugging feature which allows you to view Console Output and Screenshot - to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily view the output of your - console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see a screenshot of the VM - from the hypervisor. - - :ivar enabled: Whether boot diagnostics should be enabled on the Virtual Machine. - :vartype enabled: bool - :ivar storage_uri: Uri of the storage account to use for placing the console output and - screenshot. - :vartype storage_uri: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "storage_uri": {"key": "storageUri", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, storage_uri: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Whether boot diagnostics should be enabled on the Virtual Machine. - :paramtype enabled: bool - :keyword storage_uri: Uri of the storage account to use for placing the console output and - screenshot. - :paramtype storage_uri: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.storage_uri = storage_uri - - -class BootDiagnosticsInstanceView(_serialization.Model): - """The instance view of a virtual machine boot diagnostics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar console_screenshot_blob_uri: The console screenshot blob URI. - :vartype console_screenshot_blob_uri: str - :ivar serial_console_log_blob_uri: The Linux serial console log blob Uri. - :vartype serial_console_log_blob_uri: str - """ - - _validation = { - "console_screenshot_blob_uri": {"readonly": True}, - "serial_console_log_blob_uri": {"readonly": True}, - } - - _attribute_map = { - "console_screenshot_blob_uri": {"key": "consoleScreenshotBlobUri", "type": "str"}, - "serial_console_log_blob_uri": {"key": "serialConsoleLogBlobUri", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.console_screenshot_blob_uri: Optional[str] = None - self.serial_console_log_blob_uri: Optional[str] = None - - -class ComputeLongRunningOperationProperties(_serialization.Model): - """Compute-specific operation properties, including output. - - :ivar output: Operation output data (raw JSON). - :vartype output: JSON - """ - - _attribute_map = { - "output": {"key": "output", "type": "object"}, - } - - def __init__(self, *, output: Optional[JSON] = None, **kwargs: Any) -> None: - """ - :keyword output: Operation output data (raw JSON). - :paramtype output: JSON - """ - super().__init__(**kwargs) - self.output = output - - -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.v2017_12_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: Optional[List["_models.ComputeOperationValue"]] = None - - -class ComputeOperationValue(_serialization.Model): - """Describes the properties of a Compute Operation value. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar origin: The origin of the compute operation. - :vartype origin: str - :ivar name: The name of the compute operation. - :vartype name: str - :ivar operation: The display name of the compute operation. - :vartype operation: str - :ivar resource: The display name of the resource the operation applies to. - :vartype resource: str - :ivar description: The description of the operation. - :vartype description: str - :ivar provider: The resource provider for the operation. - :vartype provider: str - """ - - _validation = { - "origin": {"readonly": True}, - "name": {"readonly": True}, - "operation": {"readonly": True}, - "resource": {"readonly": True}, - "description": {"readonly": True}, - "provider": {"readonly": True}, - } - - _attribute_map = { - "origin": {"key": "origin", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "operation": {"key": "display.operation", "type": "str"}, - "resource": {"key": "display.resource", "type": "str"}, - "description": {"key": "display.description", "type": "str"}, - "provider": {"key": "display.provider", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.origin: Optional[str] = None - self.name: Optional[str] = None - self.operation: Optional[str] = None - self.resource: Optional[str] = None - self.description: Optional[str] = None - self.provider: Optional[str] = None - - -class DataDisk(_serialization.Model): - """Describes a data disk. - - All required parameters must be populated in order to send to server. - - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - :ivar name: The disk name. - :vartype name: str - :ivar vhd: The virtual hard disk. - :vartype vhd: ~azure.mgmt.compute.v2017_12_01.models.VirtualHardDisk - :ivar image: 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. - :vartype image: ~azure.mgmt.compute.v2017_12_01.models.VirtualHardDisk - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2017_12_01.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: ~azure.mgmt.compute.v2017_12_01.models.ManagedDiskParameters - """ - - _validation = { - "lun": {"required": True}, - "create_option": {"required": True}, - } - - _attribute_map = { - "lun": {"key": "lun", "type": "int"}, - "name": {"key": "name", "type": "str"}, - "vhd": {"key": "vhd", "type": "VirtualHardDisk"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, - } - - def __init__( - self, - *, - lun: int, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - vhd: Optional["_models.VirtualHardDisk"] = None, - image: Optional["_models.VirtualHardDisk"] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.ManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - :keyword name: The disk name. - :paramtype name: str - :keyword vhd: The virtual hard disk. - :paramtype vhd: ~azure.mgmt.compute.v2017_12_01.models.VirtualHardDisk - :keyword image: 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. - :paramtype image: ~azure.mgmt.compute.v2017_12_01.models.VirtualHardDisk - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2017_12_01.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: ~azure.mgmt.compute.v2017_12_01.models.ManagedDiskParameters - """ - super().__init__(**kwargs) - self.lun = lun - self.name = name - self.vhd = vhd - self.image = image - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - - -class DataDiskImage(_serialization.Model): - """Contains the data disk images information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - :vartype lun: int - """ - - _validation = { - "lun": {"readonly": True}, - } - - _attribute_map = { - "lun": {"key": "lun", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.lun: Optional[int] = None - - -class DiagnosticsProfile(_serialization.Model): - """Specifies the boot diagnostic settings state. :code:`
    `\\ :code:`
    `Minimum api-version: - 2015-06-15. - - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2017_12_01.models.BootDiagnostics - """ - - _attribute_map = { - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnostics"}, - } - - def __init__(self, *, boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs: Any) -> None: - """ - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2017_12_01.models.BootDiagnostics - """ - super().__init__(**kwargs) - self.boot_diagnostics = boot_diagnostics - - -class DiskEncryptionSettings(_serialization.Model): - """Describes a Encryption Settings for a Disk. - - :ivar disk_encryption_key: Specifies the location of the disk encryption key, which is a Key - Vault Secret. - :vartype disk_encryption_key: ~azure.mgmt.compute.v2017_12_01.models.KeyVaultSecretReference - :ivar key_encryption_key: Specifies the location of the key encryption key in Key Vault. - :vartype key_encryption_key: ~azure.mgmt.compute.v2017_12_01.models.KeyVaultKeyReference - :ivar enabled: Specifies whether disk encryption should be enabled on the virtual machine. - :vartype enabled: bool - """ - - _attribute_map = { - "disk_encryption_key": {"key": "diskEncryptionKey", "type": "KeyVaultSecretReference"}, - "key_encryption_key": {"key": "keyEncryptionKey", "type": "KeyVaultKeyReference"}, - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__( - self, - *, - disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, - key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, - enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_key: Specifies the location of the disk encryption key, which is a Key - Vault Secret. - :paramtype disk_encryption_key: ~azure.mgmt.compute.v2017_12_01.models.KeyVaultSecretReference - :keyword key_encryption_key: Specifies the location of the key encryption key in Key Vault. - :paramtype key_encryption_key: ~azure.mgmt.compute.v2017_12_01.models.KeyVaultKeyReference - :keyword enabled: Specifies whether disk encryption should be enabled on the virtual machine. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.disk_encryption_key = disk_encryption_key - self.key_encryption_key = key_encryption_key - self.enabled = enabled - - -class DiskInstanceView(_serialization.Model): - """The instance view of the disk. - - :ivar name: The disk name. - :vartype name: str - :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :vartype encryption_settings: - list[~azure.mgmt.compute.v2017_12_01.models.DiskEncryptionSettings] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "encryption_settings": {"key": "encryptionSettings", "type": "[DiskEncryptionSettings]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype encryption_settings: - list[~azure.mgmt.compute.v2017_12_01.models.DiskEncryptionSettings] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.name = name - self.encryption_settings = encryption_settings - self.statuses = statuses - - -class HardwareProfile(_serialization.Model): - """Specifies the hardware settings for the virtual machine. - - :ivar vm_size: Specifies the size of the virtual machine. For more information about virtual - machine sizes, see `Sizes for virtual machines - `_. - :code:`
    `\\ :code:`
    ` The available VM sizes depend on region and availability set. For a - list of available sizes use these APIs: :code:`
    `\\ :code:`
    ` `List all available - virtual machine sizes in an availability set - `_ - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in a region - `_ :code:`
    `\\ - :code:`
    ` `List all available virtual machine sizes for resizing - `_. Known - values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", - "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", - "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", - "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", - "Standard_A8m_v2", "Standard_B1s", "Standard_B1ms", "Standard_B2s", "Standard_B2ms", - "Standard_B4ms", "Standard_B8ms", "Standard_D1", "Standard_D2", "Standard_D3", "Standard_D4", - "Standard_D11", "Standard_D12", "Standard_D13", "Standard_D14", "Standard_D1_v2", - "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", "Standard_D5_v2", "Standard_D2_v3", - "Standard_D4_v3", "Standard_D8_v3", "Standard_D16_v3", "Standard_D32_v3", "Standard_D64_v3", - "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", "Standard_D16s_v3", - "Standard_D32s_v3", "Standard_D64s_v3", "Standard_D11_v2", "Standard_D12_v2", - "Standard_D13_v2", "Standard_D14_v2", "Standard_D15_v2", "Standard_DS1", "Standard_DS2", - "Standard_DS3", "Standard_DS4", "Standard_DS11", "Standard_DS12", "Standard_DS13", - "Standard_DS14", "Standard_DS1_v2", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", - "Standard_DS5_v2", "Standard_DS11_v2", "Standard_DS12_v2", "Standard_DS13_v2", - "Standard_DS14_v2", "Standard_DS15_v2", "Standard_DS13-4_v2", "Standard_DS13-2_v2", - "Standard_DS14-8_v2", "Standard_DS14-4_v2", "Standard_E2_v3", "Standard_E4_v3", - "Standard_E8_v3", "Standard_E16_v3", "Standard_E32_v3", "Standard_E64_v3", "Standard_E2s_v3", - "Standard_E4s_v3", "Standard_E8s_v3", "Standard_E16s_v3", "Standard_E32s_v3", - "Standard_E64s_v3", "Standard_E32-16_v3", "Standard_E32-8s_v3", "Standard_E64-32s_v3", - "Standard_E64-16s_v3", "Standard_F1", "Standard_F2", "Standard_F4", "Standard_F8", - "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", - "Standard_F16s", "Standard_F2s_v2", "Standard_F4s_v2", "Standard_F8s_v2", "Standard_F16s_v2", - "Standard_F32s_v2", "Standard_F64s_v2", "Standard_F72s_v2", "Standard_G1", "Standard_G2", - "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", "Standard_GS3", - "Standard_GS4", "Standard_GS5", "Standard_GS4-8", "Standard_GS4-4", "Standard_GS5-16", - "Standard_GS5-8", "Standard_H8", "Standard_H16", "Standard_H8m", "Standard_H16m", - "Standard_H16r", "Standard_H16mr", "Standard_L4s", "Standard_L8s", "Standard_L16s", - "Standard_L32s", "Standard_M64s", "Standard_M64ms", "Standard_M128s", "Standard_M128ms", - "Standard_M64-32ms", "Standard_M64-16ms", "Standard_M128-64ms", "Standard_M128-32ms", - "Standard_NC6", "Standard_NC12", "Standard_NC24", "Standard_NC24r", "Standard_NC6s_v2", - "Standard_NC12s_v2", "Standard_NC24s_v2", "Standard_NC24rs_v2", "Standard_NC6s_v3", - "Standard_NC12s_v3", "Standard_NC24s_v3", "Standard_NC24rs_v3", "Standard_ND6s", - "Standard_ND12s", "Standard_ND24s", "Standard_ND24rs", "Standard_NV6", "Standard_NV12", and - "Standard_NV24". - :vartype vm_size: str or ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineSizeTypes - """ - - _attribute_map = { - "vm_size": {"key": "vmSize", "type": "str"}, - } - - def __init__( - self, *, vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs: Any - ) -> None: - """ - :keyword vm_size: Specifies the size of the virtual machine. For more information about virtual - machine sizes, see `Sizes for virtual machines - `_. - :code:`
    `\\ :code:`
    ` The available VM sizes depend on region and availability set. For a - list of available sizes use these APIs: :code:`
    `\\ :code:`
    ` `List all available - virtual machine sizes in an availability set - `_ - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in a region - `_ :code:`
    `\\ - :code:`
    ` `List all available virtual machine sizes for resizing - `_. Known - values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", - "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", - "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", - "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", - "Standard_A8m_v2", "Standard_B1s", "Standard_B1ms", "Standard_B2s", "Standard_B2ms", - "Standard_B4ms", "Standard_B8ms", "Standard_D1", "Standard_D2", "Standard_D3", "Standard_D4", - "Standard_D11", "Standard_D12", "Standard_D13", "Standard_D14", "Standard_D1_v2", - "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", "Standard_D5_v2", "Standard_D2_v3", - "Standard_D4_v3", "Standard_D8_v3", "Standard_D16_v3", "Standard_D32_v3", "Standard_D64_v3", - "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", "Standard_D16s_v3", - "Standard_D32s_v3", "Standard_D64s_v3", "Standard_D11_v2", "Standard_D12_v2", - "Standard_D13_v2", "Standard_D14_v2", "Standard_D15_v2", "Standard_DS1", "Standard_DS2", - "Standard_DS3", "Standard_DS4", "Standard_DS11", "Standard_DS12", "Standard_DS13", - "Standard_DS14", "Standard_DS1_v2", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", - "Standard_DS5_v2", "Standard_DS11_v2", "Standard_DS12_v2", "Standard_DS13_v2", - "Standard_DS14_v2", "Standard_DS15_v2", "Standard_DS13-4_v2", "Standard_DS13-2_v2", - "Standard_DS14-8_v2", "Standard_DS14-4_v2", "Standard_E2_v3", "Standard_E4_v3", - "Standard_E8_v3", "Standard_E16_v3", "Standard_E32_v3", "Standard_E64_v3", "Standard_E2s_v3", - "Standard_E4s_v3", "Standard_E8s_v3", "Standard_E16s_v3", "Standard_E32s_v3", - "Standard_E64s_v3", "Standard_E32-16_v3", "Standard_E32-8s_v3", "Standard_E64-32s_v3", - "Standard_E64-16s_v3", "Standard_F1", "Standard_F2", "Standard_F4", "Standard_F8", - "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", - "Standard_F16s", "Standard_F2s_v2", "Standard_F4s_v2", "Standard_F8s_v2", "Standard_F16s_v2", - "Standard_F32s_v2", "Standard_F64s_v2", "Standard_F72s_v2", "Standard_G1", "Standard_G2", - "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", "Standard_GS3", - "Standard_GS4", "Standard_GS5", "Standard_GS4-8", "Standard_GS4-4", "Standard_GS5-16", - "Standard_GS5-8", "Standard_H8", "Standard_H16", "Standard_H8m", "Standard_H16m", - "Standard_H16r", "Standard_H16mr", "Standard_L4s", "Standard_L8s", "Standard_L16s", - "Standard_L32s", "Standard_M64s", "Standard_M64ms", "Standard_M128s", "Standard_M128ms", - "Standard_M64-32ms", "Standard_M64-16ms", "Standard_M128-64ms", "Standard_M128-32ms", - "Standard_NC6", "Standard_NC12", "Standard_NC24", "Standard_NC24r", "Standard_NC6s_v2", - "Standard_NC12s_v2", "Standard_NC24s_v2", "Standard_NC24rs_v2", "Standard_NC6s_v3", - "Standard_NC12s_v3", "Standard_NC24s_v3", "Standard_NC24rs_v3", "Standard_ND6s", - "Standard_ND12s", "Standard_ND24s", "Standard_ND24rs", "Standard_NV6", "Standard_NV12", and - "Standard_NV24". - :paramtype vm_size: str or ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineSizeTypes - """ - super().__init__(**kwargs) - self.vm_size = vm_size - - -class Image(Resource): - """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. - - 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] - :ivar source_virtual_machine: The source virtual machine from which Image is created. - :vartype source_virtual_machine: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2017_12_01.models.ImageStorageProfile - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "source_virtual_machine": {"key": "properties.sourceVirtualMachine", "type": "SubResource"}, - "storage_profile": {"key": "properties.storageProfile", "type": "ImageStorageProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["_models.SubResource"] = None, - storage_profile: Optional["_models.ImageStorageProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword source_virtual_machine: The source virtual machine from which Image is created. - :paramtype source_virtual_machine: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2017_12_01.models.ImageStorageProfile - """ - super().__init__(location=location, tags=tags, **kwargs) - self.source_virtual_machine = source_virtual_machine - self.storage_profile = storage_profile - self.provisioning_state: Optional[str] = None - - -class ImageDataDisk(_serialization.Model): - """Describes a data disk. - - All required parameters must be populated in order to send to server. - - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - :ivar snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. Possible - values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS" and "Premium_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2017_12_01.models.StorageAccountTypes - """ - - _validation = { - "lun": {"required": True}, - } - - _attribute_map = { - "lun": {"key": "lun", "type": "int"}, - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - } - - def __init__( - self, - *, - lun: int, - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. - Possible values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS" and - "Premium_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2017_12_01.models.StorageAccountTypes - """ - super().__init__(**kwargs) - self.lun = lun - self.snapshot = snapshot - self.managed_disk = managed_disk - self.blob_uri = blob_uri - self.caching = caching - self.disk_size_gb = disk_size_gb - self.storage_account_type = storage_account_type - - -class ImageListResult(_serialization.Model): - """The List Image operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of Images. Required. - :vartype value: list[~azure.mgmt.compute.v2017_12_01.models.Image] - :ivar next_link: The uri to fetch the next page of Images. Call ListNext() with this to fetch - the next page of Images. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Image]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Image"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of Images. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_12_01.models.Image] - :keyword next_link: The uri to fetch the next page of Images. Call ListNext() with this to - fetch the next page of Images. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ImageOSDisk(_serialization.Model): - """Describes an Operating System disk. - - All required parameters must be populated in order to send to server. - - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from a custom image. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Required. Known - values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes - :ivar os_state: The OS State. Required. Known values are: "Generalized" and "Specialized". - :vartype os_state: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemStateTypes - :ivar snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. Possible - values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS" and "Premium_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2017_12_01.models.StorageAccountTypes - """ - - _validation = { - "os_type": {"required": True}, - "os_state": {"required": True}, - } - - _attribute_map = { - "os_type": {"key": "osType", "type": "str"}, - "os_state": {"key": "osState", "type": "str"}, - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - } - - def __init__( - self, - *, - os_type: Union[str, "_models.OperatingSystemTypes"], - os_state: Union[str, "_models.OperatingSystemStateTypes"], - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from a custom image. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Required. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes - :keyword os_state: The OS State. Required. Known values are: "Generalized" and "Specialized". - :paramtype os_state: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemStateTypes - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. - Possible values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS" and - "Premium_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2017_12_01.models.StorageAccountTypes - """ - super().__init__(**kwargs) - self.os_type = os_type - self.os_state = os_state - self.snapshot = snapshot - self.managed_disk = managed_disk - self.blob_uri = blob_uri - self.caching = caching - self.disk_size_gb = disk_size_gb - self.storage_account_type = storage_account_type - - -class SubResource(_serialization.Model): - """SubResource. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class ImageReference(SubResource): - """Specifies information about the image to use. You can specify information about platform - images, marketplace images, or virtual machine images. This element is required when you want - to use a platform image, marketplace image, or virtual machine image, but is not used in other - creation operations. NOTE: Image reference publisher and offer can only be set when you create - the scale set. - - :ivar id: Resource Id. - :vartype id: str - :ivar publisher: The image publisher. - :vartype publisher: str - :ivar offer: Specifies the offer of the platform image or marketplace image used to create the - virtual machine. - :vartype offer: str - :ivar sku: The image SKU. - :vartype sku: str - :ivar version: Specifies the version of the platform image or marketplace image used to create - the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and - Build are decimal numbers. Specify 'latest' to use the latest version of an image available at - deploy time. Even if you use 'latest', the VM image will not automatically update after deploy - time even if a new version becomes available. - :vartype version: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "offer": {"key": "offer", "type": "str"}, - "sku": {"key": "sku", "type": "str"}, - "version": {"key": "version", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - publisher: Optional[str] = None, - offer: Optional[str] = None, - sku: Optional[str] = None, - version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword publisher: The image publisher. - :paramtype publisher: str - :keyword offer: Specifies the offer of the platform image or marketplace image used to create - the virtual machine. - :paramtype offer: str - :keyword sku: The image SKU. - :paramtype sku: str - :keyword version: Specifies the version of the platform image or marketplace image used to - create the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, - Minor, and Build are decimal numbers. Specify 'latest' to use the latest version of an image - available at deploy time. Even if you use 'latest', the VM image will not automatically update - after deploy time even if a new version becomes available. - :paramtype version: str - """ - super().__init__(id=id, **kwargs) - self.publisher = publisher - self.offer = offer - self.sku = sku - self.version = version - - -class ImageStorageProfile(_serialization.Model): - """Describes a storage profile. - - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2017_12_01.models.ImageOSDisk - :ivar data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype data_disks: list[~azure.mgmt.compute.v2017_12_01.models.ImageDataDisk] - :ivar zone_resilient: Specifies whether an image is zone resilient or not. Default is false. - Zone resilient images can be created only in regions that provide Zone Redundant Storage (ZRS). - :vartype zone_resilient: bool - """ - - _attribute_map = { - "os_disk": {"key": "osDisk", "type": "ImageOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[ImageDataDisk]"}, - "zone_resilient": {"key": "zoneResilient", "type": "bool"}, - } - - def __init__( - self, - *, - os_disk: Optional["_models.ImageOSDisk"] = None, - data_disks: Optional[List["_models.ImageDataDisk"]] = None, - zone_resilient: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2017_12_01.models.ImageOSDisk - :keyword data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype data_disks: list[~azure.mgmt.compute.v2017_12_01.models.ImageDataDisk] - :keyword zone_resilient: Specifies whether an image is zone resilient or not. Default is false. - Zone resilient images can be created only in regions that provide Zone Redundant Storage (ZRS). - :paramtype zone_resilient: bool - """ - super().__init__(**kwargs) - self.os_disk = os_disk - self.data_disks = data_disks - self.zone_resilient = zone_resilient - - -class ImageUpdate(UpdateResource): - """The source user image virtual hard disk. Only tags may be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar source_virtual_machine: The source virtual machine from which Image is created. - :vartype source_virtual_machine: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2017_12_01.models.ImageStorageProfile - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "source_virtual_machine": {"key": "properties.sourceVirtualMachine", "type": "SubResource"}, - "storage_profile": {"key": "properties.storageProfile", "type": "ImageStorageProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["_models.SubResource"] = None, - storage_profile: Optional["_models.ImageStorageProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword source_virtual_machine: The source virtual machine from which Image is created. - :paramtype source_virtual_machine: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2017_12_01.models.ImageStorageProfile - """ - super().__init__(tags=tags, **kwargs) - self.source_virtual_machine = source_virtual_machine - self.storage_profile = storage_profile - self.provisioning_state: Optional[str] = None - - -class InnerError(_serialization.Model): - """Inner error details. - - :ivar exceptiontype: The exception type. - :vartype exceptiontype: str - :ivar errordetail: The internal error message or exception dump. - :vartype errordetail: str - """ - - _attribute_map = { - "exceptiontype": {"key": "exceptiontype", "type": "str"}, - "errordetail": {"key": "errordetail", "type": "str"}, - } - - def __init__( - self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword exceptiontype: The exception type. - :paramtype exceptiontype: str - :keyword errordetail: The internal error message or exception dump. - :paramtype errordetail: str - """ - super().__init__(**kwargs) - self.exceptiontype = exceptiontype - self.errordetail = errordetail - - -class InstanceViewStatus(_serialization.Model): - """Instance view status. - - :ivar code: The status code. - :vartype code: str - :ivar level: The level code. Known values are: "Info", "Warning", and "Error". - :vartype level: str or ~azure.mgmt.compute.v2017_12_01.models.StatusLevelTypes - :ivar display_status: The short localizable label for the status. - :vartype display_status: str - :ivar message: The detailed status message, including for alerts and error messages. - :vartype message: str - :ivar time: The time of the status. - :vartype time: ~datetime.datetime - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "level": {"key": "level", "type": "str"}, - "display_status": {"key": "displayStatus", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "time": {"key": "time", "type": "iso-8601"}, - } - - def __init__( - self, - *, - code: Optional[str] = None, - level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, - display_status: Optional[str] = None, - message: Optional[str] = None, - time: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword code: The status code. - :paramtype code: str - :keyword level: The level code. Known values are: "Info", "Warning", and "Error". - :paramtype level: str or ~azure.mgmt.compute.v2017_12_01.models.StatusLevelTypes - :keyword display_status: The short localizable label for the status. - :paramtype display_status: str - :keyword message: The detailed status message, including for alerts and error messages. - :paramtype message: str - :keyword time: The time of the status. - :paramtype time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.code = code - self.level = level - self.display_status = display_status - self.message = message - self.time = time - - -class KeyVaultKeyReference(_serialization.Model): - """Describes a reference to Key Vault Key. - - All required parameters must be populated in order to send to server. - - :ivar key_url: The URL referencing a key encryption key in Key Vault. Required. - :vartype key_url: str - :ivar source_vault: The relative URL of the Key Vault containing the key. Required. - :vartype source_vault: ~azure.mgmt.compute.v2017_12_01.models.SubResource - """ - - _validation = { - "key_url": {"required": True}, - "source_vault": {"required": True}, - } - - _attribute_map = { - "key_url": {"key": "keyUrl", "type": "str"}, - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - } - - def __init__(self, *, key_url: str, source_vault: "_models.SubResource", **kwargs: Any) -> None: - """ - :keyword key_url: The URL referencing a key encryption key in Key Vault. Required. - :paramtype key_url: str - :keyword source_vault: The relative URL of the Key Vault containing the key. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2017_12_01.models.SubResource - """ - super().__init__(**kwargs) - self.key_url = key_url - self.source_vault = source_vault - - -class KeyVaultSecretReference(_serialization.Model): - """Describes a reference to Key Vault Secret. - - All required parameters must be populated in order to send to server. - - :ivar secret_url: The URL referencing a secret in a Key Vault. Required. - :vartype secret_url: str - :ivar source_vault: The relative URL of the Key Vault containing the secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2017_12_01.models.SubResource - """ - - _validation = { - "secret_url": {"required": True}, - "source_vault": {"required": True}, - } - - _attribute_map = { - "secret_url": {"key": "secretUrl", "type": "str"}, - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - } - - def __init__(self, *, secret_url: str, source_vault: "_models.SubResource", **kwargs: Any) -> None: - """ - :keyword secret_url: The URL referencing a secret in a Key Vault. Required. - :paramtype secret_url: str - :keyword source_vault: The relative URL of the Key Vault containing the secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2017_12_01.models.SubResource - """ - super().__init__(**kwargs) - self.secret_url = secret_url - self.source_vault = source_vault - - -class LinuxConfiguration(_serialization.Model): - """Specifies the Linux operating system settings on the virtual machine. :code:`
    `\\ - :code:`
    `For a list of supported Linux distributions, see `Linux on Azure-Endorsed - Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - - :ivar disable_password_authentication: Specifies whether password authentication should be - disabled. - :vartype disable_password_authentication: bool - :ivar ssh: Specifies the ssh key configuration for a Linux OS. - :vartype ssh: ~azure.mgmt.compute.v2017_12_01.models.SshConfiguration - """ - - _attribute_map = { - "disable_password_authentication": {"key": "disablePasswordAuthentication", "type": "bool"}, - "ssh": {"key": "ssh", "type": "SshConfiguration"}, - } - - def __init__( - self, - *, - disable_password_authentication: Optional[bool] = None, - ssh: Optional["_models.SshConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword disable_password_authentication: Specifies whether password authentication should be - disabled. - :paramtype disable_password_authentication: bool - :keyword ssh: Specifies the ssh key configuration for a Linux OS. - :paramtype ssh: ~azure.mgmt.compute.v2017_12_01.models.SshConfiguration - """ - super().__init__(**kwargs) - self.disable_password_authentication = disable_password_authentication - self.ssh = ssh - - -class ListUsagesResult(_serialization.Model): - """The List Usages operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of compute resource usages. Required. - :vartype value: list[~azure.mgmt.compute.v2017_12_01.models.Usage] - :ivar next_link: The URI to fetch the next page of compute resource usage information. Call - ListNext() with this to fetch the next page of compute resource usage information. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Usage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of compute resource usages. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_12_01.models.Usage] - :keyword next_link: The URI to fetch the next page of compute resource usage information. Call - ListNext() with this to fetch the next page of compute resource usage information. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class LogAnalyticsInputBase(_serialization.Model): - """Api input base class for LogAnalytics Api. - - All required parameters must be populated in order to send to server. - - :ivar blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api - writes output logs to. Required. - :vartype blob_container_sas_uri: str - :ivar from_time: From time of the query. Required. - :vartype from_time: ~datetime.datetime - :ivar to_time: To time of the query. Required. - :vartype to_time: ~datetime.datetime - :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. - :vartype group_by_throttle_policy: bool - :ivar group_by_operation_name: Group query result by Operation Name. - :vartype group_by_operation_name: bool - :ivar group_by_resource_name: Group query result by Resource Name. - :vartype group_by_resource_name: bool - """ - - _validation = { - "blob_container_sas_uri": {"required": True}, - "from_time": {"required": True}, - "to_time": {"required": True}, - } - - _attribute_map = { - "blob_container_sas_uri": {"key": "blobContainerSasUri", "type": "str"}, - "from_time": {"key": "fromTime", "type": "iso-8601"}, - "to_time": {"key": "toTime", "type": "iso-8601"}, - "group_by_throttle_policy": {"key": "groupByThrottlePolicy", "type": "bool"}, - "group_by_operation_name": {"key": "groupByOperationName", "type": "bool"}, - "group_by_resource_name": {"key": "groupByResourceName", "type": "bool"}, - } - - def __init__( - self, - *, - blob_container_sas_uri: str, - from_time: datetime.datetime, - to_time: datetime.datetime, - group_by_throttle_policy: Optional[bool] = None, - group_by_operation_name: Optional[bool] = None, - group_by_resource_name: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics - Api writes output logs to. Required. - :paramtype blob_container_sas_uri: str - :keyword from_time: From time of the query. Required. - :paramtype from_time: ~datetime.datetime - :keyword to_time: To time of the query. Required. - :paramtype to_time: ~datetime.datetime - :keyword group_by_throttle_policy: Group query result by Throttle Policy applied. - :paramtype group_by_throttle_policy: bool - :keyword group_by_operation_name: Group query result by Operation Name. - :paramtype group_by_operation_name: bool - :keyword group_by_resource_name: Group query result by Resource Name. - :paramtype group_by_resource_name: bool - """ - super().__init__(**kwargs) - self.blob_container_sas_uri = blob_container_sas_uri - self.from_time = from_time - self.to_time = to_time - self.group_by_throttle_policy = group_by_throttle_policy - self.group_by_operation_name = group_by_operation_name - self.group_by_resource_name = group_by_resource_name - - -class OperationStatusResponse(_serialization.Model): - """Operation status response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation ID. - :vartype name: str - :ivar status: Operation status. - :vartype status: str - :ivar start_time: Start time of the operation. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the operation. - :vartype end_time: ~datetime.datetime - :ivar error: Api error. - :vartype error: ~azure.mgmt.compute.v2017_12_01.models.ApiError - """ - - _validation = { - "name": {"readonly": True}, - "status": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - "error": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "error": {"key": "error", "type": "ApiError"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.status: Optional[str] = None - self.start_time: Optional[datetime.datetime] = None - self.end_time: Optional[datetime.datetime] = None - self.error: Optional["_models.ApiError"] = None - - -class LogAnalyticsOperationResult(OperationStatusResponse): - """LogAnalytics operation status response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation ID. - :vartype name: str - :ivar status: Operation status. - :vartype status: str - :ivar start_time: Start time of the operation. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the operation. - :vartype end_time: ~datetime.datetime - :ivar error: Api error. - :vartype error: ~azure.mgmt.compute.v2017_12_01.models.ApiError - :ivar properties: LogAnalyticsOutput. - :vartype properties: ~azure.mgmt.compute.v2017_12_01.models.LogAnalyticsOutput - """ - - _validation = { - "name": {"readonly": True}, - "status": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - "error": {"readonly": True}, - "properties": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "error": {"key": "error", "type": "ApiError"}, - "properties": {"key": "properties", "type": "LogAnalyticsOutput"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.properties: Optional["_models.LogAnalyticsOutput"] = None - - -class LogAnalyticsOutput(_serialization.Model): - """LogAnalytics output properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar output: Output file Uri path to blob container. - :vartype output: str - """ - - _validation = { - "output": {"readonly": True}, - } - - _attribute_map = { - "output": {"key": "output", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.output: Optional[str] = None - - -class MaintenanceRedeployStatus(_serialization.Model): - """Maintenance Operation Status. - - :ivar is_customer_initiated_maintenance_allowed: True, if customer is allowed to perform - Maintenance. - :vartype is_customer_initiated_maintenance_allowed: bool - :ivar pre_maintenance_window_start_time: Start Time for the Pre Maintenance Window. - :vartype pre_maintenance_window_start_time: ~datetime.datetime - :ivar pre_maintenance_window_end_time: End Time for the Pre Maintenance Window. - :vartype pre_maintenance_window_end_time: ~datetime.datetime - :ivar maintenance_window_start_time: Start Time for the Maintenance Window. - :vartype maintenance_window_start_time: ~datetime.datetime - :ivar maintenance_window_end_time: End Time for the Maintenance Window. - :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: - "None", "RetryLater", "MaintenanceAborted", and "MaintenanceCompleted". - :vartype last_operation_result_code: str or - ~azure.mgmt.compute.v2017_12_01.models.MaintenanceOperationResultCodeTypes - :ivar last_operation_message: Message returned for the last Maintenance Operation. - :vartype last_operation_message: str - """ - - _attribute_map = { - "is_customer_initiated_maintenance_allowed": {"key": "isCustomerInitiatedMaintenanceAllowed", "type": "bool"}, - "pre_maintenance_window_start_time": {"key": "preMaintenanceWindowStartTime", "type": "iso-8601"}, - "pre_maintenance_window_end_time": {"key": "preMaintenanceWindowEndTime", "type": "iso-8601"}, - "maintenance_window_start_time": {"key": "maintenanceWindowStartTime", "type": "iso-8601"}, - "maintenance_window_end_time": {"key": "maintenanceWindowEndTime", "type": "iso-8601"}, - "last_operation_result_code": {"key": "lastOperationResultCode", "type": "str"}, - "last_operation_message": {"key": "lastOperationMessage", "type": "str"}, - } - - def __init__( - self, - *, - is_customer_initiated_maintenance_allowed: Optional[bool] = None, - pre_maintenance_window_start_time: Optional[datetime.datetime] = None, - pre_maintenance_window_end_time: Optional[datetime.datetime] = None, - maintenance_window_start_time: Optional[datetime.datetime] = None, - maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, - last_operation_message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_customer_initiated_maintenance_allowed: True, if customer is allowed to perform - Maintenance. - :paramtype is_customer_initiated_maintenance_allowed: bool - :keyword pre_maintenance_window_start_time: Start Time for the Pre Maintenance Window. - :paramtype pre_maintenance_window_start_time: ~datetime.datetime - :keyword pre_maintenance_window_end_time: End Time for the Pre Maintenance Window. - :paramtype pre_maintenance_window_end_time: ~datetime.datetime - :keyword maintenance_window_start_time: Start Time for the Maintenance Window. - :paramtype maintenance_window_start_time: ~datetime.datetime - :keyword maintenance_window_end_time: End Time for the Maintenance Window. - :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values - are: "None", "RetryLater", "MaintenanceAborted", and "MaintenanceCompleted". - :paramtype last_operation_result_code: str or - ~azure.mgmt.compute.v2017_12_01.models.MaintenanceOperationResultCodeTypes - :keyword last_operation_message: Message returned for the last Maintenance Operation. - :paramtype last_operation_message: str - """ - super().__init__(**kwargs) - self.is_customer_initiated_maintenance_allowed = is_customer_initiated_maintenance_allowed - self.pre_maintenance_window_start_time = pre_maintenance_window_start_time - self.pre_maintenance_window_end_time = pre_maintenance_window_end_time - self.maintenance_window_start_time = maintenance_window_start_time - self.maintenance_window_end_time = maintenance_window_end_time - self.last_operation_result_code = last_operation_result_code - self.last_operation_message = last_operation_message - - -class ManagedDiskParameters(SubResource): - """The parameters of a managed disk. - - :ivar id: Resource Id. - :vartype id: str - :ivar storage_account_type: Specifies the storage account type for the managed disk. Possible - values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS" and "Premium_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2017_12_01.models.StorageAccountTypes - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword storage_account_type: Specifies the storage account type for the managed disk. - Possible values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS" and - "Premium_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2017_12_01.models.StorageAccountTypes - """ - super().__init__(id=id, **kwargs) - self.storage_account_type = storage_account_type - - -class NetworkInterfaceReference(SubResource): - """Describes a network interface reference. - - :ivar id: Resource Id. - :vartype id: str - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - primary: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - """ - super().__init__(id=id, **kwargs) - self.primary = primary - - -class NetworkProfile(_serialization.Model): - """Specifies the network interfaces of the virtual machine. - - :ivar network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the virtual machine. - :vartype network_interfaces: - list[~azure.mgmt.compute.v2017_12_01.models.NetworkInterfaceReference] - """ - - _attribute_map = { - "network_interfaces": {"key": "networkInterfaces", "type": "[NetworkInterfaceReference]"}, - } - - def __init__( - self, *, network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs: Any - ) -> None: - """ - :keyword network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the virtual machine. - :paramtype network_interfaces: - list[~azure.mgmt.compute.v2017_12_01.models.NetworkInterfaceReference] - """ - super().__init__(**kwargs) - self.network_interfaces = network_interfaces - - -class OSDisk(_serialization.Model): - """Specifies information about the operating system disk used by the virtual machine. - :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and VHDs for - Azure virtual machines - `_. - - All required parameters must be populated in order to send to server. - - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes - :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :vartype encryption_settings: ~azure.mgmt.compute.v2017_12_01.models.DiskEncryptionSettings - :ivar name: The disk name. - :vartype name: str - :ivar vhd: The virtual hard disk. - :vartype vhd: ~azure.mgmt.compute.v2017_12_01.models.VirtualHardDisk - :ivar image: 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. - :vartype image: ~azure.mgmt.compute.v2017_12_01.models.VirtualHardDisk - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2017_12_01.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: ~azure.mgmt.compute.v2017_12_01.models.ManagedDiskParameters - """ - - _validation = { - "create_option": {"required": True}, - } - - _attribute_map = { - "os_type": {"key": "osType", "type": "str"}, - "encryption_settings": {"key": "encryptionSettings", "type": "DiskEncryptionSettings"}, - "name": {"key": "name", "type": "str"}, - "vhd": {"key": "vhd", "type": "VirtualHardDisk"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, - name: Optional[str] = None, - vhd: Optional["_models.VirtualHardDisk"] = None, - image: Optional["_models.VirtualHardDisk"] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.ManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes - :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype encryption_settings: ~azure.mgmt.compute.v2017_12_01.models.DiskEncryptionSettings - :keyword name: The disk name. - :paramtype name: str - :keyword vhd: The virtual hard disk. - :paramtype vhd: ~azure.mgmt.compute.v2017_12_01.models.VirtualHardDisk - :keyword image: 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. - :paramtype image: ~azure.mgmt.compute.v2017_12_01.models.VirtualHardDisk - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2017_12_01.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: ~azure.mgmt.compute.v2017_12_01.models.ManagedDiskParameters - """ - super().__init__(**kwargs) - self.os_type = os_type - self.encryption_settings = encryption_settings - self.name = name - self.vhd = vhd - self.image = image - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - - -class OSDiskImage(_serialization.Model): - """Contains the os disk image information. - - All required parameters must be populated in order to send to server. - - :ivar operating_system: The operating system of the osDiskImage. Required. Known values are: - "Windows" and "Linux". - :vartype operating_system: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes - """ - - _validation = { - "operating_system": {"required": True}, - } - - _attribute_map = { - "operating_system": {"key": "operatingSystem", "type": "str"}, - } - - def __init__(self, *, operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs: Any) -> None: - """ - :keyword operating_system: The operating system of the osDiskImage. Required. Known values are: - "Windows" and "Linux". - :paramtype operating_system: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes - """ - super().__init__(**kwargs) - self.operating_system = operating_system - - -class OSProfile(_serialization.Model): - """Specifies the operating system settings for the virtual machine. - - :ivar computer_name: Specifies the host OS name of the virtual machine. :code:`
    `\\ - :code:`
    ` This name cannot be updated after the VM is created. :code:`
    `\\ :code:`
    ` - **Max-length (Windows):** 15 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 - characters. :code:`
    `\\ :code:`
    ` For naming conventions and restrictions see `Azure - infrastructure services implementation guidelines - `_. - :vartype computer_name: str - :ivar admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :vartype admin_username: str - :ivar admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :vartype admin_password: str - :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` For using cloud-init for - your VM, see `Using cloud-init to customize a Linux VM during creation - `_. - :vartype custom_data: str - :ivar windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :vartype windows_configuration: ~azure.mgmt.compute.v2017_12_01.models.WindowsConfiguration - :ivar linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :vartype linux_configuration: ~azure.mgmt.compute.v2017_12_01.models.LinuxConfiguration - :ivar secrets: Specifies set of certificates that should be installed onto the virtual machine. - :vartype secrets: list[~azure.mgmt.compute.v2017_12_01.models.VaultSecretGroup] - """ - - _attribute_map = { - "computer_name": {"key": "computerName", "type": "str"}, - "admin_username": {"key": "adminUsername", "type": "str"}, - "admin_password": {"key": "adminPassword", "type": "str"}, - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - } - - def __init__( - self, - *, - computer_name: Optional[str] = None, - admin_username: Optional[str] = None, - admin_password: Optional[str] = None, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword computer_name: Specifies the host OS name of the virtual machine. :code:`
    `\\ - :code:`
    ` This name cannot be updated after the VM is created. :code:`
    `\\ :code:`
    ` - **Max-length (Windows):** 15 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 - characters. :code:`
    `\\ :code:`
    ` For naming conventions and restrictions see `Azure - infrastructure services implementation guidelines - `_. - :paramtype computer_name: str - :keyword admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :paramtype admin_username: str - :keyword admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :paramtype admin_password: str - :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` For using cloud-init for - your VM, see `Using cloud-init to customize a Linux VM during creation - `_. - :paramtype custom_data: str - :keyword windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :paramtype windows_configuration: ~azure.mgmt.compute.v2017_12_01.models.WindowsConfiguration - :keyword linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :paramtype linux_configuration: ~azure.mgmt.compute.v2017_12_01.models.LinuxConfiguration - :keyword secrets: Specifies set of certificates that should be installed onto the virtual - machine. - :paramtype secrets: list[~azure.mgmt.compute.v2017_12_01.models.VaultSecretGroup] - """ - super().__init__(**kwargs) - self.computer_name = computer_name - self.admin_username = admin_username - self.admin_password = admin_password - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - - -class Plan(_serialization.Model): - """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 the marketplace - image that you want to use and then click **Want to deploy programmatically, Get Started ->**. - Enter any required information and then click **Save**. - - :ivar name: The plan ID. - :vartype name: str - :ivar publisher: The publisher ID. - :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. - :vartype product: str - :ivar promotion_code: The promotion code. - :vartype promotion_code: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - "promotion_code": {"key": "promotionCode", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - publisher: Optional[str] = None, - product: Optional[str] = None, - promotion_code: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The plan ID. - :paramtype name: str - :keyword publisher: The publisher ID. - :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. - :paramtype product: str - :keyword promotion_code: The promotion code. - :paramtype promotion_code: str - """ - super().__init__(**kwargs) - self.name = name - self.publisher = publisher - self.product = product - self.promotion_code = promotion_code - - -class PurchasePlan(_serialization.Model): - """Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. - - All required parameters must be populated in order to send to server. - - :ivar publisher: The publisher ID. Required. - :vartype publisher: str - :ivar name: The plan ID. Required. - :vartype name: 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 - """ - - _validation = { - "publisher": {"required": True}, - "name": {"required": True}, - "product": {"required": True}, - } - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "product": {"key": "product", "type": "str"}, - } - - def __init__(self, *, publisher: str, name: str, product: str, **kwargs: Any) -> None: - """ - :keyword publisher: The publisher ID. Required. - :paramtype publisher: str - :keyword name: The plan ID. Required. - :paramtype name: 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 - """ - super().__init__(**kwargs) - self.publisher = publisher - self.name = name - self.product = product - - -class RecoveryWalkResponse(_serialization.Model): - """Response after calling a manual recovery walk. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar walk_performed: Whether the recovery walk was performed. - :vartype walk_performed: bool - :ivar next_platform_update_domain: The next update domain that needs to be walked. Null means - walk spanning all update domains has been completed. - :vartype next_platform_update_domain: int - """ - - _validation = { - "walk_performed": {"readonly": True}, - "next_platform_update_domain": {"readonly": True}, - } - - _attribute_map = { - "walk_performed": {"key": "walkPerformed", "type": "bool"}, - "next_platform_update_domain": {"key": "nextPlatformUpdateDomain", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.walk_performed: Optional[bool] = None - self.next_platform_update_domain: Optional[int] = None - - -class RequestRateByIntervalInput(LogAnalyticsInputBase): - """Api request input for LogAnalytics getRequestRateByInterval Api. - - All required parameters must be populated in order to send to server. - - :ivar blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api - writes output logs to. Required. - :vartype blob_container_sas_uri: str - :ivar from_time: From time of the query. Required. - :vartype from_time: ~datetime.datetime - :ivar to_time: To time of the query. Required. - :vartype to_time: ~datetime.datetime - :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. - :vartype group_by_throttle_policy: bool - :ivar group_by_operation_name: Group query result by Operation Name. - :vartype group_by_operation_name: bool - :ivar group_by_resource_name: Group query result by Resource Name. - :vartype group_by_resource_name: bool - :ivar interval_length: Interval value in minutes used to create LogAnalytics call rate logs. - Required. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", and "SixtyMins". - :vartype interval_length: str or ~azure.mgmt.compute.v2017_12_01.models.IntervalInMins - """ - - _validation = { - "blob_container_sas_uri": {"required": True}, - "from_time": {"required": True}, - "to_time": {"required": True}, - "interval_length": {"required": True}, - } - - _attribute_map = { - "blob_container_sas_uri": {"key": "blobContainerSasUri", "type": "str"}, - "from_time": {"key": "fromTime", "type": "iso-8601"}, - "to_time": {"key": "toTime", "type": "iso-8601"}, - "group_by_throttle_policy": {"key": "groupByThrottlePolicy", "type": "bool"}, - "group_by_operation_name": {"key": "groupByOperationName", "type": "bool"}, - "group_by_resource_name": {"key": "groupByResourceName", "type": "bool"}, - "interval_length": {"key": "intervalLength", "type": "str"}, - } - - def __init__( - self, - *, - blob_container_sas_uri: str, - from_time: datetime.datetime, - to_time: datetime.datetime, - interval_length: Union[str, "_models.IntervalInMins"], - group_by_throttle_policy: Optional[bool] = None, - group_by_operation_name: Optional[bool] = None, - group_by_resource_name: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics - Api writes output logs to. Required. - :paramtype blob_container_sas_uri: str - :keyword from_time: From time of the query. Required. - :paramtype from_time: ~datetime.datetime - :keyword to_time: To time of the query. Required. - :paramtype to_time: ~datetime.datetime - :keyword group_by_throttle_policy: Group query result by Throttle Policy applied. - :paramtype group_by_throttle_policy: bool - :keyword group_by_operation_name: Group query result by Operation Name. - :paramtype group_by_operation_name: bool - :keyword group_by_resource_name: Group query result by Resource Name. - :paramtype group_by_resource_name: bool - :keyword interval_length: Interval value in minutes used to create LogAnalytics call rate logs. - Required. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", and "SixtyMins". - :paramtype interval_length: str or ~azure.mgmt.compute.v2017_12_01.models.IntervalInMins - """ - super().__init__( - blob_container_sas_uri=blob_container_sas_uri, - from_time=from_time, - to_time=to_time, - group_by_throttle_policy=group_by_throttle_policy, - group_by_operation_name=group_by_operation_name, - group_by_resource_name=group_by_resource_name, - **kwargs - ) - self.interval_length = interval_length - - -class RollbackStatusInfo(_serialization.Model): - """Information about rollback on failed VM instances after a OS Upgrade operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar successfully_rolledback_instance_count: The number of instances which have been - successfully rolled back. - :vartype successfully_rolledback_instance_count: int - :ivar failed_rolledback_instance_count: The number of instances which failed to rollback. - :vartype failed_rolledback_instance_count: int - :ivar rollback_error: Error details if OS rollback failed. - :vartype rollback_error: ~azure.mgmt.compute.v2017_12_01.models.ApiError - """ - - _validation = { - "successfully_rolledback_instance_count": {"readonly": True}, - "failed_rolledback_instance_count": {"readonly": True}, - "rollback_error": {"readonly": True}, - } - - _attribute_map = { - "successfully_rolledback_instance_count": {"key": "successfullyRolledbackInstanceCount", "type": "int"}, - "failed_rolledback_instance_count": {"key": "failedRolledbackInstanceCount", "type": "int"}, - "rollback_error": {"key": "rollbackError", "type": "ApiError"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.successfully_rolledback_instance_count: Optional[int] = None - self.failed_rolledback_instance_count: Optional[int] = None - self.rollback_error: Optional["_models.ApiError"] = None - - -class RollingUpgradePolicy(_serialization.Model): - """The configuration parameters used while performing a rolling upgrade. - - :ivar max_batch_instance_percent: The maximum percent of total virtual machine instances that - will be upgraded simultaneously by the rolling upgrade in one batch. As this is a maximum, - unhealthy instances in previous or future batches can cause the percentage of instances in a - batch to decrease to ensure higher reliability. The default value for this parameter is 20%. - :vartype max_batch_instance_percent: int - :ivar max_unhealthy_instance_percent: The maximum percentage of the total virtual machine - instances in the scale set that can be simultaneously unhealthy, either as a result of being - upgraded, or by being found in an unhealthy state by the virtual machine health checks before - the rolling upgrade aborts. This constraint will be checked prior to starting any batch. The - default value for this parameter is 20%. - :vartype max_unhealthy_instance_percent: int - :ivar max_unhealthy_upgraded_instance_percent: The maximum percentage of upgraded virtual - machine instances that can be found to be in an unhealthy state. This check will happen after - each batch is upgraded. If this percentage is ever exceeded, the rolling update aborts. The - default value for this parameter is 20%. - :vartype max_unhealthy_upgraded_instance_percent: int - :ivar pause_time_between_batches: The wait time between completing the update for all virtual - machines in one batch and starting the next batch. The time duration should be specified in ISO - 8601 format. The default value is 0 seconds (PT0S). - :vartype pause_time_between_batches: str - """ - - _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}, - } - - _attribute_map = { - "max_batch_instance_percent": {"key": "maxBatchInstancePercent", "type": "int"}, - "max_unhealthy_instance_percent": {"key": "maxUnhealthyInstancePercent", "type": "int"}, - "max_unhealthy_upgraded_instance_percent": {"key": "maxUnhealthyUpgradedInstancePercent", "type": "int"}, - "pause_time_between_batches": {"key": "pauseTimeBetweenBatches", "type": "str"}, - } - - def __init__( - self, - *, - max_batch_instance_percent: Optional[int] = None, - max_unhealthy_instance_percent: Optional[int] = None, - max_unhealthy_upgraded_instance_percent: Optional[int] = None, - pause_time_between_batches: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword max_batch_instance_percent: The maximum percent of total virtual machine instances - that will be upgraded simultaneously by the rolling upgrade in one batch. As this is a maximum, - unhealthy instances in previous or future batches can cause the percentage of instances in a - batch to decrease to ensure higher reliability. The default value for this parameter is 20%. - :paramtype max_batch_instance_percent: int - :keyword max_unhealthy_instance_percent: The maximum percentage of the total virtual machine - instances in the scale set that can be simultaneously unhealthy, either as a result of being - upgraded, or by being found in an unhealthy state by the virtual machine health checks before - the rolling upgrade aborts. This constraint will be checked prior to starting any batch. The - default value for this parameter is 20%. - :paramtype max_unhealthy_instance_percent: int - :keyword max_unhealthy_upgraded_instance_percent: The maximum percentage of upgraded virtual - machine instances that can be found to be in an unhealthy state. This check will happen after - each batch is upgraded. If this percentage is ever exceeded, the rolling update aborts. The - default value for this parameter is 20%. - :paramtype max_unhealthy_upgraded_instance_percent: int - :keyword pause_time_between_batches: The wait time between completing the update for all - virtual machines in one batch and starting the next batch. The time duration should be - specified in ISO 8601 format. The default value is 0 seconds (PT0S). - :paramtype pause_time_between_batches: str - """ - super().__init__(**kwargs) - self.max_batch_instance_percent = max_batch_instance_percent - self.max_unhealthy_instance_percent = max_unhealthy_instance_percent - self.max_unhealthy_upgraded_instance_percent = max_unhealthy_upgraded_instance_percent - self.pause_time_between_batches = pause_time_between_batches - - -class RollingUpgradeProgressInfo(_serialization.Model): - """Information about the number of virtual machine instances in each upgrade state. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar successful_instance_count: The number of instances that have been successfully upgraded. - :vartype successful_instance_count: int - :ivar failed_instance_count: The number of instances that have failed to be upgraded - successfully. - :vartype failed_instance_count: int - :ivar in_progress_instance_count: The number of instances that are currently being upgraded. - :vartype in_progress_instance_count: int - :ivar pending_instance_count: The number of instances that have not yet begun to be upgraded. - :vartype pending_instance_count: int - """ - - _validation = { - "successful_instance_count": {"readonly": True}, - "failed_instance_count": {"readonly": True}, - "in_progress_instance_count": {"readonly": True}, - "pending_instance_count": {"readonly": True}, - } - - _attribute_map = { - "successful_instance_count": {"key": "successfulInstanceCount", "type": "int"}, - "failed_instance_count": {"key": "failedInstanceCount", "type": "int"}, - "in_progress_instance_count": {"key": "inProgressInstanceCount", "type": "int"}, - "pending_instance_count": {"key": "pendingInstanceCount", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.successful_instance_count: Optional[int] = None - self.failed_instance_count: Optional[int] = None - self.in_progress_instance_count: Optional[int] = None - self.pending_instance_count: Optional[int] = None - - -class RollingUpgradeRunningStatus(_serialization.Model): - """Information about the current running state of the overall upgrade. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Code indicating the current status of the upgrade. Known values are: - "RollingForward", "Cancelled", "Completed", and "Faulted". - :vartype code: str or ~azure.mgmt.compute.v2017_12_01.models.RollingUpgradeStatusCode - :ivar start_time: Start time of the upgrade. - :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start" - and "Cancel". - :vartype last_action: str or ~azure.mgmt.compute.v2017_12_01.models.RollingUpgradeActionType - :ivar last_action_time: Last action time of the upgrade. - :vartype last_action_time: ~datetime.datetime - """ - - _validation = { - "code": {"readonly": True}, - "start_time": {"readonly": True}, - "last_action": {"readonly": True}, - "last_action_time": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "last_action": {"key": "lastAction", "type": "str"}, - "last_action_time": {"key": "lastActionTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[Union[str, "_models.RollingUpgradeStatusCode"]] = None - self.start_time: Optional[datetime.datetime] = None - self.last_action: Optional[Union[str, "_models.RollingUpgradeActionType"]] = None - self.last_action_time: Optional[datetime.datetime] = None - - -class RollingUpgradeStatusInfo(Resource): - """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. - :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] - :ivar policy: The rolling upgrade policies applied for this upgrade. - :vartype policy: ~azure.mgmt.compute.v2017_12_01.models.RollingUpgradePolicy - :ivar running_status: Information about the current running state of the overall upgrade. - :vartype running_status: ~azure.mgmt.compute.v2017_12_01.models.RollingUpgradeRunningStatus - :ivar progress: Information about the number of virtual machine instances in each upgrade - state. - :vartype progress: ~azure.mgmt.compute.v2017_12_01.models.RollingUpgradeProgressInfo - :ivar error: Error details for this upgrade, if there are any. - :vartype error: ~azure.mgmt.compute.v2017_12_01.models.ApiError - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "policy": {"readonly": True}, - "running_status": {"readonly": True}, - "progress": {"readonly": True}, - "error": {"readonly": 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}"}, - "policy": {"key": "properties.policy", "type": "RollingUpgradePolicy"}, - "running_status": {"key": "properties.runningStatus", "type": "RollingUpgradeRunningStatus"}, - "progress": {"key": "properties.progress", "type": "RollingUpgradeProgressInfo"}, - "error": {"key": "properties.error", "type": "ApiError"}, - } - - 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__(location=location, tags=tags, **kwargs) - self.policy: Optional["_models.RollingUpgradePolicy"] = None - self.running_status: Optional["_models.RollingUpgradeRunningStatus"] = None - self.progress: Optional["_models.RollingUpgradeProgressInfo"] = None - self.error: Optional["_models.ApiError"] = None - - -class RunCommandDocumentBase(_serialization.Model): - """Describes the properties of a Run Command metadata. - - All required parameters must be populated in order to send to server. - - :ivar schema: The VM run command schema. Required. - :vartype schema: str - :ivar id: The VM run command id. Required. - :vartype id: str - :ivar os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes - :ivar label: The VM run command label. Required. - :vartype label: str - :ivar description: The VM run command description. Required. - :vartype description: str - """ - - _validation = { - "schema": {"required": True}, - "id": {"required": True}, - "os_type": {"required": True}, - "label": {"required": True}, - "description": {"required": True}, - } - - _attribute_map = { - "schema": {"key": "$schema", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "os_type": {"key": "osType", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - schema: str, - id: str, # pylint: disable=redefined-builtin - os_type: Union[str, "_models.OperatingSystemTypes"], - label: str, - description: str, - **kwargs: Any - ) -> None: - """ - :keyword schema: The VM run command schema. Required. - :paramtype schema: str - :keyword id: The VM run command id. Required. - :paramtype id: str - :keyword os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes - :keyword label: The VM run command label. Required. - :paramtype label: str - :keyword description: The VM run command description. Required. - :paramtype description: str - """ - super().__init__(**kwargs) - self.schema = schema - self.id = id - self.os_type = os_type - self.label = label - self.description = description - - -class RunCommandDocument(RunCommandDocumentBase): - """Describes the properties of a Run Command. - - All required parameters must be populated in order to send to server. - - :ivar schema: The VM run command schema. Required. - :vartype schema: str - :ivar id: The VM run command id. Required. - :vartype id: str - :ivar os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes - :ivar label: The VM run command label. Required. - :vartype label: str - :ivar description: The VM run command description. Required. - :vartype description: str - :ivar script: The script to be executed. Required. - :vartype script: list[str] - :ivar parameters: The parameters used by the script. - :vartype parameters: list[~azure.mgmt.compute.v2017_12_01.models.RunCommandParameterDefinition] - """ - - _validation = { - "schema": {"required": True}, - "id": {"required": True}, - "os_type": {"required": True}, - "label": {"required": True}, - "description": {"required": True}, - "script": {"required": True}, - } - - _attribute_map = { - "schema": {"key": "$schema", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "os_type": {"key": "osType", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "script": {"key": "script", "type": "[str]"}, - "parameters": {"key": "parameters", "type": "[RunCommandParameterDefinition]"}, - } - - def __init__( - self, - *, - schema: str, - id: str, # pylint: disable=redefined-builtin - os_type: Union[str, "_models.OperatingSystemTypes"], - label: str, - description: str, - script: List[str], - parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword schema: The VM run command schema. Required. - :paramtype schema: str - :keyword id: The VM run command id. Required. - :paramtype id: str - :keyword os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes - :keyword label: The VM run command label. Required. - :paramtype label: str - :keyword description: The VM run command description. Required. - :paramtype description: str - :keyword script: The script to be executed. Required. - :paramtype script: list[str] - :keyword parameters: The parameters used by the script. - :paramtype parameters: - list[~azure.mgmt.compute.v2017_12_01.models.RunCommandParameterDefinition] - """ - super().__init__(schema=schema, id=id, os_type=os_type, label=label, description=description, **kwargs) - self.script = script - self.parameters = parameters - - -class RunCommandInput(_serialization.Model): - """Capture Virtual Machine parameters. - - All required parameters must be populated in order to send to server. - - :ivar command_id: The run command id. Required. - :vartype command_id: str - :ivar script: Optional. The script to be executed. When this value is given, the given script - will override the default script of the command. - :vartype script: list[str] - :ivar parameters: The run command parameters. - :vartype parameters: list[~azure.mgmt.compute.v2017_12_01.models.RunCommandInputParameter] - """ - - _validation = { - "command_id": {"required": True}, - } - - _attribute_map = { - "command_id": {"key": "commandId", "type": "str"}, - "script": {"key": "script", "type": "[str]"}, - "parameters": {"key": "parameters", "type": "[RunCommandInputParameter]"}, - } - - def __init__( - self, - *, - command_id: str, - script: Optional[List[str]] = None, - parameters: Optional[List["_models.RunCommandInputParameter"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword command_id: The run command id. Required. - :paramtype command_id: str - :keyword script: Optional. The script to be executed. When this value is given, the given - script will override the default script of the command. - :paramtype script: list[str] - :keyword parameters: The run command parameters. - :paramtype parameters: list[~azure.mgmt.compute.v2017_12_01.models.RunCommandInputParameter] - """ - super().__init__(**kwargs) - self.command_id = command_id - self.script = script - self.parameters = parameters - - -class RunCommandInputParameter(_serialization.Model): - """Describes the properties of a run command parameter. - - All required parameters must be populated in order to send to server. - - :ivar name: The run command parameter name. Required. - :vartype name: str - :ivar value: The run command parameter value. Required. - :vartype value: str - """ - - _validation = { - "name": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: - """ - :keyword name: The run command parameter name. Required. - :paramtype name: str - :keyword value: The run command parameter value. Required. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class RunCommandListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine run commands. Required. - :vartype value: list[~azure.mgmt.compute.v2017_12_01.models.RunCommandDocumentBase] - :ivar next_link: The uri to fetch the next page of run commands. Call ListNext() with this to - fetch the next page of run commands. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RunCommandDocumentBase]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine run commands. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_12_01.models.RunCommandDocumentBase] - :keyword next_link: The uri to fetch the next page of run commands. Call ListNext() with this - to fetch the next page of run commands. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RunCommandParameterDefinition(_serialization.Model): - """Describes the properties of a run command parameter. - - All required parameters must be populated in order to send to server. - - :ivar name: The run command parameter name. Required. - :vartype name: str - :ivar type: The run command parameter type. Required. - :vartype type: str - :ivar default_value: The run command parameter default value. - :vartype default_value: str - :ivar required: The run command parameter required. - :vartype required: bool - """ - - _validation = { - "name": {"required": True}, - "type": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "default_value": {"key": "defaultValue", "type": "str"}, - "required": {"key": "required", "type": "bool"}, - } - - def __init__( - self, *, name: str, type: str, default_value: Optional[str] = None, required: bool = False, **kwargs: Any - ) -> None: - """ - :keyword name: The run command parameter name. Required. - :paramtype name: str - :keyword type: The run command parameter type. Required. - :paramtype type: str - :keyword default_value: The run command parameter default value. - :paramtype default_value: str - :keyword required: The run command parameter required. - :paramtype required: bool - """ - super().__init__(**kwargs) - self.name = name - self.type = type - self.default_value = default_value - self.required = required - - -class RunCommandResult(OperationStatusResponse): - """Run command operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation ID. - :vartype name: str - :ivar status: Operation status. - :vartype status: str - :ivar start_time: Start time of the operation. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the operation. - :vartype end_time: ~datetime.datetime - :ivar error: Api error. - :vartype error: ~azure.mgmt.compute.v2017_12_01.models.ApiError - :ivar output: Operation output data (raw JSON). - :vartype output: JSON - """ - - _validation = { - "name": {"readonly": True}, - "status": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - "error": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "error": {"key": "error", "type": "ApiError"}, - "output": {"key": "properties.output", "type": "object"}, - } - - def __init__(self, *, output: Optional[JSON] = None, **kwargs: Any) -> None: - """ - :keyword output: Operation output data (raw JSON). - :paramtype output: JSON - """ - super().__init__(**kwargs) - self.output = output - - -class Sku(_serialization.Model): - """Describes a virtual machine scale set sku. NOTE: If the new VM SKU is not supported on the - hardware the scale set is currently on, you need to deallocate the VMs in the scale set before - you modify the SKU name. - - :ivar name: The sku name. - :vartype name: str - :ivar tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
    `\\ - :code:`
    ` Possible Values:\\ :code:`
    `\\ :code:`
    ` **Standard**\\ :code:`
    `\\ :code:`
    ` **Basic**. - :vartype tier: str - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: int - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "capacity": {"key": "capacity", "type": "int"}, - } - - def __init__( - self, *, name: Optional[str] = None, tier: Optional[str] = None, capacity: Optional[int] = None, **kwargs: Any - ) -> None: - """ - :keyword name: The sku name. - :paramtype name: str - :keyword tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
    `\\ - :code:`
    ` Possible Values:\\ :code:`
    `\\ :code:`
    ` **Standard**\\ :code:`
    `\\ :code:`
    ` **Basic**. - :paramtype tier: str - :keyword capacity: Specifies the number of virtual machines in the scale set. - :paramtype capacity: int - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - self.capacity = capacity - - -class SshConfiguration(_serialization.Model): - """SSH configuration for Linux based VMs running on Azure. - - :ivar public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :vartype public_keys: list[~azure.mgmt.compute.v2017_12_01.models.SshPublicKey] - """ - - _attribute_map = { - "public_keys": {"key": "publicKeys", "type": "[SshPublicKey]"}, - } - - def __init__(self, *, public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs: Any) -> None: - """ - :keyword public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :paramtype public_keys: list[~azure.mgmt.compute.v2017_12_01.models.SshPublicKey] - """ - super().__init__(**kwargs) - self.public_keys = public_keys - - -class SshPublicKey(_serialization.Model): - """Contains information about SSH certificate public key and the path on the Linux VM where the - public key is placed. - - :ivar path: Specifies the full path on the created VM where ssh public key is stored. If the - file already exists, the specified key is appended to the file. Example: - /home/user/.ssh/authorized_keys. - :vartype path: str - :ivar key_data: SSH public key certificate used to authenticate with the VM through ssh. The - key needs to be at least 2048-bit and in ssh-rsa format. :code:`
    `\\ :code:`
    ` For - creating ssh keys, see `Create SSH keys on Linux and Mac for Linux VMs in Azure - `_. - :vartype key_data: str - """ - - _attribute_map = { - "path": {"key": "path", "type": "str"}, - "key_data": {"key": "keyData", "type": "str"}, - } - - def __init__(self, *, path: Optional[str] = None, key_data: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword path: Specifies the full path on the created VM where ssh public key is stored. If the - file already exists, the specified key is appended to the file. Example: - /home/user/.ssh/authorized_keys. - :paramtype path: str - :keyword key_data: SSH public key certificate used to authenticate with the VM through ssh. The - key needs to be at least 2048-bit and in ssh-rsa format. :code:`
    `\\ :code:`
    ` For - creating ssh keys, see `Create SSH keys on Linux and Mac for Linux VMs in Azure - `_. - :paramtype key_data: str - """ - super().__init__(**kwargs) - self.path = path - self.key_data = key_data - - -class StorageProfile(_serialization.Model): - """Specifies the storage settings for the virtual machine disks. - - :ivar image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :vartype image_reference: ~azure.mgmt.compute.v2017_12_01.models.ImageReference - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2017_12_01.models.OSDisk - :ivar data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype data_disks: list[~azure.mgmt.compute.v2017_12_01.models.DataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "OSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[DataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.OSDisk"] = None, - data_disks: Optional[List["_models.DataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :paramtype image_reference: ~azure.mgmt.compute.v2017_12_01.models.ImageReference - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2017_12_01.models.OSDisk - :keyword data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype data_disks: list[~azure.mgmt.compute.v2017_12_01.models.DataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class SubResourceReadOnly(_serialization.Model): - """SubResourceReadOnly. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class ThrottledRequestsInput(LogAnalyticsInputBase): - """Api request input for LogAnalytics getThrottledRequests Api. - - All required parameters must be populated in order to send to server. - - :ivar blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api - writes output logs to. Required. - :vartype blob_container_sas_uri: str - :ivar from_time: From time of the query. Required. - :vartype from_time: ~datetime.datetime - :ivar to_time: To time of the query. Required. - :vartype to_time: ~datetime.datetime - :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. - :vartype group_by_throttle_policy: bool - :ivar group_by_operation_name: Group query result by Operation Name. - :vartype group_by_operation_name: bool - :ivar group_by_resource_name: Group query result by Resource Name. - :vartype group_by_resource_name: bool - """ - - -class UpgradeOperationHistoricalStatusInfo(_serialization.Model): - """Virtual Machine Scale Set OS Upgrade History operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar properties: Information about the properties of the upgrade operation. - :vartype properties: - ~azure.mgmt.compute.v2017_12_01.models.UpgradeOperationHistoricalStatusInfoProperties - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - """ - - _validation = { - "properties": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "properties": {"key": "properties", "type": "UpgradeOperationHistoricalStatusInfoProperties"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.properties: Optional["_models.UpgradeOperationHistoricalStatusInfoProperties"] = None - self.type: Optional[str] = None - self.location: Optional[str] = None - - -class UpgradeOperationHistoricalStatusInfoProperties(_serialization.Model): # pylint: disable=name-too-long - """Describes each OS upgrade on the Virtual Machine Scale Set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar running_status: Information about the overall status of the upgrade operation. - :vartype running_status: ~azure.mgmt.compute.v2017_12_01.models.UpgradeOperationHistoryStatus - :ivar progress: Counts of the VMs in each state. - :vartype progress: ~azure.mgmt.compute.v2017_12_01.models.RollingUpgradeProgressInfo - :ivar error: Error Details for this upgrade if there are any. - :vartype error: ~azure.mgmt.compute.v2017_12_01.models.ApiError - :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", and - "Platform". - :vartype started_by: str or ~azure.mgmt.compute.v2017_12_01.models.UpgradeOperationInvoker - :ivar target_image_reference: Image Reference details. - :vartype target_image_reference: ~azure.mgmt.compute.v2017_12_01.models.ImageReference - :ivar rollback_info: Information about OS rollback if performed. - :vartype rollback_info: ~azure.mgmt.compute.v2017_12_01.models.RollbackStatusInfo - """ - - _validation = { - "running_status": {"readonly": True}, - "progress": {"readonly": True}, - "error": {"readonly": True}, - "started_by": {"readonly": True}, - "target_image_reference": {"readonly": True}, - "rollback_info": {"readonly": True}, - } - - _attribute_map = { - "running_status": {"key": "runningStatus", "type": "UpgradeOperationHistoryStatus"}, - "progress": {"key": "progress", "type": "RollingUpgradeProgressInfo"}, - "error": {"key": "error", "type": "ApiError"}, - "started_by": {"key": "startedBy", "type": "str"}, - "target_image_reference": {"key": "targetImageReference", "type": "ImageReference"}, - "rollback_info": {"key": "rollbackInfo", "type": "RollbackStatusInfo"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.running_status: Optional["_models.UpgradeOperationHistoryStatus"] = None - self.progress: Optional["_models.RollingUpgradeProgressInfo"] = None - self.error: Optional["_models.ApiError"] = None - self.started_by: Optional[Union[str, "_models.UpgradeOperationInvoker"]] = None - self.target_image_reference: Optional["_models.ImageReference"] = None - self.rollback_info: Optional["_models.RollbackStatusInfo"] = None - - -class UpgradeOperationHistoryStatus(_serialization.Model): - """Information about the current running state of the overall upgrade. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Code indicating the current status of the upgrade. Known values are: - "RollingForward", "Cancelled", "Completed", and "Faulted". - :vartype code: str or ~azure.mgmt.compute.v2017_12_01.models.UpgradeState - :ivar start_time: Start time of the upgrade. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the upgrade. - :vartype end_time: ~datetime.datetime - """ - - _validation = { - "code": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[Union[str, "_models.UpgradeState"]] = None - self.start_time: Optional[datetime.datetime] = None - self.end_time: Optional[datetime.datetime] = None - - -class UpgradePolicy(_serialization.Model): - """Describes an upgrade policy - automatic, manual, or rolling. - - :ivar mode: Specifies the mode of an upgrade to virtual machines in the scale set.\\ :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Manual** - You - control the application of updates to virtual machines in the scale set. You do this by using - the manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - All virtual - machines in the scale set are automatically updated at the same time. Known values are: - "Automatic", "Manual", and "Rolling". - :vartype mode: str or ~azure.mgmt.compute.v2017_12_01.models.UpgradeMode - :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling - upgrade. - :vartype rolling_upgrade_policy: ~azure.mgmt.compute.v2017_12_01.models.RollingUpgradePolicy - :ivar automatic_os_upgrade: Whether OS upgrades should automatically be applied to scale set - instances in a rolling fashion when a newer version of the image becomes available. - :vartype automatic_os_upgrade: bool - :ivar auto_os_upgrade_policy: Configuration parameters used for performing automatic OS - Upgrade. - :vartype auto_os_upgrade_policy: ~azure.mgmt.compute.v2017_12_01.models.AutoOSUpgradePolicy - """ - - _attribute_map = { - "mode": {"key": "mode", "type": "str"}, - "rolling_upgrade_policy": {"key": "rollingUpgradePolicy", "type": "RollingUpgradePolicy"}, - "automatic_os_upgrade": {"key": "automaticOSUpgrade", "type": "bool"}, - "auto_os_upgrade_policy": {"key": "autoOSUpgradePolicy", "type": "AutoOSUpgradePolicy"}, - } - - def __init__( - self, - *, - mode: Optional[Union[str, "_models.UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, - automatic_os_upgrade: Optional[bool] = None, - auto_os_upgrade_policy: Optional["_models.AutoOSUpgradePolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword mode: Specifies the mode of an upgrade to virtual machines in the scale set.\\ - :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` - **Manual** - You control the application of updates to virtual machines in the scale set. You - do this by using the manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - - All virtual machines in the scale set are automatically updated at the same time. Known values - are: "Automatic", "Manual", and "Rolling". - :paramtype mode: str or ~azure.mgmt.compute.v2017_12_01.models.UpgradeMode - :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling - upgrade. - :paramtype rolling_upgrade_policy: ~azure.mgmt.compute.v2017_12_01.models.RollingUpgradePolicy - :keyword automatic_os_upgrade: Whether OS upgrades should automatically be applied to scale set - instances in a rolling fashion when a newer version of the image becomes available. - :paramtype automatic_os_upgrade: bool - :keyword auto_os_upgrade_policy: Configuration parameters used for performing automatic OS - Upgrade. - :paramtype auto_os_upgrade_policy: ~azure.mgmt.compute.v2017_12_01.models.AutoOSUpgradePolicy - """ - super().__init__(**kwargs) - self.mode = mode - self.rolling_upgrade_policy = rolling_upgrade_policy - self.automatic_os_upgrade = automatic_os_upgrade - self.auto_os_upgrade_policy = auto_os_upgrade_policy - - -class Usage(_serialization.Model): - """Describes Compute Resource Usage. - - 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 unit: An enum describing the unit of usage measurement. Required. Default value is - "Count". - :vartype unit: str - :ivar current_value: The current usage of the resource. Required. - :vartype current_value: int - :ivar limit: The maximum permitted usage of the resource. Required. - :vartype limit: int - :ivar name: The name of the type of usage. Required. - :vartype name: ~azure.mgmt.compute.v2017_12_01.models.UsageName - """ - - _validation = { - "unit": {"required": True, "constant": True}, - "current_value": {"required": True}, - "limit": {"required": True}, - "name": {"required": True}, - } - - _attribute_map = { - "unit": {"key": "unit", "type": "str"}, - "current_value": {"key": "currentValue", "type": "int"}, - "limit": {"key": "limit", "type": "int"}, - "name": {"key": "name", "type": "UsageName"}, - } - - unit = "Count" - - def __init__(self, *, current_value: int, limit: int, name: "_models.UsageName", **kwargs: Any) -> None: - """ - :keyword current_value: The current usage of the resource. Required. - :paramtype current_value: int - :keyword limit: The maximum permitted usage of the resource. Required. - :paramtype limit: int - :keyword name: The name of the type of usage. Required. - :paramtype name: ~azure.mgmt.compute.v2017_12_01.models.UsageName - """ - super().__init__(**kwargs) - self.current_value = current_value - self.limit = limit - self.name = name - - -class UsageName(_serialization.Model): - """The Usage Names. - - :ivar value: The name of the resource. - :vartype value: str - :ivar localized_value: The localized name of the resource. - :vartype localized_value: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, - } - - def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The name of the resource. - :paramtype value: str - :keyword localized_value: The localized name of the resource. - :paramtype localized_value: str - """ - super().__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - -class VaultCertificate(_serialization.Model): - """Describes a single certificate reference in a Key Vault, and where the certificate should - reside on the VM. - - :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as - a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :vartype certificate_url: str - :ivar certificate_store: For Windows VMs, specifies the certificate store on the Virtual - Machine to which the certificate should be added. The specified certificate store is implicitly - in the LocalMachine account. :code:`
    `\\ :code:`
    `For Linux VMs, the certificate file is - placed under the /var/lib/waagent directory, with the file name <UppercaseThumbprint>.crt - for the X509 certificate file and <UppercaseThumbprint>.prv for private key. Both of - these files are .pem formatted. - :vartype certificate_store: str - """ - - _attribute_map = { - "certificate_url": {"key": "certificateUrl", "type": "str"}, - "certificate_store": {"key": "certificateStore", "type": "str"}, - } - - def __init__( - self, *, certificate_url: Optional[str] = None, certificate_store: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault - as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :paramtype certificate_url: str - :keyword certificate_store: For Windows VMs, specifies the certificate store on the Virtual - Machine to which the certificate should be added. The specified certificate store is implicitly - in the LocalMachine account. :code:`
    `\\ :code:`
    `For Linux VMs, the certificate file is - placed under the /var/lib/waagent directory, with the file name <UppercaseThumbprint>.crt - for the X509 certificate file and <UppercaseThumbprint>.prv for private key. Both of - these files are .pem formatted. - :paramtype certificate_store: str - """ - super().__init__(**kwargs) - self.certificate_url = certificate_url - self.certificate_store = certificate_store - - -class VaultSecretGroup(_serialization.Model): - """Describes a set of certificates which are all in the same Key Vault. - - :ivar source_vault: The relative URL of the Key Vault containing all of the certificates in - VaultCertificates. - :vartype source_vault: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :ivar vault_certificates: The list of key vault references in SourceVault which contain - certificates. - :vartype vault_certificates: list[~azure.mgmt.compute.v2017_12_01.models.VaultCertificate] - """ - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - "vault_certificates": {"key": "vaultCertificates", "type": "[VaultCertificate]"}, - } - - def __init__( - self, - *, - source_vault: Optional["_models.SubResource"] = None, - vault_certificates: Optional[List["_models.VaultCertificate"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source_vault: The relative URL of the Key Vault containing all of the certificates in - VaultCertificates. - :paramtype source_vault: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :keyword vault_certificates: The list of key vault references in SourceVault which contain - certificates. - :paramtype vault_certificates: list[~azure.mgmt.compute.v2017_12_01.models.VaultCertificate] - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.vault_certificates = vault_certificates - - -class VirtualHardDisk(_serialization.Model): - """Describes the uri of a disk. - - :ivar uri: Specifies the virtual hard disk's uri. - :vartype uri: str - """ - - _attribute_map = { - "uri": {"key": "uri", "type": "str"}, - } - - def __init__(self, *, uri: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword uri: Specifies the virtual hard disk's uri. - :paramtype uri: str - """ - super().__init__(**kwargs) - self.uri = uri - - -class VirtualMachine(Resource): - """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. - :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] - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2017_12_01.models.Plan - :ivar resources: The virtual machine child extension resources. - :vartype resources: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtension] - :ivar identity: The identity of the virtual machine, if configured. - :vartype identity: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineIdentity - :ivar zones: The virtual machine zones. - :vartype zones: list[str] - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2017_12_01.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2017_12_01.models.StorageProfile - :ivar os_profile: Specifies the operating system settings for the virtual machine. - :vartype os_profile: ~azure.mgmt.compute.v2017_12_01.models.OSProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2017_12_01.models.NetworkProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2017_12_01.models.DiagnosticsProfile - :ivar availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :vartype availability_set: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineInstanceView - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar vm_id: Specifies the VM unique ID which is a 128-bits identifier that is encoded and - stored in all Azure IaaS VMs SMBIOS and can be read using platform BIOS commands. - :vartype vm_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "resources": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - "vm_id": {"readonly": 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}"}, - "plan": {"key": "plan", "type": "Plan"}, - "resources": {"key": "resources", "type": "[VirtualMachineExtension]"}, - "identity": {"key": "identity", "type": "VirtualMachineIdentity"}, - "zones": {"key": "zones", "type": "[str]"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineInstanceView"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineIdentity"] = None, - zones: Optional[List[str]] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - os_profile: Optional["_models.OSProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2017_12_01.models.Plan - :keyword identity: The identity of the virtual machine, if configured. - :paramtype identity: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineIdentity - :keyword zones: The virtual machine zones. - :paramtype zones: list[str] - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2017_12_01.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2017_12_01.models.StorageProfile - :keyword os_profile: Specifies the operating system settings for the virtual machine. - :paramtype os_profile: ~azure.mgmt.compute.v2017_12_01.models.OSProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2017_12_01.models.NetworkProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2017_12_01.models.DiagnosticsProfile - :keyword availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :paramtype availability_set: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.plan = plan - self.resources: Optional[List["_models.VirtualMachineExtension"]] = None - self.identity = identity - self.zones = zones - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.os_profile = os_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineInstanceView"] = None - self.license_type = license_type - self.vm_id: Optional[str] = None - - -class VirtualMachineAgentInstanceView(_serialization.Model): - """The instance view of the VM Agent running on the virtual machine. - - :ivar vm_agent_version: The VM Agent full version. - :vartype vm_agent_version: str - :ivar extension_handlers: The virtual machine extension handler instance view. - :vartype extension_handlers: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtensionHandlerInstanceView] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "vm_agent_version": {"key": "vmAgentVersion", "type": "str"}, - "extension_handlers": {"key": "extensionHandlers", "type": "[VirtualMachineExtensionHandlerInstanceView]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword vm_agent_version: The VM Agent full version. - :paramtype vm_agent_version: str - :keyword extension_handlers: The virtual machine extension handler instance view. - :paramtype extension_handlers: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtensionHandlerInstanceView] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.vm_agent_version = vm_agent_version - self.extension_handlers = extension_handlers - self.statuses = statuses - - -class VirtualMachineCaptureParameters(_serialization.Model): - """Capture Virtual Machine parameters. - - All required parameters must be populated in order to send to server. - - :ivar vhd_prefix: The captured virtual hard disk's name prefix. Required. - :vartype vhd_prefix: str - :ivar destination_container_name: The destination container name. Required. - :vartype destination_container_name: str - :ivar overwrite_vhds: Specifies whether to overwrite the destination virtual hard disk, in case - of conflict. Required. - :vartype overwrite_vhds: bool - """ - - _validation = { - "vhd_prefix": {"required": True}, - "destination_container_name": {"required": True}, - "overwrite_vhds": {"required": True}, - } - - _attribute_map = { - "vhd_prefix": {"key": "vhdPrefix", "type": "str"}, - "destination_container_name": {"key": "destinationContainerName", "type": "str"}, - "overwrite_vhds": {"key": "overwriteVhds", "type": "bool"}, - } - - def __init__( - self, *, vhd_prefix: str, destination_container_name: str, overwrite_vhds: bool, **kwargs: Any - ) -> None: - """ - :keyword vhd_prefix: The captured virtual hard disk's name prefix. Required. - :paramtype vhd_prefix: str - :keyword destination_container_name: The destination container name. Required. - :paramtype destination_container_name: str - :keyword overwrite_vhds: Specifies whether to overwrite the destination virtual hard disk, in - case of conflict. Required. - :paramtype overwrite_vhds: bool - """ - super().__init__(**kwargs) - self.vhd_prefix = vhd_prefix - self.destination_container_name = destination_container_name - self.overwrite_vhds = overwrite_vhds - - -class VirtualMachineCaptureResult(SubResource): - """Resource Id. - - :ivar id: Resource Id. - :vartype id: str - :ivar output: Operation output data (raw JSON). - :vartype output: JSON - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "output": {"key": "properties.output", "type": "object"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - output: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword output: Operation output data (raw JSON). - :paramtype output: JSON - """ - super().__init__(id=id, **kwargs) - self.output = output - - -class VirtualMachineExtension(Resource): - """Describes a Virtual Machine Extension. - - 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] - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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. - :vartype instance_view: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtensionInstanceView - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineExtensionInstanceView"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, 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, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :keyword instance_view: The virtual machine extension instance view. - :paramtype instance_view: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtensionInstanceView - """ - super().__init__(location=location, tags=tags, **kwargs) - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - self.instance_view = instance_view - - -class VirtualMachineExtensionHandlerInstanceView(_serialization.Model): # pylint: disable=name-too-long - """The instance view of a virtual machine extension handler. - - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar status: The extension handler status. - :vartype status: ~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "status": {"key": "status", "type": "InstanceViewStatus"}, - } - - def __init__( - self, - *, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - status: Optional["_models.InstanceViewStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword status: The extension handler status. - :paramtype status: ~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus - """ - super().__init__(**kwargs) - self.type = type - self.type_handler_version = type_handler_version - self.status = status - - -class VirtualMachineExtensionImage(Resource): - """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. - :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] - :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. - :vartype compute_role: str - :ivar handler_schema: The schema defined by publisher, where extension consumers should provide - settings in a matching schema. - :vartype handler_schema: str - :ivar vm_scale_set_enabled: Whether the extension can be used on xRP VMScaleSets. By default - existing extensions are usable on scalesets, but there might be cases where a publisher wants - to explicitly indicate the extension is only enabled for CRP VMs but not VMSS. - :vartype vm_scale_set_enabled: bool - :ivar supports_multiple_extensions: Whether the handler can support multiple extensions. - :vartype supports_multiple_extensions: bool - """ - - _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}"}, - "operating_system": {"key": "properties.operatingSystem", "type": "str"}, - "compute_role": {"key": "properties.computeRole", "type": "str"}, - "handler_schema": {"key": "properties.handlerSchema", "type": "str"}, - "vm_scale_set_enabled": {"key": "properties.vmScaleSetEnabled", "type": "bool"}, - "supports_multiple_extensions": {"key": "properties.supportsMultipleExtensions", "type": "bool"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - operating_system: Optional[str] = None, - compute_role: Optional[str] = None, - handler_schema: Optional[str] = None, - vm_scale_set_enabled: Optional[bool] = None, - supports_multiple_extensions: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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. - :paramtype compute_role: str - :keyword handler_schema: The schema defined by publisher, where extension consumers should - provide settings in a matching schema. - :paramtype handler_schema: str - :keyword vm_scale_set_enabled: Whether the extension can be used on xRP VMScaleSets. By default - existing extensions are usable on scalesets, but there might be cases where a publisher wants - to explicitly indicate the extension is only enabled for CRP VMs but not VMSS. - :paramtype vm_scale_set_enabled: bool - :keyword supports_multiple_extensions: Whether the handler can support multiple extensions. - :paramtype supports_multiple_extensions: bool - """ - super().__init__(location=location, tags=tags, **kwargs) - self.operating_system = operating_system - self.compute_role = compute_role - self.handler_schema = handler_schema - self.vm_scale_set_enabled = vm_scale_set_enabled - self.supports_multiple_extensions = supports_multiple_extensions - - -class VirtualMachineExtensionInstanceView(_serialization.Model): - """The instance view of a virtual machine extension. - - :ivar name: The virtual machine extension name. - :vartype name: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar substatuses: The resource status information. - :vartype substatuses: list[~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "substatuses": {"key": "substatuses", "type": "[InstanceViewStatus]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - substatuses: Optional[List["_models.InstanceViewStatus"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The virtual machine extension name. - :paramtype name: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword substatuses: The resource status information. - :paramtype substatuses: list[~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.name = name - self.type = type - self.type_handler_version = type_handler_version - self.substatuses = substatuses - self.statuses = statuses - - -class VirtualMachineExtensionsListResult(_serialization.Model): - """The List Extension operation response. - - :ivar value: The list of extensions. - :vartype value: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtension] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineExtension]"}, - } - - def __init__(self, *, value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of extensions. - :paramtype value: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtension] - """ - super().__init__(**kwargs) - self.value = value - - -class VirtualMachineExtensionUpdate(UpdateResource): - """Describes a Virtual Machine Extension. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - force_update_tag: Optional[str] = None, - publisher: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - auto_upgrade_minor_version: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - """ - super().__init__(tags=tags, **kwargs) - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type = type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - - -class VirtualMachineHealthStatus(_serialization.Model): - """The health status of the VM. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The health status information for the VM. - :vartype status: ~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus - """ - - _validation = { - "status": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "InstanceViewStatus"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional["_models.InstanceViewStatus"] = None - - -class VirtualMachineIdentity(_serialization.Model): - """Identity for the virtual machine. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of virtual machine identity. This property will only be - provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the virtual machine. This property will only be - provided for a system assigned identity. - :vartype tenant_id: str - :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, - UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Known values - are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :vartype type: str or ~azure.mgmt.compute.v2017_12_01.models.ResourceIdentityType - :ivar identity_ids: The list of user identities associated with the Virtual Machine. The user - identity references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/identities/{identityName}'. - :vartype identity_ids: list[str] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "identity_ids": {"key": "identityIds", "type": "[str]"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, - identity_ids: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, - UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Known values - are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :paramtype type: str or ~azure.mgmt.compute.v2017_12_01.models.ResourceIdentityType - :keyword identity_ids: The list of user identities associated with the Virtual Machine. The - user identity references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/identities/{identityName}'. - :paramtype identity_ids: list[str] - """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.type = type - self.identity_ids = identity_ids - - -class VirtualMachineImageResource(SubResource): - """Virtual machine image resource information. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar location: The supported Azure location of the resource. Required. - :vartype location: str - :ivar tags: Specifies the tags that are assigned to the virtual machine. For more information - about using tags, see `Using tags to organize your Azure resources - `_. - :vartype tags: dict[str, str] - """ - - _validation = { - "name": {"required": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__( - self, - *, - name: str, - location: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The name of the resource. Required. - :paramtype name: str - :keyword location: The supported Azure location of the resource. Required. - :paramtype location: str - :keyword tags: Specifies the tags that are assigned to the virtual machine. For more - information about using tags, see `Using tags to organize your Azure resources - `_. - :paramtype tags: dict[str, str] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.location = location - self.tags = tags - - -class VirtualMachineImage(VirtualMachineImageResource): - """Describes a Virtual Machine Image. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar location: The supported Azure location of the resource. Required. - :vartype location: str - :ivar tags: Specifies the tags that are assigned to the virtual machine. For more information - about using tags, see `Using tags to organize your Azure resources - `_. - :vartype tags: dict[str, str] - :ivar plan: Used for establishing the purchase context of any 3rd Party artifact through - MarketPlace. - :vartype plan: ~azure.mgmt.compute.v2017_12_01.models.PurchasePlan - :ivar os_disk_image: Contains the os disk image information. - :vartype os_disk_image: ~azure.mgmt.compute.v2017_12_01.models.OSDiskImage - :ivar data_disk_images: - :vartype data_disk_images: list[~azure.mgmt.compute.v2017_12_01.models.DataDiskImage] - """ - - _validation = { - "name": {"required": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "plan": {"key": "properties.plan", "type": "PurchasePlan"}, - "os_disk_image": {"key": "properties.osDiskImage", "type": "OSDiskImage"}, - "data_disk_images": {"key": "properties.dataDiskImages", "type": "[DataDiskImage]"}, - } - - def __init__( - self, - *, - name: str, - location: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.PurchasePlan"] = None, - os_disk_image: Optional["_models.OSDiskImage"] = None, - data_disk_images: Optional[List["_models.DataDiskImage"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The name of the resource. Required. - :paramtype name: str - :keyword location: The supported Azure location of the resource. Required. - :paramtype location: str - :keyword tags: Specifies the tags that are assigned to the virtual machine. For more - information about using tags, see `Using tags to organize your Azure resources - `_. - :paramtype tags: dict[str, str] - :keyword plan: Used for establishing the purchase context of any 3rd Party artifact through - MarketPlace. - :paramtype plan: ~azure.mgmt.compute.v2017_12_01.models.PurchasePlan - :keyword os_disk_image: Contains the os disk image information. - :paramtype os_disk_image: ~azure.mgmt.compute.v2017_12_01.models.OSDiskImage - :keyword data_disk_images: - :paramtype data_disk_images: list[~azure.mgmt.compute.v2017_12_01.models.DataDiskImage] - """ - super().__init__(id=id, name=name, location=location, tags=tags, **kwargs) - self.plan = plan - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - - -class VirtualMachineInstanceView(_serialization.Model): - """The instance view of a virtual machine. - - :ivar platform_update_domain: Specifies the update domain of the virtual machine. - :vartype platform_update_domain: int - :ivar platform_fault_domain: Specifies the fault domain of the virtual machine. - :vartype platform_fault_domain: int - :ivar computer_name: The computer name assigned to the virtual machine. - :vartype computer_name: str - :ivar os_name: The Operating System running on the virtual machine. - :vartype os_name: str - :ivar os_version: The version of Operating System running on the virtual machine. - :vartype os_version: str - :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. - :vartype rdp_thumb_print: str - :ivar vm_agent: The VM Agent running on the virtual machine. - :vartype vm_agent: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineAgentInstanceView - :ivar maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :vartype maintenance_redeploy_status: - ~azure.mgmt.compute.v2017_12_01.models.MaintenanceRedeployStatus - :ivar disks: The virtual machine disk information. - :vartype disks: list[~azure.mgmt.compute.v2017_12_01.models.DiskInstanceView] - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtensionInstanceView] - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2017_12_01.models.BootDiagnosticsInstanceView - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "platform_update_domain": {"key": "platformUpdateDomain", "type": "int"}, - "platform_fault_domain": {"key": "platformFaultDomain", "type": "int"}, - "computer_name": {"key": "computerName", "type": "str"}, - "os_name": {"key": "osName", "type": "str"}, - "os_version": {"key": "osVersion", "type": "str"}, - "rdp_thumb_print": {"key": "rdpThumbPrint", "type": "str"}, - "vm_agent": {"key": "vmAgent", "type": "VirtualMachineAgentInstanceView"}, - "maintenance_redeploy_status": {"key": "maintenanceRedeployStatus", "type": "MaintenanceRedeployStatus"}, - "disks": {"key": "disks", "type": "[DiskInstanceView]"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineExtensionInstanceView]"}, - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnosticsInstanceView"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - platform_update_domain: Optional[int] = None, - platform_fault_domain: Optional[int] = None, - computer_name: Optional[str] = None, - os_name: Optional[str] = None, - os_version: Optional[str] = None, - rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, - disks: Optional[List["_models.DiskInstanceView"]] = None, - extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword platform_update_domain: Specifies the update domain of the virtual machine. - :paramtype platform_update_domain: int - :keyword platform_fault_domain: Specifies the fault domain of the virtual machine. - :paramtype platform_fault_domain: int - :keyword computer_name: The computer name assigned to the virtual machine. - :paramtype computer_name: str - :keyword os_name: The Operating System running on the virtual machine. - :paramtype os_name: str - :keyword os_version: The version of Operating System running on the virtual machine. - :paramtype os_version: str - :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. - :paramtype rdp_thumb_print: str - :keyword vm_agent: The VM Agent running on the virtual machine. - :paramtype vm_agent: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineAgentInstanceView - :keyword maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :paramtype maintenance_redeploy_status: - ~azure.mgmt.compute.v2017_12_01.models.MaintenanceRedeployStatus - :keyword disks: The virtual machine disk information. - :paramtype disks: list[~azure.mgmt.compute.v2017_12_01.models.DiskInstanceView] - :keyword extensions: The extensions information. - :paramtype extensions: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtensionInstanceView] - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2017_12_01.models.BootDiagnosticsInstanceView - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.platform_update_domain = platform_update_domain - self.platform_fault_domain = platform_fault_domain - self.computer_name = computer_name - self.os_name = os_name - self.os_version = os_version - self.rdp_thumb_print = rdp_thumb_print - self.vm_agent = vm_agent - self.maintenance_redeploy_status = maintenance_redeploy_status - self.disks = disks - self.extensions = extensions - self.boot_diagnostics = boot_diagnostics - self.statuses = statuses - - -class VirtualMachineListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machines. Required. - :vartype value: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachine] - :ivar next_link: The URI to fetch the next page of VMs. Call ListNext() with this URI to fetch - the next page of Virtual Machines. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachine]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machines. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachine] - :keyword next_link: The URI to fetch the next page of VMs. Call ListNext() with this URI to - fetch the next page of Virtual Machines. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSet(Resource): - """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. - :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] - :ivar sku: The virtual machine scale set sku. - :vartype sku: ~azure.mgmt.compute.v2017_12_01.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2017_12_01.models.Plan - :ivar identity: The identity of the virtual machine scale set, if configured. - :vartype identity: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetIdentity - :ivar zones: The virtual machine scale set zones. NOTE: Availability zones can only be set when - you create the scale set. - :vartype zones: list[str] - :ivar upgrade_policy: The upgrade policy. - :vartype upgrade_policy: ~azure.mgmt.compute.v2017_12_01.models.UpgradePolicy - :ivar virtual_machine_profile: The virtual machine profile. - :vartype virtual_machine_profile: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVMProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar overprovision: Specifies whether the Virtual Machine Scale Set should be overprovisioned. - :vartype overprovision: bool - :ivar unique_id: Specifies the ID which uniquely identifies a Virtual Machine Scale Set. - :vartype unique_id: str - :ivar single_placement_group: When true this limits the scale set to a single placement group, - of max size 100 virtual machines. - :vartype single_placement_group: bool - :ivar zone_balance: Whether to force strictly even Virtual Machine distribution cross x-zones - in case there is zone outage. - :vartype zone_balance: bool - :ivar platform_fault_domain_count: Fault Domain count for each placement group. - :vartype platform_fault_domain_count: int - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "unique_id": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "identity": {"key": "identity", "type": "VirtualMachineScaleSetIdentity"}, - "zones": {"key": "zones", "type": "[str]"}, - "upgrade_policy": {"key": "properties.upgradePolicy", "type": "UpgradePolicy"}, - "virtual_machine_profile": { - "key": "properties.virtualMachineProfile", - "type": "VirtualMachineScaleSetVMProfile", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "overprovision": {"key": "properties.overprovision", "type": "bool"}, - "unique_id": {"key": "properties.uniqueId", "type": "str"}, - "single_placement_group": {"key": "properties.singlePlacementGroup", "type": "bool"}, - "zone_balance": {"key": "properties.zoneBalance", "type": "bool"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, - zones: Optional[List[str]] = None, - upgrade_policy: Optional["_models.UpgradePolicy"] = None, - virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, - overprovision: Optional[bool] = None, - single_placement_group: Optional[bool] = None, - zone_balance: Optional[bool] = None, - platform_fault_domain_count: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The virtual machine scale set sku. - :paramtype sku: ~azure.mgmt.compute.v2017_12_01.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2017_12_01.models.Plan - :keyword identity: The identity of the virtual machine scale set, if configured. - :paramtype identity: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetIdentity - :keyword zones: The virtual machine scale set zones. NOTE: Availability zones can only be set - when you create the scale set. - :paramtype zones: list[str] - :keyword upgrade_policy: The upgrade policy. - :paramtype upgrade_policy: ~azure.mgmt.compute.v2017_12_01.models.UpgradePolicy - :keyword virtual_machine_profile: The virtual machine profile. - :paramtype virtual_machine_profile: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVMProfile - :keyword overprovision: Specifies whether the Virtual Machine Scale Set should be - overprovisioned. - :paramtype overprovision: bool - :keyword single_placement_group: When true this limits the scale set to a single placement - group, of max size 100 virtual machines. - :paramtype single_placement_group: bool - :keyword zone_balance: Whether to force strictly even Virtual Machine distribution cross - x-zones in case there is zone outage. - :paramtype zone_balance: bool - :keyword platform_fault_domain_count: Fault Domain count for each placement group. - :paramtype platform_fault_domain_count: int - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.plan = plan - self.identity = identity - self.zones = zones - self.upgrade_policy = upgrade_policy - self.virtual_machine_profile = virtual_machine_profile - self.provisioning_state: Optional[str] = None - self.overprovision = overprovision - self.unique_id: Optional[str] = None - self.single_placement_group = single_placement_group - self.zone_balance = zone_balance - self.platform_fault_domain_count = platform_fault_domain_count - - -class VirtualMachineScaleSetDataDisk(_serialization.Model): - """Describes a virtual machine scale set data disk. - - All required parameters must be populated in order to send to server. - - :ivar name: The disk name. - :vartype name: str - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar create_option: The create option. Required. Known values are: "FromImage", "Empty", and - "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2017_12_01.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - - _validation = { - "lun": {"required": True}, - "create_option": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "VirtualMachineScaleSetManagedDiskParameters"}, - } - - def __init__( - self, - *, - lun: int, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword create_option: The create option. Required. Known values are: "FromImage", "Empty", - and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2017_12_01.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - super().__init__(**kwargs) - self.name = name - self.lun = lun - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - - -class VirtualMachineScaleSetExtension(SubResourceReadOnly): - """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. - :vartype id: str - :ivar name: The name of the extension. - :vartype name: str - :ivar force_update_tag: If a value is provided and is different from the previous value, the - extension handler will be forced to update even if the extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - """ - - _validation = { - "id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - force_update_tag: Optional[str] = None, - publisher: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - auto_upgrade_minor_version: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - """ - super().__init__(**kwargs) - self.name = name - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type = type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - - -class VirtualMachineScaleSetExtensionListResult(_serialization.Model): # pylint: disable=name-too-long - """The List VM scale set extension operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of VM scale set extensions. Required. - :vartype value: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetExtension] - :ivar next_link: The uri to fetch the next page of VM scale set extensions. Call ListNext() - with this to fetch the next page of VM scale set extensions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetExtension]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of VM scale set extensions. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetExtension] - :keyword next_link: The uri to fetch the next page of VM scale set extensions. Call ListNext() - with this to fetch the next page of VM scale set extensions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetExtensionProfile(_serialization.Model): - """Describes a virtual machine scale set extension profile. - - :ivar extensions: The virtual machine scale set child extension resources. - :vartype extensions: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetExtension] - """ - - _attribute_map = { - "extensions": {"key": "extensions", "type": "[VirtualMachineScaleSetExtension]"}, - } - - def __init__( - self, *, extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, **kwargs: Any - ) -> None: - """ - :keyword extensions: The virtual machine scale set child extension resources. - :paramtype extensions: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetExtension] - """ - super().__init__(**kwargs) - self.extensions = extensions - - -class VirtualMachineScaleSetIdentity(_serialization.Model): - """Identity for the virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of virtual machine scale set identity. This property will - only be provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the virtual machine scale set. This property - will only be provided for a system assigned identity. - :vartype tenant_id: str - :ivar type: The type of identity used for the virtual machine scale set. The type - 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user - assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and - "None". - :vartype type: str or ~azure.mgmt.compute.v2017_12_01.models.ResourceIdentityType - :ivar identity_ids: The list of user identities associated with the virtual machine scale set. - The user identity references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/identities/{identityName}'. - :vartype identity_ids: list[str] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "identity_ids": {"key": "identityIds", "type": "[str]"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, - identity_ids: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of identity used for the virtual machine scale set. The type - 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user - assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and - "None". - :paramtype type: str or ~azure.mgmt.compute.v2017_12_01.models.ResourceIdentityType - :keyword identity_ids: The list of user identities associated with the virtual machine scale - set. The user identity references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/identities/{identityName}'. - :paramtype identity_ids: list[str] - """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.type = type - self.identity_ids = identity_ids - - -class VirtualMachineScaleSetInstanceView(_serialization.Model): - """The instance view of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar virtual_machine: The instance view status summary for the virtual machine scale set. - :vartype virtual_machine: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetInstanceViewStatusesSummary - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVMExtensionsSummary] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus] - """ - - _validation = { - "virtual_machine": {"readonly": True}, - "extensions": {"readonly": True}, - } - - _attribute_map = { - "virtual_machine": {"key": "virtualMachine", "type": "VirtualMachineScaleSetInstanceViewStatusesSummary"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineScaleSetVMExtensionsSummary]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__(self, *, statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs: Any) -> None: - """ - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.virtual_machine: Optional["_models.VirtualMachineScaleSetInstanceViewStatusesSummary"] = None - self.extensions: Optional[List["_models.VirtualMachineScaleSetVMExtensionsSummary"]] = None - self.statuses = statuses - - -class VirtualMachineScaleSetInstanceViewStatusesSummary(_serialization.Model): # pylint: disable=name-too-long - """Instance view statuses summary for virtual machines of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar statuses_summary: The extensions information. - :vartype statuses_summary: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineStatusCodeCount] - """ - - _validation = { - "statuses_summary": {"readonly": True}, - } - - _attribute_map = { - "statuses_summary": {"key": "statusesSummary", "type": "[VirtualMachineStatusCodeCount]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.statuses_summary: Optional[List["_models.VirtualMachineStatusCodeCount"]] = None - - -class VirtualMachineScaleSetIPConfiguration(SubResource): - """Describes a virtual machine scale set network profile's IP configuration. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The IP configuration name. Required. - :vartype name: str - :ivar subnet: Specifies the identifier of the subnet. - :vartype subnet: ~azure.mgmt.compute.v2017_12_01.models.ApiEntityReference - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - :ivar public_ip_address_configuration: The publicIPAddressConfiguration. - :vartype public_ip_address_configuration: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration - :ivar private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2017_12_01.models.IPVersion - :ivar application_gateway_backend_address_pools: Specifies an array of references to backend - address pools of application gateways. A scale set can reference backend address pools of - multiple application gateways. Multiple scale sets cannot use the same application gateway. - :vartype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2017_12_01.models.SubResource] - :ivar load_balancer_backend_address_pools: Specifies an array of references to backend address - pools of load balancers. A scale set can reference backend address pools of one public and one - internal load balancer. Multiple scale sets cannot use the same load balancer. - :vartype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2017_12_01.models.SubResource] - :ivar load_balancer_inbound_nat_pools: Specifies an array of references to inbound Nat pools of - the load balancers. A scale set can reference inbound nat pools of one public and one internal - load balancer. Multiple scale sets cannot use the same load balancer. - :vartype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2017_12_01.models.SubResource] - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subnet": {"key": "properties.subnet", "type": "ApiEntityReference"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "public_ip_address_configuration": { - "key": "properties.publicIPAddressConfiguration", - "type": "VirtualMachineScaleSetPublicIPAddressConfiguration", - }, - "private_ip_address_version": {"key": "properties.privateIPAddressVersion", "type": "str"}, - "application_gateway_backend_address_pools": { - "key": "properties.applicationGatewayBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_backend_address_pools": { - "key": "properties.loadBalancerBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_inbound_nat_pools": {"key": "properties.loadBalancerInboundNatPools", "type": "[SubResource]"}, - } - - def __init__( - self, - *, - name: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - subnet: Optional["_models.ApiEntityReference"] = None, - primary: Optional[bool] = None, - public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The IP configuration name. Required. - :paramtype name: str - :keyword subnet: Specifies the identifier of the subnet. - :paramtype subnet: ~azure.mgmt.compute.v2017_12_01.models.ApiEntityReference - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - :keyword public_ip_address_configuration: The publicIPAddressConfiguration. - :paramtype public_ip_address_configuration: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration - :keyword private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2017_12_01.models.IPVersion - :keyword application_gateway_backend_address_pools: Specifies an array of references to backend - address pools of application gateways. A scale set can reference backend address pools of - multiple application gateways. Multiple scale sets cannot use the same application gateway. - :paramtype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2017_12_01.models.SubResource] - :keyword load_balancer_backend_address_pools: Specifies an array of references to backend - address pools of load balancers. A scale set can reference backend address pools of one public - and one internal load balancer. Multiple scale sets cannot use the same load balancer. - :paramtype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2017_12_01.models.SubResource] - :keyword load_balancer_inbound_nat_pools: Specifies an array of references to inbound Nat pools - of the load balancers. A scale set can reference inbound nat pools of one public and one - internal load balancer. Multiple scale sets cannot use the same load balancer. - :paramtype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2017_12_01.models.SubResource] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.subnet = subnet - self.primary = primary - self.public_ip_address_configuration = public_ip_address_configuration - self.private_ip_address_version = private_ip_address_version - self.application_gateway_backend_address_pools = application_gateway_backend_address_pools - self.load_balancer_backend_address_pools = load_balancer_backend_address_pools - self.load_balancer_inbound_nat_pools = load_balancer_inbound_nat_pools - - -class VirtualMachineScaleSetListOSUpgradeHistory(_serialization.Model): # pylint: disable=name-too-long - """List of Virtual Machine Scale Set OS Upgrade History operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of OS upgrades performed on the virtual machine scale set. Required. - :vartype value: - list[~azure.mgmt.compute.v2017_12_01.models.UpgradeOperationHistoricalStatusInfo] - :ivar next_link: The uri to fetch the next page of OS Upgrade History. Call ListNext() with - this to fetch the next page of history of upgrades. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[UpgradeOperationHistoricalStatusInfo]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: List["_models.UpgradeOperationHistoricalStatusInfo"], - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of OS upgrades performed on the virtual machine scale set. Required. - :paramtype value: - list[~azure.mgmt.compute.v2017_12_01.models.UpgradeOperationHistoricalStatusInfo] - :keyword next_link: The uri to fetch the next page of OS Upgrade History. Call ListNext() with - this to fetch the next page of history of upgrades. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets. Required. - :vartype value: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSet] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call ListNext() - with this to fetch the next page of VMSS. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSet] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call - ListNext() with this to fetch the next page of VMSS. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListSkusResult(_serialization.Model): - """The Virtual Machine Scale Set List Skus operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of skus available for the virtual machine scale set. Required. - :vartype value: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetSku] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Set Skus. Call - ListNext() with this to fetch the next page of VMSS Skus. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetSku]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of skus available for the virtual machine scale set. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetSku] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Set Skus. Call - ListNext() with this to fetch the next page of VMSS Skus. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListWithLinkResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets. Required. - :vartype value: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSet] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call ListNext() - with this to fetch the next page of Virtual Machine Scale Sets. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSet] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call - ListNext() with this to fetch the next page of Virtual Machine Scale Sets. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetManagedDiskParameters(_serialization.Model): # pylint: disable=name-too-long - """Describes the parameters of a ScaleSet managed disk. - - :ivar storage_account_type: Specifies the storage account type for the managed disk. Managed OS - disk storage account type can only be set when you create the scale set. Possible values are: - Standard_LRS or Premium_LRS. Known values are: "Standard_LRS" and "Premium_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2017_12_01.models.StorageAccountTypes - """ - - _attribute_map = { - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - } - - def __init__( - self, *, storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs: Any - ) -> None: - """ - :keyword storage_account_type: Specifies the storage account type for the managed disk. Managed - OS disk storage account type can only be set when you create the scale set. Possible values - are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS" and "Premium_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2017_12_01.models.StorageAccountTypes - """ - super().__init__(**kwargs) - self.storage_account_type = storage_account_type - - -class VirtualMachineScaleSetNetworkConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's network configurations. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The network configuration name. Required. - :vartype name: str - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :vartype enable_accelerated_networking: bool - :ivar network_security_group: The network security group. - :vartype network_security_group: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :ivar dns_settings: The dns settings to be applied on the network interfaces. - :vartype dns_settings: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :ivar ip_configurations: Specifies the IP configurations of the network interface. - :vartype ip_configurations: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetIPConfiguration] - :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :vartype enable_ip_forwarding: bool - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "enable_accelerated_networking": {"key": "properties.enableAcceleratedNetworking", "type": "bool"}, - "network_security_group": {"key": "properties.networkSecurityGroup", "type": "SubResource"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetNetworkConfigurationDnsSettings", - }, - "ip_configurations": {"key": "properties.ipConfigurations", "type": "[VirtualMachineScaleSetIPConfiguration]"}, - "enable_ip_forwarding": {"key": "properties.enableIPForwarding", "type": "bool"}, - } - - def __init__( - self, - *, - name: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - primary: Optional[bool] = None, - enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["_models.SubResource"] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, - enable_ip_forwarding: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The network configuration name. Required. - :paramtype name: str - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :paramtype enable_accelerated_networking: bool - :keyword network_security_group: The network security group. - :paramtype network_security_group: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :keyword dns_settings: The dns settings to be applied on the network interfaces. - :paramtype dns_settings: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :keyword ip_configurations: Specifies the IP configurations of the network interface. - :paramtype ip_configurations: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetIPConfiguration] - :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :paramtype enable_ip_forwarding: bool - """ - super().__init__(id=id, **kwargs) - self.name = name - self.primary = primary - self.enable_accelerated_networking = enable_accelerated_networking - self.network_security_group = network_security_group - self.dns_settings = dns_settings - self.ip_configurations = ip_configurations - self.enable_ip_forwarding = enable_ip_forwarding - - -class VirtualMachineScaleSetNetworkConfigurationDnsSettings(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines scale sets network configuration's DNS settings. - - :ivar dns_servers: List of DNS servers IP addresses. - :vartype dns_servers: list[str] - """ - - _attribute_map = { - "dns_servers": {"key": "dnsServers", "type": "[str]"}, - } - - def __init__(self, *, dns_servers: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword dns_servers: List of DNS servers IP addresses. - :paramtype dns_servers: list[str] - """ - super().__init__(**kwargs) - self.dns_servers = dns_servers - - -class VirtualMachineScaleSetNetworkProfile(_serialization.Model): - """Describes a virtual machine scale set network profile. - - :ivar health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :vartype health_probe: ~azure.mgmt.compute.v2017_12_01.models.ApiEntityReference - :ivar network_interface_configurations: The list of network configurations. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetNetworkConfiguration] - """ - - _attribute_map = { - "health_probe": {"key": "healthProbe", "type": "ApiEntityReference"}, - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineScaleSetNetworkConfiguration]", - }, - } - - def __init__( - self, - *, - health_probe: Optional["_models.ApiEntityReference"] = None, - network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :paramtype health_probe: ~azure.mgmt.compute.v2017_12_01.models.ApiEntityReference - :keyword network_interface_configurations: The list of network configurations. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetNetworkConfiguration] - """ - super().__init__(**kwargs) - self.health_probe = health_probe - self.network_interface_configurations = network_interface_configurations - - -class VirtualMachineScaleSetOSDisk(_serialization.Model): - """Describes a virtual machine scale set operating system disk. - - All required parameters must be populated in order to send to server. - - :ivar name: The disk name. - :vartype name: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar create_option: Specifies how the virtual machines in the scale set should be created.\\ - :code:`
    `\\ :code:`
    ` The only allowed value is: **FromImage** \\u2013 This value is used - when you are using an image to create the virtual machine. If you are using a platform image, - you also use the imageReference element described above. If you are using a marketplace image, - you also use the plan element previously described. Required. Known values are: "FromImage", - "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2017_12_01.models.DiskCreateOptionTypes - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes - :ivar image: Specifies information about the unmanaged user image to base the scale set on. - :vartype image: ~azure.mgmt.compute.v2017_12_01.models.VirtualHardDisk - :ivar vhd_containers: Specifies the container urls that are used to store operating system - disks for the scale set. - :vartype vhd_containers: list[str] - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - - _validation = { - "create_option": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "create_option": {"key": "createOption", "type": "str"}, - "os_type": {"key": "osType", "type": "str"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "vhd_containers": {"key": "vhdContainers", "type": "[str]"}, - "managed_disk": {"key": "managedDisk", "type": "VirtualMachineScaleSetManagedDiskParameters"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - image: Optional["_models.VirtualHardDisk"] = None, - vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword create_option: Specifies how the virtual machines in the scale set should be - created.\\ :code:`
    `\\ :code:`
    ` The only allowed value is: **FromImage** \\u2013 This - value is used when you are using an image to create the virtual machine. If you are using a - platform image, you also use the imageReference element described above. If you are using a - marketplace image, you also use the plan element previously described. Required. Known values - are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2017_12_01.models.DiskCreateOptionTypes - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes - :keyword image: Specifies information about the unmanaged user image to base the scale set on. - :paramtype image: ~azure.mgmt.compute.v2017_12_01.models.VirtualHardDisk - :keyword vhd_containers: Specifies the container urls that are used to store operating system - disks for the scale set. - :paramtype vhd_containers: list[str] - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - super().__init__(**kwargs) - self.name = name - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.create_option = create_option - self.os_type = os_type - self.image = image - self.vhd_containers = vhd_containers - self.managed_disk = managed_disk - - -class VirtualMachineScaleSetOSProfile(_serialization.Model): - """Describes a virtual machine scale set OS profile. - - :ivar computer_name_prefix: Specifies the computer name prefix for all of the virtual machines - in the scale set. Computer name prefixes must be 1 to 15 characters long. - :vartype computer_name_prefix: str - :ivar admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :vartype admin_username: str - :ivar admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :vartype admin_password: str - :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` For using cloud-init for - your VM, see `Using cloud-init to customize a Linux VM during creation - `_. - :vartype custom_data: str - :ivar windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :vartype windows_configuration: ~azure.mgmt.compute.v2017_12_01.models.WindowsConfiguration - :ivar linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :vartype linux_configuration: ~azure.mgmt.compute.v2017_12_01.models.LinuxConfiguration - :ivar secrets: Specifies set of certificates that should be installed onto the virtual machines - in the scale set. - :vartype secrets: list[~azure.mgmt.compute.v2017_12_01.models.VaultSecretGroup] - """ - - _attribute_map = { - "computer_name_prefix": {"key": "computerNamePrefix", "type": "str"}, - "admin_username": {"key": "adminUsername", "type": "str"}, - "admin_password": {"key": "adminPassword", "type": "str"}, - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - } - - def __init__( - self, - *, - computer_name_prefix: Optional[str] = None, - admin_username: Optional[str] = None, - admin_password: Optional[str] = None, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword computer_name_prefix: Specifies the computer name prefix for all of the virtual - machines in the scale set. Computer name prefixes must be 1 to 15 characters long. - :paramtype computer_name_prefix: str - :keyword admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :paramtype admin_username: str - :keyword admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :paramtype admin_password: str - :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` For using cloud-init for - your VM, see `Using cloud-init to customize a Linux VM during creation - `_. - :paramtype custom_data: str - :keyword windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :paramtype windows_configuration: ~azure.mgmt.compute.v2017_12_01.models.WindowsConfiguration - :keyword linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :paramtype linux_configuration: ~azure.mgmt.compute.v2017_12_01.models.LinuxConfiguration - :keyword secrets: Specifies set of certificates that should be installed onto the virtual - machines in the scale set. - :paramtype secrets: list[~azure.mgmt.compute.v2017_12_01.models.VaultSecretGroup] - """ - super().__init__(**kwargs) - self.computer_name_prefix = computer_name_prefix - self.admin_username = admin_username - self.admin_password = admin_password - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - - -class VirtualMachineScaleSetPublicIPAddressConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines scale set IP Configuration's PublicIPAddress configuration. - - All required parameters must be populated in order to send to server. - - :ivar name: The publicIP address configuration name. Required. - :vartype name: str - :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. - :vartype idle_timeout_in_minutes: int - :ivar dns_settings: The dns settings to be applied on the publicIP addresses . - :vartype dns_settings: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "idle_timeout_in_minutes": {"key": "properties.idleTimeoutInMinutes", "type": "int"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings", - }, - } - - def __init__( - self, - *, - name: str, - idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The publicIP address configuration name. Required. - :paramtype name: str - :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. - :paramtype idle_timeout_in_minutes: int - :keyword dns_settings: The dns settings to be applied on the publicIP addresses . - :paramtype dns_settings: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - """ - super().__init__(**kwargs) - self.name = name - self.idle_timeout_in_minutes = idle_timeout_in_minutes - self.dns_settings = dns_settings - - -class VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings( - _serialization.Model -): # pylint: disable=name-too-long - """Describes a virtual machines scale sets network configuration's DNS settings. - - All required parameters must be populated in order to send to server. - - :ivar domain_name_label: The Domain name label.The concatenation of the domain name label and - vm index will be the domain name labels of the PublicIPAddress resources that will be created. - Required. - :vartype domain_name_label: str - """ - - _validation = { - "domain_name_label": {"required": True}, - } - - _attribute_map = { - "domain_name_label": {"key": "domainNameLabel", "type": "str"}, - } - - def __init__(self, *, domain_name_label: str, **kwargs: Any) -> None: - """ - :keyword domain_name_label: The Domain name label.The concatenation of the domain name label - and vm index will be the domain name labels of the PublicIPAddress resources that will be - created. Required. - :paramtype domain_name_label: str - """ - super().__init__(**kwargs) - self.domain_name_label = domain_name_label - - -class VirtualMachineScaleSetSku(_serialization.Model): - """Describes an available virtual machine scale set sku. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of resource the sku applies to. - :vartype resource_type: str - :ivar sku: The Sku. - :vartype sku: ~azure.mgmt.compute.v2017_12_01.models.Sku - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetSkuCapacity - """ - - _validation = { - "resource_type": {"readonly": True}, - "sku": {"readonly": True}, - "capacity": {"readonly": True}, - } - - _attribute_map = { - "resource_type": {"key": "resourceType", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "capacity": {"key": "capacity", "type": "VirtualMachineScaleSetSkuCapacity"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_type: Optional[str] = None - self.sku: Optional["_models.Sku"] = None - self.capacity: Optional["_models.VirtualMachineScaleSetSkuCapacity"] = None - - -class VirtualMachineScaleSetSkuCapacity(_serialization.Model): - """Describes scaling information of a sku. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar minimum: The minimum capacity. - :vartype minimum: int - :ivar maximum: The maximum capacity that can be set. - :vartype maximum: int - :ivar default_capacity: The default capacity. - :vartype default_capacity: int - :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic" and - "None". - :vartype scale_type: str or - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetSkuScaleType - """ - - _validation = { - "minimum": {"readonly": True}, - "maximum": {"readonly": True}, - "default_capacity": {"readonly": True}, - "scale_type": {"readonly": True}, - } - - _attribute_map = { - "minimum": {"key": "minimum", "type": "int"}, - "maximum": {"key": "maximum", "type": "int"}, - "default_capacity": {"key": "defaultCapacity", "type": "int"}, - "scale_type": {"key": "scaleType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.minimum: Optional[int] = None - self.maximum: Optional[int] = None - self.default_capacity: Optional[int] = None - self.scale_type: Optional[Union[str, "_models.VirtualMachineScaleSetSkuScaleType"]] = None - - -class VirtualMachineScaleSetStorageProfile(_serialization.Model): - """Describes a virtual machine scale set storage profile. - - :ivar image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :vartype image_reference: ~azure.mgmt.compute.v2017_12_01.models.ImageReference - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetOSDisk - :ivar data_disks: Specifies the parameters that are used to add data disks to the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :vartype data_disks: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetDataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "VirtualMachineScaleSetOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[VirtualMachineScaleSetDataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :paramtype image_reference: ~azure.mgmt.compute.v2017_12_01.models.ImageReference - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetOSDisk - :keyword data_disks: Specifies the parameters that are used to add data disks to the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :paramtype data_disks: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetDataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class VirtualMachineScaleSetUpdate(UpdateResource): - """Describes a Virtual Machine Scale Set. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The virtual machine scale set sku. - :vartype sku: ~azure.mgmt.compute.v2017_12_01.models.Sku - :ivar plan: The purchase plan when deploying a virtual machine scale set from VM Marketplace - images. - :vartype plan: ~azure.mgmt.compute.v2017_12_01.models.Plan - :ivar identity: The identity of the virtual machine scale set, if configured. - :vartype identity: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetIdentity - :ivar upgrade_policy: The upgrade policy. - :vartype upgrade_policy: ~azure.mgmt.compute.v2017_12_01.models.UpgradePolicy - :ivar virtual_machine_profile: The virtual machine profile. - :vartype virtual_machine_profile: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetUpdateVMProfile - :ivar overprovision: Specifies whether the Virtual Machine Scale Set should be overprovisioned. - :vartype overprovision: bool - :ivar single_placement_group: When true this limits the scale set to a single placement group, - of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be modified to - false. However, if singlePlacementGroup is false, it may not be modified to true. - :vartype single_placement_group: bool - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "identity": {"key": "identity", "type": "VirtualMachineScaleSetIdentity"}, - "upgrade_policy": {"key": "properties.upgradePolicy", "type": "UpgradePolicy"}, - "virtual_machine_profile": { - "key": "properties.virtualMachineProfile", - "type": "VirtualMachineScaleSetUpdateVMProfile", - }, - "overprovision": {"key": "properties.overprovision", "type": "bool"}, - "single_placement_group": {"key": "properties.singlePlacementGroup", "type": "bool"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["_models.UpgradePolicy"] = None, - virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, - overprovision: Optional[bool] = None, - single_placement_group: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The virtual machine scale set sku. - :paramtype sku: ~azure.mgmt.compute.v2017_12_01.models.Sku - :keyword plan: The purchase plan when deploying a virtual machine scale set from VM Marketplace - images. - :paramtype plan: ~azure.mgmt.compute.v2017_12_01.models.Plan - :keyword identity: The identity of the virtual machine scale set, if configured. - :paramtype identity: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetIdentity - :keyword upgrade_policy: The upgrade policy. - :paramtype upgrade_policy: ~azure.mgmt.compute.v2017_12_01.models.UpgradePolicy - :keyword virtual_machine_profile: The virtual machine profile. - :paramtype virtual_machine_profile: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetUpdateVMProfile - :keyword overprovision: Specifies whether the Virtual Machine Scale Set should be - overprovisioned. - :paramtype overprovision: bool - :keyword single_placement_group: When true this limits the scale set to a single placement - group, of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be - modified to false. However, if singlePlacementGroup is false, it may not be modified to true. - :paramtype single_placement_group: bool - """ - super().__init__(tags=tags, **kwargs) - self.sku = sku - self.plan = plan - self.identity = identity - self.upgrade_policy = upgrade_policy - self.virtual_machine_profile = virtual_machine_profile - self.overprovision = overprovision - self.single_placement_group = single_placement_group - - -class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's IP configuration. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The IP configuration name. - :vartype name: str - :ivar subnet: The subnet. - :vartype subnet: ~azure.mgmt.compute.v2017_12_01.models.ApiEntityReference - :ivar primary: Specifies the primary IP Configuration in case the network interface has more - than one IP Configuration. - :vartype primary: bool - :ivar public_ip_address_configuration: The publicIPAddressConfiguration. - :vartype public_ip_address_configuration: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration - :ivar private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2017_12_01.models.IPVersion - :ivar application_gateway_backend_address_pools: The application gateway backend address pools. - :vartype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2017_12_01.models.SubResource] - :ivar load_balancer_backend_address_pools: The load balancer backend address pools. - :vartype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2017_12_01.models.SubResource] - :ivar load_balancer_inbound_nat_pools: The load balancer inbound nat pools. - :vartype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2017_12_01.models.SubResource] - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subnet": {"key": "properties.subnet", "type": "ApiEntityReference"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "public_ip_address_configuration": { - "key": "properties.publicIPAddressConfiguration", - "type": "VirtualMachineScaleSetUpdatePublicIPAddressConfiguration", - }, - "private_ip_address_version": {"key": "properties.privateIPAddressVersion", "type": "str"}, - "application_gateway_backend_address_pools": { - "key": "properties.applicationGatewayBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_backend_address_pools": { - "key": "properties.loadBalancerBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_inbound_nat_pools": {"key": "properties.loadBalancerInboundNatPools", "type": "[SubResource]"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - subnet: Optional["_models.ApiEntityReference"] = None, - primary: Optional[bool] = None, - public_ip_address_configuration: Optional[ - "_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration" - ] = None, - private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The IP configuration name. - :paramtype name: str - :keyword subnet: The subnet. - :paramtype subnet: ~azure.mgmt.compute.v2017_12_01.models.ApiEntityReference - :keyword primary: Specifies the primary IP Configuration in case the network interface has more - than one IP Configuration. - :paramtype primary: bool - :keyword public_ip_address_configuration: The publicIPAddressConfiguration. - :paramtype public_ip_address_configuration: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration - :keyword private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2017_12_01.models.IPVersion - :keyword application_gateway_backend_address_pools: The application gateway backend address - pools. - :paramtype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2017_12_01.models.SubResource] - :keyword load_balancer_backend_address_pools: The load balancer backend address pools. - :paramtype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2017_12_01.models.SubResource] - :keyword load_balancer_inbound_nat_pools: The load balancer inbound nat pools. - :paramtype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2017_12_01.models.SubResource] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.subnet = subnet - self.primary = primary - self.public_ip_address_configuration = public_ip_address_configuration - self.private_ip_address_version = private_ip_address_version - self.application_gateway_backend_address_pools = application_gateway_backend_address_pools - self.load_balancer_backend_address_pools = load_balancer_backend_address_pools - self.load_balancer_inbound_nat_pools = load_balancer_inbound_nat_pools - - -class VirtualMachineScaleSetUpdateNetworkConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's network configurations. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The network configuration name. - :vartype name: str - :ivar primary: Whether this is a primary NIC on a virtual machine. - :vartype primary: bool - :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :vartype enable_accelerated_networking: bool - :ivar network_security_group: The network security group. - :vartype network_security_group: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :ivar dns_settings: The dns settings to be applied on the network interfaces. - :vartype dns_settings: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :ivar ip_configurations: The virtual machine scale set IP Configuration. - :vartype ip_configurations: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetUpdateIPConfiguration] - :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :vartype enable_ip_forwarding: bool - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "enable_accelerated_networking": {"key": "properties.enableAcceleratedNetworking", "type": "bool"}, - "network_security_group": {"key": "properties.networkSecurityGroup", "type": "SubResource"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetNetworkConfigurationDnsSettings", - }, - "ip_configurations": { - "key": "properties.ipConfigurations", - "type": "[VirtualMachineScaleSetUpdateIPConfiguration]", - }, - "enable_ip_forwarding": {"key": "properties.enableIPForwarding", "type": "bool"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - primary: Optional[bool] = None, - enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["_models.SubResource"] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, - enable_ip_forwarding: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The network configuration name. - :paramtype name: str - :keyword primary: Whether this is a primary NIC on a virtual machine. - :paramtype primary: bool - :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :paramtype enable_accelerated_networking: bool - :keyword network_security_group: The network security group. - :paramtype network_security_group: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :keyword dns_settings: The dns settings to be applied on the network interfaces. - :paramtype dns_settings: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :keyword ip_configurations: The virtual machine scale set IP Configuration. - :paramtype ip_configurations: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetUpdateIPConfiguration] - :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :paramtype enable_ip_forwarding: bool - """ - super().__init__(id=id, **kwargs) - self.name = name - self.primary = primary - self.enable_accelerated_networking = enable_accelerated_networking - self.network_security_group = network_security_group - self.dns_settings = dns_settings - self.ip_configurations = ip_configurations - self.enable_ip_forwarding = enable_ip_forwarding - - -class VirtualMachineScaleSetUpdateNetworkProfile(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile. - - :ivar network_interface_configurations: The list of network configurations. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] - """ - - _attribute_map = { - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineScaleSetUpdateNetworkConfiguration]", - }, - } - - def __init__( - self, - *, - network_interface_configurations: Optional[ - List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword network_interface_configurations: The list of network configurations. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] - """ - super().__init__(**kwargs) - self.network_interface_configurations = network_interface_configurations - - -class VirtualMachineScaleSetUpdateOSDisk(_serialization.Model): - """Describes virtual machine scale set operating system disk Update Object. This should be used - for Updating VMSS OS Disk. - - :ivar caching: The caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before - using it to attach to the Virtual Machine. If SourceImage is provided, the destination - VirtualHardDisk should not exist. - :vartype image: ~azure.mgmt.compute.v2017_12_01.models.VirtualHardDisk - :ivar vhd_containers: The list of virtual hard disk container uris. - :vartype vhd_containers: list[str] - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - - _attribute_map = { - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "vhd_containers": {"key": "vhdContainers", "type": "[str]"}, - "managed_disk": {"key": "managedDisk", "type": "VirtualMachineScaleSetManagedDiskParameters"}, - } - - def __init__( - self, - *, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - image: Optional["_models.VirtualHardDisk"] = None, - vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword caching: The caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied - before using it to attach to the Virtual Machine. If SourceImage is provided, the destination - VirtualHardDisk should not exist. - :paramtype image: ~azure.mgmt.compute.v2017_12_01.models.VirtualHardDisk - :keyword vhd_containers: The list of virtual hard disk container uris. - :paramtype vhd_containers: list[str] - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - super().__init__(**kwargs) - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.image = image - self.vhd_containers = vhd_containers - self.managed_disk = managed_disk - - -class VirtualMachineScaleSetUpdateOSProfile(_serialization.Model): - """Describes a virtual machine scale set OS profile. - - :ivar custom_data: A base-64 encoded string of custom data. - :vartype custom_data: str - :ivar windows_configuration: The Windows Configuration of the OS profile. - :vartype windows_configuration: ~azure.mgmt.compute.v2017_12_01.models.WindowsConfiguration - :ivar linux_configuration: The Linux Configuration of the OS profile. - :vartype linux_configuration: ~azure.mgmt.compute.v2017_12_01.models.LinuxConfiguration - :ivar secrets: The List of certificates for addition to the VM. - :vartype secrets: list[~azure.mgmt.compute.v2017_12_01.models.VaultSecretGroup] - """ - - _attribute_map = { - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - } - - def __init__( - self, - *, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword custom_data: A base-64 encoded string of custom data. - :paramtype custom_data: str - :keyword windows_configuration: The Windows Configuration of the OS profile. - :paramtype windows_configuration: ~azure.mgmt.compute.v2017_12_01.models.WindowsConfiguration - :keyword linux_configuration: The Linux Configuration of the OS profile. - :paramtype linux_configuration: ~azure.mgmt.compute.v2017_12_01.models.LinuxConfiguration - :keyword secrets: The List of certificates for addition to the VM. - :paramtype secrets: list[~azure.mgmt.compute.v2017_12_01.models.VaultSecretGroup] - """ - super().__init__(**kwargs) - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - - -class VirtualMachineScaleSetUpdatePublicIPAddressConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines scale set IP Configuration's PublicIPAddress configuration. - - :ivar name: The publicIP address configuration name. - :vartype name: str - :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. - :vartype idle_timeout_in_minutes: int - :ivar dns_settings: The dns settings to be applied on the publicIP addresses . - :vartype dns_settings: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "idle_timeout_in_minutes": {"key": "properties.idleTimeoutInMinutes", "type": "int"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings", - }, - } - - def __init__( - self, - *, - name: Optional[str] = None, - idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The publicIP address configuration name. - :paramtype name: str - :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. - :paramtype idle_timeout_in_minutes: int - :keyword dns_settings: The dns settings to be applied on the publicIP addresses . - :paramtype dns_settings: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - """ - super().__init__(**kwargs) - self.name = name - self.idle_timeout_in_minutes = idle_timeout_in_minutes - self.dns_settings = dns_settings - - -class VirtualMachineScaleSetUpdateStorageProfile(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machine scale set storage profile. - - :ivar image_reference: The image reference. - :vartype image_reference: ~azure.mgmt.compute.v2017_12_01.models.ImageReference - :ivar os_disk: The OS disk. - :vartype os_disk: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetUpdateOSDisk - :ivar data_disks: The data disks. - :vartype data_disks: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetDataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "VirtualMachineScaleSetUpdateOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[VirtualMachineScaleSetDataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: The image reference. - :paramtype image_reference: ~azure.mgmt.compute.v2017_12_01.models.ImageReference - :keyword os_disk: The OS disk. - :paramtype os_disk: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetUpdateOSDisk - :keyword data_disks: The data disks. - :paramtype data_disks: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetDataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class VirtualMachineScaleSetUpdateVMProfile(_serialization.Model): - """Describes a virtual machine scale set virtual machine profile. - - :ivar os_profile: The virtual machine scale set OS profile. - :vartype os_profile: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetUpdateOSProfile - :ivar storage_profile: The virtual machine scale set storage profile. - :vartype storage_profile: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetUpdateStorageProfile - :ivar network_profile: The virtual machine scale set network profile. - :vartype network_profile: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetUpdateNetworkProfile - :ivar diagnostics_profile: The virtual machine scale set diagnostics profile. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2017_12_01.models.DiagnosticsProfile - :ivar extension_profile: The virtual machine scale set extension profile. - :vartype extension_profile: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetExtensionProfile - :ivar license_type: The license type, which is for bring your own license scenario. - :vartype license_type: str - """ - - _attribute_map = { - "os_profile": {"key": "osProfile", "type": "VirtualMachineScaleSetUpdateOSProfile"}, - "storage_profile": {"key": "storageProfile", "type": "VirtualMachineScaleSetUpdateStorageProfile"}, - "network_profile": {"key": "networkProfile", "type": "VirtualMachineScaleSetUpdateNetworkProfile"}, - "diagnostics_profile": {"key": "diagnosticsProfile", "type": "DiagnosticsProfile"}, - "extension_profile": {"key": "extensionProfile", "type": "VirtualMachineScaleSetExtensionProfile"}, - "license_type": {"key": "licenseType", "type": "str"}, - } - - def __init__( - self, - *, - os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, - license_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_profile: The virtual machine scale set OS profile. - :paramtype os_profile: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetUpdateOSProfile - :keyword storage_profile: The virtual machine scale set storage profile. - :paramtype storage_profile: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetUpdateStorageProfile - :keyword network_profile: The virtual machine scale set network profile. - :paramtype network_profile: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetUpdateNetworkProfile - :keyword diagnostics_profile: The virtual machine scale set diagnostics profile. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2017_12_01.models.DiagnosticsProfile - :keyword extension_profile: The virtual machine scale set extension profile. - :paramtype extension_profile: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetExtensionProfile - :keyword license_type: The license type, which is for bring your own license scenario. - :paramtype license_type: str - """ - super().__init__(**kwargs) - self.os_profile = os_profile - self.storage_profile = storage_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.extension_profile = extension_profile - self.license_type = license_type - - -class VirtualMachineScaleSetVM(Resource): - """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. - :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] - :ivar instance_id: The virtual machine instance ID. - :vartype instance_id: str - :ivar sku: The virtual machine SKU. - :vartype sku: ~azure.mgmt.compute.v2017_12_01.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2017_12_01.models.Plan - :ivar resources: The virtual machine child extension resources. - :vartype resources: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtension] - :ivar latest_model_applied: Specifies whether the latest model has been applied to the virtual - machine. - :vartype latest_model_applied: bool - :ivar vm_id: Azure VM unique ID. - :vartype vm_id: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVMInstanceView - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2017_12_01.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2017_12_01.models.StorageProfile - :ivar os_profile: Specifies the operating system settings for the virtual machine. - :vartype os_profile: ~azure.mgmt.compute.v2017_12_01.models.OSProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2017_12_01.models.NetworkProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2017_12_01.models.DiagnosticsProfile - :ivar availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :vartype availability_set: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "instance_id": {"readonly": True}, - "sku": {"readonly": True}, - "resources": {"readonly": True}, - "latest_model_applied": {"readonly": True}, - "vm_id": {"readonly": True}, - "instance_view": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "instance_id": {"key": "instanceId", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "resources": {"key": "resources", "type": "[VirtualMachineExtension]"}, - "latest_model_applied": {"key": "properties.latestModelApplied", "type": "bool"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineScaleSetVMInstanceView"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - os_profile: Optional["_models.OSProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2017_12_01.models.Plan - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2017_12_01.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2017_12_01.models.StorageProfile - :keyword os_profile: Specifies the operating system settings for the virtual machine. - :paramtype os_profile: ~azure.mgmt.compute.v2017_12_01.models.OSProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2017_12_01.models.NetworkProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2017_12_01.models.DiagnosticsProfile - :keyword availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :paramtype availability_set: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.instance_id: Optional[str] = None - self.sku: Optional["_models.Sku"] = None - self.plan = plan - self.resources: Optional[List["_models.VirtualMachineExtension"]] = None - self.latest_model_applied: Optional[bool] = None - self.vm_id: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineScaleSetVMInstanceView"] = None - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.os_profile = os_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.provisioning_state: Optional[str] = None - self.license_type = license_type - - -class VirtualMachineScaleSetVMExtensionsSummary(_serialization.Model): # pylint: disable=name-too-long - """Extensions summary for virtual machines of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The extension name. - :vartype name: str - :ivar statuses_summary: The extensions information. - :vartype statuses_summary: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineStatusCodeCount] - """ - - _validation = { - "name": {"readonly": True}, - "statuses_summary": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "statuses_summary": {"key": "statusesSummary", "type": "[VirtualMachineStatusCodeCount]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.statuses_summary: Optional[List["_models.VirtualMachineStatusCodeCount"]] = None - - -class VirtualMachineScaleSetVMInstanceIDs(_serialization.Model): - """Specifies a list of virtual machine instance IDs from the VM scale set. - - :ivar instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :vartype instance_ids: list[str] - """ - - _attribute_map = { - "instance_ids": {"key": "instanceIds", "type": "[str]"}, - } - - def __init__(self, *, instance_ids: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :paramtype instance_ids: list[str] - """ - super().__init__(**kwargs) - self.instance_ids = instance_ids - - -class VirtualMachineScaleSetVMInstanceRequiredIDs(_serialization.Model): # pylint: disable=name-too-long - """Specifies a list of virtual machine instance IDs from the VM scale set. - - All required parameters must be populated in order to send to server. - - :ivar instance_ids: The virtual machine scale set instance ids. Required. - :vartype instance_ids: list[str] - """ - - _validation = { - "instance_ids": {"required": True}, - } - - _attribute_map = { - "instance_ids": {"key": "instanceIds", "type": "[str]"}, - } - - def __init__(self, *, instance_ids: List[str], **kwargs: Any) -> None: - """ - :keyword instance_ids: The virtual machine scale set instance ids. Required. - :paramtype instance_ids: list[str] - """ - super().__init__(**kwargs) - self.instance_ids = instance_ids - - -class VirtualMachineScaleSetVMInstanceView(_serialization.Model): - """The instance view of a virtual machine scale set VM. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar platform_update_domain: The Update Domain count. - :vartype platform_update_domain: int - :ivar platform_fault_domain: The Fault Domain count. - :vartype platform_fault_domain: int - :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. - :vartype rdp_thumb_print: str - :ivar vm_agent: The VM Agent running on the virtual machine. - :vartype vm_agent: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineAgentInstanceView - :ivar maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :vartype maintenance_redeploy_status: - ~azure.mgmt.compute.v2017_12_01.models.MaintenanceRedeployStatus - :ivar disks: The disks information. - :vartype disks: list[~azure.mgmt.compute.v2017_12_01.models.DiskInstanceView] - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtensionInstanceView] - :ivar vm_health: The health status for the VM. - :vartype vm_health: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineHealthStatus - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2017_12_01.models.BootDiagnosticsInstanceView - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus] - :ivar placement_group_id: The placement group in which the VM is running. If the VM is - deallocated it will not have a placementGroupId. - :vartype placement_group_id: str - """ - - _validation = { - "vm_health": {"readonly": True}, - } - - _attribute_map = { - "platform_update_domain": {"key": "platformUpdateDomain", "type": "int"}, - "platform_fault_domain": {"key": "platformFaultDomain", "type": "int"}, - "rdp_thumb_print": {"key": "rdpThumbPrint", "type": "str"}, - "vm_agent": {"key": "vmAgent", "type": "VirtualMachineAgentInstanceView"}, - "maintenance_redeploy_status": {"key": "maintenanceRedeployStatus", "type": "MaintenanceRedeployStatus"}, - "disks": {"key": "disks", "type": "[DiskInstanceView]"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineExtensionInstanceView]"}, - "vm_health": {"key": "vmHealth", "type": "VirtualMachineHealthStatus"}, - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnosticsInstanceView"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - "placement_group_id": {"key": "placementGroupId", "type": "str"}, - } - - def __init__( - self, - *, - platform_update_domain: Optional[int] = None, - platform_fault_domain: Optional[int] = None, - rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, - disks: Optional[List["_models.DiskInstanceView"]] = None, - extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - placement_group_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword platform_update_domain: The Update Domain count. - :paramtype platform_update_domain: int - :keyword platform_fault_domain: The Fault Domain count. - :paramtype platform_fault_domain: int - :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. - :paramtype rdp_thumb_print: str - :keyword vm_agent: The VM Agent running on the virtual machine. - :paramtype vm_agent: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineAgentInstanceView - :keyword maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :paramtype maintenance_redeploy_status: - ~azure.mgmt.compute.v2017_12_01.models.MaintenanceRedeployStatus - :keyword disks: The disks information. - :paramtype disks: list[~azure.mgmt.compute.v2017_12_01.models.DiskInstanceView] - :keyword extensions: The extensions information. - :paramtype extensions: - list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtensionInstanceView] - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2017_12_01.models.BootDiagnosticsInstanceView - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2017_12_01.models.InstanceViewStatus] - :keyword placement_group_id: The placement group in which the VM is running. If the VM is - deallocated it will not have a placementGroupId. - :paramtype placement_group_id: str - """ - super().__init__(**kwargs) - self.platform_update_domain = platform_update_domain - self.platform_fault_domain = platform_fault_domain - self.rdp_thumb_print = rdp_thumb_print - self.vm_agent = vm_agent - self.maintenance_redeploy_status = maintenance_redeploy_status - self.disks = disks - self.extensions = extensions - self.vm_health: Optional["_models.VirtualMachineHealthStatus"] = None - self.boot_diagnostics = boot_diagnostics - self.statuses = statuses - self.placement_group_id = placement_group_id - - -class VirtualMachineScaleSetVMListResult(_serialization.Model): - """The List Virtual Machine Scale Set VMs operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets VMs. Required. - :vartype value: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVM] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Set VMs. Call - ListNext() with this to fetch the next page of VMSS VMs. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetVM]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets VMs. Required. - :paramtype value: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVM] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Set VMs. Call - ListNext() with this to fetch the next page of VMSS VMs. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetVMProfile(_serialization.Model): - """Describes a virtual machine scale set virtual machine profile. - - :ivar os_profile: Specifies the operating system settings for the virtual machines in the scale - set. - :vartype os_profile: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetOSProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetStorageProfile - :ivar network_profile: Specifies properties of the network interfaces of the virtual machines - in the scale set. - :vartype network_profile: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetNetworkProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2017_12_01.models.DiagnosticsProfile - :ivar extension_profile: Specifies a collection of settings for extensions installed on virtual - machines in the scale set. - :vartype extension_profile: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetExtensionProfile - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
    `\\ :code:`
    `Minimum api-version: 2017-10-30-preview. Known values are: "Regular" - and "Low". - :vartype priority: str or ~azure.mgmt.compute.v2017_12_01.models.VirtualMachinePriorityTypes - :ivar eviction_policy: Specifies the eviction policy for virtual machines in a low priority - scale set. :code:`
    `\\ :code:`
    `Minimum api-version: 2017-10-30-preview. Known values - are: "Deallocate" and "Delete". - :vartype eviction_policy: str or - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineEvictionPolicyTypes - """ - - _attribute_map = { - "os_profile": {"key": "osProfile", "type": "VirtualMachineScaleSetOSProfile"}, - "storage_profile": {"key": "storageProfile", "type": "VirtualMachineScaleSetStorageProfile"}, - "network_profile": {"key": "networkProfile", "type": "VirtualMachineScaleSetNetworkProfile"}, - "diagnostics_profile": {"key": "diagnosticsProfile", "type": "DiagnosticsProfile"}, - "extension_profile": {"key": "extensionProfile", "type": "VirtualMachineScaleSetExtensionProfile"}, - "license_type": {"key": "licenseType", "type": "str"}, - "priority": {"key": "priority", "type": "str"}, - "eviction_policy": {"key": "evictionPolicy", "type": "str"}, - } - - def __init__( - self, - *, - os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, - license_type: Optional[str] = None, - priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_profile: Specifies the operating system settings for the virtual machines in the - scale set. - :paramtype os_profile: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetOSProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetStorageProfile - :keyword network_profile: Specifies properties of the network interfaces of the virtual - machines in the scale set. - :paramtype network_profile: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetNetworkProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2017_12_01.models.DiagnosticsProfile - :keyword extension_profile: Specifies a collection of settings for extensions installed on - virtual machines in the scale set. - :paramtype extension_profile: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetExtensionProfile - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
    `\\ :code:`
    `Minimum api-version: 2017-10-30-preview. Known values are: "Regular" - and "Low". - :paramtype priority: str or ~azure.mgmt.compute.v2017_12_01.models.VirtualMachinePriorityTypes - :keyword eviction_policy: Specifies the eviction policy for virtual machines in a low priority - scale set. :code:`
    `\\ :code:`
    `Minimum api-version: 2017-10-30-preview. Known values - are: "Deallocate" and "Delete". - :paramtype eviction_policy: str or - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineEvictionPolicyTypes - """ - super().__init__(**kwargs) - self.os_profile = os_profile - self.storage_profile = storage_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.extension_profile = extension_profile - self.license_type = license_type - self.priority = priority - self.eviction_policy = eviction_policy - - -class VirtualMachineSize(_serialization.Model): - """Describes the properties of a VM size. - - :ivar name: The name of the virtual machine size. - :vartype name: str - :ivar number_of_cores: The number of cores supported by the virtual machine size. - :vartype number_of_cores: int - :ivar os_disk_size_in_mb: The OS disk size, in MB, allowed by the virtual machine size. - :vartype os_disk_size_in_mb: int - :ivar resource_disk_size_in_mb: The resource disk size, in MB, allowed by the virtual machine - size. - :vartype resource_disk_size_in_mb: int - :ivar memory_in_mb: The amount of memory, in MB, supported by the virtual machine size. - :vartype memory_in_mb: int - :ivar max_data_disk_count: The maximum number of data disks that can be attached to the virtual - machine size. - :vartype max_data_disk_count: int - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "number_of_cores": {"key": "numberOfCores", "type": "int"}, - "os_disk_size_in_mb": {"key": "osDiskSizeInMB", "type": "int"}, - "resource_disk_size_in_mb": {"key": "resourceDiskSizeInMB", "type": "int"}, - "memory_in_mb": {"key": "memoryInMB", "type": "int"}, - "max_data_disk_count": {"key": "maxDataDiskCount", "type": "int"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - number_of_cores: Optional[int] = None, - os_disk_size_in_mb: Optional[int] = None, - resource_disk_size_in_mb: Optional[int] = None, - memory_in_mb: Optional[int] = None, - max_data_disk_count: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the virtual machine size. - :paramtype name: str - :keyword number_of_cores: The number of cores supported by the virtual machine size. - :paramtype number_of_cores: int - :keyword os_disk_size_in_mb: The OS disk size, in MB, allowed by the virtual machine size. - :paramtype os_disk_size_in_mb: int - :keyword resource_disk_size_in_mb: The resource disk size, in MB, allowed by the virtual - machine size. - :paramtype resource_disk_size_in_mb: int - :keyword memory_in_mb: The amount of memory, in MB, supported by the virtual machine size. - :paramtype memory_in_mb: int - :keyword max_data_disk_count: The maximum number of data disks that can be attached to the - virtual machine size. - :paramtype max_data_disk_count: int - """ - super().__init__(**kwargs) - self.name = name - self.number_of_cores = number_of_cores - self.os_disk_size_in_mb = os_disk_size_in_mb - self.resource_disk_size_in_mb = resource_disk_size_in_mb - self.memory_in_mb = memory_in_mb - self.max_data_disk_count = max_data_disk_count - - -class VirtualMachineSizeListResult(_serialization.Model): - """The List Virtual Machine operation response. - - :ivar value: The list of virtual machine sizes. - :vartype value: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineSize] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineSize]"}, - } - - def __init__(self, *, value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of virtual machine sizes. - :paramtype value: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineSize] - """ - super().__init__(**kwargs) - self.value = value - - -class VirtualMachineStatusCodeCount(_serialization.Model): - """The status code and count of the virtual machine scale set instance view status summary. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The instance view status code. - :vartype code: str - :ivar count: The number of instances having a particular status code. - :vartype count: int - """ - - _validation = { - "code": {"readonly": True}, - "count": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "count": {"key": "count", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.count: Optional[int] = None - - -class VirtualMachineUpdate(UpdateResource): - """Describes a Virtual Machine Update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2017_12_01.models.Plan - :ivar identity: The identity of the virtual machine, if configured. - :vartype identity: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineIdentity - :ivar zones: The virtual machine zones. - :vartype zones: list[str] - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2017_12_01.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2017_12_01.models.StorageProfile - :ivar os_profile: Specifies the operating system settings for the virtual machine. - :vartype os_profile: ~azure.mgmt.compute.v2017_12_01.models.OSProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2017_12_01.models.NetworkProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2017_12_01.models.DiagnosticsProfile - :ivar availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :vartype availability_set: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineInstanceView - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar vm_id: Specifies the VM unique ID which is a 128-bits identifier that is encoded and - stored in all Azure IaaS VMs SMBIOS and can be read using platform BIOS commands. - :vartype vm_id: str - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - "vm_id": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "plan": {"key": "plan", "type": "Plan"}, - "identity": {"key": "identity", "type": "VirtualMachineIdentity"}, - "zones": {"key": "zones", "type": "[str]"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineInstanceView"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineIdentity"] = None, - zones: Optional[List[str]] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - os_profile: Optional["_models.OSProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2017_12_01.models.Plan - :keyword identity: The identity of the virtual machine, if configured. - :paramtype identity: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineIdentity - :keyword zones: The virtual machine zones. - :paramtype zones: list[str] - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2017_12_01.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2017_12_01.models.StorageProfile - :keyword os_profile: Specifies the operating system settings for the virtual machine. - :paramtype os_profile: ~azure.mgmt.compute.v2017_12_01.models.OSProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2017_12_01.models.NetworkProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2017_12_01.models.DiagnosticsProfile - :keyword availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :paramtype availability_set: ~azure.mgmt.compute.v2017_12_01.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - """ - super().__init__(tags=tags, **kwargs) - self.plan = plan - self.identity = identity - self.zones = zones - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.os_profile = os_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineInstanceView"] = None - self.license_type = license_type - self.vm_id: Optional[str] = None - - -class WindowsConfiguration(_serialization.Model): - """Specifies Windows operating system settings on the virtual machine. - - :ivar provision_vm_agent: Indicates whether virtual machine agent should be provisioned on the - virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the request - body, default behavior is to set it to true. This will ensure that VM Agent is installed on - the VM so that extensions can be added to the VM later. - :vartype provision_vm_agent: bool - :ivar enable_automatic_updates: Indicates whether virtual machine is enabled for automatic - updates. - :vartype enable_automatic_updates: bool - :ivar time_zone: Specifies the time zone of the virtual machine. e.g. "Pacific Standard Time". - :vartype time_zone: str - :ivar additional_unattend_content: Specifies additional base-64 encoded XML formatted - information that can be included in the Unattend.xml file, which is used by Windows Setup. - :vartype additional_unattend_content: - list[~azure.mgmt.compute.v2017_12_01.models.AdditionalUnattendContent] - :ivar win_rm: Specifies the Windows Remote Management listeners. This enables remote Windows - PowerShell. - :vartype win_rm: ~azure.mgmt.compute.v2017_12_01.models.WinRMConfiguration - """ - - _attribute_map = { - "provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"}, - "enable_automatic_updates": {"key": "enableAutomaticUpdates", "type": "bool"}, - "time_zone": {"key": "timeZone", "type": "str"}, - "additional_unattend_content": {"key": "additionalUnattendContent", "type": "[AdditionalUnattendContent]"}, - "win_rm": {"key": "winRM", "type": "WinRMConfiguration"}, - } - - def __init__( - self, - *, - provision_vm_agent: Optional[bool] = None, - enable_automatic_updates: Optional[bool] = None, - time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, - win_rm: Optional["_models.WinRMConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword provision_vm_agent: Indicates whether virtual machine agent should be provisioned on - the virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the - request body, default behavior is to set it to true. This will ensure that VM Agent is - installed on the VM so that extensions can be added to the VM later. - :paramtype provision_vm_agent: bool - :keyword enable_automatic_updates: Indicates whether virtual machine is enabled for automatic - updates. - :paramtype enable_automatic_updates: bool - :keyword time_zone: Specifies the time zone of the virtual machine. e.g. "Pacific Standard - Time". - :paramtype time_zone: str - :keyword additional_unattend_content: Specifies additional base-64 encoded XML formatted - information that can be included in the Unattend.xml file, which is used by Windows Setup. - :paramtype additional_unattend_content: - list[~azure.mgmt.compute.v2017_12_01.models.AdditionalUnattendContent] - :keyword win_rm: Specifies the Windows Remote Management listeners. This enables remote Windows - PowerShell. - :paramtype win_rm: ~azure.mgmt.compute.v2017_12_01.models.WinRMConfiguration - """ - super().__init__(**kwargs) - self.provision_vm_agent = provision_vm_agent - self.enable_automatic_updates = enable_automatic_updates - self.time_zone = time_zone - self.additional_unattend_content = additional_unattend_content - self.win_rm = win_rm - - -class WinRMConfiguration(_serialization.Model): - """Describes Windows Remote Management configuration of the VM. - - :ivar listeners: The list of Windows Remote Management listeners. - :vartype listeners: list[~azure.mgmt.compute.v2017_12_01.models.WinRMListener] - """ - - _attribute_map = { - "listeners": {"key": "listeners", "type": "[WinRMListener]"}, - } - - def __init__(self, *, listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs: Any) -> None: - """ - :keyword listeners: The list of Windows Remote Management listeners. - :paramtype listeners: list[~azure.mgmt.compute.v2017_12_01.models.WinRMListener] - """ - super().__init__(**kwargs) - self.listeners = listeners - - -class WinRMListener(_serialization.Model): - """Describes Protocol and thumbprint of Windows Remote Management listener. - - :ivar protocol: Specifies the protocol of listener. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. Known values are: "Http" - and "Https". - :vartype protocol: str or ~azure.mgmt.compute.v2017_12_01.models.ProtocolTypes - :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as - a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :vartype certificate_url: str - """ - - _attribute_map = { - "protocol": {"key": "protocol", "type": "str"}, - "certificate_url": {"key": "certificateUrl", "type": "str"}, - } - - def __init__( - self, - *, - protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, - certificate_url: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword protocol: Specifies the protocol of listener. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. Known values are: - "Http" and "Https". - :paramtype protocol: str or ~azure.mgmt.compute.v2017_12_01.models.ProtocolTypes - :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault - as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :paramtype certificate_url: str - """ - super().__init__(**kwargs) - self.protocol = protocol - self.certificate_url = certificate_url diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/__init__.py deleted file mode 100644 index 120054eeda4f..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/__init__.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import Operations # type: ignore -from ._operations import AvailabilitySetsOperations # type: ignore -from ._operations import VirtualMachineExtensionImagesOperations # type: ignore -from ._operations import VirtualMachineExtensionsOperations # type: ignore -from ._operations import VirtualMachinesOperations # type: ignore -from ._operations import VirtualMachineImagesOperations # type: ignore -from ._operations import UsageOperations # type: ignore -from ._operations import VirtualMachineSizesOperations # type: ignore -from ._operations import ImagesOperations # type: ignore -from ._operations import VirtualMachineScaleSetsOperations # type: ignore -from ._operations import VirtualMachineScaleSetExtensionsOperations # type: ignore -from ._operations import VirtualMachineScaleSetRollingUpgradesOperations # type: ignore -from ._operations import VirtualMachineScaleSetVMsOperations # type: ignore -from ._operations import LogAnalyticsOperations # type: ignore -from ._operations import VirtualMachineRunCommandsOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AvailabilitySetsOperations", - "VirtualMachineExtensionImagesOperations", - "VirtualMachineExtensionsOperations", - "VirtualMachinesOperations", - "VirtualMachineImagesOperations", - "UsageOperations", - "VirtualMachineSizesOperations", - "ImagesOperations", - "VirtualMachineScaleSetsOperations", - "VirtualMachineScaleSetExtensionsOperations", - "VirtualMachineScaleSetRollingUpgradesOperations", - "VirtualMachineScaleSetVMsOperations", - "LogAnalyticsOperations", - "VirtualMachineRunCommandsOperations", -] -__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/v2017_12_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_operations.py deleted file mode 100644 index d833f2aa61c4..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_operations.py +++ /dev/null @@ -1,13901 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterator, List, Literal, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import ComputeManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_operations_list_request(**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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/operations") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_availability_sets_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes", - ) - 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"), - } - - _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_extension_images_get_request( # pylint: disable=name-too-long - location: str, publisher_name: str, type: str, version: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types", - ) - 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"), - } - - _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_extension_images_list_versions_request( # pylint: disable=name-too-long - location: str, - publisher_name: str, - type: str, - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - if orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2017-12-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-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}", - ) - 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"), - } - - _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_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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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) - - -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 -) -> 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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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) - - -def build_virtual_machines_get_extensions_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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines", - ) - 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_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", "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture", - ) - 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"), - } - - _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_machines_create_or_update_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", "2017-12-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_update_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", "2017-12-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}", - ) - 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"), - } - - _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_virtual_machines_delete_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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", - ) - 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"), - } - - _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) - - -def build_virtual_machines_get_request( - resource_group_name: str, - vm_name: str, - subscription_id: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", - ) - 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"), - } - - _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) - - -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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView", - ) - 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"), - } - - _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_machines_convert_to_managed_disks_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks", - ) - 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"), - } - - _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="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, **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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_generalize_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_list_all_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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes", - ) - 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"), - } - - _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_machines_power_off_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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_restart_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart", - ) - 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"), - } - - _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="POST", 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 -) -> 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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_redeploy_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_perform_maintenance_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_run_command_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", - ) - 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"), - } - - _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) - - -def build_virtual_machine_images_list_offers_request( # pylint: disable=name-too-long - location: str, publisher_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers" - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_images_list_skus_request( # pylint: disable=name-too-long - location: str, publisher_name: str, offer: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages" - ) - 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_sizes_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes" - ) - 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-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}", - ) - 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"), - } - - _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_images_delete_request( - resource_group_name: str, image_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", - ) - 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"), - } - - _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) - - -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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", - ) - 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"), - } - - _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) - - -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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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, **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", "2017-12-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_update_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", "2017-12-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}", - ) - 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"), - } - - _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_virtual_machine_scale_sets_delete_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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", - ) - 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"), - } - - _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) - - -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, **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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", - ) - 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"), - } - - _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_scale_sets_deallocate_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", "2017-12-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", - ) - 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"), - } - - _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_scale_sets_delete_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", "2017-12-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", - ) - 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"), - } - - _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_scale_sets_get_instance_view_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_list_all_request( # pylint: disable=name-too-long - subscription_id: str, **kwargs: Any -) -> 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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_list_skus_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory", - ) - 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"), - } - - _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_scale_sets_power_off_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", "2017-12-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", - ) - 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"), - } - - _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_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", "2017-12-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", - ) - 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"), - } - - _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_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", "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start", - ) - 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"), - } - - _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_scale_sets_redeploy_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-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", - ) - 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"), - } - - _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_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", "2017-12-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", - ) - 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"), - } - - _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_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", "2017-12-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", - ) - 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"), - } - - _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_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", "2017-12-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", - ) - 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"), - } - - _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_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", "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall", - ) - 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"), - } - - _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_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, - **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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk", - ) - 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"), - } - - _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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", 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 -) -> 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", "2017-12-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions", - ) - 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"), - } - - _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_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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel", - ) - 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"), - } - - _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="POST", 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 -) -> 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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade", - ) - 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"), - } - - _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="POST", 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 -) -> 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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest", - ) - 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"), - } - - _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_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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_set_vms_reimage_all_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any -) -> 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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall", - ) - 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"), - } - - _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="POST", 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 -) -> 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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate", - ) - 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"), - } - - _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="POST", 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, **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", "2017-12-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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, **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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", - ) - 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"), - } - - _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) - - -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, **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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView", - ) - 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"), - } - - _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_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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines", - ) - 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"), - } - - _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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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, **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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff", - ) - 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"), - } - - _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="POST", 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 -) -> 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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart", - ) - 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"), - } - - _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="POST", 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 -) -> 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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_set_vms_redeploy_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01")) - 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", - ) - 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"), - } - - _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="POST", 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 -) -> 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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance", - ) - 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"), - } - - _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="POST", 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", "2017-12-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", - ) - 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 -) -> 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", "2017-12-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", - ) - 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", "2017-12-01")) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands" - ) - 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", "2017-12-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}", - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"), - "commandId": _SERIALIZER.url("command_id", command_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.ComputeManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.ComputeOperationValue"]: - """Gets a list of compute operations. - - :return: An iterator like instance of either ComputeOperationValue or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.ComputeOperationValue] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.ComputeOperationListResult] = 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_operations_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def 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) - - 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 AvailabilitySetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.ComputeManagementClient`'s - :attr:`availability_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: _models.AvailabilitySet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySet, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Is either a - AvailabilitySet type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySet") - - _request = build_availability_sets_create_or_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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, - availability_set_name: str, - parameters: _models.AvailabilitySetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySetUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Is either a - AvailabilitySetUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySetUpdate or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySetUpdate") - - _request = build_availability_sets_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Optional[_models.OperationStatusResponse]: - """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: OperationStatusResponse or None or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse or 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 "2017-12-01")) - cls: ClsType[Optional[_models.OperationStatusResponse]] = 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) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("OperationStatusResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get(self, resource_group_name: str, 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.v2017_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", 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) - - _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("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription( - self, *, expand: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. - - :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.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets 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 AvailabilitySet or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - 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_available_sizes( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes that can be used to create a new virtual machine in - an existing availability set. - - :param resource_group_name: The name of the resource group. Required. - :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.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_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 - - if response.status_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 VirtualMachineExtensionImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_extension_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, type: str, version: str, **kwargs: Any - ) -> _models.VirtualMachineExtensionImage: - """Gets a virtual machine extension image. - - :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.v2017_12_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 "2017-12-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 - - @distributed_trace - def list_types( - self, location: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineExtensionImage]: - """Gets a list of virtual machine extension image types. - - :param location: The name of 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.v2017_12_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 "2017-12-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - - _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) - - _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 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 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.v2017_12_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 "2017-12-01")) - 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 - - -class VirtualMachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, 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 "2017-12-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, "VirtualMachineExtension") - - _request = build_virtual_machine_extensions_create_or_update_request( - resource_group_name=resource_group_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2017_12_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 VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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] - :keyword content_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.v2017_12_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2017_12_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.v2017_12_01.models.VirtualMachineExtension] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - 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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineExtensionUpdate") - - _request = build_virtual_machine_extensions_update_request( - resource_group_name=resource_group_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, - 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]: - 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, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to update the extension. - - :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: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtensionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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 - ) -> 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_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 LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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.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.v2017_12_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.v2017_12_01.models.VirtualMachineExtension] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2017-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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) - - _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, vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """The operation to delete 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 deleted. - 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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.v2017_12_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 "2017-12-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) - - deserialized = self._deserialize("VirtualMachineExtension", 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.v2017_12_01.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_extensions( - 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.v2017_12_01.models.VirtualMachineExtensionsListResult - :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 "2017-12-01")) - cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machines_get_extensions_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineExtensionsListResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_location(self, location: str, **kwargs: Any) -> ItemPaged["_models.VirtualMachine"]: - """Gets all the virtual machines under the specified subscription for the specified location. - - :param location: The location for which virtual machines under the subscription are queried. - Required. - :type location: str - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-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 - - 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) - - def _capture_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-12-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 - - 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_capture( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachineCaptureParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. - - :param resource_group_name: The name of the resource group. Required. - :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.v2017_12_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.v2017_12_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. - - :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.v2017_12_01.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_capture( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. - - :param resource_group_name: The name of the resource group. 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.v2017_12_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.v2017_12_01.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineCaptureResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._capture_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineCaptureResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # 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) - ) - 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 - ) - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, 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 "2017-12-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, "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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachine, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or 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 Create Virtual Machine operation. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachine - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or 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 Create 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 VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or 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 Create Virtual Machine operation. Is either a - VirtualMachine type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachine or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_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 "2017-12-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._create_or_update_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("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 _update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineUpdate, 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 "2017-12-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, "VirtualMachineUpdate") - - _request = build_virtual_machines_update_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 - - 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 = 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, - vm_name: str, - parameters: _models.VirtualMachineUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. - - :param resource_group_name: The name of the resource group. 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.v2017_12_01.models.VirtualMachineUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. - - :param resource_group_name: The name of the resource group. 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 content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_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]], - **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.v2017_12_01.models.VirtualMachineUpdate or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_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 "2017-12-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, - 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, **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 "2017-12-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, - 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, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """The operation to delete 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 LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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: Literal["instanceView"] = "instanceView", **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_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 "2017-12-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.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) - - _request = build_virtual_machines_instance_view_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineInstanceView", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _convert_to_managed_disks_initial( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> 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 "2017-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_convert_to_managed_disks_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_convert_to_managed_disks( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - :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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._convert_to_managed_disks_initial( - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _deallocate_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[Iterator[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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_deallocate( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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_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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def generalize(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> _models.OperationStatusResponse: - """Sets the state of the virtual machine to generalized. - - :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: OperationStatusResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse - :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 "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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) - - deserialized = self._deserialize("OperationStatusResponse", 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) -> ItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-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, - 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, **kwargs: Any) -> ItemPaged["_models.VirtualMachine"]: - """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. - - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-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, - 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_available_sizes( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes to which the specified virtual machine can be - resized. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_available_sizes_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _power_off_initial(self, resource_group_name: str, vm_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 "2017-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_power_off_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_power_off( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - :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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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]: - 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 "2017-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_restart_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_restart( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """The operation to restart 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 LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._restart_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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]: - 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 "2017-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_start( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_redeploy_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_redeploy( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _perform_maintenance_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_perform_maintenance( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """The operation to perform maintenance on 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 LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _run_command_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - 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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RunCommandInput") - - _request = build_virtual_machines_run_command_request( - 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 - - 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_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.RunCommandInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_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.v2017_12_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._run_command_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: 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.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.v2017_12_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 "2017-12-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.v2017_12_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 "2017-12-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. - - :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.v2017_12_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 "2017-12-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_list_offers_request( - location=location, - publisher_name=publisher_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2017_12_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 "2017-12-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 = 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_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 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.v2017_12_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 "2017-12-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _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) - - _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 - - -class UsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.ComputeManagementClient`'s - :attr:`usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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 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.v2017_12_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 "2017-12-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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - 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.v2017_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes for a subscription in a location. - - :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.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_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 - - 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 - - if response.status_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 ImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.ComputeManagementClient`'s - :attr:`images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any - ) -> 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 "2017-12-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, "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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: _models.Image, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Create or update 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 - :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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.Image] - :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. - - :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 - :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.v2017_12_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.v2017_12_01.models.Image] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._create_or_update_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: 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.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Image]( - 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]], - **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 "2017-12-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, "ImageUpdate") - - _request = build_images_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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, - image_name: str, - parameters: _models.ImageUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Update 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 - :param parameters: Parameters supplied to the Update Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Update 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 - :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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Update 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 - :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.v2017_12_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.v2017_12_01.models.Image] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: 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.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Image]( - 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]: - 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 "2017-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_images_delete_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, image_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Deletes 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 - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - image_name=image_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.Image] = kwargs.pop("cls", None) - - _request = build_images_get_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Image", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Image"]: - """Gets the list of images 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 Image or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_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.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class 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.v2017_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, 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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualMachineScaleSet") - - _request = build_virtual_machine_scale_sets_create_or_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSet - :keyword content_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.v2017_12_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. 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 VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 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.v2017_12_01.models.VirtualMachineScaleSet or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_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 "2017-12-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, - 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]], - **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 "2017-12-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, "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, - 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]: - 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, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. - - :param resource_group_name: The name of the resource group. 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.v2017_12_01.models.VirtualMachineScaleSetUpdate - :keyword content_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.v2017_12_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. - - :param resource_group_name: The name of the resource group. 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: IO[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 VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_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]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update 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 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.v2017_12_01.models.VirtualMachineScaleSetUpdate or - IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_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 "2017-12-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, - 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, **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 "2017-12-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, - 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, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, **kwargs: Any) -> _models.VirtualMachineScaleSet: - """Display information about a 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 - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_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 "2017-12-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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _deallocate_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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_deallocate( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - :type 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.v2017_12_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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - :type 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_deallocate( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - :type 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.v2017_12_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-12-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") - - _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, - 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_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_12_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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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. - 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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.v2017_12_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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. - - :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.v2017_12_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 "2017-12-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 - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_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 - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-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_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: - 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) -> ItemPaged["_models.VirtualMachineScaleSet"]: - """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource - group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this - till nextLink is null to fetch all the VM Scale Sets. - - :return: An iterator like instance of either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = 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_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("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) - - 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_skus( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineScaleSetSku"]: - """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM - instances allowed for each SKU. - - :param resource_group_name: The name of the resource group. Required. - :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.v2017_12_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 "2017-12-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) - - @distributed_trace - def get_os_upgrade_history( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.UpgradeOperationHistoricalStatusInfo"]: - """Gets list of OS upgrades 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 - :return: An iterator like instance of either UpgradeOperationHistoricalStatusInfo or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_sets_get_os_upgrade_history_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListOSUpgradeHistory", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _power_off_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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_power_off_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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.v2017_12_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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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, - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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.v2017_12_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, - 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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_restart_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_12_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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, - 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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_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 - 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_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[_models.OperationStatusResponse]: - """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.v2017_12_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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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.v2017_12_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, - 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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_redeploy_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_redeploy( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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.v2017_12_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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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.v2017_12_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _perform_maintenance_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_perform_maintenance( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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.v2017_12_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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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[_models.OperationStatusResponse]: - """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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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.v2017_12_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-12-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") - - _request = build_virtual_machine_scale_sets_update_instances_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_12_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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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_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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Reimages (upgrade the operating system) 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.v2017_12_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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_reimage( - 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[_models.OperationStatusResponse]: - """Reimages (upgrade the operating system) 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Reimages (upgrade the operating system) 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.v2017_12_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reimage_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_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[_models.OperationStatusResponse]: - """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.v2017_12_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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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[_models.OperationStatusResponse]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, **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 - :return: RecoveryWalkResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_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 "2017-12-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, - 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("RecoveryWalkResponse", 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.v2017_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtension, 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 "2017-12-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") - - _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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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. - - :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.v2017_12_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.v2017_12_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.v2017_12_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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.v2017_12_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.v2017_12_01.models.VirtualMachineScaleSetExtension] - :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 "2017-12-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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2017-12-01")) - 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, - 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, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """The operation to delete the extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be deleted. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def get( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSetExtension: - """The operation to get the extension. - - :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.v2017_12_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 "2017-12-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 - - @distributed_trace - def list( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_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.v2017_12_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 "2017-12-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) - - -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.v2017_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2017-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_rolling_upgrades_cancel_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - 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 - - return deserialized # type: ignore - - @distributed_trace - def begin_cancel( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Cancels the current 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: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, - 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 "2017-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request( - resource_group_name=resource_group_name, - 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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_start_os_upgrade( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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.v2017_12_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 "2017-12-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 - ) - - response = pipeline_response.http_response - - if response.status_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 VirtualMachineScaleSetVMsOperations: # 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.v2017_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _reimage_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 "2017-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_reimage_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - 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 - - return deserialized # type: ignore - - @distributed_trace - def begin_reimage( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _reimage_all_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_reimage_all( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. - This operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reimage_all_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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 "2017-12-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) - - 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_deallocate( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and - releases the compute resources it uses. You are not billed for the compute resources of this - virtual machine once it is deallocated. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._deallocate_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, - parameters: Union[_models.VirtualMachineScaleSetVM, 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 "2017-12-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, "VirtualMachineScaleSetVM") - - _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, - 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, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.VirtualMachineScaleSetVM, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVM - :keyword content_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.v2017_12_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - 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 VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. - Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVM or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVM] - :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 "2017-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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, - 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("VirtualMachineScaleSetVM", 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.VirtualMachineScaleSetVM].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetVM]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, 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 "2017-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - 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, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Deletes 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: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, **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 - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2017_12_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 "2017-12-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, - 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.v2017_12_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 "2017-12-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 - ) -> ItemPaged["_models.VirtualMachineScaleSetVM"]: - """Gets a list of all virtual machines in a VM scale sets. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param virtual_machine_scale_set_name: The name of the VM scale set. Required. - :type virtual_machine_scale_set_name: str - :keyword filter: The filter to apply to the operation. Allowed values are - 'startswith(instanceView/statuses/code, 'PowerState') eq true', 'properties/latestModelApplied - eq true', 'properties/latestModelApplied eq false'. Default value is None. - :paramtype filter: str - :keyword select: The list parameters. Allowed values are 'instanceView', - 'instanceView/statuses'. Default value is None. - :paramtype select: str - :keyword expand: The expand expression to apply to the operation. Allowed values are - 'instanceView'. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_set_vms_list_request( - resource_group_name=resource_group_name, - virtual_machine_scale_set_name=virtual_machine_scale_set_name, - subscription_id=self._config.subscription_id, - filter=filter, - select=select, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVMListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _power_off_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **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 "2017-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_power_off_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_power_off( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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 "2017-12-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 - - return deserialized # type: ignore - - @distributed_trace - def begin_restart( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Restarts a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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 - ) -> 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 "2017-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_start_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 - - return deserialized # type: ignore - - @distributed_trace - def begin_start( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 - :param vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = 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, - 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): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, - 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 "2017-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_redeploy( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """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 vm_scale_set_name: The name of the VM 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 OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._redeploy_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - 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, 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 "2017-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_perform_maintenance( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[_models.OperationStatusResponse]: - """Performs maintenance on a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either OperationStatusResponse or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-12-01")) - cls: ClsType[_models.OperationStatusResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationStatusResponse", 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OperationStatusResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OperationStatusResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class LogAnalyticsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.ComputeManagementClient`'s - :attr:`log_analytics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - 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 "2017-12-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, "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, - ) - _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_export_request_rate_by_interval( - self, - location: str, - parameters: _models.RequestRateByIntervalInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. - - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. - Required. - :type parameters: ~azure.mgmt.compute.v2017_12_01.models.RequestRateByIntervalInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.LogAnalyticsOperationResult] - :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. - - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_export_request_rate_by_interval( - self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. - - :param location: The 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.v2017_12_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.v2017_12_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 "2017-12-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, 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, - 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("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, 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.LogAnalyticsOperationResult].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 - ) - - def _export_throttled_requests_initial( - self, location: str, parameters: Union[_models.ThrottledRequestsInput, 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 "2017-12-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, - 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_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.v2017_12_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.v2017_12_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.v2017_12_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. - - :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.v2017_12_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.v2017_12_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 "2017-12-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, 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, - 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("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, 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.LogAnalyticsOperationResult].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 - ) - - -class VirtualMachineRunCommandsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2017_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.RunCommandDocumentBase"]: - """Lists all available run commands for a subscription in a location. - - :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 - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_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 "2017-12-01")) - cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_run_commands_list_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RunCommandListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - 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, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: - """Gets specific run command for a subscription in a location. - - :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.v2017_12_01.models.RunCommandDocument - :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 "2017-12-01")) - cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) - - _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, - 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("RunCommandDocument", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2019_04_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_compute_management_client.py deleted file mode 100644 index df314dcf1d9f..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_compute_management_client.py +++ /dev/null @@ -1,116 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ResourceSkusOperations - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar resource_skus: ResourceSkusOperations operations - :vartype resource_skus: azure.mgmt.compute.v2019_04_01.operations.ResourceSkusOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.resource_skus = ResourceSkusOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-04-01" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_configuration.py deleted file mode 100644 index e705886c1599..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2019-04-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_metadata.json deleted file mode 100644 index 5567fd7cb9e5..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2019-04-01", - "total_api_version_list": ["2019-04-01"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "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.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "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.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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": { - "resource_skus": "ResourceSkusOperations" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node
    is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj 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 deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2019_04_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/_compute_management_client.py deleted file mode 100644 index 60fed9d70dc1..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/_compute_management_client.py +++ /dev/null @@ -1,120 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ResourceSkusOperations - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar resource_skus: ResourceSkusOperations operations - :vartype resource_skus: azure.mgmt.compute.v2019_04_01.aio.operations.ResourceSkusOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.resource_skus = ResourceSkusOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-04-01" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/_configuration.py deleted file mode 100644 index 98926aa32b5f..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2019-04-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/__init__.py deleted file mode 100644 index a17cbc8abb0e..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import ResourceSkusOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ResourceSkusOperations", -] -__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/v2019_04_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/__init__.py deleted file mode 100644 index e91e0a123383..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/__init__.py +++ /dev/null @@ -1,52 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - ResourceSku, - ResourceSkuCapabilities, - ResourceSkuCapacity, - ResourceSkuCosts, - ResourceSkuLocationInfo, - ResourceSkuRestrictionInfo, - ResourceSkuRestrictions, - ResourceSkuZoneDetails, - ResourceSkusResult, -) - -from ._compute_management_client_enums import ( # type: ignore - ResourceSkuCapacityScaleType, - ResourceSkuRestrictionsReasonCode, - ResourceSkuRestrictionsType, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ResourceSku", - "ResourceSkuCapabilities", - "ResourceSkuCapacity", - "ResourceSkuCosts", - "ResourceSkuLocationInfo", - "ResourceSkuRestrictionInfo", - "ResourceSkuRestrictions", - "ResourceSkuZoneDetails", - "ResourceSkusResult", - "ResourceSkuCapacityScaleType", - "ResourceSkuRestrictionsReasonCode", - "ResourceSkuRestrictionsType", -] -__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/v2019_04_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_compute_management_client_enums.py deleted file mode 100644 index 6a772bbc0075..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_compute_management_client_enums.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class ResourceSkuCapacityScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scale type applicable to the sku.""" - - AUTOMATIC = "Automatic" - MANUAL = "Manual" - NONE = "None" - - -class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The reason for restriction.""" - - QUOTA_ID = "QuotaId" - NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" - - -class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of restrictions.""" - - LOCATION = "Location" - ZONE = "Zone" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_models_py3.py deleted file mode 100644 index 8c8eaa614acd..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_models_py3.py +++ /dev/null @@ -1,366 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -class ResourceSku(_serialization.Model): - """Describes an available Compute SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of resource the SKU applies to. - :vartype resource_type: str - :ivar name: The name of SKU. - :vartype name: str - :ivar tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
    `\\ - :code:`
    ` Possible Values:\\ :code:`
    `\\ :code:`
    ` **Standard**\\ :code:`
    `\\ :code:`
    ` **Basic**. - :vartype tier: str - :ivar size: The Size of the SKU. - :vartype size: str - :ivar family: The Family of this particular SKU. - :vartype family: str - :ivar kind: The Kind of resources that are supported in this SKU. - :vartype kind: str - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: ~azure.mgmt.compute.v2019_04_01.models.ResourceSkuCapacity - :ivar locations: The set of locations that the SKU is available. - :vartype locations: list[str] - :ivar location_info: A list of locations and availability zones in those locations where the - SKU is available. - :vartype location_info: list[~azure.mgmt.compute.v2019_04_01.models.ResourceSkuLocationInfo] - :ivar api_versions: The api versions that support this SKU. - :vartype api_versions: list[str] - :ivar costs: Metadata for retrieving price info. - :vartype costs: list[~azure.mgmt.compute.v2019_04_01.models.ResourceSkuCosts] - :ivar capabilities: A name value pair to describe the capability. - :vartype capabilities: list[~azure.mgmt.compute.v2019_04_01.models.ResourceSkuCapabilities] - :ivar restrictions: The restrictions because of which SKU cannot be used. This is empty if - there are no restrictions. - :vartype restrictions: list[~azure.mgmt.compute.v2019_04_01.models.ResourceSkuRestrictions] - """ - - _validation = { - "resource_type": {"readonly": True}, - "name": {"readonly": True}, - "tier": {"readonly": True}, - "size": {"readonly": True}, - "family": {"readonly": True}, - "kind": {"readonly": True}, - "capacity": {"readonly": True}, - "locations": {"readonly": True}, - "location_info": {"readonly": True}, - "api_versions": {"readonly": True}, - "costs": {"readonly": True}, - "capabilities": {"readonly": True}, - "restrictions": {"readonly": True}, - } - - _attribute_map = { - "resource_type": {"key": "resourceType", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "size": {"key": "size", "type": "str"}, - "family": {"key": "family", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "capacity": {"key": "capacity", "type": "ResourceSkuCapacity"}, - "locations": {"key": "locations", "type": "[str]"}, - "location_info": {"key": "locationInfo", "type": "[ResourceSkuLocationInfo]"}, - "api_versions": {"key": "apiVersions", "type": "[str]"}, - "costs": {"key": "costs", "type": "[ResourceSkuCosts]"}, - "capabilities": {"key": "capabilities", "type": "[ResourceSkuCapabilities]"}, - "restrictions": {"key": "restrictions", "type": "[ResourceSkuRestrictions]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_type: Optional[str] = None - self.name: Optional[str] = None - self.tier: Optional[str] = None - self.size: Optional[str] = None - self.family: Optional[str] = None - self.kind: Optional[str] = None - self.capacity: Optional["_models.ResourceSkuCapacity"] = None - self.locations: Optional[List[str]] = None - self.location_info: Optional[List["_models.ResourceSkuLocationInfo"]] = None - self.api_versions: Optional[List[str]] = None - self.costs: Optional[List["_models.ResourceSkuCosts"]] = None - self.capabilities: Optional[List["_models.ResourceSkuCapabilities"]] = None - self.restrictions: Optional[List["_models.ResourceSkuRestrictions"]] = None - - -class ResourceSkuCapabilities(_serialization.Model): - """Describes The SKU capabilities object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: An invariant to describe the feature. - :vartype name: str - :ivar value: An invariant if the feature is measured by quantity. - :vartype value: str - """ - - _validation = { - "name": {"readonly": True}, - "value": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.value: Optional[str] = None - - -class ResourceSkuCapacity(_serialization.Model): - """Describes scaling information of a SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar minimum: The minimum capacity. - :vartype minimum: int - :ivar maximum: The maximum capacity that can be set. - :vartype maximum: int - :ivar default: The default capacity. - :vartype default: int - :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", - "Manual", and "None". - :vartype scale_type: str or ~azure.mgmt.compute.v2019_04_01.models.ResourceSkuCapacityScaleType - """ - - _validation = { - "minimum": {"readonly": True}, - "maximum": {"readonly": True}, - "default": {"readonly": True}, - "scale_type": {"readonly": True}, - } - - _attribute_map = { - "minimum": {"key": "minimum", "type": "int"}, - "maximum": {"key": "maximum", "type": "int"}, - "default": {"key": "default", "type": "int"}, - "scale_type": {"key": "scaleType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.minimum: Optional[int] = None - self.maximum: Optional[int] = None - self.default: Optional[int] = None - self.scale_type: Optional[Union[str, "_models.ResourceSkuCapacityScaleType"]] = None - - -class ResourceSkuCosts(_serialization.Model): - """Describes metadata for retrieving price info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar meter_id: Used for querying price from commerce. - :vartype meter_id: str - :ivar quantity: The multiplier is needed to extend the base metered cost. - :vartype quantity: int - :ivar extended_unit: An invariant to show the extended unit. - :vartype extended_unit: str - """ - - _validation = { - "meter_id": {"readonly": True}, - "quantity": {"readonly": True}, - "extended_unit": {"readonly": True}, - } - - _attribute_map = { - "meter_id": {"key": "meterID", "type": "str"}, - "quantity": {"key": "quantity", "type": "int"}, - "extended_unit": {"key": "extendedUnit", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.meter_id: Optional[str] = None - self.quantity: Optional[int] = None - self.extended_unit: Optional[str] = None - - -class ResourceSkuLocationInfo(_serialization.Model): - """ResourceSkuLocationInfo. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: Location of the SKU. - :vartype location: str - :ivar zones: List of availability zones where the SKU is supported. - :vartype zones: list[str] - :ivar zone_details: Details of capabilities available to a SKU in specific zones. - :vartype zone_details: list[~azure.mgmt.compute.v2019_04_01.models.ResourceSkuZoneDetails] - """ - - _validation = { - "location": {"readonly": True}, - "zones": {"readonly": True}, - "zone_details": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "zones": {"key": "zones", "type": "[str]"}, - "zone_details": {"key": "zoneDetails", "type": "[ResourceSkuZoneDetails]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.location: Optional[str] = None - self.zones: Optional[List[str]] = None - self.zone_details: Optional[List["_models.ResourceSkuZoneDetails"]] = None - - -class ResourceSkuRestrictionInfo(_serialization.Model): - """ResourceSkuRestrictionInfo. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar locations: Locations where the SKU is restricted. - :vartype locations: list[str] - :ivar zones: List of availability zones where the SKU is restricted. - :vartype zones: list[str] - """ - - _validation = { - "locations": {"readonly": True}, - "zones": {"readonly": True}, - } - - _attribute_map = { - "locations": {"key": "locations", "type": "[str]"}, - "zones": {"key": "zones", "type": "[str]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.locations: Optional[List[str]] = None - self.zones: Optional[List[str]] = None - - -class ResourceSkuRestrictions(_serialization.Model): - """Describes scaling information of a SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of restrictions. Known values are: "Location" and "Zone". - :vartype type: str or ~azure.mgmt.compute.v2019_04_01.models.ResourceSkuRestrictionsType - :ivar values: The value of restrictions. If the restriction type is set to location. This would - be different locations where the SKU is restricted. - :vartype values: list[str] - :ivar restriction_info: The information about the restriction where the SKU cannot be used. - :vartype restriction_info: ~azure.mgmt.compute.v2019_04_01.models.ResourceSkuRestrictionInfo - :ivar reason_code: The reason for restriction. Known values are: "QuotaId" and - "NotAvailableForSubscription". - :vartype reason_code: str or - ~azure.mgmt.compute.v2019_04_01.models.ResourceSkuRestrictionsReasonCode - """ - - _validation = { - "type": {"readonly": True}, - "values": {"readonly": True}, - "restriction_info": {"readonly": True}, - "reason_code": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "values": {"key": "values", "type": "[str]"}, - "restriction_info": {"key": "restrictionInfo", "type": "ResourceSkuRestrictionInfo"}, - "reason_code": {"key": "reasonCode", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[Union[str, "_models.ResourceSkuRestrictionsType"]] = None - self.values: Optional[List[str]] = None - self.restriction_info: Optional["_models.ResourceSkuRestrictionInfo"] = None - self.reason_code: Optional[Union[str, "_models.ResourceSkuRestrictionsReasonCode"]] = None - - -class ResourceSkusResult(_serialization.Model): - """The List Resource Skus operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of skus available for the subscription. Required. - :vartype value: list[~azure.mgmt.compute.v2019_04_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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ResourceSku]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - 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. - :paramtype value: list[~azure.mgmt.compute.v2019_04_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ResourceSkuZoneDetails(_serialization.Model): - """Describes The zonal capabilities of a SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The set of zones that the SKU is available in with the specified capabilities. - :vartype name: list[str] - :ivar capabilities: A list of capabilities that are available for the SKU in the specified list - of zones. - :vartype capabilities: list[~azure.mgmt.compute.v2019_04_01.models.ResourceSkuCapabilities] - """ - - _validation = { - "name": {"readonly": True}, - "capabilities": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "[str]"}, - "capabilities": {"key": "capabilities", "type": "[ResourceSkuCapabilities]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[List[str]] = None - self.capabilities: Optional[List["_models.ResourceSkuCapabilities"]] = None diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/__init__.py deleted file mode 100644 index a17cbc8abb0e..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import ResourceSkusOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ResourceSkusOperations", -] -__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/v2019_04_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2019_07_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_compute_management_client.py deleted file mode 100644 index dc1803c51f39..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_compute_management_client.py +++ /dev/null @@ -1,288 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ( - AvailabilitySetsOperations, - DedicatedHostGroupsOperations, - DedicatedHostsOperations, - DiskEncryptionSetsOperations, - DisksOperations, - GalleriesOperations, - GalleryApplicationVersionsOperations, - GalleryApplicationsOperations, - GalleryImageVersionsOperations, - GalleryImagesOperations, - ImagesOperations, - LogAnalyticsOperations, - Operations, - ProximityPlacementGroupsOperations, - SnapshotsOperations, - UsageOperations, - VirtualMachineExtensionImagesOperations, - VirtualMachineExtensionsOperations, - VirtualMachineImagesOperations, - VirtualMachineRunCommandsOperations, - VirtualMachineScaleSetExtensionsOperations, - VirtualMachineScaleSetRollingUpgradesOperations, - VirtualMachineScaleSetVMExtensionsOperations, - VirtualMachineScaleSetVMsOperations, - VirtualMachineScaleSetsOperations, - VirtualMachineSizesOperations, - VirtualMachinesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.compute.v2019_07_01.operations.Operations - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2019_07_01.operations.AvailabilitySetsOperations - :ivar proximity_placement_groups: ProximityPlacementGroupsOperations operations - :vartype proximity_placement_groups: - azure.mgmt.compute.v2019_07_01.operations.ProximityPlacementGroupsOperations - :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations - :vartype dedicated_host_groups: - azure.mgmt.compute.v2019_07_01.operations.DedicatedHostGroupsOperations - :ivar dedicated_hosts: DedicatedHostsOperations operations - :vartype dedicated_hosts: azure.mgmt.compute.v2019_07_01.operations.DedicatedHostsOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2019_07_01.operations.VirtualMachineExtensionImagesOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2019_07_01.operations.VirtualMachineExtensionsOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2019_07_01.operations.VirtualMachineImagesOperations - :ivar usage: UsageOperations operations - :vartype usage: azure.mgmt.compute.v2019_07_01.operations.UsageOperations - :ivar virtual_machines: VirtualMachinesOperations operations - :vartype virtual_machines: azure.mgmt.compute.v2019_07_01.operations.VirtualMachinesOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2019_07_01.operations.VirtualMachineSizesOperations - :ivar images: ImagesOperations operations - :vartype images: azure.mgmt.compute.v2019_07_01.operations.ImagesOperations - :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations - :vartype virtual_machine_scale_sets: - azure.mgmt.compute.v2019_07_01.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations - operations - :vartype virtual_machine_scale_set_extensions: - azure.mgmt.compute.v2019_07_01.operations.VirtualMachineScaleSetExtensionsOperations - :ivar virtual_machine_scale_set_rolling_upgrades: - VirtualMachineScaleSetRollingUpgradesOperations operations - :vartype virtual_machine_scale_set_rolling_upgrades: - azure.mgmt.compute.v2019_07_01.operations.VirtualMachineScaleSetRollingUpgradesOperations - :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations - operations - :vartype virtual_machine_scale_set_vm_extensions: - azure.mgmt.compute.v2019_07_01.operations.VirtualMachineScaleSetVMExtensionsOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2019_07_01.operations.VirtualMachineScaleSetVMsOperations - :ivar log_analytics: LogAnalyticsOperations operations - :vartype log_analytics: azure.mgmt.compute.v2019_07_01.operations.LogAnalyticsOperations - :ivar disks: DisksOperations operations - :vartype disks: azure.mgmt.compute.v2019_07_01.operations.DisksOperations - :ivar snapshots: SnapshotsOperations operations - :vartype snapshots: azure.mgmt.compute.v2019_07_01.operations.SnapshotsOperations - :ivar disk_encryption_sets: DiskEncryptionSetsOperations operations - :vartype disk_encryption_sets: - azure.mgmt.compute.v2019_07_01.operations.DiskEncryptionSetsOperations - :ivar galleries: GalleriesOperations operations - :vartype galleries: azure.mgmt.compute.v2019_07_01.operations.GalleriesOperations - :ivar gallery_images: GalleryImagesOperations operations - :vartype gallery_images: azure.mgmt.compute.v2019_07_01.operations.GalleryImagesOperations - :ivar gallery_image_versions: GalleryImageVersionsOperations operations - :vartype gallery_image_versions: - azure.mgmt.compute.v2019_07_01.operations.GalleryImageVersionsOperations - :ivar gallery_applications: GalleryApplicationsOperations operations - :vartype gallery_applications: - azure.mgmt.compute.v2019_07_01.operations.GalleryApplicationsOperations - :ivar gallery_application_versions: GalleryApplicationVersionsOperations operations - :vartype gallery_application_versions: - azure.mgmt.compute.v2019_07_01.operations.GalleryApplicationVersionsOperations - :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations - :vartype virtual_machine_run_commands: - azure.mgmt.compute.v2019_07_01.operations.VirtualMachineRunCommandsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2019-07-01") - self.availability_sets = AvailabilitySetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.proximity_placement_groups = ProximityPlacementGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.dedicated_host_groups = DedicatedHostGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.dedicated_hosts = DedicatedHostsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.virtual_machine_images = VirtualMachineImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2019-07-01") - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2019-07-01") - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.log_analytics = LogAnalyticsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize, "2019-07-01") - self.snapshots = SnapshotsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.disk_encryption_sets = DiskEncryptionSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.galleries = GalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.gallery_images = GalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.gallery_image_versions = GalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.gallery_applications = GalleryApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.gallery_application_versions = GalleryApplicationVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_configuration.py deleted file mode 100644 index bfd6b1b88df0..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2019-07-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_metadata.json deleted file mode 100644 index 301841906a4f..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_metadata.json +++ /dev/null @@ -1,136 +0,0 @@ -{ - "chosen_version": "2019-07-01", - "total_api_version_list": ["2019-07-01"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "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.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "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.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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": { - "operations": "Operations", - "availability_sets": "AvailabilitySetsOperations", - "proximity_placement_groups": "ProximityPlacementGroupsOperations", - "dedicated_host_groups": "DedicatedHostGroupsOperations", - "dedicated_hosts": "DedicatedHostsOperations", - "virtual_machine_extension_images": "VirtualMachineExtensionImagesOperations", - "virtual_machine_extensions": "VirtualMachineExtensionsOperations", - "virtual_machine_images": "VirtualMachineImagesOperations", - "usage": "UsageOperations", - "virtual_machines": "VirtualMachinesOperations", - "virtual_machine_sizes": "VirtualMachineSizesOperations", - "images": "ImagesOperations", - "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", - "log_analytics": "LogAnalyticsOperations", - "disks": "DisksOperations", - "snapshots": "SnapshotsOperations", - "disk_encryption_sets": "DiskEncryptionSetsOperations", - "galleries": "GalleriesOperations", - "gallery_images": "GalleryImagesOperations", - "gallery_image_versions": "GalleryImageVersionsOperations", - "gallery_applications": "GalleryApplicationsOperations", - "gallery_application_versions": "GalleryApplicationVersionsOperations", - "virtual_machine_run_commands": "VirtualMachineRunCommandsOperations" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node
    is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj 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 deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2019_07_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/_compute_management_client.py deleted file mode 100644 index f65dcc063a9f..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/_compute_management_client.py +++ /dev/null @@ -1,294 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ( - AvailabilitySetsOperations, - DedicatedHostGroupsOperations, - DedicatedHostsOperations, - DiskEncryptionSetsOperations, - DisksOperations, - GalleriesOperations, - GalleryApplicationVersionsOperations, - GalleryApplicationsOperations, - GalleryImageVersionsOperations, - GalleryImagesOperations, - ImagesOperations, - LogAnalyticsOperations, - Operations, - ProximityPlacementGroupsOperations, - SnapshotsOperations, - UsageOperations, - VirtualMachineExtensionImagesOperations, - VirtualMachineExtensionsOperations, - VirtualMachineImagesOperations, - VirtualMachineRunCommandsOperations, - VirtualMachineScaleSetExtensionsOperations, - VirtualMachineScaleSetRollingUpgradesOperations, - VirtualMachineScaleSetVMExtensionsOperations, - VirtualMachineScaleSetVMsOperations, - VirtualMachineScaleSetsOperations, - VirtualMachineSizesOperations, - VirtualMachinesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.compute.v2019_07_01.aio.operations.Operations - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2019_07_01.aio.operations.AvailabilitySetsOperations - :ivar proximity_placement_groups: ProximityPlacementGroupsOperations operations - :vartype proximity_placement_groups: - azure.mgmt.compute.v2019_07_01.aio.operations.ProximityPlacementGroupsOperations - :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations - :vartype dedicated_host_groups: - azure.mgmt.compute.v2019_07_01.aio.operations.DedicatedHostGroupsOperations - :ivar dedicated_hosts: DedicatedHostsOperations operations - :vartype dedicated_hosts: - azure.mgmt.compute.v2019_07_01.aio.operations.DedicatedHostsOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2019_07_01.aio.operations.VirtualMachineExtensionImagesOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2019_07_01.aio.operations.VirtualMachineExtensionsOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2019_07_01.aio.operations.VirtualMachineImagesOperations - :ivar usage: UsageOperations operations - :vartype usage: azure.mgmt.compute.v2019_07_01.aio.operations.UsageOperations - :ivar virtual_machines: VirtualMachinesOperations operations - :vartype virtual_machines: - azure.mgmt.compute.v2019_07_01.aio.operations.VirtualMachinesOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2019_07_01.aio.operations.VirtualMachineSizesOperations - :ivar images: ImagesOperations operations - :vartype images: azure.mgmt.compute.v2019_07_01.aio.operations.ImagesOperations - :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations - :vartype virtual_machine_scale_sets: - azure.mgmt.compute.v2019_07_01.aio.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations - operations - :vartype virtual_machine_scale_set_extensions: - azure.mgmt.compute.v2019_07_01.aio.operations.VirtualMachineScaleSetExtensionsOperations - :ivar virtual_machine_scale_set_rolling_upgrades: - VirtualMachineScaleSetRollingUpgradesOperations operations - :vartype virtual_machine_scale_set_rolling_upgrades: - azure.mgmt.compute.v2019_07_01.aio.operations.VirtualMachineScaleSetRollingUpgradesOperations - :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations - operations - :vartype virtual_machine_scale_set_vm_extensions: - azure.mgmt.compute.v2019_07_01.aio.operations.VirtualMachineScaleSetVMExtensionsOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2019_07_01.aio.operations.VirtualMachineScaleSetVMsOperations - :ivar log_analytics: LogAnalyticsOperations operations - :vartype log_analytics: azure.mgmt.compute.v2019_07_01.aio.operations.LogAnalyticsOperations - :ivar disks: DisksOperations operations - :vartype disks: azure.mgmt.compute.v2019_07_01.aio.operations.DisksOperations - :ivar snapshots: SnapshotsOperations operations - :vartype snapshots: azure.mgmt.compute.v2019_07_01.aio.operations.SnapshotsOperations - :ivar disk_encryption_sets: DiskEncryptionSetsOperations operations - :vartype disk_encryption_sets: - azure.mgmt.compute.v2019_07_01.aio.operations.DiskEncryptionSetsOperations - :ivar galleries: GalleriesOperations operations - :vartype galleries: azure.mgmt.compute.v2019_07_01.aio.operations.GalleriesOperations - :ivar gallery_images: GalleryImagesOperations operations - :vartype gallery_images: azure.mgmt.compute.v2019_07_01.aio.operations.GalleryImagesOperations - :ivar gallery_image_versions: GalleryImageVersionsOperations operations - :vartype gallery_image_versions: - azure.mgmt.compute.v2019_07_01.aio.operations.GalleryImageVersionsOperations - :ivar gallery_applications: GalleryApplicationsOperations operations - :vartype gallery_applications: - azure.mgmt.compute.v2019_07_01.aio.operations.GalleryApplicationsOperations - :ivar gallery_application_versions: GalleryApplicationVersionsOperations operations - :vartype gallery_application_versions: - azure.mgmt.compute.v2019_07_01.aio.operations.GalleryApplicationVersionsOperations - :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations - :vartype virtual_machine_run_commands: - azure.mgmt.compute.v2019_07_01.aio.operations.VirtualMachineRunCommandsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2019-07-01") - self.availability_sets = AvailabilitySetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.proximity_placement_groups = ProximityPlacementGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.dedicated_host_groups = DedicatedHostGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.dedicated_hosts = DedicatedHostsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.virtual_machine_images = VirtualMachineImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2019-07-01") - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2019-07-01") - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.log_analytics = LogAnalyticsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize, "2019-07-01") - self.snapshots = SnapshotsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.disk_encryption_sets = DiskEncryptionSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.galleries = GalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.gallery_images = GalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.gallery_image_versions = GalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.gallery_applications = GalleryApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.gallery_application_versions = GalleryApplicationVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-07-01" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/_configuration.py deleted file mode 100644 index a6bfda1ba4dd..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2019-07-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/__init__.py deleted file mode 100644 index 8dd8f5ede493..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/__init__.py +++ /dev/null @@ -1,77 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import Operations # type: ignore -from ._operations import AvailabilitySetsOperations # type: ignore -from ._operations import ProximityPlacementGroupsOperations # type: ignore -from ._operations import DedicatedHostGroupsOperations # type: ignore -from ._operations import DedicatedHostsOperations # type: ignore -from ._operations import VirtualMachineExtensionImagesOperations # type: ignore -from ._operations import VirtualMachineExtensionsOperations # type: ignore -from ._operations import VirtualMachineImagesOperations # type: ignore -from ._operations import UsageOperations # type: ignore -from ._operations import VirtualMachinesOperations # type: ignore -from ._operations import VirtualMachineSizesOperations # type: ignore -from ._operations import ImagesOperations # 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 LogAnalyticsOperations # type: ignore -from ._operations import DisksOperations # type: ignore -from ._operations import SnapshotsOperations # type: ignore -from ._operations import DiskEncryptionSetsOperations # type: ignore -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 VirtualMachineRunCommandsOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AvailabilitySetsOperations", - "ProximityPlacementGroupsOperations", - "DedicatedHostGroupsOperations", - "DedicatedHostsOperations", - "VirtualMachineExtensionImagesOperations", - "VirtualMachineExtensionsOperations", - "VirtualMachineImagesOperations", - "UsageOperations", - "VirtualMachinesOperations", - "VirtualMachineSizesOperations", - "ImagesOperations", - "VirtualMachineScaleSetsOperations", - "VirtualMachineScaleSetExtensionsOperations", - "VirtualMachineScaleSetRollingUpgradesOperations", - "VirtualMachineScaleSetVMExtensionsOperations", - "VirtualMachineScaleSetVMsOperations", - "LogAnalyticsOperations", - "DisksOperations", - "SnapshotsOperations", - "DiskEncryptionSetsOperations", - "GalleriesOperations", - "GalleryImagesOperations", - "GalleryImageVersionsOperations", - "GalleryApplicationsOperations", - "GalleryApplicationVersionsOperations", - "VirtualMachineRunCommandsOperations", -] -__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/v2019_07_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_operations.py deleted file mode 100644 index 73983884d5a0..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_operations.py +++ /dev/null @@ -1,20863 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, Dict, IO, List, Literal, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import ( - build_availability_sets_create_or_update_request, - build_availability_sets_delete_request, - build_availability_sets_get_request, - build_availability_sets_list_available_sizes_request, - build_availability_sets_list_by_subscription_request, - build_availability_sets_list_request, - build_availability_sets_update_request, - build_dedicated_host_groups_create_or_update_request, - build_dedicated_host_groups_delete_request, - build_dedicated_host_groups_get_request, - build_dedicated_host_groups_list_by_resource_group_request, - build_dedicated_host_groups_list_by_subscription_request, - build_dedicated_host_groups_update_request, - build_dedicated_hosts_create_or_update_request, - build_dedicated_hosts_delete_request, - build_dedicated_hosts_get_request, - build_dedicated_hosts_list_by_host_group_request, - build_dedicated_hosts_update_request, - build_disk_encryption_sets_create_or_update_request, - build_disk_encryption_sets_delete_request, - build_disk_encryption_sets_get_request, - build_disk_encryption_sets_list_by_resource_group_request, - build_disk_encryption_sets_list_request, - build_disk_encryption_sets_update_request, - build_disks_create_or_update_request, - build_disks_delete_request, - build_disks_get_request, - build_disks_grant_access_request, - build_disks_list_by_resource_group_request, - build_disks_list_request, - build_disks_revoke_access_request, - build_disks_update_request, - build_galleries_create_or_update_request, - build_galleries_delete_request, - build_galleries_get_request, - build_galleries_list_by_resource_group_request, - build_galleries_list_request, - build_galleries_update_request, - build_gallery_application_versions_create_or_update_request, - build_gallery_application_versions_delete_request, - build_gallery_application_versions_get_request, - build_gallery_application_versions_list_by_gallery_application_request, - build_gallery_application_versions_update_request, - build_gallery_applications_create_or_update_request, - build_gallery_applications_delete_request, - build_gallery_applications_get_request, - build_gallery_applications_list_by_gallery_request, - build_gallery_applications_update_request, - build_gallery_image_versions_create_or_update_request, - build_gallery_image_versions_delete_request, - build_gallery_image_versions_get_request, - build_gallery_image_versions_list_by_gallery_image_request, - build_gallery_image_versions_update_request, - build_gallery_images_create_or_update_request, - build_gallery_images_delete_request, - build_gallery_images_get_request, - build_gallery_images_list_by_gallery_request, - build_gallery_images_update_request, - build_images_create_or_update_request, - build_images_delete_request, - build_images_get_request, - build_images_list_by_resource_group_request, - build_images_list_request, - build_images_update_request, - build_log_analytics_export_request_rate_by_interval_request, - build_log_analytics_export_throttled_requests_request, - build_operations_list_request, - build_proximity_placement_groups_create_or_update_request, - build_proximity_placement_groups_delete_request, - build_proximity_placement_groups_get_request, - build_proximity_placement_groups_list_by_resource_group_request, - build_proximity_placement_groups_list_by_subscription_request, - build_proximity_placement_groups_update_request, - build_snapshots_create_or_update_request, - build_snapshots_delete_request, - build_snapshots_get_request, - build_snapshots_grant_access_request, - build_snapshots_list_by_resource_group_request, - build_snapshots_list_request, - build_snapshots_revoke_access_request, - build_snapshots_update_request, - build_usage_list_request, - build_virtual_machine_extension_images_get_request, - build_virtual_machine_extension_images_list_types_request, - build_virtual_machine_extension_images_list_versions_request, - build_virtual_machine_extensions_create_or_update_request, - build_virtual_machine_extensions_delete_request, - build_virtual_machine_extensions_get_request, - build_virtual_machine_extensions_list_request, - build_virtual_machine_extensions_update_request, - build_virtual_machine_images_get_request, - build_virtual_machine_images_list_offers_request, - build_virtual_machine_images_list_publishers_request, - build_virtual_machine_images_list_request, - build_virtual_machine_images_list_skus_request, - build_virtual_machine_run_commands_get_request, - build_virtual_machine_run_commands_list_request, - build_virtual_machine_scale_set_extensions_create_or_update_request, - build_virtual_machine_scale_set_extensions_delete_request, - build_virtual_machine_scale_set_extensions_get_request, - build_virtual_machine_scale_set_extensions_list_request, - build_virtual_machine_scale_set_extensions_update_request, - build_virtual_machine_scale_set_rolling_upgrades_cancel_request, - build_virtual_machine_scale_set_rolling_upgrades_get_latest_request, - build_virtual_machine_scale_set_rolling_upgrades_start_extension_upgrade_request, - build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request, - build_virtual_machine_scale_set_vm_extensions_create_or_update_request, - build_virtual_machine_scale_set_vm_extensions_delete_request, - build_virtual_machine_scale_set_vm_extensions_get_request, - build_virtual_machine_scale_set_vm_extensions_list_request, - build_virtual_machine_scale_set_vm_extensions_update_request, - build_virtual_machine_scale_set_vms_deallocate_request, - build_virtual_machine_scale_set_vms_delete_request, - build_virtual_machine_scale_set_vms_get_instance_view_request, - build_virtual_machine_scale_set_vms_get_request, - build_virtual_machine_scale_set_vms_list_request, - build_virtual_machine_scale_set_vms_perform_maintenance_request, - build_virtual_machine_scale_set_vms_power_off_request, - build_virtual_machine_scale_set_vms_redeploy_request, - build_virtual_machine_scale_set_vms_reimage_all_request, - build_virtual_machine_scale_set_vms_reimage_request, - build_virtual_machine_scale_set_vms_restart_request, - build_virtual_machine_scale_set_vms_run_command_request, - build_virtual_machine_scale_set_vms_start_request, - build_virtual_machine_scale_set_vms_update_request, - build_virtual_machine_scale_sets_convert_to_single_placement_group_request, - build_virtual_machine_scale_sets_create_or_update_request, - build_virtual_machine_scale_sets_deallocate_request, - build_virtual_machine_scale_sets_delete_instances_request, - build_virtual_machine_scale_sets_delete_request, - build_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk_request, - build_virtual_machine_scale_sets_get_instance_view_request, - build_virtual_machine_scale_sets_get_os_upgrade_history_request, - build_virtual_machine_scale_sets_get_request, - build_virtual_machine_scale_sets_list_all_request, - build_virtual_machine_scale_sets_list_request, - build_virtual_machine_scale_sets_list_skus_request, - build_virtual_machine_scale_sets_perform_maintenance_request, - build_virtual_machine_scale_sets_power_off_request, - build_virtual_machine_scale_sets_redeploy_request, - build_virtual_machine_scale_sets_reimage_all_request, - build_virtual_machine_scale_sets_reimage_request, - build_virtual_machine_scale_sets_restart_request, - build_virtual_machine_scale_sets_start_request, - build_virtual_machine_scale_sets_update_instances_request, - build_virtual_machine_scale_sets_update_request, - build_virtual_machine_sizes_list_request, - build_virtual_machines_capture_request, - build_virtual_machines_convert_to_managed_disks_request, - build_virtual_machines_create_or_update_request, - build_virtual_machines_deallocate_request, - build_virtual_machines_delete_request, - build_virtual_machines_generalize_request, - build_virtual_machines_get_request, - build_virtual_machines_instance_view_request, - build_virtual_machines_list_all_request, - build_virtual_machines_list_available_sizes_request, - build_virtual_machines_list_by_location_request, - build_virtual_machines_list_request, - build_virtual_machines_perform_maintenance_request, - build_virtual_machines_power_off_request, - build_virtual_machines_reapply_request, - build_virtual_machines_redeploy_request, - build_virtual_machines_reimage_request, - build_virtual_machines_restart_request, - build_virtual_machines_run_command_request, - build_virtual_machines_start_request, - build_virtual_machines_update_request, -) -from .._configuration import ComputeManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.ComputeOperationValue"]: - """Gets a list of compute operations. - - :return: An iterator like instance of either ComputeOperationValue or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.ComputeOperationValue] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[_models.ComputeOperationListResult] = 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_operations_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async 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, 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 AvailabilitySetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`availability_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_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: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySet, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Is either a - AvailabilitySet type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySet") - - _request = build_availability_sets_create_or_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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, - availability_set_name: str, - parameters: _models.AvailabilitySetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_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: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Is either a - AvailabilitySetUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.AvailabilitySetUpdate or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySetUpdate") - - _request = build_availability_sets_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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: - """ - 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 "2019-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 = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get(self, resource_group_name: str, availability_set_name: str, **kwargs: Any) -> _models.AvailabilitySet: - """Retrieves information about an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", 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) - - _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("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription( - self, *, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. - - :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.v2019_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 "2019-07-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, 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(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets 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 AvailabilitySet or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_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 "2019-07-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, 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_available_sizes( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes that can be used to create a new virtual machine in - an existing availability set. - - :param resource_group_name: The name of the resource group. Required. - :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.v2019_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 "2019-07-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_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 - - if response.status_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 ProximityPlacementGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`proximity_placement_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - 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. 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.v2019_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.v2019_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. 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.v2019_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - 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 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. Is - either a ProximityPlacementGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroup or IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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. 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.v2019_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.v2019_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. 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.v2019_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - 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 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. Is - either a ProximityPlacementGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroupUpdate or - IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ProximityPlacementGroupUpdate") - - _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, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete(self, resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any) -> None: - """Delete a proximity placement group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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 "2019-07-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _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, - 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_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. 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.v2019_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - _request = build_proximity_placement_groups_get_request( - resource_group_name=resource_group_name, - proximity_placement_group_name=proximity_placement_group_name, - subscription_id=self._config.subscription_id, - include_colocation_status=include_colocation_status, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a subscription. - - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_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 "2019-07-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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 - ) -> AsyncItemPaged["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a resource group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_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 "2019-07-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) - - -class DedicatedHostGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`dedicated_host_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - host_group_name: str, - parameters: _models.DedicatedHostGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: ~azure.mgmt.compute.v2019_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: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroup, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Is either a - DedicatedHostGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroup or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-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, "DedicatedHostGroup") - - _request = build_dedicated_host_groups_create_or_update_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DedicatedHostGroup", 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, - host_group_name: str, - parameters: _models.DedicatedHostGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_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: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :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: IO[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.v2019_07_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroupUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Is either - a DedicatedHostGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroupUpdate or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-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") - - _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) - - _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("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: - """ - 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 "2019-07-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_dedicated_host_groups_delete_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get(self, resource_group_name: str, host_group_name: str, **kwargs: Any) -> _models.DedicatedHostGroup: - """Retrieves information about a dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-07-01")) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", 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, - 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("DedicatedHostGroup", 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 - ) -> AsyncItemPaged["_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. - :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.v2019_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 "2019-07-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 - def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_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.v2019_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 "2019-07-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_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 - - if response.status_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 DedicatedHostsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`dedicated_hosts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, 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 "2019-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, "DedicatedHost") - - _request = build_dedicated_hosts_create_or_update_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, - 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) - - 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, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHost, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHost - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. 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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. Is either a DedicatedHost - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHost or IO[bytes] - :return: An instance of AsyncLROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.DedicatedHost] - :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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, 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 "2019-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, "DedicatedHostUpdate") - - _request = build_dedicated_hosts_update_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, - 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, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHostUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostUpdate - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host 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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Is either a - DedicatedHostUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.DedicatedHost] - :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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_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 "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_delete_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 [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, host_group_name: str, host_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete 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 - :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 "2019-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, - 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_async - async def get( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: DedicatedHost or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-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 - - return deserialized # type: ignore - - @distributed_trace - def list_by_host_group( - self, resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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. - :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.v2019_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 "2019-07-01")) - cls: ClsType[_models.DedicatedHostListResult] = 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_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, - 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("DedicatedHostListResult", 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 VirtualMachineExtensionImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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. - - :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.v2019_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 "2019-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 = 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 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 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.v2019_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 "2019-07-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - - _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) - - _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 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 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.v2019_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 "2019-07-01")) - 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 = 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 - - -class VirtualMachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, 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 "2019-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, "VirtualMachineExtension") - - _request = build_virtual_machine_extensions_create_or_update_request( - resource_group_name=resource_group_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, - 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) - - 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, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2019_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 VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_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 create or 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 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] - :keyword content_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.v2019_07_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2019_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.v2019_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2019-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( - resource_group_name=resource_group_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, - 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, - 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. - - :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: - ~azure.mgmt.compute.v2019_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.v2019_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.v2019_07_01.models.VirtualMachineExtension] - :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.v2019_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.v2019_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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) - - _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, vm_name: str, vm_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_name: The name of the virtual machine where the extension should be deleted. - 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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, - vm_extension_name=vm_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - 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.v2019_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 "2019-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 = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list( - self, resource_group_name: str, vm_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.VirtualMachineExtensionsListResult: - """The operation to get all extensions of a Virtual Machine. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine containing the extension. Required. - :type vm_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineExtensionsListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionsListResult - :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 "2019-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 VirtualMachineImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.v2019_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 "2019-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.v2019_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 "2019-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.v2019_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 "2019-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. - - :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.v2019_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 "2019-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) - 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. - - :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.v2019_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 "2019-07-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _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) - - _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 - - -class UsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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 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.v2019_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 "2019-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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ListUsagesResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class 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.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.VirtualMachine"]: - """Gets all the virtual machines under the specified subscription for the specified location. - - :param location: The location for which virtual machines under the subscription are queried. - Required. - :type location: str - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_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 "2019-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 - - 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) - - 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 _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, - 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 "2019-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, "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 = 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_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. 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.v2019_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.v2019_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. 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.v2019_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. 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.v2019_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.v2019_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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 - ) - 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) - 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.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 _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, 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 "2019-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, - 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) - - 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, - vm_name: str, - parameters: _models.VirtualMachine, - *, - 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. 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.v2019_07_01.models.VirtualMachine - :keyword content_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.v2019_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], - *, - 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. 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 content_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.v2019_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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :param resource_group_name: The name of the resource group. Required. - :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.v2019_07_01.models.VirtualMachine or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_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 "2019-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, - 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, **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]], - **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 "2019-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, - 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) - - 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, - vm_name: str, - parameters: _models.VirtualMachineUpdate, - *, - 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. 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.v2019_07_01.models.VirtualMachineUpdate - :keyword content_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.v2019_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], - *, - 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. 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 content_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.v2019_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]], - **kwargs: Any - ) -> AsyncLROPoller[_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.v2019_07_01.models.VirtualMachineUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_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 "2019-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, - 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, **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, **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 "2019-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, - 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, vm_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """The operation to delete 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 "2019-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, - 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_name: str, *, expand: Literal["instanceView"] = "instanceView", **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-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 - - @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. 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.v2019_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 "2019-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 - - 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, - 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 "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_convert_to_managed_disks_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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. :code:`
    `For Windows, please refer to - `Convert a virtual machine from unmanaged disks to managed disks. - `_.\\ - :code:`
    `For Linux, please refer to `Convert a virtual machine from unmanaged disks to - managed disks. - `_. - - :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 "2019-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, **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 "2019-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, - 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, **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 - :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 "2019-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, - 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. :code:`
    `For Windows, please refer to - `Create a managed image of a generalized VM in Azure - `_.\\ - :code:`
    `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 "2019-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, **kwargs: Any) -> AsyncItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_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 "2019-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, - 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("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) - - 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, *, status_only: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_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 "2019-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, - 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("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) - - 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_available_sizes( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes to which the specified virtual machine can be - resized. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_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 "2019-07-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_available_sizes_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 - - if response.status_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_name: 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 "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_power_off_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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_name: str, *, skip_shutdown: bool = False, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with - the same provisioned resources. You are still charged for this virtual machine. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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_name=vm_name, - skip_shutdown=skip_shutdown, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reapply_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - 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 "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_reapply_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - 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_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. - :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 "2019-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_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 _restart_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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_restart_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - 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_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. - :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 "2019-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._restart_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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_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 "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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_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 "2019-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]: - 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 "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_redeploy_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_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. - :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 "2019-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_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 _reimage_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-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( - 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) - - 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 the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: ~azure.mgmt.compute.v2019_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 the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. 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.v2019_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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **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 _perform_maintenance_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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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_perform_maintenance( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Shuts down the virtual machine, moves it to an already updated node, and powers it back on - during the self-service phase of planned maintenance. - - :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 "2019-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_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 _run_command_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, 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 "2019-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, "RunCommandInput") - - _request = build_virtual_machines_run_command_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) - - 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_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_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 RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_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.v2019_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._run_command_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineSizesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """This API is deprecated. Use `Resources Skus - `_. - - :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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_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 "2019-07-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_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 - - 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 - - if response.status_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 ImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> 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 "2019-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) - - 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, - image_name: str, - parameters: _models.Image, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Create or update an image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param 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.v2019_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Create or update an image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param 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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Image] - :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. - - :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 - :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.v2019_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.v2019_07_01.models.Image] - :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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._create_or_update_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Image]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, 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 "2019-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, "ImageUpdate") - - _request = build_images_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) - - 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, - image_name: str, - parameters: _models.ImageUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Update 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 - :param parameters: Parameters supplied to the Update Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Update 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 - :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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Update 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 - :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.v2019_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.v2019_07_01.models.Image] - :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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Image]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial(self, resource_group_name: str, image_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_images_delete_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, image_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes 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 - :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 "2019-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, - image_name=image_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - 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.v2019_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 "2019-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 = 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("Image", 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) -> AsyncItemPaged["_models.Image"]: - """Gets the list of images 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 Image or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_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 "2019-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 - - 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) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2019_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 "2019-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_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) - - -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.v2019_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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - parameters: Union[_models.VirtualMachineScaleSet, 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 "2019-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, - 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) - - 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, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. 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.v2019_07_01.models.VirtualMachineScaleSet - :keyword content_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.v2019_07_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. 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: IO[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 VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 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.v2019_07_01.models.VirtualMachineScaleSet or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_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 "2019-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, - 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]], - **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 "2019-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, "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, - 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, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSetUpdate, - *, - 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. 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.v2019_07_01.models.VirtualMachineScaleSetUpdate - :keyword content_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.v2019_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], - *, - 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. 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: IO[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 VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Update 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 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.v2019_07_01.models.VirtualMachineScaleSetUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_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 "2019-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, - 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 _delete_initial( - self, resource_group_name: str, vm_scale_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 "2019-07-01")) - cls: ClsType[AsyncIterator[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, - 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, vm_scale_set_name: str, **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 - :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 "2019-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, - 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, **kwargs: Any - ) -> _models.VirtualMachineScaleSet: - """Display information about a 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 - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-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, - 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 _deallocate_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 "2019-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_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_deallocate( - 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]: - """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. - :type 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.v2019_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_deallocate( - 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]: - """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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_deallocate( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and - releases the compute resources. You are not billed for the compute resources that this virtual - machine scale set deallocates. - - :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.v2019_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 "2019-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, - 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 _delete_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-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: - _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, - 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_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """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. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2019_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 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], - *, - 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. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **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.v2019_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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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, - 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.v2019_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 "2019-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) -> AsyncItemPaged["_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 - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_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 "2019-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_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("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 - def list_all(self, **kwargs: Any) -> AsyncItemPaged["_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.v2019_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 "2019-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = 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_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("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) - - 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_skus( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineScaleSetSku"]: - """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM - instances allowed for each SKU. - - :param resource_group_name: The name of the resource group. Required. - :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.v2019_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 "2019-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 - - 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) - - @distributed_trace - def get_os_upgrade_history( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.UpgradeOperationHistoricalStatusInfo"]: - """Gets list of OS upgrades 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 - :return: An iterator like instance of either UpgradeOperationHistoricalStatusInfo or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_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 "2019-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 _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]: - 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 "2019-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_power_off_request( - resource_group_name=resource_group_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, - 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_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - 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. - - :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.v2019_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 - :keyword content_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_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - 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. - - :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 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 - :keyword content_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_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: bool = False, - **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. - - :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.v2019_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] - :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 "2019-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 "2019-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_restart_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2019_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_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :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.v2019_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 "2019-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, - 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 "2019-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 - 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_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. Required. - :type 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.v2019_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. Required. - :type 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.v2019_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 "2019-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 _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, - 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 "2019-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_redeploy_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_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. - - :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.v2019_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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_redeploy( - self, - resource_group_name: str, - vm_scale_set_name: str, - 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. Required. - :type 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.v2019_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 "2019-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) - - 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 _perform_maintenance_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_perform_maintenance( - 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]: - """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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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.v2019_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_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 - ) -> 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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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_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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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.v2019_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 "2019-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._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-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: - _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, - 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_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :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.v2019_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 None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2019_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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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._update_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reimage_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which - don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual - machine is reset to initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2019_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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Is either a - VirtualMachineScaleSetReimageParameters type or a IO[bytes] type. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2019_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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_scale_set_reimage_input=vm_scale_set_reimage_input, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reimage_all_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2019_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_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2019_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 "2019-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) - - 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, **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 - :return: RecoveryWalkResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RecoveryWalkResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 true 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.v2019_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 true 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 true 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. Is either a - VMScaleSetConvertToSinglePlacementGroupInput type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.compute.v2019_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 "2019-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 - - -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.v2019_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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2019-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") - - _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, - 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) - - 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, - 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. - - :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.v2019_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.v2019_07_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2019_07_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtension, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to create or update an extension. - - :param resource_group_name: The name of the resource group. Required. - :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.v2019_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.v2019_07_01.models.VirtualMachineScaleSetExtension] - :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 "2019-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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _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]: - 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 "2019-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") - - _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, - 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) - - 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, - 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.v2019_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.v2019_07_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :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.v2019_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.v2019_07_01.models.VirtualMachineScaleSetExtension] - :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 "2019-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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-07-01")) - cls: ClsType[AsyncIterator[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, - 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, 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 "2019-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.v2019_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 "2019-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 - ) -> AsyncItemPaged["_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.v2019_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 "2019-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. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> 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 "2019-07-01")) - 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, - 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 - - @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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _start_os_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-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, - 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) - - _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_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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _start_extension_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - 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 - - @distributed_trace_async - async def begin_start_extension_upgrade( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Starts a rolling upgrade to move all extensions for all virtual machine scale set instances to - the latest available extension version. Instances which are already running the latest - extension versions are not affected. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get_latest( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> _models.RollingUpgradeStatusInfo: - """Gets the status of the latest virtual machine scale set rolling upgrade. - - :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.v2019_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 "2019-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 = 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("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.v2019_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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.VirtualMachineExtension, 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 "2019-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, "VirtualMachineExtension") - - _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) - - _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) - - 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, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """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.v2019_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 VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] - :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.VirtualMachineExtension]: - """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 VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] - :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.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """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 VirtualMachineExtension type or a IO[bytes] type. Required. - :type extension_parameters: ~azure.mgmt.compute.v2019_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.v2019_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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, - 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("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)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_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.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, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, 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 "2019-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_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, - 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, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """The operation to 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 Update Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2019_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.v2019_07_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """The operation to 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 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.v2019_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, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """The operation to 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 Update Virtual Machine Extension - operation. Is either a VirtualMachineExtensionUpdate type or a IO[bytes] type. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2019_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.v2019_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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, - 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("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)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_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.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, vm_extension_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 "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_extensions_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - 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, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to delete the VMSS VM extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineExtension: - """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: VirtualMachineExtension or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-07-01")) - cls: ClsType[_models.VirtualMachineExtension] = 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 = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineExtensionsListResult: - """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: VirtualMachineExtensionsListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionsListResult - :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 "2019-07-01")) - cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_extensions_list_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_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 VirtualMachineScaleSetVMsOperations: # 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.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _reimage_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[ - Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] - ] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - 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 "2019-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( - 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 - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - 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.v2019_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 - ) -> 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. - Is either a VirtualMachineScaleSetVMReimageParameters type or a IO[bytes] type. Default value - is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2019_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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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( - 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, **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, - 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 "2019-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) - - 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_reimage_all( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. - This operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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 - - async def _deallocate_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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. - - :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 "2019-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 - - async def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, 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 "2019-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, "VirtualMachineScaleSetVM") - - _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, - 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( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.VirtualMachineScaleSetVM, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVM - :keyword content_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) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - 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 VirtualMachineScaleSetVM or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVM] - :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, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. - Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVM or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVM or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVM] - :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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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, - 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("VirtualMachineScaleSetVM", 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.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 - ) - - async def _delete_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 "2019-07-01")) - 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, - 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, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes 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: 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 "2019-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, - 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 get( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-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 = 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("VirtualMachineScaleSetVM", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_instance_view( - self, resource_group_name: str, vm_scale_set_name: str, 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.v2019_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 "2019-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 - ) -> AsyncItemPaged["_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.v2019_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 "2019-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 "2019-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. - - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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) - - 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, 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 "2019-07-01")) - cls: ClsType[AsyncIterator[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 = 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_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. - :type 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 "2019-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._restart_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _start_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 "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_start_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - 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 - :param vm_scale_set_name: The name of the VM 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 "2019-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_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _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, - 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 "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_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, - 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_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. - :type 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 "2019-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) - - 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 _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 "2019-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) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_perform_maintenance( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Shuts down the virtual machine in a VMScaleSet, moves it to an already updated node, and powers - it back on during the self-service phase of planned maintenance. - - :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 "2019-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 - - async def _run_command_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, 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 "2019-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, "RunCommandInput") - - _request = build_virtual_machine_scale_set_vms_run_command_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 - 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_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - :type 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.v2019_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 RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> 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. - :type 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.v2019_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.v2019_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._run_command_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class LogAnalyticsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`log_analytics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _export_request_rate_by_interval_initial( - self, location: str, parameters: Union[_models.RequestRateByIntervalInput, 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 "2019-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, "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, - ) - _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_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 location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. - Required. - :type parameters: ~azure.mgmt.compute.v2019_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.v2019_07_01.models.LogAnalyticsOperationResult] - :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. - - :param location: The location upon which virtual-machine-sizes is queried. 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.v2019_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 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.v2019_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.v2019_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 "2019-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._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, - **kwargs - ) - 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) - 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LogAnalyticsOperationResult]( - 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 - ) -> 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 "2019-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, - 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_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.v2019_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.v2019_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.v2019_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. - - :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.v2019_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.v2019_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 "2019-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._export_throttled_requests_initial( - location=location, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - 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) - 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LogAnalyticsOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class DisksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`disks` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_name: str, disk: Union[_models.Disk, 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 "2019-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(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_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) - - _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_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. 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.v2019_07_01.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.v2019_07_01.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. 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.v2019_07_01.models.Disk] - :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. - - :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 - :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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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._create_or_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 - ) - await 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: 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.Disk].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Disk]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _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, - 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 "2019-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(disk, (IOBase, bytes)): - _content = disk - else: - _json = self._serialize.body(disk, "DiskUpdate") - - _request = build_disks_update_request( - resource_group_name=resource_group_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) - - _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( - self, - resource_group_name: str, - disk_name: str, - disk: _models.DiskUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Updates (patches) a disk. - - :param resource_group_name: The name of the resource group. 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.v2019_07_01.models.DiskUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Disk] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - disk_name: str, - disk: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Updates (patches) a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Patch disk operation. Required. - :type disk: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Disk] - :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. - - :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 - :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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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._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 - ) - await 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: 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.Disk].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Disk]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) - - _request = build_disks_get_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) - - _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("Disk", 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_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 "2019-07-01")) - 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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, - 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, **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) -> AsyncItemPaged["_models.Disk"]: - """Lists all the disks 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 Disk or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - 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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disks_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _grant_access_initial( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, 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 "2019-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disks_grant_access_request( - resource_group_name=resource_group_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) - - _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_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2019_07_01.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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param grant_access_data: Access data object supplied in the body of the get disk access - operation. Required. - :type grant_access_data: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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, - disk_name=disk_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, 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 "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disks_revoke_access_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]: - 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_revoke_access( - self, resource_group_name: str, disk_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Revokes access to 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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._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) - - 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 SnapshotsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`snapshots` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, snapshot_name: str, snapshot: Union[_models.Snapshot, 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 "2019-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(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "Snapshot") - - _request = build_snapshots_create_or_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.Snapshot, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: ~azure.mgmt.compute.v2019_07_01.models.Snapshot - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :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.v2019_07_01.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.v2019_07_01.models.Snapshot] - :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 "2019-07-01")) - 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._create_or_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, **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 _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, - 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 "2019-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(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "SnapshotUpdate") - - _request = build_snapshots_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.SnapshotUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. 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.v2019_07_01.models.SnapshotUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. - Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. Is - either a SnapshotUpdate type or a IO[bytes] type. Required. - :type snapshot: ~azure.mgmt.compute.v2019_07_01.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.v2019_07_01.models.Snapshot] - :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 "2019-07-01")) - 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, **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 - ) - - @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.v2019_07_01.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 "2019-07-01")) - 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( - 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 "2019-07-01")) - 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) - - 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, snapshot_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes 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: 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 "2019-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, - snapshot_name=snapshot_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) -> AsyncItemPaged["_models.Snapshot"]: - """Lists snapshots 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 Snapshot or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - 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(self, **kwargs: Any) -> AsyncItemPaged["_models.Snapshot"]: - """Lists snapshots under a subscription. - - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _grant_access_initial( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, 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 "2019-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_snapshots_grant_access_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param grant_access_data: Access data object supplied in the body of the get snapshot access - operation. Required. - :type grant_access_data: ~azure.mgmt.compute.v2019_07_01.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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param 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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param 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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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, - snapshot_name=snapshot_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, 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 "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_snapshots_revoke_access_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]: - 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_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. - :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 "2019-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._revoke_access_initial( - resource_group_name=resource_group_name, - snapshot_name=snapshot_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 DiskEncryptionSetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`disk_encryption_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set - else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") - - _request = build_disk_encryption_sets_create_or_update_request( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = 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, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9 and _. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9 and _. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9 and _. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Is either a DiskEncryptionSet type or a IO[bytes] type. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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._create_or_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, **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 _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, - 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 "2019-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(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_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, - 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. - :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.v2019_07_01.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.v2019_07_01.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. 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.v2019_07_01.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. 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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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, **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 - ) - - @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.v2019_07_01.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 "2019-07-01")) - 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 - ) -> 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 "2019-07-01")) - 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) - - 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_encryption_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[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 - :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 "2019-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, - 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 - ) -> AsyncItemPaged["_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.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class GalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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: Union[_models.Gallery, 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 "2019-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(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 = 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: _models.Gallery, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - Required. - :type gallery_name: str - :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. - Required. - :type gallery: ~azure.mgmt.compute.v2019_07_01.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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - 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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, gallery_name: str, gallery: Union[_models.Gallery, IO[bytes]], **kwargs: Any - ) -> 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. - 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.v2019_07_01.models.Gallery or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Gallery] = 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=gallery, - 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("Gallery", 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.Gallery].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Gallery]( - 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: Union[_models.GalleryUpdate, 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 "2019-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(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) - - _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: _models.GalleryUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - Required. - :type gallery_name: str - :param gallery: Parameters supplied to the update Shared Image Gallery operation. Required. - :type gallery: ~azure.mgmt.compute.v2019_07_01.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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - 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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: Union[_models.GalleryUpdate, IO[bytes]], - **kwargs: Any - ) -> 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. - 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.v2019_07_01.models.GalleryUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Gallery] = 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=gallery, - 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("Gallery", 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.Gallery].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Gallery]( - 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, **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 - :return: Gallery or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - 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, - 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, - 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 "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_galleries_delete_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) - - _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, gallery_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Delete 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 to be deleted. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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, - gallery_name=gallery_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) -> AsyncItemPaged["_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.v2019_07_01.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 "2019-07-01")) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2019_07_01.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 "2019-07-01")) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class GalleryImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 "2019-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(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.v2019_07_01.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.v2019_07_01.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.v2019_07_01.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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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 "2019-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(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.v2019_07_01.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.v2019_07_01.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.v2019_07_01.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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.GalleryImage] = kwargs.pop("cls", None) - - _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 = 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("GalleryImage", 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]: - 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 "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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) - - _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, 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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, - 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, **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_gallery( - self, resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.GalleryImageList] = 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_images_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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryImageList", 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 GalleryImageVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 "2019-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(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.v2019_07_01.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.v2019_07_01.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.v2019_07_01.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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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]: - 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 "2019-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(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) - - _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_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.v2019_07_01.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.v2019_07_01.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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 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.v2019_07_01.models.GalleryImageVersion] - :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_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. 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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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) - - 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 - ) - - @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. - - :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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2019_07_01.models.ReplicationStatusTypes - :return: GalleryImageVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - 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) - 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 - - 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, - 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 "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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, - 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) - - 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_gallery_image( - self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.GalleryImageVersion"]: - """List gallery Image Versions in 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 - resides. 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) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.GalleryImageVersionList] = 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_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, - 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("GalleryImageVersionList", 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 GalleryApplicationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`gallery_applications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application: Union[_models.GalleryApplication, 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 "2019-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(gallery_application, (IOBase, bytes)): - _content = gallery_application - else: - _json = self._serialize.body(gallery_application, "GalleryApplication") - - _request = build_gallery_applications_create_or_update_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, - 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_application_name: str, - gallery_application: _models.GalleryApplication, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2019_07_01.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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the create or 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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplication, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2019_07_01.models.GalleryApplication or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryApplication] = 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_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 - ) - await 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: 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.GalleryApplication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GalleryApplication]( - 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_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, 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 "2019-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(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_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, - ) - _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_application_name: str, - gallery_application: _models.GalleryApplicationUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the update gallery Application operation. - Required. - :type gallery_application: ~azure.mgmt.compute.v2019_07_01.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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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 - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :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.v2019_07_01.models.GalleryApplicationUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryApplication] = 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=gallery_application, - 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("GalleryApplication", 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.GalleryApplication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GalleryApplication]( - 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.v2019_07_01.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 "2019-07-01")) - 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]: - 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 "2019-07-01")) - cls: ClsType[AsyncIterator[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 = 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, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete a gallery Application. - - :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 is to be deleted. Required. - :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be deleted. - 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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, - 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 - ) - 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_gallery( - self, resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.GalleryApplication"]: - """List gallery Application 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 Application Gallery from which Application - Definitions are to be listed. Required. - :type gallery_name: str - :return: An iterator like instance of either GalleryApplication or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.GalleryApplicationList] = 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_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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryApplicationList", 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 GalleryApplicationVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`gallery_application_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: Union[_models.GalleryApplicationVersion, 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 "2019-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(gallery_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersion") - - _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, - 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersion, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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.v2019_07_01.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 AsyncLROPoller that returns either GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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] - :keyword content_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 GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async 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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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.v2019_07_01.models.GalleryApplicationVersion 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.v2019_07_01.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 "2019-07-01")) - 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._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, - 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 - ) - - async 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]], - **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 "2019-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(gallery_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersionUpdate") - - _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, - 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2019_07_01.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 AsyncLROPoller that returns either GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Update 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 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] - :keyword content_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 GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async 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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2019_07_01.models.ReplicationStatusTypes - :return: GalleryApplicationVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - 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) - - deserialized = self._deserialize("GalleryApplicationVersion", 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, - gallery_application_version_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 "2019-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete 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 - deleted. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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, - 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, - 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_gallery_application( - self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - 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 - - async 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, 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 VirtualMachineRunCommandsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.RunCommandDocumentBase"]: - """Lists all available run commands for a subscription in a location. - - :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 - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_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 "2019-07-01")) - cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_run_commands_list_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RunCommandListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, location: str, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: - """Gets specific run command for a subscription in a location. - - :param location: The 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.v2019_07_01.models.RunCommandDocument - :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 "2019-07-01")) - cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) - - _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, - 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("RunCommandDocument", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/__init__.py deleted file mode 100644 index 58007a409a76..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/__init__.py +++ /dev/null @@ -1,576 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - AccessUri, - AdditionalCapabilities, - AdditionalUnattendContent, - ApiEntityReference, - ApiError, - ApiErrorBase, - AutomaticOSUpgradePolicy, - AutomaticOSUpgradeProperties, - AutomaticRepairsPolicy, - AvailabilitySet, - AvailabilitySetListResult, - AvailabilitySetUpdate, - BillingProfile, - BootDiagnostics, - BootDiagnosticsInstanceView, - ComputeOperationListResult, - ComputeOperationValue, - CreationData, - DataDisk, - DataDiskImage, - DedicatedHost, - DedicatedHostAllocatableVM, - DedicatedHostAvailableCapacity, - DedicatedHostGroup, - DedicatedHostGroupListResult, - DedicatedHostGroupUpdate, - DedicatedHostInstanceView, - DedicatedHostListResult, - DedicatedHostUpdate, - DiagnosticsProfile, - DiffDiskSettings, - Disallowed, - Disk, - DiskEncryptionSet, - DiskEncryptionSetList, - DiskEncryptionSetParameters, - DiskEncryptionSetUpdate, - DiskEncryptionSettings, - DiskInstanceView, - DiskList, - DiskSku, - DiskUpdate, - Encryption, - EncryptionSetIdentity, - EncryptionSettingsCollection, - EncryptionSettingsElement, - Gallery, - GalleryApplication, - GalleryApplicationList, - GalleryApplicationUpdate, - GalleryApplicationVersion, - GalleryApplicationVersionList, - GalleryApplicationVersionPublishingProfile, - GalleryApplicationVersionUpdate, - GalleryArtifactPublishingProfileBase, - GalleryArtifactSource, - GalleryArtifactVersionSource, - GalleryDataDiskImage, - GalleryDiskImage, - GalleryIdentifier, - GalleryImage, - GalleryImageIdentifier, - GalleryImageList, - GalleryImageUpdate, - GalleryImageVersion, - GalleryImageVersionList, - GalleryImageVersionPublishingProfile, - GalleryImageVersionStorageProfile, - GalleryImageVersionUpdate, - GalleryList, - GalleryOSDiskImage, - GalleryUpdate, - GrantAccessData, - HardwareProfile, - Image, - ImageDataDisk, - ImageDisk, - ImageDiskReference, - ImageListResult, - ImageOSDisk, - ImagePurchasePlan, - ImageReference, - ImageStorageProfile, - ImageUpdate, - InnerError, - InstanceViewStatus, - KeyVaultAndKeyReference, - KeyVaultAndSecretReference, - KeyVaultKeyReference, - KeyVaultSecretReference, - LinuxConfiguration, - ListUsagesResult, - LogAnalyticsInputBase, - LogAnalyticsOperationResult, - LogAnalyticsOutput, - MaintenanceRedeployStatus, - ManagedArtifact, - ManagedDiskParameters, - NetworkInterfaceReference, - NetworkProfile, - OSDisk, - OSDiskImage, - OSProfile, - Plan, - ProximityPlacementGroup, - ProximityPlacementGroupListResult, - ProximityPlacementGroupUpdate, - PurchasePlan, - RecommendedMachineConfiguration, - RecoveryWalkResponse, - RegionalReplicationStatus, - ReplicationStatus, - RequestRateByIntervalInput, - Resource, - ResourceRange, - RollbackStatusInfo, - RollingUpgradePolicy, - RollingUpgradeProgressInfo, - RollingUpgradeRunningStatus, - RollingUpgradeStatusInfo, - RunCommandDocument, - RunCommandDocumentBase, - RunCommandInput, - RunCommandInputParameter, - RunCommandListResult, - RunCommandParameterDefinition, - RunCommandResult, - ScaleInPolicy, - ScheduledEventsProfile, - Sku, - Snapshot, - SnapshotList, - SnapshotSku, - SnapshotUpdate, - SourceVault, - SshConfiguration, - SshPublicKey, - StorageProfile, - SubResource, - SubResourceReadOnly, - SubResourceWithColocationStatus, - TargetRegion, - TerminateNotificationProfile, - ThrottledRequestsInput, - UpdateResource, - UpgradeOperationHistoricalStatusInfo, - UpgradeOperationHistoricalStatusInfoProperties, - UpgradeOperationHistoryStatus, - UpgradePolicy, - Usage, - UsageName, - UserArtifactManage, - UserArtifactSource, - UserAssignedIdentitiesValue, - VMScaleSetConvertToSinglePlacementGroupInput, - VaultCertificate, - VaultSecretGroup, - VirtualHardDisk, - VirtualMachine, - VirtualMachineAgentInstanceView, - VirtualMachineCaptureParameters, - VirtualMachineCaptureResult, - VirtualMachineExtension, - VirtualMachineExtensionHandlerInstanceView, - VirtualMachineExtensionImage, - VirtualMachineExtensionInstanceView, - VirtualMachineExtensionUpdate, - VirtualMachineExtensionsListResult, - VirtualMachineHealthStatus, - VirtualMachineIdentity, - VirtualMachineImage, - VirtualMachineImageResource, - VirtualMachineInstanceView, - VirtualMachineListResult, - VirtualMachineReimageParameters, - VirtualMachineScaleSet, - VirtualMachineScaleSetDataDisk, - VirtualMachineScaleSetExtension, - VirtualMachineScaleSetExtensionListResult, - VirtualMachineScaleSetExtensionProfile, - VirtualMachineScaleSetExtensionUpdate, - VirtualMachineScaleSetIPConfiguration, - VirtualMachineScaleSetIdentity, - VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue, - VirtualMachineScaleSetInstanceView, - VirtualMachineScaleSetInstanceViewStatusesSummary, - VirtualMachineScaleSetIpTag, - VirtualMachineScaleSetListOSUpgradeHistory, - VirtualMachineScaleSetListResult, - VirtualMachineScaleSetListSkusResult, - VirtualMachineScaleSetListWithLinkResult, - VirtualMachineScaleSetManagedDiskParameters, - VirtualMachineScaleSetNetworkConfiguration, - VirtualMachineScaleSetNetworkConfigurationDnsSettings, - VirtualMachineScaleSetNetworkProfile, - VirtualMachineScaleSetOSDisk, - VirtualMachineScaleSetOSProfile, - VirtualMachineScaleSetPublicIPAddressConfiguration, - VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings, - VirtualMachineScaleSetReimageParameters, - VirtualMachineScaleSetSku, - VirtualMachineScaleSetSkuCapacity, - VirtualMachineScaleSetStorageProfile, - VirtualMachineScaleSetUpdate, - VirtualMachineScaleSetUpdateIPConfiguration, - VirtualMachineScaleSetUpdateNetworkConfiguration, - VirtualMachineScaleSetUpdateNetworkProfile, - VirtualMachineScaleSetUpdateOSDisk, - VirtualMachineScaleSetUpdateOSProfile, - VirtualMachineScaleSetUpdatePublicIPAddressConfiguration, - VirtualMachineScaleSetUpdateStorageProfile, - VirtualMachineScaleSetUpdateVMProfile, - VirtualMachineScaleSetVM, - VirtualMachineScaleSetVMExtensionsSummary, - VirtualMachineScaleSetVMInstanceIDs, - VirtualMachineScaleSetVMInstanceRequiredIDs, - VirtualMachineScaleSetVMInstanceView, - VirtualMachineScaleSetVMListResult, - VirtualMachineScaleSetVMNetworkProfileConfiguration, - VirtualMachineScaleSetVMProfile, - VirtualMachineScaleSetVMProtectionPolicy, - VirtualMachineScaleSetVMReimageParameters, - VirtualMachineSize, - VirtualMachineSizeListResult, - VirtualMachineStatusCodeCount, - VirtualMachineUpdate, - WinRMConfiguration, - WinRMListener, - WindowsConfiguration, -) - -from ._compute_management_client_enums import ( # type: ignore - AccessLevel, - AggregatedReplicationState, - AvailabilitySetSkuTypes, - CachingTypes, - DedicatedHostLicenseTypes, - DiffDiskOptions, - DiskCreateOption, - DiskCreateOptionTypes, - DiskEncryptionSetIdentityType, - DiskState, - DiskStorageAccountTypes, - EncryptionType, - GalleryApplicationVersionPropertiesProvisioningState, - GalleryImagePropertiesProvisioningState, - GalleryImageVersionPropertiesProvisioningState, - GalleryPropertiesProvisioningState, - HostCaching, - HyperVGeneration, - HyperVGenerationType, - HyperVGenerationTypes, - IPVersion, - IntervalInMins, - MaintenanceOperationResultCodeTypes, - OperatingSystemStateTypes, - OperatingSystemTypes, - ProtocolTypes, - ProximityPlacementGroupType, - ReplicationState, - ReplicationStatusTypes, - ResourceIdentityType, - RollingUpgradeActionType, - RollingUpgradeStatusCode, - SettingNames, - SnapshotStorageAccountTypes, - StatusLevelTypes, - StorageAccountType, - StorageAccountTypes, - UpgradeMode, - UpgradeOperationInvoker, - UpgradeState, - VirtualMachineEvictionPolicyTypes, - VirtualMachinePriorityTypes, - VirtualMachineScaleSetScaleInRules, - VirtualMachineScaleSetSkuScaleType, - VirtualMachineSizeTypes, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AccessUri", - "AdditionalCapabilities", - "AdditionalUnattendContent", - "ApiEntityReference", - "ApiError", - "ApiErrorBase", - "AutomaticOSUpgradePolicy", - "AutomaticOSUpgradeProperties", - "AutomaticRepairsPolicy", - "AvailabilitySet", - "AvailabilitySetListResult", - "AvailabilitySetUpdate", - "BillingProfile", - "BootDiagnostics", - "BootDiagnosticsInstanceView", - "ComputeOperationListResult", - "ComputeOperationValue", - "CreationData", - "DataDisk", - "DataDiskImage", - "DedicatedHost", - "DedicatedHostAllocatableVM", - "DedicatedHostAvailableCapacity", - "DedicatedHostGroup", - "DedicatedHostGroupListResult", - "DedicatedHostGroupUpdate", - "DedicatedHostInstanceView", - "DedicatedHostListResult", - "DedicatedHostUpdate", - "DiagnosticsProfile", - "DiffDiskSettings", - "Disallowed", - "Disk", - "DiskEncryptionSet", - "DiskEncryptionSetList", - "DiskEncryptionSetParameters", - "DiskEncryptionSetUpdate", - "DiskEncryptionSettings", - "DiskInstanceView", - "DiskList", - "DiskSku", - "DiskUpdate", - "Encryption", - "EncryptionSetIdentity", - "EncryptionSettingsCollection", - "EncryptionSettingsElement", - "Gallery", - "GalleryApplication", - "GalleryApplicationList", - "GalleryApplicationUpdate", - "GalleryApplicationVersion", - "GalleryApplicationVersionList", - "GalleryApplicationVersionPublishingProfile", - "GalleryApplicationVersionUpdate", - "GalleryArtifactPublishingProfileBase", - "GalleryArtifactSource", - "GalleryArtifactVersionSource", - "GalleryDataDiskImage", - "GalleryDiskImage", - "GalleryIdentifier", - "GalleryImage", - "GalleryImageIdentifier", - "GalleryImageList", - "GalleryImageUpdate", - "GalleryImageVersion", - "GalleryImageVersionList", - "GalleryImageVersionPublishingProfile", - "GalleryImageVersionStorageProfile", - "GalleryImageVersionUpdate", - "GalleryList", - "GalleryOSDiskImage", - "GalleryUpdate", - "GrantAccessData", - "HardwareProfile", - "Image", - "ImageDataDisk", - "ImageDisk", - "ImageDiskReference", - "ImageListResult", - "ImageOSDisk", - "ImagePurchasePlan", - "ImageReference", - "ImageStorageProfile", - "ImageUpdate", - "InnerError", - "InstanceViewStatus", - "KeyVaultAndKeyReference", - "KeyVaultAndSecretReference", - "KeyVaultKeyReference", - "KeyVaultSecretReference", - "LinuxConfiguration", - "ListUsagesResult", - "LogAnalyticsInputBase", - "LogAnalyticsOperationResult", - "LogAnalyticsOutput", - "MaintenanceRedeployStatus", - "ManagedArtifact", - "ManagedDiskParameters", - "NetworkInterfaceReference", - "NetworkProfile", - "OSDisk", - "OSDiskImage", - "OSProfile", - "Plan", - "ProximityPlacementGroup", - "ProximityPlacementGroupListResult", - "ProximityPlacementGroupUpdate", - "PurchasePlan", - "RecommendedMachineConfiguration", - "RecoveryWalkResponse", - "RegionalReplicationStatus", - "ReplicationStatus", - "RequestRateByIntervalInput", - "Resource", - "ResourceRange", - "RollbackStatusInfo", - "RollingUpgradePolicy", - "RollingUpgradeProgressInfo", - "RollingUpgradeRunningStatus", - "RollingUpgradeStatusInfo", - "RunCommandDocument", - "RunCommandDocumentBase", - "RunCommandInput", - "RunCommandInputParameter", - "RunCommandListResult", - "RunCommandParameterDefinition", - "RunCommandResult", - "ScaleInPolicy", - "ScheduledEventsProfile", - "Sku", - "Snapshot", - "SnapshotList", - "SnapshotSku", - "SnapshotUpdate", - "SourceVault", - "SshConfiguration", - "SshPublicKey", - "StorageProfile", - "SubResource", - "SubResourceReadOnly", - "SubResourceWithColocationStatus", - "TargetRegion", - "TerminateNotificationProfile", - "ThrottledRequestsInput", - "UpdateResource", - "UpgradeOperationHistoricalStatusInfo", - "UpgradeOperationHistoricalStatusInfoProperties", - "UpgradeOperationHistoryStatus", - "UpgradePolicy", - "Usage", - "UsageName", - "UserArtifactManage", - "UserArtifactSource", - "UserAssignedIdentitiesValue", - "VMScaleSetConvertToSinglePlacementGroupInput", - "VaultCertificate", - "VaultSecretGroup", - "VirtualHardDisk", - "VirtualMachine", - "VirtualMachineAgentInstanceView", - "VirtualMachineCaptureParameters", - "VirtualMachineCaptureResult", - "VirtualMachineExtension", - "VirtualMachineExtensionHandlerInstanceView", - "VirtualMachineExtensionImage", - "VirtualMachineExtensionInstanceView", - "VirtualMachineExtensionUpdate", - "VirtualMachineExtensionsListResult", - "VirtualMachineHealthStatus", - "VirtualMachineIdentity", - "VirtualMachineImage", - "VirtualMachineImageResource", - "VirtualMachineInstanceView", - "VirtualMachineListResult", - "VirtualMachineReimageParameters", - "VirtualMachineScaleSet", - "VirtualMachineScaleSetDataDisk", - "VirtualMachineScaleSetExtension", - "VirtualMachineScaleSetExtensionListResult", - "VirtualMachineScaleSetExtensionProfile", - "VirtualMachineScaleSetExtensionUpdate", - "VirtualMachineScaleSetIPConfiguration", - "VirtualMachineScaleSetIdentity", - "VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue", - "VirtualMachineScaleSetInstanceView", - "VirtualMachineScaleSetInstanceViewStatusesSummary", - "VirtualMachineScaleSetIpTag", - "VirtualMachineScaleSetListOSUpgradeHistory", - "VirtualMachineScaleSetListResult", - "VirtualMachineScaleSetListSkusResult", - "VirtualMachineScaleSetListWithLinkResult", - "VirtualMachineScaleSetManagedDiskParameters", - "VirtualMachineScaleSetNetworkConfiguration", - "VirtualMachineScaleSetNetworkConfigurationDnsSettings", - "VirtualMachineScaleSetNetworkProfile", - "VirtualMachineScaleSetOSDisk", - "VirtualMachineScaleSetOSProfile", - "VirtualMachineScaleSetPublicIPAddressConfiguration", - "VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings", - "VirtualMachineScaleSetReimageParameters", - "VirtualMachineScaleSetSku", - "VirtualMachineScaleSetSkuCapacity", - "VirtualMachineScaleSetStorageProfile", - "VirtualMachineScaleSetUpdate", - "VirtualMachineScaleSetUpdateIPConfiguration", - "VirtualMachineScaleSetUpdateNetworkConfiguration", - "VirtualMachineScaleSetUpdateNetworkProfile", - "VirtualMachineScaleSetUpdateOSDisk", - "VirtualMachineScaleSetUpdateOSProfile", - "VirtualMachineScaleSetUpdatePublicIPAddressConfiguration", - "VirtualMachineScaleSetUpdateStorageProfile", - "VirtualMachineScaleSetUpdateVMProfile", - "VirtualMachineScaleSetVM", - "VirtualMachineScaleSetVMExtensionsSummary", - "VirtualMachineScaleSetVMInstanceIDs", - "VirtualMachineScaleSetVMInstanceRequiredIDs", - "VirtualMachineScaleSetVMInstanceView", - "VirtualMachineScaleSetVMListResult", - "VirtualMachineScaleSetVMNetworkProfileConfiguration", - "VirtualMachineScaleSetVMProfile", - "VirtualMachineScaleSetVMProtectionPolicy", - "VirtualMachineScaleSetVMReimageParameters", - "VirtualMachineSize", - "VirtualMachineSizeListResult", - "VirtualMachineStatusCodeCount", - "VirtualMachineUpdate", - "WinRMConfiguration", - "WinRMListener", - "WindowsConfiguration", - "AccessLevel", - "AggregatedReplicationState", - "AvailabilitySetSkuTypes", - "CachingTypes", - "DedicatedHostLicenseTypes", - "DiffDiskOptions", - "DiskCreateOption", - "DiskCreateOptionTypes", - "DiskEncryptionSetIdentityType", - "DiskState", - "DiskStorageAccountTypes", - "EncryptionType", - "GalleryApplicationVersionPropertiesProvisioningState", - "GalleryImagePropertiesProvisioningState", - "GalleryImageVersionPropertiesProvisioningState", - "GalleryPropertiesProvisioningState", - "HostCaching", - "HyperVGeneration", - "HyperVGenerationType", - "HyperVGenerationTypes", - "IPVersion", - "IntervalInMins", - "MaintenanceOperationResultCodeTypes", - "OperatingSystemStateTypes", - "OperatingSystemTypes", - "ProtocolTypes", - "ProximityPlacementGroupType", - "ReplicationState", - "ReplicationStatusTypes", - "ResourceIdentityType", - "RollingUpgradeActionType", - "RollingUpgradeStatusCode", - "SettingNames", - "SnapshotStorageAccountTypes", - "StatusLevelTypes", - "StorageAccountType", - "StorageAccountTypes", - "UpgradeMode", - "UpgradeOperationInvoker", - "UpgradeState", - "VirtualMachineEvictionPolicyTypes", - "VirtualMachinePriorityTypes", - "VirtualMachineScaleSetScaleInRules", - "VirtualMachineScaleSetSkuScaleType", - "VirtualMachineSizeTypes", -] -__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/v2019_07_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/_compute_management_client_enums.py deleted file mode 100644 index 683e67caf434..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/_compute_management_client_enums.py +++ /dev/null @@ -1,631 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AccessLevel.""" - - NONE = "None" - READ = "Read" - WRITE = "Write" - - -class AggregatedReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is the aggregated replication status based on all the regional replication status flags.""" - - UNKNOWN = "Unknown" - IN_PROGRESS = "InProgress" - COMPLETED = "Completed" - FAILED = "Failed" - - -class AvailabilitySetSkuTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the sku of an Availability Set. Use 'Aligned' for virtual machines with managed disks - and 'Classic' for virtual machines with unmanaged disks. Default value is 'Classic'. - """ - - CLASSIC = "Classic" - ALIGNED = "Aligned" - - -class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** :code:`
    `\\ - :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for Standard storage. - ReadOnly for Premium storage**. - """ - - NONE = "None" - READ_ONLY = "ReadOnly" - READ_WRITE = "ReadWrite" - - -class DedicatedHostLicenseTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the software license type that will be applied to the VMs deployed on the dedicated - host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **None** - :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ :code:`
    ` - **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. - """ - - NONE = "None" - WINDOWS_SERVER_HYBRID = "Windows_Server_Hybrid" - WINDOWS_SERVER_PERPETUAL = "Windows_Server_Perpetual" - - -class DiffDiskOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the ephemeral disk option for operating system disk.""" - - LOCAL = "Local" - - -class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This enumerates the possible sources of a disk's creation.""" - - EMPTY = "Empty" - """Create an empty data disk of a size given by diskSizeGB.""" - ATTACH = "Attach" - """Disk will be attached to a VM.""" - FROM_IMAGE = "FromImage" - """Create a new disk from a platform image specified by the given imageReference.""" - IMPORT = "Import" - """Create a disk by importing from a blob specified by a sourceUri in a storage account specified - by storageAccountId.""" - COPY = "Copy" - """Create a new disk or snapshot by copying from a disk or snapshot specified by the given - sourceResourceId.""" - RESTORE = "Restore" - """Create a new disk by copying from a backup recovery point.""" - UPLOAD = "Upload" - """Create a new disk by obtaining a write token and using it to directly upload the contents of - the disk.""" - IMPORT_ENUM = "Import" - """Create a disk by importing from a blob specified by a sourceUri in a storage account specified - by storageAccountId.""" - - -class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies how the virtual machine should be created.\\ :code:`
    `\\ :code:`
    ` Possible - values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value is used when you are - using a specialized disk to create the virtual machine.\\ :code:`
    `\\ :code:`
    ` - **FromImage** \\u2013 This value is used when you are using an image to create the virtual - machine. If you are using a platform image, you also use the imageReference element described - above. If you are using a marketplace image, you also use the plan element previously - described. - """ - - FROM_IMAGE = "FromImage" - EMPTY = "Empty" - ATTACH = "Attach" - - -class DiskEncryptionSetIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported.""" - - SYSTEM_ASSIGNED = "SystemAssigned" - - -class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The state of the disk.""" - - UNATTACHED = "Unattached" - """The disk is not being used and can be attached to a VM.""" - ATTACHED = "Attached" - """The disk is currently mounted to a running VM.""" - RESERVED = "Reserved" - """The disk is mounted to a stopped-deallocated VM""" - ACTIVE_SAS = "ActiveSAS" - """The disk currently has an Active SAS Uri associated with it.""" - READY_TO_UPLOAD = "ReadyToUpload" - """A disk is ready to be created by upload by requesting a write token.""" - ACTIVE_UPLOAD = "ActiveUpload" - """A disk is created for upload and a write token has been issued for uploading to it.""" - - -class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The sku name.""" - - STANDARD_LRS = "Standard_LRS" - """Standard HDD locally redundant storage. Best for backup, non-critical, and infrequent access.""" - PREMIUM_LRS = "Premium_LRS" - """Premium SSD locally redundant storage. Best for production and performance sensitive workloads.""" - STANDARD_SSD_LRS = "StandardSSD_LRS" - """Standard SSD locally redundant storage. Best for web servers, lightly used enterprise - applications and dev/test.""" - ULTRA_SSD_LRS = "UltraSSD_LRS" - """Ultra SSD locally redundant storage. Best for IO-intensive workloads such as SAP HANA, top tier - databases (for example, SQL, Oracle), and other transaction-heavy workloads.""" - - -class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of key used to encrypt the data of the disk.""" - - ENCRYPTION_AT_REST_WITH_PLATFORM_KEY = "EncryptionAtRestWithPlatformKey" - """Disk is encrypted with XStore managed key at rest. It is the default encryption type.""" - ENCRYPTION_AT_REST_WITH_CUSTOMER_KEY = "EncryptionAtRestWithCustomerKey" - """Disk is encrypted with Customer managed key at rest.""" - - -class GalleryApplicationVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state, which only appears in the response.""" - - CREATING = "Creating" - UPDATING = "Updating" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - MIGRATING = "Migrating" - - -class GalleryImagePropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state, which only appears in the response.""" - - CREATING = "Creating" - UPDATING = "Updating" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - MIGRATING = "Migrating" - - -class GalleryImageVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state, which only appears in the response.""" - - CREATING = "Creating" - UPDATING = "Updating" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - MIGRATING = "Migrating" - - -class GalleryPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state, which only appears in the response.""" - - CREATING = "Creating" - UPDATING = "Updating" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - MIGRATING = "Migrating" - - -class HostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'.""" - - NONE = "None" - READ_ONLY = "ReadOnly" - READ_WRITE = "ReadWrite" - - -class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The hypervisor generation of the Virtual Machine. Applicable to OS disks only.""" - - V1 = "V1" - V2 = "V2" - - -class HyperVGenerationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the HyperVGeneration Type associated with a resource.""" - - V1 = "V1" - V2 = "V2" - - -class HyperVGenerationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the HyperVGeneration Type.""" - - V1 = "V1" - V2 = "V2" - - -class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Interval value in minutes used to create LogAnalytics call rate logs.""" - - THREE_MINS = "ThreeMins" - FIVE_MINS = "FiveMins" - THIRTY_MINS = "ThirtyMins" - SIXTY_MINS = "SixtyMins" - - -class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """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'. - """ - - I_PV4 = "IPv4" - I_PV6 = "IPv6" - - -class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The Last Maintenance Operation Result Code.""" - - NONE = "None" - RETRY_LATER = "RetryLater" - MAINTENANCE_ABORTED = "MaintenanceAborted" - MAINTENANCE_COMPLETED = "MaintenanceCompleted" - - -class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The OS State.""" - - GENERALIZED = "Generalized" - """Generalized image. Needs to be provisioned during deployment time.""" - SPECIALIZED = "Specialized" - """Specialized image. Contains already provisioned OS Disk.""" - - -class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The operating system of the osDiskImage.""" - - WINDOWS = "Windows" - LINUX = "Linux" - - -class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the protocol of WinRM listener. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. - """ - - HTTP = "Http" - HTTPS = "Https" - - -class ProximityPlacementGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the type of the proximity placement group. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **Standard** : Co-locate resources within an Azure - region or Availability Zone. :code:`
    `\\ :code:`
    ` **Ultra** : For future use. - """ - - STANDARD = "Standard" - ULTRA = "Ultra" - - -class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is the regional replication state.""" - - UNKNOWN = "Unknown" - REPLICATING = "Replicating" - COMPLETED = "Completed" - FAILED = "Failed" - - -class ReplicationStatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ReplicationStatusTypes.""" - - REPLICATION_STATUS = "ReplicationStatus" - - -class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' - includes both an implicitly created identity and a set of user assigned identities. The type - 'None' will remove any identities from the virtual machine. - """ - - SYSTEM_ASSIGNED = "SystemAssigned" - USER_ASSIGNED = "UserAssigned" - SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" - NONE = "None" - - -class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The last action performed on the rolling upgrade.""" - - START = "Start" - CANCEL = "Cancel" - - -class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Code indicating the current status of the upgrade.""" - - ROLLING_FORWARD = "RollingForward" - CANCELLED = "Cancelled" - COMPLETED = "Completed" - FAULTED = "Faulted" - - -class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the name of the setting to which the content applies. Possible values are: - FirstLogonCommands and AutoLogon. - """ - - AUTO_LOGON = "AutoLogon" - FIRST_LOGON_COMMANDS = "FirstLogonCommands" - - -class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The sku name.""" - - STANDARD_LRS = "Standard_LRS" - """Standard HDD locally redundant storage""" - PREMIUM_LRS = "Premium_LRS" - """Premium SSD locally redundant storage""" - STANDARD_ZRS = "Standard_ZRS" - """Standard zone redundant storage""" - - -class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The level code.""" - - INFO = "Info" - WARNING = "Warning" - ERROR = "Error" - - -class StorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the storage account type to be used to store the image. This property is not - updatable. - """ - - STANDARD_LRS = "Standard_LRS" - STANDARD_ZRS = "Standard_ZRS" - - -class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used - with data disks. It cannot be used with OS Disk. Standard_LRS uses Standard HDD. - StandardSSD_LRS uses Standard SSD. Premium_LRS uses Premium SSD. UltraSSD_LRS uses Ultra disk. - For more information regarding disks supported for Windows Virtual Machines, refer to - https://docs.microsoft.com/en-us/azure/virtual-machines/windows/disks-types and, for Linux - Virtual Machines, refer to - https://docs.microsoft.com/en-us/azure/virtual-machines/linux/disks-types. - """ - - STANDARD_LRS = "Standard_LRS" - PREMIUM_LRS = "Premium_LRS" - STANDARD_SSD_LRS = "StandardSSD_LRS" - ULTRA_SSD_LRS = "UltraSSD_LRS" - - -class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the mode of an upgrade to virtual machines in the scale set.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Manual** - You control - the application of updates to virtual machines in the scale set. You do this by using the - manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - All virtual machines in - the scale set are automatically updated at the same time. - """ - - AUTOMATIC = "Automatic" - MANUAL = "Manual" - ROLLING = "Rolling" - - -class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Invoker of the Upgrade Operation.""" - - UNKNOWN = "Unknown" - USER = "User" - PLATFORM = "Platform" - - -class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Code indicating the current status of the upgrade.""" - - ROLLING_FORWARD = "RollingForward" - CANCELLED = "Cancelled" - COMPLETED = "Completed" - FAULTED = "Faulted" - - -class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the eviction policy for the Azure Spot VM/VMSS.""" - - DEALLOCATE = "Deallocate" - DELETE = "Delete" - - -class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the priority for a standalone virtual machine or the virtual machines in the scale - set. :code:`
    `\\ :code:`
    ` 'Low' enum will be deprecated in the future, please use 'Spot' - as the enum to deploy Azure Spot VM/VMSS. - """ - - REGULAR = "Regular" - LOW = "Low" - SPOT = "Spot" - - -class VirtualMachineScaleSetScaleInRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """VirtualMachineScaleSetScaleInRules.""" - - DEFAULT = "Default" - OLDEST_VM = "OldestVM" - NEWEST_VM = "NewestVM" - - -class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scale type applicable to the sku.""" - - AUTOMATIC = "Automatic" - NONE = "None" - - -class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the size of the virtual machine. For more information about virtual machine sizes, - see `Sizes for virtual machines - `_. - :code:`
    `\\ :code:`
    ` The available VM sizes depend on region and availability set. For a - list of available sizes use these APIs: :code:`
    `\\ :code:`
    ` `List all available - virtual machine sizes in an availability set - `_ - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in a region - `_ :code:`
    `\\ - :code:`
    ` `List all available virtual machine sizes for resizing - `_. - """ - - BASIC_A0 = "Basic_A0" - BASIC_A1 = "Basic_A1" - BASIC_A2 = "Basic_A2" - BASIC_A3 = "Basic_A3" - BASIC_A4 = "Basic_A4" - STANDARD_A0 = "Standard_A0" - STANDARD_A1 = "Standard_A1" - STANDARD_A2 = "Standard_A2" - STANDARD_A3 = "Standard_A3" - STANDARD_A4 = "Standard_A4" - STANDARD_A5 = "Standard_A5" - STANDARD_A6 = "Standard_A6" - STANDARD_A7 = "Standard_A7" - STANDARD_A8 = "Standard_A8" - STANDARD_A9 = "Standard_A9" - STANDARD_A10 = "Standard_A10" - STANDARD_A11 = "Standard_A11" - STANDARD_A1_V2 = "Standard_A1_v2" - STANDARD_A2_V2 = "Standard_A2_v2" - STANDARD_A4_V2 = "Standard_A4_v2" - STANDARD_A8_V2 = "Standard_A8_v2" - STANDARD_A2_M_V2 = "Standard_A2m_v2" - STANDARD_A4_M_V2 = "Standard_A4m_v2" - STANDARD_A8_M_V2 = "Standard_A8m_v2" - STANDARD_B1_S = "Standard_B1s" - STANDARD_B1_MS = "Standard_B1ms" - STANDARD_B2_S = "Standard_B2s" - STANDARD_B2_MS = "Standard_B2ms" - STANDARD_B4_MS = "Standard_B4ms" - STANDARD_B8_MS = "Standard_B8ms" - STANDARD_D1 = "Standard_D1" - STANDARD_D2 = "Standard_D2" - STANDARD_D3 = "Standard_D3" - STANDARD_D4 = "Standard_D4" - STANDARD_D11 = "Standard_D11" - STANDARD_D12 = "Standard_D12" - STANDARD_D13 = "Standard_D13" - STANDARD_D14 = "Standard_D14" - STANDARD_D1_V2 = "Standard_D1_v2" - STANDARD_D2_V2 = "Standard_D2_v2" - STANDARD_D3_V2 = "Standard_D3_v2" - STANDARD_D4_V2 = "Standard_D4_v2" - STANDARD_D5_V2 = "Standard_D5_v2" - STANDARD_D2_V3 = "Standard_D2_v3" - STANDARD_D4_V3 = "Standard_D4_v3" - STANDARD_D8_V3 = "Standard_D8_v3" - STANDARD_D16_V3 = "Standard_D16_v3" - STANDARD_D32_V3 = "Standard_D32_v3" - STANDARD_D64_V3 = "Standard_D64_v3" - STANDARD_D2_S_V3 = "Standard_D2s_v3" - STANDARD_D4_S_V3 = "Standard_D4s_v3" - STANDARD_D8_S_V3 = "Standard_D8s_v3" - STANDARD_D16_S_V3 = "Standard_D16s_v3" - STANDARD_D32_S_V3 = "Standard_D32s_v3" - STANDARD_D64_S_V3 = "Standard_D64s_v3" - STANDARD_D11_V2 = "Standard_D11_v2" - STANDARD_D12_V2 = "Standard_D12_v2" - STANDARD_D13_V2 = "Standard_D13_v2" - STANDARD_D14_V2 = "Standard_D14_v2" - STANDARD_D15_V2 = "Standard_D15_v2" - STANDARD_DS1 = "Standard_DS1" - STANDARD_DS2 = "Standard_DS2" - STANDARD_DS3 = "Standard_DS3" - STANDARD_DS4 = "Standard_DS4" - STANDARD_DS11 = "Standard_DS11" - STANDARD_DS12 = "Standard_DS12" - STANDARD_DS13 = "Standard_DS13" - STANDARD_DS14 = "Standard_DS14" - STANDARD_DS1_V2 = "Standard_DS1_v2" - STANDARD_DS2_V2 = "Standard_DS2_v2" - STANDARD_DS3_V2 = "Standard_DS3_v2" - STANDARD_DS4_V2 = "Standard_DS4_v2" - STANDARD_DS5_V2 = "Standard_DS5_v2" - STANDARD_DS11_V2 = "Standard_DS11_v2" - STANDARD_DS12_V2 = "Standard_DS12_v2" - STANDARD_DS13_V2 = "Standard_DS13_v2" - STANDARD_DS14_V2 = "Standard_DS14_v2" - STANDARD_DS15_V2 = "Standard_DS15_v2" - STANDARD_DS13_4_V2 = "Standard_DS13-4_v2" - STANDARD_DS13_2_V2 = "Standard_DS13-2_v2" - STANDARD_DS14_8_V2 = "Standard_DS14-8_v2" - STANDARD_DS14_4_V2 = "Standard_DS14-4_v2" - STANDARD_E2_V3 = "Standard_E2_v3" - STANDARD_E4_V3 = "Standard_E4_v3" - STANDARD_E8_V3 = "Standard_E8_v3" - STANDARD_E16_V3 = "Standard_E16_v3" - STANDARD_E32_V3 = "Standard_E32_v3" - STANDARD_E64_V3 = "Standard_E64_v3" - STANDARD_E2_S_V3 = "Standard_E2s_v3" - STANDARD_E4_S_V3 = "Standard_E4s_v3" - STANDARD_E8_S_V3 = "Standard_E8s_v3" - STANDARD_E16_S_V3 = "Standard_E16s_v3" - STANDARD_E32_S_V3 = "Standard_E32s_v3" - STANDARD_E64_S_V3 = "Standard_E64s_v3" - STANDARD_E32_16_V3 = "Standard_E32-16_v3" - STANDARD_E32_8_S_V3 = "Standard_E32-8s_v3" - STANDARD_E64_32_S_V3 = "Standard_E64-32s_v3" - STANDARD_E64_16_S_V3 = "Standard_E64-16s_v3" - STANDARD_F1 = "Standard_F1" - STANDARD_F2 = "Standard_F2" - STANDARD_F4 = "Standard_F4" - STANDARD_F8 = "Standard_F8" - STANDARD_F16 = "Standard_F16" - STANDARD_F1_S = "Standard_F1s" - STANDARD_F2_S = "Standard_F2s" - STANDARD_F4_S = "Standard_F4s" - STANDARD_F8_S = "Standard_F8s" - STANDARD_F16_S = "Standard_F16s" - STANDARD_F2_S_V2 = "Standard_F2s_v2" - STANDARD_F4_S_V2 = "Standard_F4s_v2" - STANDARD_F8_S_V2 = "Standard_F8s_v2" - STANDARD_F16_S_V2 = "Standard_F16s_v2" - STANDARD_F32_S_V2 = "Standard_F32s_v2" - STANDARD_F64_S_V2 = "Standard_F64s_v2" - STANDARD_F72_S_V2 = "Standard_F72s_v2" - STANDARD_G1 = "Standard_G1" - STANDARD_G2 = "Standard_G2" - STANDARD_G3 = "Standard_G3" - STANDARD_G4 = "Standard_G4" - STANDARD_G5 = "Standard_G5" - STANDARD_GS1 = "Standard_GS1" - STANDARD_GS2 = "Standard_GS2" - STANDARD_GS3 = "Standard_GS3" - STANDARD_GS4 = "Standard_GS4" - STANDARD_GS5 = "Standard_GS5" - STANDARD_GS4_8 = "Standard_GS4-8" - STANDARD_GS4_4 = "Standard_GS4-4" - STANDARD_GS5_16 = "Standard_GS5-16" - STANDARD_GS5_8 = "Standard_GS5-8" - STANDARD_H8 = "Standard_H8" - STANDARD_H16 = "Standard_H16" - STANDARD_H8_M = "Standard_H8m" - STANDARD_H16_M = "Standard_H16m" - STANDARD_H16_R = "Standard_H16r" - STANDARD_H16_MR = "Standard_H16mr" - STANDARD_L4_S = "Standard_L4s" - STANDARD_L8_S = "Standard_L8s" - STANDARD_L16_S = "Standard_L16s" - STANDARD_L32_S = "Standard_L32s" - STANDARD_M64_S = "Standard_M64s" - STANDARD_M64_MS = "Standard_M64ms" - STANDARD_M128_S = "Standard_M128s" - STANDARD_M128_MS = "Standard_M128ms" - STANDARD_M64_32_MS = "Standard_M64-32ms" - STANDARD_M64_16_MS = "Standard_M64-16ms" - STANDARD_M128_64_MS = "Standard_M128-64ms" - STANDARD_M128_32_MS = "Standard_M128-32ms" - STANDARD_NC6 = "Standard_NC6" - STANDARD_NC12 = "Standard_NC12" - STANDARD_NC24 = "Standard_NC24" - STANDARD_NC24_R = "Standard_NC24r" - STANDARD_NC6_S_V2 = "Standard_NC6s_v2" - STANDARD_NC12_S_V2 = "Standard_NC12s_v2" - STANDARD_NC24_S_V2 = "Standard_NC24s_v2" - STANDARD_NC24_RS_V2 = "Standard_NC24rs_v2" - STANDARD_NC6_S_V3 = "Standard_NC6s_v3" - STANDARD_NC12_S_V3 = "Standard_NC12s_v3" - STANDARD_NC24_S_V3 = "Standard_NC24s_v3" - STANDARD_NC24_RS_V3 = "Standard_NC24rs_v3" - STANDARD_ND6_S = "Standard_ND6s" - STANDARD_ND12_S = "Standard_ND12s" - STANDARD_ND24_S = "Standard_ND24s" - STANDARD_ND24_RS = "Standard_ND24rs" - STANDARD_NV6 = "Standard_NV6" - STANDARD_NV12 = "Standard_NV12" - STANDARD_NV24 = "Standard_NV24" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/_models_py3.py deleted file mode 100644 index bc4024a65d56..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/_models_py3.py +++ /dev/null @@ -1,12932 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from collections.abc import MutableMapping -import datetime -from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models -JSON = MutableMapping[str, Any] - - -class AccessUri(_serialization.Model): - """A disk access SAS uri. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar access_sas: A SAS uri for accessing a disk. - :vartype access_sas: str - """ - - _validation = { - "access_sas": {"readonly": True}, - } - - _attribute_map = { - "access_sas": {"key": "accessSAS", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.access_sas: Optional[str] = None - - -class AdditionalCapabilities(_serialization.Model): - """Enables or disables a capability on the virtual machine or virtual machine scale set. - - :ivar ultra_ssd_enabled: The flag that enables or disables a capability to have one or more - managed data disks with UltraSSD_LRS storage account type on the VM or VMSS. Managed disks with - storage account type UltraSSD_LRS can be added to a virtual machine or virtual machine scale - set only if this property is enabled. - :vartype ultra_ssd_enabled: bool - """ - - _attribute_map = { - "ultra_ssd_enabled": {"key": "ultraSSDEnabled", "type": "bool"}, - } - - def __init__(self, *, ultra_ssd_enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword ultra_ssd_enabled: The flag that enables or disables a capability to have one or more - managed data disks with UltraSSD_LRS storage account type on the VM or VMSS. Managed disks with - storage account type UltraSSD_LRS can be added to a virtual machine or virtual machine scale - set only if this property is enabled. - :paramtype ultra_ssd_enabled: bool - """ - super().__init__(**kwargs) - self.ultra_ssd_enabled = ultra_ssd_enabled - - -class AdditionalUnattendContent(_serialization.Model): - """Specifies additional XML formatted information that can be included in the Unattend.xml file, - which is used by Windows Setup. Contents are defined by setting name, component name, and the - pass in which the content is applied. - - :ivar pass_name: The pass name. Currently, the only allowable value is OobeSystem. Default - value is "OobeSystem". - :vartype pass_name: str - :ivar component_name: The component name. Currently, the only allowable value is - Microsoft-Windows-Shell-Setup. Default value is "Microsoft-Windows-Shell-Setup". - :vartype component_name: str - :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon" and - "FirstLogonCommands". - :vartype setting_name: str or ~azure.mgmt.compute.v2019_07_01.models.SettingNames - :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for - the specified path and component. The XML must be less than 4KB and must include the root - element for the setting or feature that is being inserted. - :vartype content: str - """ - - _attribute_map = { - "pass_name": {"key": "passName", "type": "str"}, - "component_name": {"key": "componentName", "type": "str"}, - "setting_name": {"key": "settingName", "type": "str"}, - "content": {"key": "content", "type": "str"}, - } - - def __init__( - self, - *, - pass_name: Optional[Literal["OobeSystem"]] = None, - component_name: Optional[Literal["Microsoft-Windows-Shell-Setup"]] = None, - setting_name: Optional[Union[str, "_models.SettingNames"]] = None, - content: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword pass_name: The pass name. Currently, the only allowable value is OobeSystem. Default - value is "OobeSystem". - :paramtype pass_name: str - :keyword component_name: The component name. Currently, the only allowable value is - Microsoft-Windows-Shell-Setup. Default value is "Microsoft-Windows-Shell-Setup". - :paramtype component_name: str - :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon" and - "FirstLogonCommands". - :paramtype setting_name: str or ~azure.mgmt.compute.v2019_07_01.models.SettingNames - :keyword content: Specifies the XML formatted content that is added to the unattend.xml file - for the specified path and component. The XML must be less than 4KB and must include the root - element for the setting or feature that is being inserted. - :paramtype content: str - """ - super().__init__(**kwargs) - self.pass_name = pass_name - self.component_name = component_name - self.setting_name = setting_name - self.content = content - - -class ApiEntityReference(_serialization.Model): - """The API entity reference. - - :ivar id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class ApiError(_serialization.Model): - """Api error. - - :ivar details: The Api error details. - :vartype details: list[~azure.mgmt.compute.v2019_07_01.models.ApiErrorBase] - :ivar innererror: The Api inner error. - :vartype innererror: ~azure.mgmt.compute.v2019_07_01.models.InnerError - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "details": {"key": "details", "type": "[ApiErrorBase]"}, - "innererror": {"key": "innererror", "type": "InnerError"}, - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - details: Optional[List["_models.ApiErrorBase"]] = None, - innererror: Optional["_models.InnerError"] = None, - code: Optional[str] = None, - target: Optional[str] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword details: The Api error details. - :paramtype details: list[~azure.mgmt.compute.v2019_07_01.models.ApiErrorBase] - :keyword innererror: The Api inner error. - :paramtype innererror: ~azure.mgmt.compute.v2019_07_01.models.InnerError - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.details = details - self.innererror = innererror - self.code = code - self.target = target - self.message = message - - -class ApiErrorBase(_serialization.Model): - """Api error base. - - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.target = target - self.message = message - - -class AutomaticOSUpgradePolicy(_serialization.Model): - """The configuration parameters used for performing automatic OS upgrade. - - :ivar enable_automatic_os_upgrade: Indicates whether OS upgrades should automatically be - applied to scale set instances in a rolling fashion when a newer version of the OS image - becomes available. Default value is false. :code:`
    `\\ :code:`
    ` If this is set to true - for Windows based scale sets, `enableAutomaticUpdates - `_ - is automatically set to false and cannot be set to true. - :vartype enable_automatic_os_upgrade: bool - :ivar disable_automatic_rollback: Whether OS image rollback feature should be disabled. Default - value is false. - :vartype disable_automatic_rollback: bool - """ - - _attribute_map = { - "enable_automatic_os_upgrade": {"key": "enableAutomaticOSUpgrade", "type": "bool"}, - "disable_automatic_rollback": {"key": "disableAutomaticRollback", "type": "bool"}, - } - - def __init__( - self, - *, - enable_automatic_os_upgrade: Optional[bool] = None, - disable_automatic_rollback: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword enable_automatic_os_upgrade: Indicates whether OS upgrades should automatically be - applied to scale set instances in a rolling fashion when a newer version of the OS image - becomes available. Default value is false. :code:`
    `\\ :code:`
    ` If this is set to true - for Windows based scale sets, `enableAutomaticUpdates - `_ - is automatically set to false and cannot be set to true. - :paramtype enable_automatic_os_upgrade: bool - :keyword disable_automatic_rollback: Whether OS image rollback feature should be disabled. - Default value is false. - :paramtype disable_automatic_rollback: bool - """ - super().__init__(**kwargs) - self.enable_automatic_os_upgrade = enable_automatic_os_upgrade - self.disable_automatic_rollback = disable_automatic_rollback - - -class AutomaticOSUpgradeProperties(_serialization.Model): - """Describes automatic OS upgrade properties on the image. - - All required parameters must be populated in order to send to server. - - :ivar automatic_os_upgrade_supported: Specifies whether automatic OS upgrade is supported on - the image. Required. - :vartype automatic_os_upgrade_supported: bool - """ - - _validation = { - "automatic_os_upgrade_supported": {"required": True}, - } - - _attribute_map = { - "automatic_os_upgrade_supported": {"key": "automaticOSUpgradeSupported", "type": "bool"}, - } - - def __init__(self, *, automatic_os_upgrade_supported: bool, **kwargs: Any) -> None: - """ - :keyword automatic_os_upgrade_supported: Specifies whether automatic OS upgrade is supported on - the image. Required. - :paramtype automatic_os_upgrade_supported: bool - """ - super().__init__(**kwargs) - self.automatic_os_upgrade_supported = automatic_os_upgrade_supported - - -class AutomaticRepairsPolicy(_serialization.Model): - """Specifies the configuration parameters for automatic repairs on the virtual machine scale set. - - :ivar enabled: Specifies whether automatic repairs should be enabled on the virtual machine - scale set. The default value is false. - :vartype enabled: bool - :ivar grace_period: The amount of time for which automatic repairs are suspended due to a state - change on VM. The grace time starts after the state change has completed. This helps avoid - premature or accidental repairs. The time duration should be specified in ISO 8601 format. The - minimum allowed grace period is 30 minutes (PT30M), which is also the default value. The - maximum allowed grace period is 90 minutes (PT90M). - :vartype grace_period: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "grace_period": {"key": "gracePeriod", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, grace_period: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Specifies whether automatic repairs should be enabled on the virtual machine - scale set. The default value is false. - :paramtype enabled: bool - :keyword grace_period: The amount of time for which automatic repairs are suspended due to a - state change on VM. The grace time starts after the state change has completed. This helps - avoid premature or accidental repairs. The time duration should be specified in ISO 8601 - format. The minimum allowed grace period is 30 minutes (PT30M), which is also the default - value. The maximum allowed grace period is 90 minutes (PT90M). - :paramtype grace_period: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.grace_period = grace_period - - -class Resource(_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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - - -class AvailabilitySet(Resource): - """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 `Manage the - availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability 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. - :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] - :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 - 'Classic'. - :vartype sku: ~azure.mgmt.compute.v2019_07_01.models.Sku - :ivar platform_update_domain_count: Update Domain count. - :vartype platform_update_domain_count: int - :ivar platform_fault_domain_count: Fault Domain count. - :vartype platform_fault_domain_count: int - :ivar virtual_machines: A list of references to all virtual machines in the availability set. - :vartype virtual_machines: list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the availability set should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "statuses": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "Sku"}, - "platform_update_domain_count": {"key": "properties.platformUpdateDomainCount", "type": "int"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResource]"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "statuses": {"key": "properties.statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - platform_update_domain_count: Optional[int] = None, - platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["_models.SubResource"]] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - 'Classic'. - :paramtype sku: ~azure.mgmt.compute.v2019_07_01.models.Sku - :keyword platform_update_domain_count: Update Domain count. - :paramtype platform_update_domain_count: int - :keyword platform_fault_domain_count: Fault Domain count. - :paramtype platform_fault_domain_count: int - :keyword virtual_machines: A list of references to all virtual machines in the availability - set. - :paramtype virtual_machines: list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the availability set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.platform_update_domain_count = platform_update_domain_count - self.platform_fault_domain_count = platform_fault_domain_count - self.virtual_machines = virtual_machines - self.proximity_placement_group = proximity_placement_group - self.statuses: Optional[List["_models.InstanceViewStatus"]] = None - - -class AvailabilitySetListResult(_serialization.Model): - """The List Availability Set operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of availability sets. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.AvailabilitySet] - :ivar next_link: The URI to fetch the next page of AvailabilitySets. Call ListNext() with this - URI to fetch the next page of AvailabilitySets. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AvailabilitySet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of availability sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.AvailabilitySet] - :keyword next_link: The URI to fetch the next page of AvailabilitySets. Call ListNext() with - this URI to fetch the next page of AvailabilitySets. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class UpdateResource(_serialization.Model): - """The Update Resource model definition. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class AvailabilitySetUpdate(UpdateResource): - """Specifies information about the availability set that the virtual machine should be assigned - to. Only tags may be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: Sku of the availability set. - :vartype sku: ~azure.mgmt.compute.v2019_07_01.models.Sku - :ivar platform_update_domain_count: Update Domain count. - :vartype platform_update_domain_count: int - :ivar platform_fault_domain_count: Fault Domain count. - :vartype platform_fault_domain_count: int - :ivar virtual_machines: A list of references to all virtual machines in the availability set. - :vartype virtual_machines: list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the availability set should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - """ - - _validation = { - "statuses": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "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"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResource]"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "statuses": {"key": "properties.statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - platform_update_domain_count: Optional[int] = None, - platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["_models.SubResource"]] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: Sku of the availability set. - :paramtype sku: ~azure.mgmt.compute.v2019_07_01.models.Sku - :keyword platform_update_domain_count: Update Domain count. - :paramtype platform_update_domain_count: int - :keyword platform_fault_domain_count: Fault Domain count. - :paramtype platform_fault_domain_count: int - :keyword virtual_machines: A list of references to all virtual machines in the availability - set. - :paramtype virtual_machines: list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the availability set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource - """ - super().__init__(tags=tags, **kwargs) - self.sku = sku - self.platform_update_domain_count = platform_update_domain_count - self.platform_fault_domain_count = platform_fault_domain_count - self.virtual_machines = virtual_machines - self.proximity_placement_group = proximity_placement_group - self.statuses: Optional[List["_models.InstanceViewStatus"]] = None - - -class BillingProfile(_serialization.Model): - """Specifies the billing related details of a Azure Spot VM or VMSS. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. - - :ivar max_price: Specifies the maximum price you are willing to pay for a Azure Spot VM/VMSS. - This price is in US Dollars. :code:`
    `\\ :code:`
    ` This price will be compared with the - current Azure Spot price for the VM size. Also, the prices are compared at the time of - create/update of Azure Spot VM/VMSS and the operation will only succeed if the maxPrice is - greater than the current Azure Spot price. :code:`
    `\\ :code:`
    ` The maxPrice will also - be used for evicting a Azure Spot VM/VMSS if the current Azure Spot price goes beyond the - maxPrice after creation of VM/VMSS. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` - Any decimal value greater than zero. Example: 0.01538 - :code:`
    `\\ :code:`
    ` -1 – indicates default price to be up-to on-demand. :code:`
    `\\ - :code:`
    ` You can set the maxPrice to -1 to indicate that the Azure Spot VM/VMSS should not - be evicted for price reasons. Also, the default max price is -1 if it is not provided by you. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype max_price: float - """ - - _attribute_map = { - "max_price": {"key": "maxPrice", "type": "float"}, - } - - def __init__(self, *, max_price: Optional[float] = None, **kwargs: Any) -> None: - """ - :keyword max_price: Specifies the maximum price you are willing to pay for a Azure Spot - VM/VMSS. This price is in US Dollars. :code:`
    `\\ :code:`
    ` This price will be compared - with the current Azure Spot price for the VM size. Also, the prices are compared at the time of - create/update of Azure Spot VM/VMSS and the operation will only succeed if the maxPrice is - greater than the current Azure Spot price. :code:`
    `\\ :code:`
    ` The maxPrice will also - be used for evicting a Azure Spot VM/VMSS if the current Azure Spot price goes beyond the - maxPrice after creation of VM/VMSS. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` - Any decimal value greater than zero. Example: 0.01538 - :code:`
    `\\ :code:`
    ` -1 – indicates default price to be up-to on-demand. :code:`
    `\\ - :code:`
    ` You can set the maxPrice to -1 to indicate that the Azure Spot VM/VMSS should not - be evicted for price reasons. Also, the default max price is -1 if it is not provided by you. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype max_price: float - """ - super().__init__(**kwargs) - self.max_price = max_price - - -class BootDiagnostics(_serialization.Model): - """Boot Diagnostics is a debugging feature which allows you to view Console Output and Screenshot - to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily view the output of your - console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see a screenshot of the VM - from the hypervisor. - - :ivar enabled: Whether boot diagnostics should be enabled on the Virtual Machine. - :vartype enabled: bool - :ivar storage_uri: Uri of the storage account to use for placing the console output and - screenshot. - :vartype storage_uri: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "storage_uri": {"key": "storageUri", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, storage_uri: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Whether boot diagnostics should be enabled on the Virtual Machine. - :paramtype enabled: bool - :keyword storage_uri: Uri of the storage account to use for placing the console output and - screenshot. - :paramtype storage_uri: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.storage_uri = storage_uri - - -class BootDiagnosticsInstanceView(_serialization.Model): - """The instance view of a virtual machine boot diagnostics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar console_screenshot_blob_uri: The console screenshot blob URI. - :vartype console_screenshot_blob_uri: str - :ivar serial_console_log_blob_uri: The Linux serial console log blob Uri. - :vartype serial_console_log_blob_uri: str - :ivar status: The boot diagnostics status information for the VM. :code:`
    `\\ :code:`
    ` - NOTE: It will be set only if there are errors encountered in enabling boot diagnostics. - :vartype status: ~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus - """ - - _validation = { - "console_screenshot_blob_uri": {"readonly": True}, - "serial_console_log_blob_uri": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "console_screenshot_blob_uri": {"key": "consoleScreenshotBlobUri", "type": "str"}, - "serial_console_log_blob_uri": {"key": "serialConsoleLogBlobUri", "type": "str"}, - "status": {"key": "status", "type": "InstanceViewStatus"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.console_screenshot_blob_uri: Optional[str] = None - self.serial_console_log_blob_uri: Optional[str] = None - self.status: Optional["_models.InstanceViewStatus"] = 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.v2019_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: Optional[List["_models.ComputeOperationValue"]] = None - - -class ComputeOperationValue(_serialization.Model): - """Describes the properties of a Compute Operation value. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar origin: The origin of the compute operation. - :vartype origin: str - :ivar name: The name of the compute operation. - :vartype name: str - :ivar operation: The display name of the compute operation. - :vartype operation: str - :ivar resource: The display name of the resource the operation applies to. - :vartype resource: str - :ivar description: The description of the operation. - :vartype description: str - :ivar provider: The resource provider for the operation. - :vartype provider: str - """ - - _validation = { - "origin": {"readonly": True}, - "name": {"readonly": True}, - "operation": {"readonly": True}, - "resource": {"readonly": True}, - "description": {"readonly": True}, - "provider": {"readonly": True}, - } - - _attribute_map = { - "origin": {"key": "origin", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "operation": {"key": "display.operation", "type": "str"}, - "resource": {"key": "display.resource", "type": "str"}, - "description": {"key": "display.description", "type": "str"}, - "provider": {"key": "display.provider", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.origin: Optional[str] = None - self.name: Optional[str] = None - self.operation: Optional[str] = None - self.resource: Optional[str] = None - self.description: Optional[str] = None - self.provider: Optional[str] = None - - -class CreationData(_serialization.Model): - """Data used when creating a disk. - - 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 create_option: This enumerates the possible sources of a disk's creation. Required. Known - values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", and - "Import". - :vartype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOption - :ivar storage_account_id: Required if createOption is Import. The Azure Resource Manager - identifier of the storage account containing the blob to import as a disk. - :vartype storage_account_id: str - :ivar image_reference: Disk source information. - :vartype image_reference: ~azure.mgmt.compute.v2019_07_01.models.ImageDiskReference - :ivar source_uri: If createOption is Import, this is the URI of a blob to be imported into a - managed disk. - :vartype source_uri: str - :ivar source_resource_id: If createOption is Copy, this is the ARM id of the source snapshot or - disk. - :vartype source_resource_id: str - :ivar source_unique_id: If this field is set, this is the unique id identifying the source of - this resource. - :vartype source_unique_id: str - :ivar upload_size_bytes: If createOption is Upload, this is the size of the contents of the - upload including the VHD footer. This value should be between 20972032 (20 MiB + 512 bytes for - the VHD footer) and 35183298347520 bytes (32 TiB + 512 bytes for the VHD footer). - :vartype upload_size_bytes: int - """ - - _validation = { - "create_option": {"required": True}, - "source_unique_id": {"readonly": True}, - } - - _attribute_map = { - "create_option": {"key": "createOption", "type": "str"}, - "storage_account_id": {"key": "storageAccountId", "type": "str"}, - "image_reference": {"key": "imageReference", "type": "ImageDiskReference"}, - "source_uri": {"key": "sourceUri", "type": "str"}, - "source_resource_id": {"key": "sourceResourceId", "type": "str"}, - "source_unique_id": {"key": "sourceUniqueId", "type": "str"}, - "upload_size_bytes": {"key": "uploadSizeBytes", "type": "int"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOption"], - storage_account_id: Optional[str] = None, - image_reference: Optional["_models.ImageDiskReference"] = None, - source_uri: Optional[str] = None, - source_resource_id: Optional[str] = None, - upload_size_bytes: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword create_option: This enumerates the possible sources of a disk's creation. Required. - Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", and - "Import". - :paramtype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOption - :keyword storage_account_id: Required if createOption is Import. The Azure Resource Manager - identifier of the storage account containing the blob to import as a disk. - :paramtype storage_account_id: str - :keyword image_reference: Disk source information. - :paramtype image_reference: ~azure.mgmt.compute.v2019_07_01.models.ImageDiskReference - :keyword source_uri: If createOption is Import, this is the URI of a blob to be imported into a - managed disk. - :paramtype source_uri: str - :keyword source_resource_id: If createOption is Copy, this is the ARM id of the source snapshot - or disk. - :paramtype source_resource_id: str - :keyword upload_size_bytes: If createOption is Upload, this is the size of the contents of the - upload including the VHD footer. This value should be between 20972032 (20 MiB + 512 bytes for - the VHD footer) and 35183298347520 bytes (32 TiB + 512 bytes for the VHD footer). - :paramtype upload_size_bytes: int - """ - super().__init__(**kwargs) - self.create_option = create_option - self.storage_account_id = storage_account_id - self.image_reference = image_reference - self.source_uri = source_uri - self.source_resource_id = source_resource_id - self.source_unique_id: Optional[str] = None - self.upload_size_bytes = upload_size_bytes - - -class DataDisk(_serialization.Model): - """Describes a data disk. - - 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 lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - :ivar name: The disk name. - :vartype name: str - :ivar vhd: The virtual hard disk. - :vartype vhd: ~azure.mgmt.compute.v2019_07_01.models.VirtualHardDisk - :ivar image: 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. - :vartype image: ~azure.mgmt.compute.v2019_07_01.models.VirtualHardDisk - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: ~azure.mgmt.compute.v2019_07_01.models.ManagedDiskParameters - :ivar to_be_detached: Specifies whether the data disk is in process of detachment from the - VirtualMachine/VirtualMachineScaleset. - :vartype to_be_detached: bool - :ivar disk_iops_read_write: Specifies the Read-Write IOPS for the managed disk when - StorageAccountType is UltraSSD_LRS. Returned only for VirtualMachine ScaleSet VM disks. Can be - updated only via updates to the VirtualMachine Scale Set. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: Specifies the bandwidth in MB per second for the managed disk when - StorageAccountType is UltraSSD_LRS. Returned only for VirtualMachine ScaleSet VM disks. Can be - updated only via updates to the VirtualMachine Scale Set. - :vartype disk_m_bps_read_write: int - """ - - _validation = { - "lun": {"required": True}, - "create_option": {"required": True}, - "disk_iops_read_write": {"readonly": True}, - "disk_m_bps_read_write": {"readonly": True}, - } - - _attribute_map = { - "lun": {"key": "lun", "type": "int"}, - "name": {"key": "name", "type": "str"}, - "vhd": {"key": "vhd", "type": "VirtualHardDisk"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, - "to_be_detached": {"key": "toBeDetached", "type": "bool"}, - "disk_iops_read_write": {"key": "diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "diskMBpsReadWrite", "type": "int"}, - } - - def __init__( - self, - *, - lun: int, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - vhd: Optional["_models.VirtualHardDisk"] = None, - image: Optional["_models.VirtualHardDisk"] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.ManagedDiskParameters"] = None, - to_be_detached: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - :keyword name: The disk name. - :paramtype name: str - :keyword vhd: The virtual hard disk. - :paramtype vhd: ~azure.mgmt.compute.v2019_07_01.models.VirtualHardDisk - :keyword image: 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. - :paramtype image: ~azure.mgmt.compute.v2019_07_01.models.VirtualHardDisk - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: ~azure.mgmt.compute.v2019_07_01.models.ManagedDiskParameters - :keyword to_be_detached: Specifies whether the data disk is in process of detachment from the - VirtualMachine/VirtualMachineScaleset. - :paramtype to_be_detached: bool - """ - super().__init__(**kwargs) - self.lun = lun - self.name = name - self.vhd = vhd - self.image = image - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - self.to_be_detached = to_be_detached - self.disk_iops_read_write: Optional[int] = None - self.disk_m_bps_read_write: Optional[int] = None - - -class DataDiskImage(_serialization.Model): - """Contains the data disk images information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - :vartype lun: int - """ - - _validation = { - "lun": {"readonly": True}, - } - - _attribute_map = { - "lun": {"key": "lun", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.lun: Optional[int] = None - - -class DedicatedHost(Resource): - """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. - :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] - :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.v2019_07_01.models.Sku - :ivar platform_fault_domain: Fault domain of the dedicated host within a dedicated host group. - :vartype platform_fault_domain: int - :ivar auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :vartype auto_replace_on_failure: bool - :ivar host_id: A unique id generated and assigned to the dedicated host by the platform. - :code:`
    `\\ :code:`
    ` Does not change throughout the lifetime of the host. - :vartype host_id: str - :ivar virtual_machines: A list of references to all virtual machines in the Dedicated Host. - :vartype virtual_machines: list[~azure.mgmt.compute.v2019_07_01.models.SubResourceReadOnly] - :ivar license_type: Specifies the software license type that will be applied to the VMs - deployed on the dedicated host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ - :code:`
    ` **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. Known - values are: "None", "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :vartype license_type: str or ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostLicenseTypes - :ivar provisioning_time: The date when the host was first provisioned. - :vartype provisioning_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The dedicated host instance view. - :vartype instance_view: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostInstanceView - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "sku": {"required": True}, - "platform_fault_domain": {"maximum": 2, "minimum": 0}, - "host_id": {"readonly": True}, - "virtual_machines": {"readonly": True}, - "provisioning_time": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "Sku"}, - "platform_fault_domain": {"key": "properties.platformFaultDomain", "type": "int"}, - "auto_replace_on_failure": {"key": "properties.autoReplaceOnFailure", "type": "bool"}, - "host_id": {"key": "properties.hostId", "type": "str"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResourceReadOnly]"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "provisioning_time": {"key": "properties.provisioningTime", "type": "iso-8601"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostInstanceView"}, - } - - def __init__( - self, - *, - location: str, - sku: "_models.Sku", - tags: Optional[Dict[str, str]] = None, - platform_fault_domain: Optional[int] = None, - auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2019_07_01.models.Sku - :keyword platform_fault_domain: Fault domain of the dedicated host within a dedicated host - group. - :paramtype platform_fault_domain: int - :keyword auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :paramtype auto_replace_on_failure: bool - :keyword license_type: Specifies the software license type that will be applied to the VMs - deployed on the dedicated host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ - :code:`
    ` **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. Known - values are: "None", "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :paramtype license_type: str or - ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostLicenseTypes - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.platform_fault_domain = platform_fault_domain - self.auto_replace_on_failure = auto_replace_on_failure - self.host_id: Optional[str] = None - self.virtual_machines: Optional[List["_models.SubResourceReadOnly"]] = None - self.license_type = license_type - self.provisioning_time: Optional[datetime.datetime] = None - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.DedicatedHostInstanceView"] = None - - -class DedicatedHostAllocatableVM(_serialization.Model): - """Represents the dedicated host unutilized capacity in terms of a specific VM size. - - :ivar vm_size: VM size in terms of which the unutilized capacity is represented. - :vartype vm_size: str - :ivar count: Maximum number of VMs of size vmSize that can fit in the dedicated host's - remaining capacity. - :vartype count: float - """ - - _attribute_map = { - "vm_size": {"key": "vmSize", "type": "str"}, - "count": {"key": "count", "type": "float"}, - } - - def __init__(self, *, vm_size: Optional[str] = None, count: Optional[float] = None, **kwargs: Any) -> None: - """ - :keyword vm_size: VM size in terms of which the unutilized capacity is represented. - :paramtype vm_size: str - :keyword count: Maximum number of VMs of size vmSize that can fit in the dedicated host's - remaining capacity. - :paramtype count: float - """ - super().__init__(**kwargs) - self.vm_size = vm_size - self.count = count - - -class DedicatedHostAvailableCapacity(_serialization.Model): - """Dedicated host unutilized capacity. - - :ivar allocatable_v_ms: The unutilized capacity of the dedicated host represented in terms of - each VM size that is allowed to be deployed to the dedicated host. - :vartype allocatable_v_ms: - list[~azure.mgmt.compute.v2019_07_01.models.DedicatedHostAllocatableVM] - """ - - _attribute_map = { - "allocatable_v_ms": {"key": "allocatableVMs", "type": "[DedicatedHostAllocatableVM]"}, - } - - def __init__( - self, *, allocatable_v_ms: Optional[List["_models.DedicatedHostAllocatableVM"]] = None, **kwargs: Any - ) -> None: - """ - :keyword allocatable_v_ms: The unutilized capacity of the dedicated host represented in terms - of each VM size that is allowed to be deployed to the dedicated host. - :paramtype allocatable_v_ms: - list[~azure.mgmt.compute.v2019_07_01.models.DedicatedHostAllocatableVM] - """ - super().__init__(**kwargs) - self.allocatable_v_ms = allocatable_v_ms - - -class DedicatedHostGroup(Resource): - """Specifies information about the dedicated host group that the dedicated hosts should be - assigned to. :code:`
    `\\ :code:`
    ` 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. - - 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] - :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. - :vartype zones: list[str] - :ivar platform_fault_domain_count: Number of fault domains that the host group can span. - :vartype platform_fault_domain_count: int - :ivar hosts: A list of references to all dedicated hosts in the dedicated host group. - :vartype hosts: list[~azure.mgmt.compute.v2019_07_01.models.SubResourceReadOnly] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "platform_fault_domain_count": {"maximum": 3, "minimum": 1}, - "hosts": {"readonly": 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}"}, - "zones": {"key": "zones", "type": "[str]"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "hosts": {"key": "properties.hosts", "type": "[SubResourceReadOnly]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - zones: Optional[List[str]] = None, - platform_fault_domain_count: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword zones: Availability Zone to use for this host group. Only single zone is supported. - The zone can be assigned only during creation. If not provided, the group supports all zones in - the region. If provided, enforces each host in the group to be in the same zone. - :paramtype zones: list[str] - :keyword platform_fault_domain_count: Number of fault domains that the host group can span. - :paramtype platform_fault_domain_count: int - """ - super().__init__(location=location, tags=tags, **kwargs) - self.zones = zones - self.platform_fault_domain_count = platform_fault_domain_count - self.hosts: Optional[List["_models.SubResourceReadOnly"]] = None - - -class DedicatedHostGroupListResult(_serialization.Model): - """The List Dedicated Host Group with resource group response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of dedicated host groups. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroup] - :ivar next_link: The URI to fetch the next page of Dedicated Host Groups. Call ListNext() with - this URI to fetch the next page of Dedicated Host Groups. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DedicatedHostGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DedicatedHostGroup"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of dedicated host groups. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroup] - :keyword next_link: The URI to fetch the next page of Dedicated Host Groups. Call ListNext() - with this URI to fetch the next page of Dedicated Host Groups. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DedicatedHostGroupUpdate(UpdateResource): - """Specifies information about the dedicated host group that the dedicated host should be assigned - to. Only tags may be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar zones: Availability Zone to use for this host group. Only single zone is supported. The - zone can be assigned only during creation. If not provided, the group supports all zones in the - region. If provided, enforces each host in the group to be in the same zone. - :vartype zones: list[str] - :ivar platform_fault_domain_count: Number of fault domains that the host group can span. - :vartype platform_fault_domain_count: int - :ivar hosts: A list of references to all dedicated hosts in the dedicated host group. - :vartype hosts: list[~azure.mgmt.compute.v2019_07_01.models.SubResourceReadOnly] - """ - - _validation = { - "platform_fault_domain_count": {"maximum": 3, "minimum": 1}, - "hosts": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "zones": {"key": "zones", "type": "[str]"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "hosts": {"key": "properties.hosts", "type": "[SubResourceReadOnly]"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - zones: Optional[List[str]] = None, - platform_fault_domain_count: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword zones: Availability Zone to use for this host group. Only single zone is supported. - The zone can be assigned only during creation. If not provided, the group supports all zones in - the region. If provided, enforces each host in the group to be in the same zone. - :paramtype zones: list[str] - :keyword platform_fault_domain_count: Number of fault domains that the host group can span. - :paramtype platform_fault_domain_count: int - """ - super().__init__(tags=tags, **kwargs) - self.zones = zones - self.platform_fault_domain_count = platform_fault_domain_count - self.hosts: Optional[List["_models.SubResourceReadOnly"]] = None - - -class DedicatedHostInstanceView(_serialization.Model): - """The instance view of a dedicated host. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar asset_id: Specifies the unique id of the dedicated physical machine on which the - dedicated host resides. - :vartype asset_id: str - :ivar available_capacity: Unutilized capacity of the dedicated host. - :vartype available_capacity: - ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostAvailableCapacity - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - """ - - _validation = { - "asset_id": {"readonly": True}, - } - - _attribute_map = { - "asset_id": {"key": "assetId", "type": "str"}, - "available_capacity": {"key": "availableCapacity", "type": "DedicatedHostAvailableCapacity"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword available_capacity: Unutilized capacity of the dedicated host. - :paramtype available_capacity: - ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostAvailableCapacity - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.asset_id: Optional[str] = None - self.available_capacity = available_capacity - self.statuses = statuses - - -class DedicatedHostListResult(_serialization.Model): - """The list dedicated host operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of dedicated hosts. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.DedicatedHost] - :ivar next_link: The URI to fetch the next page of dedicated hosts. Call ListNext() with this - URI to fetch the next page of dedicated hosts. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DedicatedHost]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.DedicatedHost"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of dedicated hosts. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.DedicatedHost] - :keyword next_link: The URI to fetch the next page of dedicated hosts. Call ListNext() with - this URI to fetch the next page of dedicated hosts. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DedicatedHostUpdate(UpdateResource): - """Specifies information about the dedicated host. Only tags, autoReplaceOnFailure and licenseType - may be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar platform_fault_domain: Fault domain of the dedicated host within a dedicated host group. - :vartype platform_fault_domain: int - :ivar auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :vartype auto_replace_on_failure: bool - :ivar host_id: A unique id generated and assigned to the dedicated host by the platform. - :code:`
    `\\ :code:`
    ` Does not change throughout the lifetime of the host. - :vartype host_id: str - :ivar virtual_machines: A list of references to all virtual machines in the Dedicated Host. - :vartype virtual_machines: list[~azure.mgmt.compute.v2019_07_01.models.SubResourceReadOnly] - :ivar license_type: Specifies the software license type that will be applied to the VMs - deployed on the dedicated host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ - :code:`
    ` **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. Known - values are: "None", "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :vartype license_type: str or ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostLicenseTypes - :ivar provisioning_time: The date when the host was first provisioned. - :vartype provisioning_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The dedicated host instance view. - :vartype instance_view: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostInstanceView - """ - - _validation = { - "platform_fault_domain": {"maximum": 2, "minimum": 0}, - "host_id": {"readonly": True}, - "virtual_machines": {"readonly": True}, - "provisioning_time": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "platform_fault_domain": {"key": "properties.platformFaultDomain", "type": "int"}, - "auto_replace_on_failure": {"key": "properties.autoReplaceOnFailure", "type": "bool"}, - "host_id": {"key": "properties.hostId", "type": "str"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResourceReadOnly]"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "provisioning_time": {"key": "properties.provisioningTime", "type": "iso-8601"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostInstanceView"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - platform_fault_domain: Optional[int] = None, - auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword platform_fault_domain: Fault domain of the dedicated host within a dedicated host - group. - :paramtype platform_fault_domain: int - :keyword auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :paramtype auto_replace_on_failure: bool - :keyword license_type: Specifies the software license type that will be applied to the VMs - deployed on the dedicated host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ - :code:`
    ` **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. Known - values are: "None", "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :paramtype license_type: str or - ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostLicenseTypes - """ - super().__init__(tags=tags, **kwargs) - self.platform_fault_domain = platform_fault_domain - self.auto_replace_on_failure = auto_replace_on_failure - self.host_id: Optional[str] = None - self.virtual_machines: Optional[List["_models.SubResourceReadOnly"]] = None - self.license_type = license_type - self.provisioning_time: Optional[datetime.datetime] = None - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.DedicatedHostInstanceView"] = None - - -class DiagnosticsProfile(_serialization.Model): - """Specifies the boot diagnostic settings state. :code:`
    `\\ :code:`
    `Minimum api-version: - 2015-06-15. - - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2019_07_01.models.BootDiagnostics - """ - - _attribute_map = { - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnostics"}, - } - - def __init__(self, *, boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs: Any) -> None: - """ - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2019_07_01.models.BootDiagnostics - """ - super().__init__(**kwargs) - self.boot_diagnostics = boot_diagnostics - - -class DiffDiskSettings(_serialization.Model): - """Describes the parameters of ephemeral disk settings that can be specified for operating system - disk. :code:`
    `\\ :code:`
    ` NOTE: The ephemeral disk settings can only be specified for - managed disk. - - :ivar option: Specifies the ephemeral disk settings for operating system disk. "Local" - :vartype option: str or ~azure.mgmt.compute.v2019_07_01.models.DiffDiskOptions - """ - - _attribute_map = { - "option": {"key": "option", "type": "str"}, - } - - def __init__(self, *, option: Optional[Union[str, "_models.DiffDiskOptions"]] = None, **kwargs: Any) -> None: - """ - :keyword option: Specifies the ephemeral disk settings for operating system disk. "Local" - :paramtype option: str or ~azure.mgmt.compute.v2019_07_01.models.DiffDiskOptions - """ - super().__init__(**kwargs) - self.option = option - - -class Disallowed(_serialization.Model): - """Describes the disallowed disk types. - - :ivar disk_types: A list of disk types. - :vartype disk_types: list[str] - """ - - _attribute_map = { - "disk_types": {"key": "diskTypes", "type": "[str]"}, - } - - def __init__(self, *, disk_types: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword disk_types: A list of disk types. - :paramtype disk_types: list[str] - """ - super().__init__(**kwargs) - self.disk_types = disk_types - - -class Disk(Resource): - """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. - :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] - :ivar managed_by: A relative URI containing the ID of the VM that has the disk attached. - :vartype managed_by: str - :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or - UltraSSD_LRS. - :vartype sku: ~azure.mgmt.compute.v2019_07_01.models.DiskSku - :ivar zones: The Logical zone list for Disk. - :vartype zones: list[str] - :ivar time_created: The time when the disk was created. - :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGeneration - :ivar creation_data: Disk source information. CreationData information cannot be changed after - the disk has been created. - :vartype creation_data: ~azure.mgmt.compute.v2019_07_01.models.CreationData - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. - :vartype disk_size_bytes: int - :ivar unique_id: Unique Guid identifying the resource. - :vartype unique_id: str - :ivar encryption_settings_collection: Encryption settings collection used for Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2019_07_01.models.EncryptionSettingsCollection - :ivar provisioning_state: The disk provisioning state. - :vartype provisioning_state: str - :ivar disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :vartype disk_m_bps_read_write: int - :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", - "Reserved", "ActiveSAS", "ReadyToUpload", and "ActiveUpload". - :vartype disk_state: str or ~azure.mgmt.compute.v2019_07_01.models.DiskState - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2019_07_01.models.Encryption - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "managed_by": {"readonly": True}, - "time_created": {"readonly": True}, - "disk_size_bytes": {"readonly": True}, - "unique_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "disk_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "sku": {"key": "sku", "type": "DiskSku"}, - "zones": {"key": "zones", "type": "[str]"}, - "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "creation_data": {"key": "properties.creationData", "type": "CreationData"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "disk_size_bytes": {"key": "properties.diskSizeBytes", "type": "int"}, - "unique_id": {"key": "properties.uniqueId", "type": "str"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "disk_iops_read_write": {"key": "properties.diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "properties.diskMBpsReadWrite", "type": "int"}, - "disk_state": {"key": "properties.diskState", "type": "str"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.DiskSku"] = None, - zones: Optional[List[str]] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - creation_data: Optional["_models.CreationData"] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - disk_iops_read_write: Optional[int] = None, - disk_m_bps_read_write: Optional[int] = None, - encryption: Optional["_models.Encryption"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or - UltraSSD_LRS. - :paramtype sku: ~azure.mgmt.compute.v2019_07_01.models.DiskSku - :keyword zones: The Logical zone list for Disk. - :paramtype zones: list[str] - :keyword os_type: The Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :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.v2019_07_01.models.HyperVGeneration - :keyword creation_data: Disk source information. CreationData information cannot be changed - after the disk has been created. - :paramtype creation_data: ~azure.mgmt.compute.v2019_07_01.models.CreationData - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used for Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2019_07_01.models.EncryptionSettingsCollection - :keyword disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_write: int - :keyword disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :paramtype disk_m_bps_read_write: int - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2019_07_01.models.Encryption - """ - super().__init__(location=location, tags=tags, **kwargs) - self.managed_by: Optional[str] = None - self.sku = sku - self.zones = zones - self.time_created: Optional[datetime.datetime] = None - self.os_type = os_type - self.hyper_v_generation = hyper_v_generation - self.creation_data = creation_data - self.disk_size_gb = disk_size_gb - self.disk_size_bytes: Optional[int] = None - self.unique_id: Optional[str] = None - self.encryption_settings_collection = encryption_settings_collection - self.provisioning_state: Optional[str] = None - self.disk_iops_read_write = disk_iops_read_write - self.disk_m_bps_read_write = disk_m_bps_read_write - self.disk_state: Optional[Union[str, "_models.DiskState"]] = None - self.encryption = encryption - - -class DiskEncryptionSet(Resource): - """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. - :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] - :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.v2019_07_01.models.EncryptionSetIdentity - :ivar active_key: The key vault key which is currently used by this disk encryption set. - :vartype active_key: ~azure.mgmt.compute.v2019_07_01.models.KeyVaultAndKeyReference - :ivar previous_keys: A readonly collection of key vault keys previously used by this disk - encryption set while a key rotation is in progress. It will be empty if there is no ongoing key - rotation. - :vartype previous_keys: list[~azure.mgmt.compute.v2019_07_01.models.KeyVaultAndKeyReference] - :ivar provisioning_state: The disk encryption set provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "previous_keys": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "identity": {"key": "identity", "type": "EncryptionSetIdentity"}, - "active_key": {"key": "properties.activeKey", "type": "KeyVaultAndKeyReference"}, - "previous_keys": {"key": "properties.previousKeys", "type": "[KeyVaultAndKeyReference]"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.EncryptionSetIdentity"] = None, - active_key: Optional["_models.KeyVaultAndKeyReference"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2019_07_01.models.EncryptionSetIdentity - :keyword active_key: The key vault key which is currently used by this disk encryption set. - :paramtype active_key: ~azure.mgmt.compute.v2019_07_01.models.KeyVaultAndKeyReference - """ - super().__init__(location=location, tags=tags, **kwargs) - self.identity = identity - self.active_key = active_key - self.previous_keys: Optional[List["_models.KeyVaultAndKeyReference"]] = None - self.provisioning_state: Optional[str] = None - - -class DiskEncryptionSetList(_serialization.Model): - """The List disk encryption set operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of disk encryption sets. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DiskEncryptionSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DiskEncryptionSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of disk encryption sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SubResource(_serialization.Model): - """SubResource. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class DiskEncryptionSetParameters(SubResource): - """Describes the parameter of customer managed disk encryption set resource id that can be - specified for disk. :code:`
    `\\ :code:`
    ` NOTE: The disk encryption set resource id can - only be specified for managed disk. Please refer https://aka.ms/mdssewithcmkoverview for more - details. - - :ivar id: Resource Id. - :vartype id: str - """ - - -class DiskEncryptionSettings(_serialization.Model): - """Describes a Encryption Settings for a Disk. - - :ivar disk_encryption_key: Specifies the location of the disk encryption key, which is a Key - Vault Secret. - :vartype disk_encryption_key: ~azure.mgmt.compute.v2019_07_01.models.KeyVaultSecretReference - :ivar key_encryption_key: Specifies the location of the key encryption key in Key Vault. - :vartype key_encryption_key: ~azure.mgmt.compute.v2019_07_01.models.KeyVaultKeyReference - :ivar enabled: Specifies whether disk encryption should be enabled on the virtual machine. - :vartype enabled: bool - """ - - _attribute_map = { - "disk_encryption_key": {"key": "diskEncryptionKey", "type": "KeyVaultSecretReference"}, - "key_encryption_key": {"key": "keyEncryptionKey", "type": "KeyVaultKeyReference"}, - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__( - self, - *, - disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, - key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, - enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_key: Specifies the location of the disk encryption key, which is a Key - Vault Secret. - :paramtype disk_encryption_key: ~azure.mgmt.compute.v2019_07_01.models.KeyVaultSecretReference - :keyword key_encryption_key: Specifies the location of the key encryption key in Key Vault. - :paramtype key_encryption_key: ~azure.mgmt.compute.v2019_07_01.models.KeyVaultKeyReference - :keyword enabled: Specifies whether disk encryption should be enabled on the virtual machine. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.disk_encryption_key = disk_encryption_key - self.key_encryption_key = key_encryption_key - self.enabled = enabled - - -class DiskEncryptionSetUpdate(_serialization.Model): - """disk encryption set update resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar active_key: Key Vault Key Url and vault id of KeK, KeK is optional and when provided is - used to unwrap the encryptionKey. - :vartype active_key: ~azure.mgmt.compute.v2019_07_01.models.KeyVaultAndKeyReference - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "active_key": {"key": "properties.activeKey", "type": "KeyVaultAndKeyReference"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - active_key: Optional["_models.KeyVaultAndKeyReference"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword active_key: Key Vault Key Url and vault id of KeK, KeK is optional and when provided - is used to unwrap the encryptionKey. - :paramtype active_key: ~azure.mgmt.compute.v2019_07_01.models.KeyVaultAndKeyReference - """ - super().__init__(**kwargs) - self.tags = tags - self.active_key = active_key - - -class DiskInstanceView(_serialization.Model): - """The instance view of the disk. - - :ivar name: The disk name. - :vartype name: str - :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :vartype encryption_settings: - list[~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSettings] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "encryption_settings": {"key": "encryptionSettings", "type": "[DiskEncryptionSettings]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype encryption_settings: - list[~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSettings] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.name = name - self.encryption_settings = encryption_settings - self.statuses = statuses - - -class DiskList(_serialization.Model): - """The List Disks operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of disks. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Disk]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of disks. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DiskSku(_serialization.Model): - """The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", - and "UltraSSD_LRS". - :vartype name: str or ~azure.mgmt.compute.v2019_07_01.models.DiskStorageAccountTypes - :ivar tier: The sku tier. - :vartype tier: str - """ - - _validation = { - "tier": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__(self, *, name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs: Any) -> None: - """ - :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", and "UltraSSD_LRS". - :paramtype name: str or ~azure.mgmt.compute.v2019_07_01.models.DiskStorageAccountTypes - """ - super().__init__(**kwargs) - self.name = name - self.tier: Optional[str] = None - - -class DiskUpdate(_serialization.Model): - """Disk update resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or - UltraSSD_LRS. - :vartype sku: ~azure.mgmt.compute.v2019_07_01.models.DiskSku - :ivar os_type: the Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2019_07_01.models.EncryptionSettingsCollection - :ivar disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :vartype disk_m_bps_read_write: int - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2019_07_01.models.Encryption - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "DiskSku"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "disk_iops_read_write": {"key": "properties.diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "properties.diskMBpsReadWrite", "type": "int"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.DiskSku"] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - disk_iops_read_write: Optional[int] = None, - disk_m_bps_read_write: Optional[int] = None, - encryption: Optional["_models.Encryption"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or - UltraSSD_LRS. - :paramtype sku: ~azure.mgmt.compute.v2019_07_01.models.DiskSku - :keyword os_type: the Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2019_07_01.models.EncryptionSettingsCollection - :keyword disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_write: int - :keyword disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :paramtype disk_m_bps_read_write: int - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2019_07_01.models.Encryption - """ - super().__init__(**kwargs) - self.tags = tags - self.sku = sku - self.os_type = os_type - self.disk_size_gb = disk_size_gb - self.encryption_settings_collection = encryption_settings_collection - self.disk_iops_read_write = disk_iops_read_write - self.disk_m_bps_read_write = disk_m_bps_read_write - self.encryption = encryption - - -class Encryption(_serialization.Model): - """Encryption at rest settings for disk or snapshot. - - All required parameters must be populated in order to send to server. - - :ivar disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling - encryption at rest. - :vartype disk_encryption_set_id: str - :ivar type: The type of key used to encrypt the data of the disk. Required. Known values are: - "EncryptionAtRestWithPlatformKey" and "EncryptionAtRestWithCustomerKey". - :vartype type: str or ~azure.mgmt.compute.v2019_07_01.models.EncryptionType - """ - - _validation = { - "type": {"required": True}, - } - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, *, type: Union[str, "_models.EncryptionType"], disk_encryption_set_id: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling - encryption at rest. - :paramtype disk_encryption_set_id: str - :keyword type: The type of key used to encrypt the data of the disk. Required. Known values - are: "EncryptionAtRestWithPlatformKey" and "EncryptionAtRestWithCustomerKey". - :paramtype type: str or ~azure.mgmt.compute.v2019_07_01.models.EncryptionType - """ - super().__init__(**kwargs) - self.disk_encryption_set_id = disk_encryption_set_id - self.type = type - - -class EncryptionSetIdentity(_serialization.Model): - """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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is - supported. "SystemAssigned" - :vartype type: str or ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetIdentityType - :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-client-tenant-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype tenant_id: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__( - self, *, type: Optional[Union[str, "_models.DiskEncryptionSetIdentityType"]] = None, **kwargs: Any - ) -> None: - """ - :keyword type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned - is supported. "SystemAssigned" - :paramtype type: str or ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetIdentityType - """ - super().__init__(**kwargs) - self.type = type - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - - -class EncryptionSettingsCollection(_serialization.Model): - """Encryption settings for disk or snapshot. - - All required parameters must be populated in order to send to server. - - :ivar enabled: Set this flag to true and provide DiskEncryptionKey and optional - KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and - KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, - the existing settings remain unchanged. Required. - :vartype enabled: bool - :ivar encryption_settings: A collection of encryption settings, one for each disk volume. - :vartype encryption_settings: - list[~azure.mgmt.compute.v2019_07_01.models.EncryptionSettingsElement] - :ivar encryption_settings_version: Describes what type of encryption is used for the disks. - Once this field is set, it cannot be overwritten. '1.0' corresponds to Azure Disk Encryption - with AAD app.'1.1' corresponds to Azure Disk Encryption. - :vartype encryption_settings_version: str - """ - - _validation = { - "enabled": {"required": True}, - } - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "encryption_settings": {"key": "encryptionSettings", "type": "[EncryptionSettingsElement]"}, - "encryption_settings_version": {"key": "encryptionSettingsVersion", "type": "str"}, - } - - def __init__( - self, - *, - enabled: bool, - encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, - encryption_settings_version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Set this flag to true and provide DiskEncryptionKey and optional - KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and - KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, - the existing settings remain unchanged. Required. - :paramtype enabled: bool - :keyword encryption_settings: A collection of encryption settings, one for each disk volume. - :paramtype encryption_settings: - list[~azure.mgmt.compute.v2019_07_01.models.EncryptionSettingsElement] - :keyword encryption_settings_version: Describes what type of encryption is used for the disks. - Once this field is set, it cannot be overwritten. '1.0' corresponds to Azure Disk Encryption - with AAD app.'1.1' corresponds to Azure Disk Encryption. - :paramtype encryption_settings_version: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.encryption_settings = encryption_settings - self.encryption_settings_version = encryption_settings_version - - -class EncryptionSettingsElement(_serialization.Model): - """Encryption settings for one disk volume. - - :ivar disk_encryption_key: Key Vault Secret Url and vault id of the disk encryption key. - :vartype disk_encryption_key: ~azure.mgmt.compute.v2019_07_01.models.KeyVaultAndSecretReference - :ivar key_encryption_key: Key Vault Key Url and vault id of the key encryption key. - KeyEncryptionKey is optional and when provided is used to unwrap the disk encryption key. - :vartype key_encryption_key: ~azure.mgmt.compute.v2019_07_01.models.KeyVaultAndKeyReference - """ - - _attribute_map = { - "disk_encryption_key": {"key": "diskEncryptionKey", "type": "KeyVaultAndSecretReference"}, - "key_encryption_key": {"key": "keyEncryptionKey", "type": "KeyVaultAndKeyReference"}, - } - - def __init__( - self, - *, - disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_key: Key Vault Secret Url and vault id of the disk encryption key. - :paramtype disk_encryption_key: - ~azure.mgmt.compute.v2019_07_01.models.KeyVaultAndSecretReference - :keyword key_encryption_key: Key Vault Key Url and vault id of the key encryption key. - KeyEncryptionKey is optional and when provided is used to unwrap the disk encryption key. - :paramtype key_encryption_key: ~azure.mgmt.compute.v2019_07_01.models.KeyVaultAndKeyReference - """ - super().__init__(**kwargs) - self.disk_encryption_key = disk_encryption_key - self.key_encryption_key = key_encryption_key - - -class Gallery(Resource): - """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. - :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] - :ivar description: The description of this Shared Image Gallery resource. This property is - updatable. - :vartype description: str - :ivar identifier: Describes the gallery unique name. - :vartype identifier: ~azure.mgmt.compute.v2019_07_01.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2019_07_01.models.GalleryPropertiesProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "identifier": {"key": "properties.identifier", "type": "GalleryIdentifier"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - identifier: Optional["_models.GalleryIdentifier"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this Shared Image Gallery resource. This property is - updatable. - :paramtype description: str - :keyword identifier: Describes the gallery unique name. - :paramtype identifier: ~azure.mgmt.compute.v2019_07_01.models.GalleryIdentifier - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.identifier = identifier - self.provisioning_state: Optional[Union[str, "_models.GalleryPropertiesProvisioningState"]] = None - - -class GalleryApplication(Resource): - """Specifies information about the gallery Application 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. - :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] - :ivar description: The description of this gallery Application Definition resource. This - property is updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery Application Definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar supported_os_type: This property allows you to specify the supported type of the OS that - application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :vartype supported_os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - """ - - _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}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "supported_os_type": {"key": "properties.supportedOSType", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery Application Definition resource. This - property is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery Application Definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: str - :keyword end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword supported_os_type: This property allows you to specify the supported type of the OS - that application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :paramtype supported_os_type: str or - ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.end_of_life_date = end_of_life_date - self.supported_os_type = supported_os_type - - -class GalleryApplicationList(_serialization.Model): - """The List Gallery Applications operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of Gallery Applications. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryApplication]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.GalleryApplication"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of Gallery Applications. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryApplicationUpdate(UpdateResource): - """Specifies information about the gallery Application Definition that you want to update. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar description: The description of this gallery Application Definition resource. This - property is updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery Application Definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar supported_os_type: This property allows you to specify the supported type of the OS that - application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :vartype supported_os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "supported_os_type": {"key": "properties.supportedOSType", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery Application Definition resource. This - property is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery Application Definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: str - :keyword end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword supported_os_type: This property allows you to specify the supported type of the OS - that application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :paramtype supported_os_type: str or - ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - """ - super().__init__(tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.end_of_life_date = end_of_life_date - self.supported_os_type = supported_os_type - - -class GalleryApplicationVersion(Resource): - """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. - :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] - :ivar publishing_profile: The publishing profile of a gallery image version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersionPropertiesProvisioningState - :ivar replication_status: This is the replication status of the gallery Image Version. - :vartype replication_status: ~azure.mgmt.compute.v2019_07_01.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": 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}"}, - "publishing_profile": { - "key": "properties.publishingProfile", - "type": "GalleryApplicationVersionPublishingProfile", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersionPublishingProfile - """ - super().__init__(location=location, tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[ - Union[str, "_models.GalleryApplicationVersionPropertiesProvisioningState"] - ] = None - self.replication_status: Optional["_models.ReplicationStatus"] = None - - -class GalleryApplicationVersionList(_serialization.Model): - """The List Gallery Application version operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of gallery Application Versions. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersion] - :ivar next_link: The uri to fetch the next page of gallery Application Versions. Call - ListNext() with this to fetch the next page of gallery Application Versions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryApplicationVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.GalleryApplicationVersion"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of gallery Application Versions. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersion] - :keyword next_link: The uri to fetch the next page of gallery Application Versions. Call - ListNext() with this to fetch the next page of gallery Application Versions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryArtifactPublishingProfileBase(_serialization.Model): - """Describes the basic gallery artifact publishing profile. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar target_regions: The target regions where the Image Version is going to be replicated to. - This property is updatable. - :vartype target_regions: list[~azure.mgmt.compute.v2019_07_01.models.TargetRegion] - :ivar replica_count: The number of replicas of the Image Version to be created per region. This - property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :vartype replica_count: int - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar published_date: The timestamp for when the gallery Image Version is published. - :vartype published_date: ~datetime.datetime - :ivar end_of_life_date: The end of life date of the gallery Image Version. This property can be - used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS" and "Standard_ZRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountType - """ - - _validation = { - "published_date": {"readonly": True}, - } - - _attribute_map = { - "target_regions": {"key": "targetRegions", "type": "[TargetRegion]"}, - "replica_count": {"key": "replicaCount", "type": "int"}, - "exclude_from_latest": {"key": "excludeFromLatest", "type": "bool"}, - "published_date": {"key": "publishedDate", "type": "iso-8601"}, - "end_of_life_date": {"key": "endOfLifeDate", "type": "iso-8601"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - } - - def __init__( - self, - *, - target_regions: Optional[List["_models.TargetRegion"]] = None, - replica_count: Optional[int] = None, - exclude_from_latest: Optional[bool] = None, - end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword target_regions: The target regions where the Image Version is going to be replicated - to. This property is updatable. - :paramtype target_regions: list[~azure.mgmt.compute.v2019_07_01.models.TargetRegion] - :keyword replica_count: The number of replicas of the Image Version to be created per region. - This property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :paramtype replica_count: int - :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 end_of_life_date: The end of life date of the gallery Image Version. This property can - be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS" and "Standard_ZRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2019_07_01.models.StorageAccountType - """ - super().__init__(**kwargs) - self.target_regions = target_regions - self.replica_count = replica_count - self.exclude_from_latest = exclude_from_latest - self.published_date: Optional[datetime.datetime] = None - self.end_of_life_date = end_of_life_date - self.storage_account_type = storage_account_type - - -class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfileBase): # pylint: disable=name-too-long - """The publishing profile of a gallery image version. - - 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 target_regions: The target regions where the Image Version is going to be replicated to. - This property is updatable. - :vartype target_regions: list[~azure.mgmt.compute.v2019_07_01.models.TargetRegion] - :ivar replica_count: The number of replicas of the Image Version to be created per region. This - property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :vartype replica_count: int - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar published_date: The timestamp for when the gallery Image Version is published. - :vartype published_date: ~datetime.datetime - :ivar end_of_life_date: The end of life date of the gallery Image Version. This property can be - used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS" and "Standard_ZRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountType - :ivar source: The source image from which the Image Version is going to be created. Required. - :vartype source: ~azure.mgmt.compute.v2019_07_01.models.UserArtifactSource - :ivar manage_actions: - :vartype manage_actions: ~azure.mgmt.compute.v2019_07_01.models.UserArtifactManage - :ivar enable_health_check: Optional. Whether or not this application reports health. - :vartype enable_health_check: bool - """ - - _validation = { - "published_date": {"readonly": True}, - "source": {"required": True}, - } - - _attribute_map = { - "target_regions": {"key": "targetRegions", "type": "[TargetRegion]"}, - "replica_count": {"key": "replicaCount", "type": "int"}, - "exclude_from_latest": {"key": "excludeFromLatest", "type": "bool"}, - "published_date": {"key": "publishedDate", "type": "iso-8601"}, - "end_of_life_date": {"key": "endOfLifeDate", "type": "iso-8601"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "source": {"key": "source", "type": "UserArtifactSource"}, - "manage_actions": {"key": "manageActions", "type": "UserArtifactManage"}, - "enable_health_check": {"key": "enableHealthCheck", "type": "bool"}, - } - - def __init__( - self, - *, - source: "_models.UserArtifactSource", - target_regions: Optional[List["_models.TargetRegion"]] = None, - replica_count: Optional[int] = None, - exclude_from_latest: Optional[bool] = None, - end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - manage_actions: Optional["_models.UserArtifactManage"] = None, - enable_health_check: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword target_regions: The target regions where the Image Version is going to be replicated - to. This property is updatable. - :paramtype target_regions: list[~azure.mgmt.compute.v2019_07_01.models.TargetRegion] - :keyword replica_count: The number of replicas of the Image Version to be created per region. - This property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :paramtype replica_count: int - :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 end_of_life_date: The end of life date of the gallery Image Version. This property can - be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS" and "Standard_ZRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2019_07_01.models.StorageAccountType - :keyword source: The source image from which the Image Version is going to be created. - Required. - :paramtype source: ~azure.mgmt.compute.v2019_07_01.models.UserArtifactSource - :keyword manage_actions: - :paramtype manage_actions: ~azure.mgmt.compute.v2019_07_01.models.UserArtifactManage - :keyword enable_health_check: Optional. Whether or not this application reports health. - :paramtype enable_health_check: bool - """ - super().__init__( - target_regions=target_regions, - replica_count=replica_count, - exclude_from_latest=exclude_from_latest, - end_of_life_date=end_of_life_date, - storage_account_type=storage_account_type, - **kwargs - ) - self.source = source - self.manage_actions = manage_actions - self.enable_health_check = enable_health_check - - -class GalleryApplicationVersionUpdate(UpdateResource): - """Specifies information about the gallery Application Version that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar publishing_profile: The publishing profile of a gallery image version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersionPropertiesProvisioningState - :ivar replication_status: This is the replication status of the gallery Image Version. - :vartype replication_status: ~azure.mgmt.compute.v2019_07_01.models.ReplicationStatus - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "publishing_profile": { - "key": "properties.publishingProfile", - "type": "GalleryApplicationVersionPublishingProfile", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersionPublishingProfile - """ - super().__init__(tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[ - Union[str, "_models.GalleryApplicationVersionPropertiesProvisioningState"] - ] = None - self.replication_status: Optional["_models.ReplicationStatus"] = 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.v2019_07_01.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.v2019_07_01.models.ManagedArtifact - """ - super().__init__(**kwargs) - self.managed_image = managed_image - - -class GalleryArtifactVersionSource(_serialization.Model): - """The gallery artifact version source. - - :ivar id: The id of the gallery artifact version source. Can specify a disk uri, snapshot uri, - or user image. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: The id of the gallery artifact version source. Can specify a disk uri, snapshot - uri, or user image. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class GalleryDiskImage(_serialization.Model): - """This is the disk image base class. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar size_in_gb: This property indicates the size of the VHD to be created. - :vartype size_in_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2019_07_01.models.HostCaching - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2019_07_01.models.GalleryArtifactVersionSource - """ - - _validation = { - "size_in_gb": {"readonly": True}, - } - - _attribute_map = { - "size_in_gb": {"key": "sizeInGB", "type": "int"}, - "host_caching": {"key": "hostCaching", "type": "str"}, - "source": {"key": "source", "type": "GalleryArtifactVersionSource"}, - } - - def __init__( - self, - *, - host_caching: Optional[Union[str, "_models.HostCaching"]] = None, - source: Optional["_models.GalleryArtifactVersionSource"] = 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.v2019_07_01.models.HostCaching - :keyword source: The gallery artifact version source. - :paramtype source: ~azure.mgmt.compute.v2019_07_01.models.GalleryArtifactVersionSource - """ - super().__init__(**kwargs) - self.size_in_gb: Optional[int] = None - self.host_caching = host_caching - self.source = source - - -class GalleryDataDiskImage(GalleryDiskImage): - """This is the data disk 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 size_in_gb: This property indicates the size of the VHD to be created. - :vartype size_in_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2019_07_01.models.HostCaching - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2019_07_01.models.GalleryArtifactVersionSource - :ivar 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. - :vartype lun: int - """ - - _validation = { - "size_in_gb": {"readonly": True}, - "lun": {"required": True}, - } - - _attribute_map = { - "size_in_gb": {"key": "sizeInGB", "type": "int"}, - "host_caching": {"key": "hostCaching", "type": "str"}, - "source": {"key": "source", "type": "GalleryArtifactVersionSource"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__( - self, - *, - lun: int, - host_caching: Optional[Union[str, "_models.HostCaching"]] = None, - source: Optional["_models.GalleryArtifactVersionSource"] = 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.v2019_07_01.models.HostCaching - :keyword source: The gallery artifact version source. - :paramtype source: ~azure.mgmt.compute.v2019_07_01.models.GalleryArtifactVersionSource - :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, source=source, **kwargs) - self.lun = lun - - -class GalleryIdentifier(_serialization.Model): - """Describes the gallery unique name. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar unique_name: The unique name of the Shared Image Gallery. This name is generated - automatically by Azure. - :vartype unique_name: str - """ - - _validation = { - "unique_name": {"readonly": True}, - } - - _attribute_map = { - "unique_name": {"key": "uniqueName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.unique_name: Optional[str] = None - - -class GalleryImage(Resource): - """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. - :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] - :ivar description: The description of this gallery Image Definition resource. This property is - updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery Image Definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar 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. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values - are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :ivar 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". - :vartype os_state: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemStateTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGeneration - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar identifier: This is the gallery Image Definition identifier. - :vartype identifier: ~azure.mgmt.compute.v2019_07_01.models.GalleryImageIdentifier - :ivar recommended: The properties describe the recommended machine configuration for this Image - Definition. These properties are updatable. - :vartype recommended: ~azure.mgmt.compute.v2019_07_01.models.RecommendedMachineConfiguration - :ivar disallowed: Describes the disallowed disk types. - :vartype disallowed: ~azure.mgmt.compute.v2019_07_01.models.Disallowed - :ivar purchase_plan: Describes the gallery Image Definition purchase plan. This is used by - marketplace images. - :vartype purchase_plan: ~azure.mgmt.compute.v2019_07_01.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2019_07_01.models.GalleryImagePropertiesProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "os_state": {"key": "properties.osState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, - "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["_models.GalleryImageIdentifier"] = None, - recommended: Optional["_models.RecommendedMachineConfiguration"] = None, - disallowed: Optional["_models.Disallowed"] = None, - purchase_plan: Optional["_models.ImagePurchasePlan"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery Image Definition resource. This property - is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery Image Definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: 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. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.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.v2019_07_01.models.OperatingSystemStateTypes - :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.v2019_07_01.models.HyperVGeneration - :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.v2019_07_01.models.GalleryImageIdentifier - :keyword recommended: The properties describe the recommended machine configuration for this - Image Definition. These properties are updatable. - :paramtype recommended: ~azure.mgmt.compute.v2019_07_01.models.RecommendedMachineConfiguration - :keyword disallowed: Describes the disallowed disk types. - :paramtype disallowed: ~azure.mgmt.compute.v2019_07_01.models.Disallowed - :keyword purchase_plan: Describes the gallery Image Definition purchase plan. This is used by - marketplace images. - :paramtype purchase_plan: ~azure.mgmt.compute.v2019_07_01.models.ImagePurchasePlan - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.os_type = os_type - self.os_state = os_state - self.hyper_v_generation = hyper_v_generation - self.end_of_life_date = end_of_life_date - self.identifier = identifier - self.recommended = recommended - self.disallowed = disallowed - self.purchase_plan = purchase_plan - self.provisioning_state: Optional[Union[str, "_models.GalleryImagePropertiesProvisioningState"]] = None - - -class GalleryImageIdentifier(_serialization.Model): - """This is the gallery Image Definition identifier. - - All required parameters must be populated in order to send to server. - - :ivar publisher: The name of the gallery Image Definition publisher. Required. - :vartype publisher: str - :ivar offer: The name of the gallery Image Definition offer. Required. - :vartype offer: str - :ivar sku: The name of the gallery Image Definition SKU. Required. - :vartype sku: str - """ - - _validation = { - "publisher": {"required": True}, - "offer": {"required": True}, - "sku": {"required": True}, - } - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "offer": {"key": "offer", "type": "str"}, - "sku": {"key": "sku", "type": "str"}, - } - - def __init__(self, *, publisher: str, offer: str, sku: str, **kwargs: Any) -> None: - """ - :keyword publisher: The name of the gallery Image Definition publisher. Required. - :paramtype publisher: str - :keyword offer: The name of the gallery Image Definition offer. Required. - :paramtype offer: str - :keyword sku: The name of the gallery Image Definition SKU. Required. - :paramtype sku: str - """ - super().__init__(**kwargs) - self.publisher = publisher - self.offer = offer - self.sku = sku - - -class GalleryImageList(_serialization.Model): - """The List Gallery Images operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of Shared Image Gallery images. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.GalleryImage] - :ivar next_link: The uri to fetch the next page of Image Definitions in the Shared Image - Gallery. Call ListNext() with this to fetch the next page of gallery Image Definitions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryImage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.GalleryImage"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of Shared Image Gallery images. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.GalleryImage] - :keyword next_link: The uri to fetch the next page of Image Definitions in the Shared Image - Gallery. Call ListNext() with this to fetch the next page of gallery Image Definitions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryImageUpdate(UpdateResource): - """Specifies information about the gallery Image Definition that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar description: The description of this gallery Image Definition resource. This property is - updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery Image Definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar 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. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values - are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :ivar 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". - :vartype os_state: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemStateTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGeneration - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar identifier: This is the gallery Image Definition identifier. - :vartype identifier: ~azure.mgmt.compute.v2019_07_01.models.GalleryImageIdentifier - :ivar recommended: The properties describe the recommended machine configuration for this Image - Definition. These properties are updatable. - :vartype recommended: ~azure.mgmt.compute.v2019_07_01.models.RecommendedMachineConfiguration - :ivar disallowed: Describes the disallowed disk types. - :vartype disallowed: ~azure.mgmt.compute.v2019_07_01.models.Disallowed - :ivar purchase_plan: Describes the gallery Image Definition purchase plan. This is used by - marketplace images. - :vartype purchase_plan: ~azure.mgmt.compute.v2019_07_01.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2019_07_01.models.GalleryImagePropertiesProvisioningState - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "os_state": {"key": "properties.osState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, - "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["_models.GalleryImageIdentifier"] = None, - recommended: Optional["_models.RecommendedMachineConfiguration"] = None, - disallowed: Optional["_models.Disallowed"] = None, - purchase_plan: Optional["_models.ImagePurchasePlan"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery Image Definition resource. This property - is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery Image Definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: 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. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.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.v2019_07_01.models.OperatingSystemStateTypes - :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.v2019_07_01.models.HyperVGeneration - :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.v2019_07_01.models.GalleryImageIdentifier - :keyword recommended: The properties describe the recommended machine configuration for this - Image Definition. These properties are updatable. - :paramtype recommended: ~azure.mgmt.compute.v2019_07_01.models.RecommendedMachineConfiguration - :keyword disallowed: Describes the disallowed disk types. - :paramtype disallowed: ~azure.mgmt.compute.v2019_07_01.models.Disallowed - :keyword purchase_plan: Describes the gallery Image Definition purchase plan. This is used by - marketplace images. - :paramtype purchase_plan: ~azure.mgmt.compute.v2019_07_01.models.ImagePurchasePlan - """ - super().__init__(tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.os_type = os_type - self.os_state = os_state - self.hyper_v_generation = hyper_v_generation - self.end_of_life_date = end_of_life_date - self.identifier = identifier - self.recommended = recommended - self.disallowed = disallowed - self.purchase_plan = purchase_plan - self.provisioning_state: Optional[Union[str, "_models.GalleryImagePropertiesProvisioningState"]] = None - - -class GalleryImageVersion(Resource): - """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. - :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] - :ivar publishing_profile: The publishing profile of a gallery Image Version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersionPropertiesProvisioningState - :ivar storage_profile: This is the storage profile of a Gallery Image Version. - :vartype storage_profile: - ~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersionStorageProfile - :ivar replication_status: This is the replication status of the gallery Image Version. - :vartype replication_status: ~azure.mgmt.compute.v2019_07_01.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": 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}"}, - "publishing_profile": {"key": "properties.publishingProfile", "type": "GalleryImageVersionPublishingProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery Image Version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersionPublishingProfile - :keyword storage_profile: This is the storage profile of a Gallery Image Version. - :paramtype storage_profile: - ~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersionStorageProfile - """ - super().__init__(location=location, tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[Union[str, "_models.GalleryImageVersionPropertiesProvisioningState"]] = None - self.storage_profile = storage_profile - self.replication_status: Optional["_models.ReplicationStatus"] = None - - -class GalleryImageVersionList(_serialization.Model): - """The List Gallery Image version operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of gallery Image Versions. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersion] - :ivar next_link: The uri to fetch the next page of gallery Image Versions. Call ListNext() with - this to fetch the next page of gallery Image Versions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryImageVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.GalleryImageVersion"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of gallery Image Versions. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersion] - :keyword next_link: The uri to fetch the next page of gallery Image Versions. Call ListNext() - with this to fetch the next page of gallery Image Versions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase): - """The publishing profile of a gallery Image Version. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar target_regions: The target regions where the Image Version is going to be replicated to. - This property is updatable. - :vartype target_regions: list[~azure.mgmt.compute.v2019_07_01.models.TargetRegion] - :ivar replica_count: The number of replicas of the Image Version to be created per region. This - property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :vartype replica_count: int - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar published_date: The timestamp for when the gallery Image Version is published. - :vartype published_date: ~datetime.datetime - :ivar end_of_life_date: The end of life date of the gallery Image Version. This property can be - used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS" and "Standard_ZRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountType - """ - - -class GalleryImageVersionStorageProfile(_serialization.Model): - """This is the storage profile of a Gallery Image Version. - - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2019_07_01.models.GalleryArtifactVersionSource - :ivar os_disk_image: This is the OS disk image. - :vartype os_disk_image: ~azure.mgmt.compute.v2019_07_01.models.GalleryOSDiskImage - :ivar data_disk_images: A list of data disk images. - :vartype data_disk_images: list[~azure.mgmt.compute.v2019_07_01.models.GalleryDataDiskImage] - """ - - _attribute_map = { - "source": {"key": "source", "type": "GalleryArtifactVersionSource"}, - "os_disk_image": {"key": "osDiskImage", "type": "GalleryOSDiskImage"}, - "data_disk_images": {"key": "dataDiskImages", "type": "[GalleryDataDiskImage]"}, - } - - def __init__( - self, - *, - source: Optional["_models.GalleryArtifactVersionSource"] = None, - os_disk_image: Optional["_models.GalleryOSDiskImage"] = None, - data_disk_images: Optional[List["_models.GalleryDataDiskImage"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source: The gallery artifact version source. - :paramtype source: ~azure.mgmt.compute.v2019_07_01.models.GalleryArtifactVersionSource - :keyword os_disk_image: This is the OS disk image. - :paramtype os_disk_image: ~azure.mgmt.compute.v2019_07_01.models.GalleryOSDiskImage - :keyword data_disk_images: A list of data disk images. - :paramtype data_disk_images: list[~azure.mgmt.compute.v2019_07_01.models.GalleryDataDiskImage] - """ - super().__init__(**kwargs) - self.source = source - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - - -class GalleryImageVersionUpdate(UpdateResource): - """Specifies information about the gallery Image Version that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar publishing_profile: The publishing profile of a gallery Image Version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersionPropertiesProvisioningState - :ivar storage_profile: This is the storage profile of a Gallery Image Version. - :vartype storage_profile: - ~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersionStorageProfile - :ivar replication_status: This is the replication status of the gallery Image Version. - :vartype replication_status: ~azure.mgmt.compute.v2019_07_01.models.ReplicationStatus - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "publishing_profile": {"key": "properties.publishingProfile", "type": "GalleryImageVersionPublishingProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery Image Version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersionPublishingProfile - :keyword storage_profile: This is the storage profile of a Gallery Image Version. - :paramtype storage_profile: - ~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersionStorageProfile - """ - super().__init__(tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[Union[str, "_models.GalleryImageVersionPropertiesProvisioningState"]] = None - self.storage_profile = storage_profile - self.replication_status: Optional["_models.ReplicationStatus"] = None - - -class GalleryList(_serialization.Model): - """The List Galleries operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of galleries. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.Gallery] - :ivar next_link: The uri to fetch the next page of galleries. Call ListNext() with this to - fetch the next page of galleries. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Gallery]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Gallery"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of galleries. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.Gallery] - :keyword next_link: The uri to fetch the next page of galleries. Call ListNext() with this to - fetch the next page of galleries. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryOSDiskImage(GalleryDiskImage): - """This is the OS disk image. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar size_in_gb: This property indicates the size of the VHD to be created. - :vartype size_in_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2019_07_01.models.HostCaching - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2019_07_01.models.GalleryArtifactVersionSource - """ - - -class GalleryUpdate(UpdateResource): - """Specifies information about the Shared Image Gallery that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar description: The description of this Shared Image Gallery resource. This property is - updatable. - :vartype description: str - :ivar identifier: Describes the gallery unique name. - :vartype identifier: ~azure.mgmt.compute.v2019_07_01.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2019_07_01.models.GalleryPropertiesProvisioningState - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "identifier": {"key": "properties.identifier", "type": "GalleryIdentifier"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - identifier: Optional["_models.GalleryIdentifier"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this Shared Image Gallery resource. This property is - updatable. - :paramtype description: str - :keyword identifier: Describes the gallery unique name. - :paramtype identifier: ~azure.mgmt.compute.v2019_07_01.models.GalleryIdentifier - """ - super().__init__(tags=tags, **kwargs) - self.description = description - self.identifier = identifier - self.provisioning_state: Optional[Union[str, "_models.GalleryPropertiesProvisioningState"]] = None - - -class GrantAccessData(_serialization.Model): - """Data used for requesting a SAS. - - All required parameters must be populated in order to send to server. - - :ivar access: Required. Known values are: "None", "Read", and "Write". - :vartype access: str or ~azure.mgmt.compute.v2019_07_01.models.AccessLevel - :ivar duration_in_seconds: Time duration in seconds until the SAS access expires. Required. - :vartype duration_in_seconds: int - """ - - _validation = { - "access": {"required": True}, - "duration_in_seconds": {"required": True}, - } - - _attribute_map = { - "access": {"key": "access", "type": "str"}, - "duration_in_seconds": {"key": "durationInSeconds", "type": "int"}, - } - - def __init__(self, *, access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, **kwargs: Any) -> None: - """ - :keyword access: Required. Known values are: "None", "Read", and "Write". - :paramtype access: str or ~azure.mgmt.compute.v2019_07_01.models.AccessLevel - :keyword duration_in_seconds: Time duration in seconds until the SAS access expires. Required. - :paramtype duration_in_seconds: int - """ - super().__init__(**kwargs) - self.access = access - self.duration_in_seconds = duration_in_seconds - - -class HardwareProfile(_serialization.Model): - """Specifies the hardware settings for the virtual machine. - - :ivar vm_size: Specifies the size of the virtual machine. For more information about virtual - machine sizes, see `Sizes for virtual machines - `_. - :code:`
    `\\ :code:`
    ` The available VM sizes depend on region and availability set. For a - list of available sizes use these APIs: :code:`
    `\\ :code:`
    ` `List all available - virtual machine sizes in an availability set - `_ - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in a region - `_ :code:`
    `\\ - :code:`
    ` `List all available virtual machine sizes for resizing - `_. Known - values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", - "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", - "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", - "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", - "Standard_A8m_v2", "Standard_B1s", "Standard_B1ms", "Standard_B2s", "Standard_B2ms", - "Standard_B4ms", "Standard_B8ms", "Standard_D1", "Standard_D2", "Standard_D3", "Standard_D4", - "Standard_D11", "Standard_D12", "Standard_D13", "Standard_D14", "Standard_D1_v2", - "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", "Standard_D5_v2", "Standard_D2_v3", - "Standard_D4_v3", "Standard_D8_v3", "Standard_D16_v3", "Standard_D32_v3", "Standard_D64_v3", - "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", "Standard_D16s_v3", - "Standard_D32s_v3", "Standard_D64s_v3", "Standard_D11_v2", "Standard_D12_v2", - "Standard_D13_v2", "Standard_D14_v2", "Standard_D15_v2", "Standard_DS1", "Standard_DS2", - "Standard_DS3", "Standard_DS4", "Standard_DS11", "Standard_DS12", "Standard_DS13", - "Standard_DS14", "Standard_DS1_v2", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", - "Standard_DS5_v2", "Standard_DS11_v2", "Standard_DS12_v2", "Standard_DS13_v2", - "Standard_DS14_v2", "Standard_DS15_v2", "Standard_DS13-4_v2", "Standard_DS13-2_v2", - "Standard_DS14-8_v2", "Standard_DS14-4_v2", "Standard_E2_v3", "Standard_E4_v3", - "Standard_E8_v3", "Standard_E16_v3", "Standard_E32_v3", "Standard_E64_v3", "Standard_E2s_v3", - "Standard_E4s_v3", "Standard_E8s_v3", "Standard_E16s_v3", "Standard_E32s_v3", - "Standard_E64s_v3", "Standard_E32-16_v3", "Standard_E32-8s_v3", "Standard_E64-32s_v3", - "Standard_E64-16s_v3", "Standard_F1", "Standard_F2", "Standard_F4", "Standard_F8", - "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", - "Standard_F16s", "Standard_F2s_v2", "Standard_F4s_v2", "Standard_F8s_v2", "Standard_F16s_v2", - "Standard_F32s_v2", "Standard_F64s_v2", "Standard_F72s_v2", "Standard_G1", "Standard_G2", - "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", "Standard_GS3", - "Standard_GS4", "Standard_GS5", "Standard_GS4-8", "Standard_GS4-4", "Standard_GS5-16", - "Standard_GS5-8", "Standard_H8", "Standard_H16", "Standard_H8m", "Standard_H16m", - "Standard_H16r", "Standard_H16mr", "Standard_L4s", "Standard_L8s", "Standard_L16s", - "Standard_L32s", "Standard_M64s", "Standard_M64ms", "Standard_M128s", "Standard_M128ms", - "Standard_M64-32ms", "Standard_M64-16ms", "Standard_M128-64ms", "Standard_M128-32ms", - "Standard_NC6", "Standard_NC12", "Standard_NC24", "Standard_NC24r", "Standard_NC6s_v2", - "Standard_NC12s_v2", "Standard_NC24s_v2", "Standard_NC24rs_v2", "Standard_NC6s_v3", - "Standard_NC12s_v3", "Standard_NC24s_v3", "Standard_NC24rs_v3", "Standard_ND6s", - "Standard_ND12s", "Standard_ND24s", "Standard_ND24rs", "Standard_NV6", "Standard_NV12", and - "Standard_NV24". - :vartype vm_size: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineSizeTypes - """ - - _attribute_map = { - "vm_size": {"key": "vmSize", "type": "str"}, - } - - def __init__( - self, *, vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs: Any - ) -> None: - """ - :keyword vm_size: Specifies the size of the virtual machine. For more information about virtual - machine sizes, see `Sizes for virtual machines - `_. - :code:`
    `\\ :code:`
    ` The available VM sizes depend on region and availability set. For a - list of available sizes use these APIs: :code:`
    `\\ :code:`
    ` `List all available - virtual machine sizes in an availability set - `_ - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in a region - `_ :code:`
    `\\ - :code:`
    ` `List all available virtual machine sizes for resizing - `_. Known - values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", - "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", - "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", - "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", - "Standard_A8m_v2", "Standard_B1s", "Standard_B1ms", "Standard_B2s", "Standard_B2ms", - "Standard_B4ms", "Standard_B8ms", "Standard_D1", "Standard_D2", "Standard_D3", "Standard_D4", - "Standard_D11", "Standard_D12", "Standard_D13", "Standard_D14", "Standard_D1_v2", - "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", "Standard_D5_v2", "Standard_D2_v3", - "Standard_D4_v3", "Standard_D8_v3", "Standard_D16_v3", "Standard_D32_v3", "Standard_D64_v3", - "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", "Standard_D16s_v3", - "Standard_D32s_v3", "Standard_D64s_v3", "Standard_D11_v2", "Standard_D12_v2", - "Standard_D13_v2", "Standard_D14_v2", "Standard_D15_v2", "Standard_DS1", "Standard_DS2", - "Standard_DS3", "Standard_DS4", "Standard_DS11", "Standard_DS12", "Standard_DS13", - "Standard_DS14", "Standard_DS1_v2", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", - "Standard_DS5_v2", "Standard_DS11_v2", "Standard_DS12_v2", "Standard_DS13_v2", - "Standard_DS14_v2", "Standard_DS15_v2", "Standard_DS13-4_v2", "Standard_DS13-2_v2", - "Standard_DS14-8_v2", "Standard_DS14-4_v2", "Standard_E2_v3", "Standard_E4_v3", - "Standard_E8_v3", "Standard_E16_v3", "Standard_E32_v3", "Standard_E64_v3", "Standard_E2s_v3", - "Standard_E4s_v3", "Standard_E8s_v3", "Standard_E16s_v3", "Standard_E32s_v3", - "Standard_E64s_v3", "Standard_E32-16_v3", "Standard_E32-8s_v3", "Standard_E64-32s_v3", - "Standard_E64-16s_v3", "Standard_F1", "Standard_F2", "Standard_F4", "Standard_F8", - "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", - "Standard_F16s", "Standard_F2s_v2", "Standard_F4s_v2", "Standard_F8s_v2", "Standard_F16s_v2", - "Standard_F32s_v2", "Standard_F64s_v2", "Standard_F72s_v2", "Standard_G1", "Standard_G2", - "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", "Standard_GS3", - "Standard_GS4", "Standard_GS5", "Standard_GS4-8", "Standard_GS4-4", "Standard_GS5-16", - "Standard_GS5-8", "Standard_H8", "Standard_H16", "Standard_H8m", "Standard_H16m", - "Standard_H16r", "Standard_H16mr", "Standard_L4s", "Standard_L8s", "Standard_L16s", - "Standard_L32s", "Standard_M64s", "Standard_M64ms", "Standard_M128s", "Standard_M128ms", - "Standard_M64-32ms", "Standard_M64-16ms", "Standard_M128-64ms", "Standard_M128-32ms", - "Standard_NC6", "Standard_NC12", "Standard_NC24", "Standard_NC24r", "Standard_NC6s_v2", - "Standard_NC12s_v2", "Standard_NC24s_v2", "Standard_NC24rs_v2", "Standard_NC6s_v3", - "Standard_NC12s_v3", "Standard_NC24s_v3", "Standard_NC24rs_v3", "Standard_ND6s", - "Standard_ND12s", "Standard_ND24s", "Standard_ND24rs", "Standard_NV6", "Standard_NV12", and - "Standard_NV24". - :paramtype vm_size: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineSizeTypes - """ - super().__init__(**kwargs) - self.vm_size = vm_size - - -class Image(Resource): - """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. - - 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] - :ivar source_virtual_machine: The source virtual machine from which Image is created. - :vartype source_virtual_machine: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2019_07_01.models.ImageStorageProfile - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str - :ivar hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from the - image. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or - ~azure.mgmt.compute.v2019_07_01.models.HyperVGenerationTypes - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "source_virtual_machine": {"key": "properties.sourceVirtualMachine", "type": "SubResource"}, - "storage_profile": {"key": "properties.storageProfile", "type": "ImageStorageProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["_models.SubResource"] = None, - storage_profile: Optional["_models.ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword source_virtual_machine: The source virtual machine from which Image is created. - :paramtype source_virtual_machine: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2019_07_01.models.ImageStorageProfile - :keyword hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from - the image. Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2019_07_01.models.HyperVGenerationTypes - """ - super().__init__(location=location, tags=tags, **kwargs) - self.source_virtual_machine = source_virtual_machine - self.storage_profile = storage_profile - self.provisioning_state: Optional[str] = None - self.hyper_v_generation = hyper_v_generation - - -class ImageDisk(_serialization.Model): - """Describes a image disk. - - :ivar snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed image disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetParameters - """ - - _attribute_map = { - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - } - - def __init__( - self, - *, - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed image disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetParameters - """ - super().__init__(**kwargs) - self.snapshot = snapshot - self.managed_disk = managed_disk - self.blob_uri = blob_uri - self.caching = caching - self.disk_size_gb = disk_size_gb - self.storage_account_type = storage_account_type - self.disk_encryption_set = disk_encryption_set - - -class ImageDataDisk(ImageDisk): - """Describes a data disk. - - All required parameters must be populated in order to send to server. - - :ivar snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed image disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetParameters - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - """ - - _validation = { - "lun": {"required": True}, - } - - _attribute_map = { - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__( - self, - *, - lun: int, - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed image disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetParameters - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - """ - super().__init__( - snapshot=snapshot, - managed_disk=managed_disk, - blob_uri=blob_uri, - caching=caching, - disk_size_gb=disk_size_gb, - storage_account_type=storage_account_type, - disk_encryption_set=disk_encryption_set, - **kwargs - ) - self.lun = lun - - -class ImageDiskReference(_serialization.Model): - """The source image used for creating the disk. - - All required parameters must be populated in order to send to server. - - :ivar id: A relative uri containing either a Platform Image Repository or user image reference. - Required. - :vartype id: str - :ivar lun: If the disk is created from an image's data disk, this is an index that indicates - which of the data disks in the image to use. For OS disks, this field is null. - :vartype lun: int - """ - - _validation = { - "id": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__( - self, *, id: str, lun: Optional[int] = None, **kwargs: Any # pylint: disable=redefined-builtin - ) -> None: - """ - :keyword id: A relative uri containing either a Platform Image Repository or user image - reference. Required. - :paramtype id: str - :keyword lun: If the disk is created from an image's data disk, this is an index that indicates - which of the data disks in the image to use. For OS disks, this field is null. - :paramtype lun: int - """ - super().__init__(**kwargs) - self.id = id - self.lun = lun - - -class ImageListResult(_serialization.Model): - """The List Image operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of Images. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.Image] - :ivar next_link: The uri to fetch the next page of Images. Call ListNext() with this to fetch - the next page of Images. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Image]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Image"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of Images. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.Image] - :keyword next_link: The uri to fetch the next page of Images. Call ListNext() with this to - fetch the next page of Images. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ImageOSDisk(ImageDisk): - """Describes an Operating System disk. - - All required parameters must be populated in order to send to server. - - :ivar snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed image disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetParameters - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from a custom image. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Required. Known - values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :ivar os_state: The OS State. Required. Known values are: "Generalized" and "Specialized". - :vartype os_state: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemStateTypes - """ - - _validation = { - "os_type": {"required": True}, - "os_state": {"required": True}, - } - - _attribute_map = { - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - "os_type": {"key": "osType", "type": "str"}, - "os_state": {"key": "osState", "type": "str"}, - } - - def __init__( - self, - *, - os_type: Union[str, "_models.OperatingSystemTypes"], - os_state: Union[str, "_models.OperatingSystemStateTypes"], - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed image disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetParameters - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from a custom image. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Required. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :keyword os_state: The OS State. Required. Known values are: "Generalized" and "Specialized". - :paramtype os_state: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemStateTypes - """ - super().__init__( - snapshot=snapshot, - managed_disk=managed_disk, - blob_uri=blob_uri, - caching=caching, - disk_size_gb=disk_size_gb, - storage_account_type=storage_account_type, - disk_encryption_set=disk_encryption_set, - **kwargs - ) - self.os_type = os_type - self.os_state = os_state - - -class ImagePurchasePlan(_serialization.Model): - """Describes the gallery Image Definition purchase plan. This is used by marketplace images. - - :ivar name: The plan ID. - :vartype name: str - :ivar publisher: The publisher ID. - :vartype publisher: str - :ivar product: The product ID. - :vartype product: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - publisher: Optional[str] = None, - product: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The plan ID. - :paramtype name: str - :keyword publisher: The publisher ID. - :paramtype publisher: str - :keyword product: The product ID. - :paramtype product: str - """ - super().__init__(**kwargs) - self.name = name - self.publisher = publisher - self.product = product - - -class ImageReference(SubResource): - """Specifies information about the image to use. You can specify information about platform - images, marketplace images, or virtual machine images. This element is required when you want - to use a platform image, marketplace image, or virtual machine image, but is not used in other - creation operations. NOTE: Image reference publisher and offer can only be set when you create - the scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar publisher: The image publisher. - :vartype publisher: str - :ivar offer: Specifies the offer of the platform image or marketplace image used to create the - virtual machine. - :vartype offer: str - :ivar sku: The image SKU. - :vartype sku: str - :ivar version: Specifies the version of the platform image or marketplace image used to create - the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and - Build are decimal numbers. Specify 'latest' to use the latest version of an image available at - deploy time. Even if you use 'latest', the VM image will not automatically update after deploy - time even if a new version becomes available. - :vartype version: str - :ivar exact_version: Specifies in decimal numbers, the version of platform image or marketplace - image used to create the virtual machine. This readonly field differs from 'version', only if - the value specified in 'version' field is 'latest'. - :vartype exact_version: str - """ - - _validation = { - "exact_version": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "offer": {"key": "offer", "type": "str"}, - "sku": {"key": "sku", "type": "str"}, - "version": {"key": "version", "type": "str"}, - "exact_version": {"key": "exactVersion", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - publisher: Optional[str] = None, - offer: Optional[str] = None, - sku: Optional[str] = None, - version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword publisher: The image publisher. - :paramtype publisher: str - :keyword offer: Specifies the offer of the platform image or marketplace image used to create - the virtual machine. - :paramtype offer: str - :keyword sku: The image SKU. - :paramtype sku: str - :keyword version: Specifies the version of the platform image or marketplace image used to - create the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, - Minor, and Build are decimal numbers. Specify 'latest' to use the latest version of an image - available at deploy time. Even if you use 'latest', the VM image will not automatically update - after deploy time even if a new version becomes available. - :paramtype version: str - """ - super().__init__(id=id, **kwargs) - self.publisher = publisher - self.offer = offer - self.sku = sku - self.version = version - self.exact_version: Optional[str] = None - - -class ImageStorageProfile(_serialization.Model): - """Describes a storage profile. - - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2019_07_01.models.ImageOSDisk - :ivar data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype data_disks: list[~azure.mgmt.compute.v2019_07_01.models.ImageDataDisk] - :ivar zone_resilient: Specifies whether an image is zone resilient or not. Default is false. - Zone resilient images can be created only in regions that provide Zone Redundant Storage (ZRS). - :vartype zone_resilient: bool - """ - - _attribute_map = { - "os_disk": {"key": "osDisk", "type": "ImageOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[ImageDataDisk]"}, - "zone_resilient": {"key": "zoneResilient", "type": "bool"}, - } - - def __init__( - self, - *, - os_disk: Optional["_models.ImageOSDisk"] = None, - data_disks: Optional[List["_models.ImageDataDisk"]] = None, - zone_resilient: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2019_07_01.models.ImageOSDisk - :keyword data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype data_disks: list[~azure.mgmt.compute.v2019_07_01.models.ImageDataDisk] - :keyword zone_resilient: Specifies whether an image is zone resilient or not. Default is false. - Zone resilient images can be created only in regions that provide Zone Redundant Storage (ZRS). - :paramtype zone_resilient: bool - """ - super().__init__(**kwargs) - self.os_disk = os_disk - self.data_disks = data_disks - self.zone_resilient = zone_resilient - - -class ImageUpdate(UpdateResource): - """The source user image virtual hard disk. Only tags may be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar source_virtual_machine: The source virtual machine from which Image is created. - :vartype source_virtual_machine: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2019_07_01.models.ImageStorageProfile - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str - :ivar hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from the - image. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or - ~azure.mgmt.compute.v2019_07_01.models.HyperVGenerationTypes - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "source_virtual_machine": {"key": "properties.sourceVirtualMachine", "type": "SubResource"}, - "storage_profile": {"key": "properties.storageProfile", "type": "ImageStorageProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["_models.SubResource"] = None, - storage_profile: Optional["_models.ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword source_virtual_machine: The source virtual machine from which Image is created. - :paramtype source_virtual_machine: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2019_07_01.models.ImageStorageProfile - :keyword hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from - the image. Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2019_07_01.models.HyperVGenerationTypes - """ - super().__init__(tags=tags, **kwargs) - self.source_virtual_machine = source_virtual_machine - self.storage_profile = storage_profile - self.provisioning_state: Optional[str] = None - self.hyper_v_generation = hyper_v_generation - - -class InnerError(_serialization.Model): - """Inner error details. - - :ivar exceptiontype: The exception type. - :vartype exceptiontype: str - :ivar errordetail: The internal error message or exception dump. - :vartype errordetail: str - """ - - _attribute_map = { - "exceptiontype": {"key": "exceptiontype", "type": "str"}, - "errordetail": {"key": "errordetail", "type": "str"}, - } - - def __init__( - self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword exceptiontype: The exception type. - :paramtype exceptiontype: str - :keyword errordetail: The internal error message or exception dump. - :paramtype errordetail: str - """ - super().__init__(**kwargs) - self.exceptiontype = exceptiontype - self.errordetail = errordetail - - -class InstanceViewStatus(_serialization.Model): - """Instance view status. - - :ivar code: The status code. - :vartype code: str - :ivar level: The level code. Known values are: "Info", "Warning", and "Error". - :vartype level: str or ~azure.mgmt.compute.v2019_07_01.models.StatusLevelTypes - :ivar display_status: The short localizable label for the status. - :vartype display_status: str - :ivar message: The detailed status message, including for alerts and error messages. - :vartype message: str - :ivar time: The time of the status. - :vartype time: ~datetime.datetime - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "level": {"key": "level", "type": "str"}, - "display_status": {"key": "displayStatus", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "time": {"key": "time", "type": "iso-8601"}, - } - - def __init__( - self, - *, - code: Optional[str] = None, - level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, - display_status: Optional[str] = None, - message: Optional[str] = None, - time: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword code: The status code. - :paramtype code: str - :keyword level: The level code. Known values are: "Info", "Warning", and "Error". - :paramtype level: str or ~azure.mgmt.compute.v2019_07_01.models.StatusLevelTypes - :keyword display_status: The short localizable label for the status. - :paramtype display_status: str - :keyword message: The detailed status message, including for alerts and error messages. - :paramtype message: str - :keyword time: The time of the status. - :paramtype time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.code = code - self.level = level - self.display_status = display_status - self.message = message - self.time = time - - -class KeyVaultAndKeyReference(_serialization.Model): - """Key Vault Key Url and vault id of KeK, KeK is optional and when provided is used to unwrap the - encryptionKey. - - All required parameters must be populated in order to send to server. - - :ivar source_vault: Resource id of the KeyVault containing the key or secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2019_07_01.models.SourceVault - :ivar key_url: Url pointing to a key or secret in KeyVault. Required. - :vartype key_url: str - """ - - _validation = { - "source_vault": {"required": True}, - "key_url": {"required": True}, - } - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SourceVault"}, - "key_url": {"key": "keyUrl", "type": "str"}, - } - - def __init__(self, *, source_vault: "_models.SourceVault", key_url: str, **kwargs: Any) -> None: - """ - :keyword source_vault: Resource id of the KeyVault containing the key or secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2019_07_01.models.SourceVault - :keyword key_url: Url pointing to a key or secret in KeyVault. Required. - :paramtype key_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.key_url = key_url - - -class KeyVaultAndSecretReference(_serialization.Model): - """Key Vault Secret Url and vault id of the encryption key. - - All required parameters must be populated in order to send to server. - - :ivar source_vault: Resource id of the KeyVault containing the key or secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2019_07_01.models.SourceVault - :ivar secret_url: Url pointing to a key or secret in KeyVault. Required. - :vartype secret_url: str - """ - - _validation = { - "source_vault": {"required": True}, - "secret_url": {"required": True}, - } - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SourceVault"}, - "secret_url": {"key": "secretUrl", "type": "str"}, - } - - def __init__(self, *, source_vault: "_models.SourceVault", secret_url: str, **kwargs: Any) -> None: - """ - :keyword source_vault: Resource id of the KeyVault containing the key or secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2019_07_01.models.SourceVault - :keyword secret_url: Url pointing to a key or secret in KeyVault. Required. - :paramtype secret_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.secret_url = secret_url - - -class KeyVaultKeyReference(_serialization.Model): - """Describes a reference to Key Vault Key. - - All required parameters must be populated in order to send to server. - - :ivar key_url: The URL referencing a key encryption key in Key Vault. Required. - :vartype key_url: str - :ivar source_vault: The relative URL of the Key Vault containing the key. Required. - :vartype source_vault: ~azure.mgmt.compute.v2019_07_01.models.SubResource - """ - - _validation = { - "key_url": {"required": True}, - "source_vault": {"required": True}, - } - - _attribute_map = { - "key_url": {"key": "keyUrl", "type": "str"}, - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - } - - def __init__(self, *, key_url: str, source_vault: "_models.SubResource", **kwargs: Any) -> None: - """ - :keyword key_url: The URL referencing a key encryption key in Key Vault. Required. - :paramtype key_url: str - :keyword source_vault: The relative URL of the Key Vault containing the key. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2019_07_01.models.SubResource - """ - super().__init__(**kwargs) - self.key_url = key_url - self.source_vault = source_vault - - -class KeyVaultSecretReference(_serialization.Model): - """Describes a reference to Key Vault Secret. - - All required parameters must be populated in order to send to server. - - :ivar secret_url: The URL referencing a secret in a Key Vault. Required. - :vartype secret_url: str - :ivar source_vault: The relative URL of the Key Vault containing the secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2019_07_01.models.SubResource - """ - - _validation = { - "secret_url": {"required": True}, - "source_vault": {"required": True}, - } - - _attribute_map = { - "secret_url": {"key": "secretUrl", "type": "str"}, - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - } - - def __init__(self, *, secret_url: str, source_vault: "_models.SubResource", **kwargs: Any) -> None: - """ - :keyword secret_url: The URL referencing a secret in a Key Vault. Required. - :paramtype secret_url: str - :keyword source_vault: The relative URL of the Key Vault containing the secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2019_07_01.models.SubResource - """ - super().__init__(**kwargs) - self.secret_url = secret_url - self.source_vault = source_vault - - -class LinuxConfiguration(_serialization.Model): - """Specifies the Linux operating system settings on the virtual machine. :code:`
    `\\ - :code:`
    `For a list of supported Linux distributions, see `Linux on Azure-Endorsed - Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - - :ivar disable_password_authentication: Specifies whether password authentication should be - disabled. - :vartype disable_password_authentication: bool - :ivar ssh: Specifies the ssh key configuration for a Linux OS. - :vartype ssh: ~azure.mgmt.compute.v2019_07_01.models.SshConfiguration - :ivar provision_vm_agent: Indicates whether virtual machine agent should be provisioned on the - virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the request - body, default behavior is to set it to true. This will ensure that VM Agent is installed on - the VM so that extensions can be added to the VM later. - :vartype provision_vm_agent: bool - """ - - _attribute_map = { - "disable_password_authentication": {"key": "disablePasswordAuthentication", "type": "bool"}, - "ssh": {"key": "ssh", "type": "SshConfiguration"}, - "provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"}, - } - - def __init__( - self, - *, - disable_password_authentication: Optional[bool] = None, - ssh: Optional["_models.SshConfiguration"] = None, - provision_vm_agent: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword disable_password_authentication: Specifies whether password authentication should be - disabled. - :paramtype disable_password_authentication: bool - :keyword ssh: Specifies the ssh key configuration for a Linux OS. - :paramtype ssh: ~azure.mgmt.compute.v2019_07_01.models.SshConfiguration - :keyword provision_vm_agent: Indicates whether virtual machine agent should be provisioned on - the virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the - request body, default behavior is to set it to true. This will ensure that VM Agent is - installed on the VM so that extensions can be added to the VM later. - :paramtype provision_vm_agent: bool - """ - super().__init__(**kwargs) - self.disable_password_authentication = disable_password_authentication - self.ssh = ssh - self.provision_vm_agent = provision_vm_agent - - -class ListUsagesResult(_serialization.Model): - """The List Usages operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of compute resource usages. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.Usage] - :ivar next_link: The URI to fetch the next page of compute resource usage information. Call - ListNext() with this to fetch the next page of compute resource usage information. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Usage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of compute resource usages. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.Usage] - :keyword next_link: The URI to fetch the next page of compute resource usage information. Call - ListNext() with this to fetch the next page of compute resource usage information. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class LogAnalyticsInputBase(_serialization.Model): - """Api input base class for LogAnalytics Api. - - All required parameters must be populated in order to send to server. - - :ivar blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api - writes output logs to. Required. - :vartype blob_container_sas_uri: str - :ivar from_time: From time of the query. Required. - :vartype from_time: ~datetime.datetime - :ivar to_time: To time of the query. Required. - :vartype to_time: ~datetime.datetime - :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. - :vartype group_by_throttle_policy: bool - :ivar group_by_operation_name: Group query result by Operation Name. - :vartype group_by_operation_name: bool - :ivar group_by_resource_name: Group query result by Resource Name. - :vartype group_by_resource_name: bool - """ - - _validation = { - "blob_container_sas_uri": {"required": True}, - "from_time": {"required": True}, - "to_time": {"required": True}, - } - - _attribute_map = { - "blob_container_sas_uri": {"key": "blobContainerSasUri", "type": "str"}, - "from_time": {"key": "fromTime", "type": "iso-8601"}, - "to_time": {"key": "toTime", "type": "iso-8601"}, - "group_by_throttle_policy": {"key": "groupByThrottlePolicy", "type": "bool"}, - "group_by_operation_name": {"key": "groupByOperationName", "type": "bool"}, - "group_by_resource_name": {"key": "groupByResourceName", "type": "bool"}, - } - - def __init__( - self, - *, - blob_container_sas_uri: str, - from_time: datetime.datetime, - to_time: datetime.datetime, - group_by_throttle_policy: Optional[bool] = None, - group_by_operation_name: Optional[bool] = None, - group_by_resource_name: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics - Api writes output logs to. Required. - :paramtype blob_container_sas_uri: str - :keyword from_time: From time of the query. Required. - :paramtype from_time: ~datetime.datetime - :keyword to_time: To time of the query. Required. - :paramtype to_time: ~datetime.datetime - :keyword group_by_throttle_policy: Group query result by Throttle Policy applied. - :paramtype group_by_throttle_policy: bool - :keyword group_by_operation_name: Group query result by Operation Name. - :paramtype group_by_operation_name: bool - :keyword group_by_resource_name: Group query result by Resource Name. - :paramtype group_by_resource_name: bool - """ - super().__init__(**kwargs) - self.blob_container_sas_uri = blob_container_sas_uri - self.from_time = from_time - self.to_time = to_time - self.group_by_throttle_policy = group_by_throttle_policy - self.group_by_operation_name = group_by_operation_name - self.group_by_resource_name = group_by_resource_name - - -class LogAnalyticsOperationResult(_serialization.Model): - """LogAnalytics operation status response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar properties: LogAnalyticsOutput. - :vartype properties: ~azure.mgmt.compute.v2019_07_01.models.LogAnalyticsOutput - """ - - _validation = { - "properties": {"readonly": True}, - } - - _attribute_map = { - "properties": {"key": "properties", "type": "LogAnalyticsOutput"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.properties: Optional["_models.LogAnalyticsOutput"] = None - - -class LogAnalyticsOutput(_serialization.Model): - """LogAnalytics output properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar output: Output file Uri path to blob container. - :vartype output: str - """ - - _validation = { - "output": {"readonly": True}, - } - - _attribute_map = { - "output": {"key": "output", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.output: Optional[str] = None - - -class MaintenanceRedeployStatus(_serialization.Model): - """Maintenance Operation Status. - - :ivar is_customer_initiated_maintenance_allowed: True, if customer is allowed to perform - Maintenance. - :vartype is_customer_initiated_maintenance_allowed: bool - :ivar pre_maintenance_window_start_time: Start Time for the Pre Maintenance Window. - :vartype pre_maintenance_window_start_time: ~datetime.datetime - :ivar pre_maintenance_window_end_time: End Time for the Pre Maintenance Window. - :vartype pre_maintenance_window_end_time: ~datetime.datetime - :ivar maintenance_window_start_time: Start Time for the Maintenance Window. - :vartype maintenance_window_start_time: ~datetime.datetime - :ivar maintenance_window_end_time: End Time for the Maintenance Window. - :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: - "None", "RetryLater", "MaintenanceAborted", and "MaintenanceCompleted". - :vartype last_operation_result_code: str or - ~azure.mgmt.compute.v2019_07_01.models.MaintenanceOperationResultCodeTypes - :ivar last_operation_message: Message returned for the last Maintenance Operation. - :vartype last_operation_message: str - """ - - _attribute_map = { - "is_customer_initiated_maintenance_allowed": {"key": "isCustomerInitiatedMaintenanceAllowed", "type": "bool"}, - "pre_maintenance_window_start_time": {"key": "preMaintenanceWindowStartTime", "type": "iso-8601"}, - "pre_maintenance_window_end_time": {"key": "preMaintenanceWindowEndTime", "type": "iso-8601"}, - "maintenance_window_start_time": {"key": "maintenanceWindowStartTime", "type": "iso-8601"}, - "maintenance_window_end_time": {"key": "maintenanceWindowEndTime", "type": "iso-8601"}, - "last_operation_result_code": {"key": "lastOperationResultCode", "type": "str"}, - "last_operation_message": {"key": "lastOperationMessage", "type": "str"}, - } - - def __init__( - self, - *, - is_customer_initiated_maintenance_allowed: Optional[bool] = None, - pre_maintenance_window_start_time: Optional[datetime.datetime] = None, - pre_maintenance_window_end_time: Optional[datetime.datetime] = None, - maintenance_window_start_time: Optional[datetime.datetime] = None, - maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, - last_operation_message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_customer_initiated_maintenance_allowed: True, if customer is allowed to perform - Maintenance. - :paramtype is_customer_initiated_maintenance_allowed: bool - :keyword pre_maintenance_window_start_time: Start Time for the Pre Maintenance Window. - :paramtype pre_maintenance_window_start_time: ~datetime.datetime - :keyword pre_maintenance_window_end_time: End Time for the Pre Maintenance Window. - :paramtype pre_maintenance_window_end_time: ~datetime.datetime - :keyword maintenance_window_start_time: Start Time for the Maintenance Window. - :paramtype maintenance_window_start_time: ~datetime.datetime - :keyword maintenance_window_end_time: End Time for the Maintenance Window. - :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values - are: "None", "RetryLater", "MaintenanceAborted", and "MaintenanceCompleted". - :paramtype last_operation_result_code: str or - ~azure.mgmt.compute.v2019_07_01.models.MaintenanceOperationResultCodeTypes - :keyword last_operation_message: Message returned for the last Maintenance Operation. - :paramtype last_operation_message: str - """ - super().__init__(**kwargs) - self.is_customer_initiated_maintenance_allowed = is_customer_initiated_maintenance_allowed - self.pre_maintenance_window_start_time = pre_maintenance_window_start_time - self.pre_maintenance_window_end_time = pre_maintenance_window_end_time - self.maintenance_window_start_time = maintenance_window_start_time - self.maintenance_window_end_time = maintenance_window_end_time - self.last_operation_result_code = last_operation_result_code - self.last_operation_message = last_operation_message - - -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 ManagedDiskParameters(SubResource): - """The parameters of a managed disk. - - :ivar id: Resource Id. - :vartype id: str - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetParameters - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetParameters - """ - super().__init__(id=id, **kwargs) - self.storage_account_type = storage_account_type - self.disk_encryption_set = disk_encryption_set - - -class NetworkInterfaceReference(SubResource): - """Describes a network interface reference. - - :ivar id: Resource Id. - :vartype id: str - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - primary: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - """ - super().__init__(id=id, **kwargs) - self.primary = primary - - -class NetworkProfile(_serialization.Model): - """Specifies the network interfaces of the virtual machine. - - :ivar network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the virtual machine. - :vartype network_interfaces: - list[~azure.mgmt.compute.v2019_07_01.models.NetworkInterfaceReference] - """ - - _attribute_map = { - "network_interfaces": {"key": "networkInterfaces", "type": "[NetworkInterfaceReference]"}, - } - - def __init__( - self, *, network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs: Any - ) -> None: - """ - :keyword network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the virtual machine. - :paramtype network_interfaces: - list[~azure.mgmt.compute.v2019_07_01.models.NetworkInterfaceReference] - """ - super().__init__(**kwargs) - self.network_interfaces = network_interfaces - - -class OSDisk(_serialization.Model): - """Specifies information about the operating system disk used by the virtual machine. - :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and VHDs for - Azure virtual machines - `_. - - All required parameters must be populated in order to send to server. - - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :vartype encryption_settings: ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSettings - :ivar name: The disk name. - :vartype name: str - :ivar vhd: The virtual hard disk. - :vartype vhd: ~azure.mgmt.compute.v2019_07_01.models.VirtualHardDisk - :ivar image: 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. - :vartype image: ~azure.mgmt.compute.v2019_07_01.models.VirtualHardDisk - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar diff_disk_settings: Specifies the ephemeral Disk Settings for the operating system disk - used by the virtual machine. - :vartype diff_disk_settings: ~azure.mgmt.compute.v2019_07_01.models.DiffDiskSettings - :ivar create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: ~azure.mgmt.compute.v2019_07_01.models.ManagedDiskParameters - """ - - _validation = { - "create_option": {"required": True}, - } - - _attribute_map = { - "os_type": {"key": "osType", "type": "str"}, - "encryption_settings": {"key": "encryptionSettings", "type": "DiskEncryptionSettings"}, - "name": {"key": "name", "type": "str"}, - "vhd": {"key": "vhd", "type": "VirtualHardDisk"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "diff_disk_settings": {"key": "diffDiskSettings", "type": "DiffDiskSettings"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, - name: Optional[str] = None, - vhd: Optional["_models.VirtualHardDisk"] = None, - image: Optional["_models.VirtualHardDisk"] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.ManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype encryption_settings: ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSettings - :keyword name: The disk name. - :paramtype name: str - :keyword vhd: The virtual hard disk. - :paramtype vhd: ~azure.mgmt.compute.v2019_07_01.models.VirtualHardDisk - :keyword image: 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. - :paramtype image: ~azure.mgmt.compute.v2019_07_01.models.VirtualHardDisk - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword diff_disk_settings: Specifies the ephemeral Disk Settings for the operating system - disk used by the virtual machine. - :paramtype diff_disk_settings: ~azure.mgmt.compute.v2019_07_01.models.DiffDiskSettings - :keyword create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: ~azure.mgmt.compute.v2019_07_01.models.ManagedDiskParameters - """ - super().__init__(**kwargs) - self.os_type = os_type - self.encryption_settings = encryption_settings - self.name = name - self.vhd = vhd - self.image = image - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.diff_disk_settings = diff_disk_settings - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - - -class OSDiskImage(_serialization.Model): - """Contains the os disk image information. - - All required parameters must be populated in order to send to server. - - :ivar operating_system: The operating system of the osDiskImage. Required. Known values are: - "Windows" and "Linux". - :vartype operating_system: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - """ - - _validation = { - "operating_system": {"required": True}, - } - - _attribute_map = { - "operating_system": {"key": "operatingSystem", "type": "str"}, - } - - def __init__(self, *, operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs: Any) -> None: - """ - :keyword operating_system: The operating system of the osDiskImage. Required. Known values are: - "Windows" and "Linux". - :paramtype operating_system: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - """ - super().__init__(**kwargs) - self.operating_system = operating_system - - -class OSProfile(_serialization.Model): - """Specifies the operating system settings for the virtual machine. Some of the settings cannot be - changed once VM is provisioned. - - :ivar computer_name: Specifies the host OS name of the virtual machine. :code:`
    `\\ - :code:`
    ` This name cannot be updated after the VM is created. :code:`
    `\\ :code:`
    ` - **Max-length (Windows):** 15 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 - characters. :code:`
    `\\ :code:`
    ` For naming conventions and restrictions see `Azure - infrastructure services implementation guidelines - `_. - :vartype computer_name: str - :ivar admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` This property cannot be updated after the VM is created. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :vartype admin_username: str - :ivar admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :vartype admin_password: str - :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` **Note: Do not pass any - secrets or passwords in customData property** :code:`
    `\\ :code:`
    ` This property cannot - be updated after the VM is created. :code:`
    `\\ :code:`
    ` customData is passed to the VM - to be saved as a file, for more information see `Custom Data on Azure VMs - `_ :code:`
    `\\ :code:`
    ` - For using cloud-init for your Linux VM, see `Using cloud-init to customize a Linux VM during - creation - `_. - :vartype custom_data: str - :ivar windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :vartype windows_configuration: ~azure.mgmt.compute.v2019_07_01.models.WindowsConfiguration - :ivar linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :vartype linux_configuration: ~azure.mgmt.compute.v2019_07_01.models.LinuxConfiguration - :ivar secrets: Specifies set of certificates that should be installed onto the virtual machine. - :vartype secrets: list[~azure.mgmt.compute.v2019_07_01.models.VaultSecretGroup] - :ivar allow_extension_operations: Specifies whether extension operations should be allowed on - the virtual machine. :code:`
    `\\ :code:`
    `This may only be set to False when no - extensions are present on the virtual machine. - :vartype allow_extension_operations: bool - :ivar require_guest_provision_signal: Specifies whether the guest provision signal is required - to infer provision success of the virtual machine. - :vartype require_guest_provision_signal: bool - """ - - _attribute_map = { - "computer_name": {"key": "computerName", "type": "str"}, - "admin_username": {"key": "adminUsername", "type": "str"}, - "admin_password": {"key": "adminPassword", "type": "str"}, - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - "allow_extension_operations": {"key": "allowExtensionOperations", "type": "bool"}, - "require_guest_provision_signal": {"key": "requireGuestProvisionSignal", "type": "bool"}, - } - - def __init__( - self, - *, - computer_name: Optional[str] = None, - admin_username: Optional[str] = None, - admin_password: Optional[str] = None, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - allow_extension_operations: Optional[bool] = None, - require_guest_provision_signal: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword computer_name: Specifies the host OS name of the virtual machine. :code:`
    `\\ - :code:`
    ` This name cannot be updated after the VM is created. :code:`
    `\\ :code:`
    ` - **Max-length (Windows):** 15 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 - characters. :code:`
    `\\ :code:`
    ` For naming conventions and restrictions see `Azure - infrastructure services implementation guidelines - `_. - :paramtype computer_name: str - :keyword admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` This property cannot be updated after the VM is created. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :paramtype admin_username: str - :keyword admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :paramtype admin_password: str - :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` **Note: Do not pass any - secrets or passwords in customData property** :code:`
    `\\ :code:`
    ` This property cannot - be updated after the VM is created. :code:`
    `\\ :code:`
    ` customData is passed to the VM - to be saved as a file, for more information see `Custom Data on Azure VMs - `_ :code:`
    `\\ :code:`
    ` - For using cloud-init for your Linux VM, see `Using cloud-init to customize a Linux VM during - creation - `_. - :paramtype custom_data: str - :keyword windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :paramtype windows_configuration: ~azure.mgmt.compute.v2019_07_01.models.WindowsConfiguration - :keyword linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :paramtype linux_configuration: ~azure.mgmt.compute.v2019_07_01.models.LinuxConfiguration - :keyword secrets: Specifies set of certificates that should be installed onto the virtual - machine. - :paramtype secrets: list[~azure.mgmt.compute.v2019_07_01.models.VaultSecretGroup] - :keyword allow_extension_operations: Specifies whether extension operations should be allowed - on the virtual machine. :code:`
    `\\ :code:`
    `This may only be set to False when no - extensions are present on the virtual machine. - :paramtype allow_extension_operations: bool - :keyword require_guest_provision_signal: Specifies whether the guest provision signal is - required to infer provision success of the virtual machine. - :paramtype require_guest_provision_signal: bool - """ - super().__init__(**kwargs) - self.computer_name = computer_name - self.admin_username = admin_username - self.admin_password = admin_password - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - self.allow_extension_operations = allow_extension_operations - self.require_guest_provision_signal = require_guest_provision_signal - - -class Plan(_serialization.Model): - """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 the marketplace - image that you want to use and then click **Want to deploy programmatically, Get Started ->**. - Enter any required information and then click **Save**. - - :ivar name: The plan ID. - :vartype name: str - :ivar publisher: The publisher ID. - :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. - :vartype product: str - :ivar promotion_code: The promotion code. - :vartype promotion_code: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - "promotion_code": {"key": "promotionCode", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - publisher: Optional[str] = None, - product: Optional[str] = None, - promotion_code: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The plan ID. - :paramtype name: str - :keyword publisher: The publisher ID. - :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. - :paramtype product: str - :keyword promotion_code: The promotion code. - :paramtype promotion_code: str - """ - super().__init__(**kwargs) - self.name = name - self.publisher = publisher - self.product = product - self.promotion_code = promotion_code - - -class ProximityPlacementGroup(Resource): - """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. - :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] - :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Standard** : - Co-locate resources within an Azure region or Availability Zone. :code:`
    `\\ :code:`
    ` - **Ultra** : For future use. Known values are: "Standard" and "Ultra". - :vartype proximity_placement_group_type: str or - ~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroupType - :ivar virtual_machines: A list of references to all virtual machines in the proximity placement - group. - :vartype virtual_machines: - list[~azure.mgmt.compute.v2019_07_01.models.SubResourceWithColocationStatus] - :ivar virtual_machine_scale_sets: A list of references to all virtual machine scale sets in the - proximity placement group. - :vartype virtual_machine_scale_sets: - list[~azure.mgmt.compute.v2019_07_01.models.SubResourceWithColocationStatus] - :ivar availability_sets: A list of references to all availability sets in the proximity - placement group. - :vartype availability_sets: - list[~azure.mgmt.compute.v2019_07_01.models.SubResourceWithColocationStatus] - :ivar colocation_status: Describes colocation status of the Proximity Placement Group. - :vartype colocation_status: ~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "virtual_machines": {"readonly": True}, - "virtual_machine_scale_sets": {"readonly": True}, - "availability_sets": {"readonly": 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}"}, - "proximity_placement_group_type": {"key": "properties.proximityPlacementGroupType", "type": "str"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResourceWithColocationStatus]"}, - "virtual_machine_scale_sets": { - "key": "properties.virtualMachineScaleSets", - "type": "[SubResourceWithColocationStatus]", - }, - "availability_sets": {"key": "properties.availabilitySets", "type": "[SubResourceWithColocationStatus]"}, - "colocation_status": {"key": "properties.colocationStatus", "type": "InstanceViewStatus"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, - colocation_status: Optional["_models.InstanceViewStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Standard** : - Co-locate resources within an Azure region or Availability Zone. :code:`
    `\\ :code:`
    ` - **Ultra** : For future use. Known values are: "Standard" and "Ultra". - :paramtype proximity_placement_group_type: str or - ~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroupType - :keyword colocation_status: Describes colocation status of the Proximity Placement Group. - :paramtype colocation_status: ~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus - """ - super().__init__(location=location, tags=tags, **kwargs) - self.proximity_placement_group_type = proximity_placement_group_type - self.virtual_machines: Optional[List["_models.SubResourceWithColocationStatus"]] = None - self.virtual_machine_scale_sets: Optional[List["_models.SubResourceWithColocationStatus"]] = None - self.availability_sets: Optional[List["_models.SubResourceWithColocationStatus"]] = None - self.colocation_status = colocation_status - - -class ProximityPlacementGroupListResult(_serialization.Model): - """The List Proximity Placement Group operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of proximity placement groups. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroup] - :ivar next_link: The URI to fetch the next page of proximity placement groups. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ProximityPlacementGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of proximity placement groups. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroup] - :keyword next_link: The URI to fetch the next page of proximity placement groups. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ProximityPlacementGroupUpdate(UpdateResource): - """Specifies information about the proximity placement group. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - -class PurchasePlan(_serialization.Model): - """Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. - - All required parameters must be populated in order to send to server. - - :ivar publisher: The publisher ID. Required. - :vartype publisher: str - :ivar name: The plan ID. Required. - :vartype name: 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 - """ - - _validation = { - "publisher": {"required": True}, - "name": {"required": True}, - "product": {"required": True}, - } - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "product": {"key": "product", "type": "str"}, - } - - def __init__(self, *, publisher: str, name: str, product: str, **kwargs: Any) -> None: - """ - :keyword publisher: The publisher ID. Required. - :paramtype publisher: str - :keyword name: The plan ID. Required. - :paramtype name: 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 - """ - super().__init__(**kwargs) - self.publisher = publisher - self.name = name - self.product = product - - -class RecommendedMachineConfiguration(_serialization.Model): - """The properties describe the recommended machine configuration for this Image Definition. These - properties are updatable. - - :ivar v_cp_us: Describes the resource range. - :vartype v_cp_us: ~azure.mgmt.compute.v2019_07_01.models.ResourceRange - :ivar memory: Describes the resource range. - :vartype memory: ~azure.mgmt.compute.v2019_07_01.models.ResourceRange - """ - - _attribute_map = { - "v_cp_us": {"key": "vCPUs", "type": "ResourceRange"}, - "memory": {"key": "memory", "type": "ResourceRange"}, - } - - def __init__( - self, - *, - v_cp_us: Optional["_models.ResourceRange"] = None, - memory: Optional["_models.ResourceRange"] = None, - **kwargs: Any - ) -> None: - """ - :keyword v_cp_us: Describes the resource range. - :paramtype v_cp_us: ~azure.mgmt.compute.v2019_07_01.models.ResourceRange - :keyword memory: Describes the resource range. - :paramtype memory: ~azure.mgmt.compute.v2019_07_01.models.ResourceRange - """ - super().__init__(**kwargs) - self.v_cp_us = v_cp_us - self.memory = memory - - -class RecoveryWalkResponse(_serialization.Model): - """Response after calling a manual recovery walk. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar walk_performed: Whether the recovery walk was performed. - :vartype walk_performed: bool - :ivar next_platform_update_domain: The next update domain that needs to be walked. Null means - walk spanning all update domains has been completed. - :vartype next_platform_update_domain: int - """ - - _validation = { - "walk_performed": {"readonly": True}, - "next_platform_update_domain": {"readonly": True}, - } - - _attribute_map = { - "walk_performed": {"key": "walkPerformed", "type": "bool"}, - "next_platform_update_domain": {"key": "nextPlatformUpdateDomain", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.walk_performed: Optional[bool] = None - self.next_platform_update_domain: Optional[int] = None - - -class RegionalReplicationStatus(_serialization.Model): - """This is the regional replication status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar region: The region to which the gallery Image Version is being replicated to. - :vartype region: str - :ivar state: This is the regional replication state. Known values are: "Unknown", - "Replicating", "Completed", and "Failed". - :vartype state: str or ~azure.mgmt.compute.v2019_07_01.models.ReplicationState - :ivar details: The details of the replication status. - :vartype details: str - :ivar progress: It indicates progress of the replication job. - :vartype progress: int - """ - - _validation = { - "region": {"readonly": True}, - "state": {"readonly": True}, - "details": {"readonly": True}, - "progress": {"readonly": True}, - } - - _attribute_map = { - "region": {"key": "region", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "details": {"key": "details", "type": "str"}, - "progress": {"key": "progress", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.region: Optional[str] = None - self.state: Optional[Union[str, "_models.ReplicationState"]] = None - self.details: Optional[str] = None - self.progress: Optional[int] = None - - -class ReplicationStatus(_serialization.Model): - """This is the replication status of the gallery Image Version. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar aggregated_state: This is the aggregated replication status based on all the regional - replication status flags. Known values are: "Unknown", "InProgress", "Completed", and "Failed". - :vartype aggregated_state: str or - ~azure.mgmt.compute.v2019_07_01.models.AggregatedReplicationState - :ivar summary: This is a summary of replication status for each region. - :vartype summary: list[~azure.mgmt.compute.v2019_07_01.models.RegionalReplicationStatus] - """ - - _validation = { - "aggregated_state": {"readonly": True}, - "summary": {"readonly": True}, - } - - _attribute_map = { - "aggregated_state": {"key": "aggregatedState", "type": "str"}, - "summary": {"key": "summary", "type": "[RegionalReplicationStatus]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.aggregated_state: Optional[Union[str, "_models.AggregatedReplicationState"]] = None - self.summary: Optional[List["_models.RegionalReplicationStatus"]] = None - - -class RequestRateByIntervalInput(LogAnalyticsInputBase): - """Api request input for LogAnalytics getRequestRateByInterval Api. - - All required parameters must be populated in order to send to server. - - :ivar blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api - writes output logs to. Required. - :vartype blob_container_sas_uri: str - :ivar from_time: From time of the query. Required. - :vartype from_time: ~datetime.datetime - :ivar to_time: To time of the query. Required. - :vartype to_time: ~datetime.datetime - :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. - :vartype group_by_throttle_policy: bool - :ivar group_by_operation_name: Group query result by Operation Name. - :vartype group_by_operation_name: bool - :ivar group_by_resource_name: Group query result by Resource Name. - :vartype group_by_resource_name: bool - :ivar interval_length: Interval value in minutes used to create LogAnalytics call rate logs. - Required. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", and "SixtyMins". - :vartype interval_length: str or ~azure.mgmt.compute.v2019_07_01.models.IntervalInMins - """ - - _validation = { - "blob_container_sas_uri": {"required": True}, - "from_time": {"required": True}, - "to_time": {"required": True}, - "interval_length": {"required": True}, - } - - _attribute_map = { - "blob_container_sas_uri": {"key": "blobContainerSasUri", "type": "str"}, - "from_time": {"key": "fromTime", "type": "iso-8601"}, - "to_time": {"key": "toTime", "type": "iso-8601"}, - "group_by_throttle_policy": {"key": "groupByThrottlePolicy", "type": "bool"}, - "group_by_operation_name": {"key": "groupByOperationName", "type": "bool"}, - "group_by_resource_name": {"key": "groupByResourceName", "type": "bool"}, - "interval_length": {"key": "intervalLength", "type": "str"}, - } - - def __init__( - self, - *, - blob_container_sas_uri: str, - from_time: datetime.datetime, - to_time: datetime.datetime, - interval_length: Union[str, "_models.IntervalInMins"], - group_by_throttle_policy: Optional[bool] = None, - group_by_operation_name: Optional[bool] = None, - group_by_resource_name: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics - Api writes output logs to. Required. - :paramtype blob_container_sas_uri: str - :keyword from_time: From time of the query. Required. - :paramtype from_time: ~datetime.datetime - :keyword to_time: To time of the query. Required. - :paramtype to_time: ~datetime.datetime - :keyword group_by_throttle_policy: Group query result by Throttle Policy applied. - :paramtype group_by_throttle_policy: bool - :keyword group_by_operation_name: Group query result by Operation Name. - :paramtype group_by_operation_name: bool - :keyword group_by_resource_name: Group query result by Resource Name. - :paramtype group_by_resource_name: bool - :keyword interval_length: Interval value in minutes used to create LogAnalytics call rate logs. - Required. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", and "SixtyMins". - :paramtype interval_length: str or ~azure.mgmt.compute.v2019_07_01.models.IntervalInMins - """ - super().__init__( - blob_container_sas_uri=blob_container_sas_uri, - from_time=from_time, - to_time=to_time, - group_by_throttle_policy=group_by_throttle_policy, - group_by_operation_name=group_by_operation_name, - group_by_resource_name=group_by_resource_name, - **kwargs - ) - self.interval_length = interval_length - - -class ResourceRange(_serialization.Model): - """Describes the resource range. - - :ivar min: The minimum number of the resource. - :vartype min: int - :ivar max: The maximum number of the resource. - :vartype max: int - """ - - _attribute_map = { - "min": {"key": "min", "type": "int"}, - "max": {"key": "max", "type": "int"}, - } - - def __init__( - self, - *, - min: Optional[int] = None, # pylint: disable=redefined-builtin - max: Optional[int] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword min: The minimum number of the resource. - :paramtype min: int - :keyword max: The maximum number of the resource. - :paramtype max: int - """ - super().__init__(**kwargs) - self.min = min - self.max = max - - -class RollbackStatusInfo(_serialization.Model): - """Information about rollback on failed VM instances after a OS Upgrade operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar successfully_rolledback_instance_count: The number of instances which have been - successfully rolled back. - :vartype successfully_rolledback_instance_count: int - :ivar failed_rolledback_instance_count: The number of instances which failed to rollback. - :vartype failed_rolledback_instance_count: int - :ivar rollback_error: Error details if OS rollback failed. - :vartype rollback_error: ~azure.mgmt.compute.v2019_07_01.models.ApiError - """ - - _validation = { - "successfully_rolledback_instance_count": {"readonly": True}, - "failed_rolledback_instance_count": {"readonly": True}, - "rollback_error": {"readonly": True}, - } - - _attribute_map = { - "successfully_rolledback_instance_count": {"key": "successfullyRolledbackInstanceCount", "type": "int"}, - "failed_rolledback_instance_count": {"key": "failedRolledbackInstanceCount", "type": "int"}, - "rollback_error": {"key": "rollbackError", "type": "ApiError"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.successfully_rolledback_instance_count: Optional[int] = None - self.failed_rolledback_instance_count: Optional[int] = None - self.rollback_error: Optional["_models.ApiError"] = None - - -class RollingUpgradePolicy(_serialization.Model): - """The configuration parameters used while performing a rolling upgrade. - - :ivar max_batch_instance_percent: The maximum percent of total virtual machine instances that - will be upgraded simultaneously by the rolling upgrade in one batch. As this is a maximum, - unhealthy instances in previous or future batches can cause the percentage of instances in a - batch to decrease to ensure higher reliability. The default value for this parameter is 20%. - :vartype max_batch_instance_percent: int - :ivar max_unhealthy_instance_percent: The maximum percentage of the total virtual machine - instances in the scale set that can be simultaneously unhealthy, either as a result of being - upgraded, or by being found in an unhealthy state by the virtual machine health checks before - the rolling upgrade aborts. This constraint will be checked prior to starting any batch. The - default value for this parameter is 20%. - :vartype max_unhealthy_instance_percent: int - :ivar max_unhealthy_upgraded_instance_percent: The maximum percentage of upgraded virtual - machine instances that can be found to be in an unhealthy state. This check will happen after - each batch is upgraded. If this percentage is ever exceeded, the rolling update aborts. The - default value for this parameter is 20%. - :vartype max_unhealthy_upgraded_instance_percent: int - :ivar pause_time_between_batches: The wait time between completing the update for all virtual - machines in one batch and starting the next batch. The time duration should be specified in ISO - 8601 format. The default value is 0 seconds (PT0S). - :vartype pause_time_between_batches: str - """ - - _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}, - } - - _attribute_map = { - "max_batch_instance_percent": {"key": "maxBatchInstancePercent", "type": "int"}, - "max_unhealthy_instance_percent": {"key": "maxUnhealthyInstancePercent", "type": "int"}, - "max_unhealthy_upgraded_instance_percent": {"key": "maxUnhealthyUpgradedInstancePercent", "type": "int"}, - "pause_time_between_batches": {"key": "pauseTimeBetweenBatches", "type": "str"}, - } - - def __init__( - self, - *, - max_batch_instance_percent: Optional[int] = None, - max_unhealthy_instance_percent: Optional[int] = None, - max_unhealthy_upgraded_instance_percent: Optional[int] = None, - pause_time_between_batches: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword max_batch_instance_percent: The maximum percent of total virtual machine instances - that will be upgraded simultaneously by the rolling upgrade in one batch. As this is a maximum, - unhealthy instances in previous or future batches can cause the percentage of instances in a - batch to decrease to ensure higher reliability. The default value for this parameter is 20%. - :paramtype max_batch_instance_percent: int - :keyword max_unhealthy_instance_percent: The maximum percentage of the total virtual machine - instances in the scale set that can be simultaneously unhealthy, either as a result of being - upgraded, or by being found in an unhealthy state by the virtual machine health checks before - the rolling upgrade aborts. This constraint will be checked prior to starting any batch. The - default value for this parameter is 20%. - :paramtype max_unhealthy_instance_percent: int - :keyword max_unhealthy_upgraded_instance_percent: The maximum percentage of upgraded virtual - machine instances that can be found to be in an unhealthy state. This check will happen after - each batch is upgraded. If this percentage is ever exceeded, the rolling update aborts. The - default value for this parameter is 20%. - :paramtype max_unhealthy_upgraded_instance_percent: int - :keyword pause_time_between_batches: The wait time between completing the update for all - virtual machines in one batch and starting the next batch. The time duration should be - specified in ISO 8601 format. The default value is 0 seconds (PT0S). - :paramtype pause_time_between_batches: str - """ - super().__init__(**kwargs) - self.max_batch_instance_percent = max_batch_instance_percent - self.max_unhealthy_instance_percent = max_unhealthy_instance_percent - self.max_unhealthy_upgraded_instance_percent = max_unhealthy_upgraded_instance_percent - self.pause_time_between_batches = pause_time_between_batches - - -class RollingUpgradeProgressInfo(_serialization.Model): - """Information about the number of virtual machine instances in each upgrade state. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar successful_instance_count: The number of instances that have been successfully upgraded. - :vartype successful_instance_count: int - :ivar failed_instance_count: The number of instances that have failed to be upgraded - successfully. - :vartype failed_instance_count: int - :ivar in_progress_instance_count: The number of instances that are currently being upgraded. - :vartype in_progress_instance_count: int - :ivar pending_instance_count: The number of instances that have not yet begun to be upgraded. - :vartype pending_instance_count: int - """ - - _validation = { - "successful_instance_count": {"readonly": True}, - "failed_instance_count": {"readonly": True}, - "in_progress_instance_count": {"readonly": True}, - "pending_instance_count": {"readonly": True}, - } - - _attribute_map = { - "successful_instance_count": {"key": "successfulInstanceCount", "type": "int"}, - "failed_instance_count": {"key": "failedInstanceCount", "type": "int"}, - "in_progress_instance_count": {"key": "inProgressInstanceCount", "type": "int"}, - "pending_instance_count": {"key": "pendingInstanceCount", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.successful_instance_count: Optional[int] = None - self.failed_instance_count: Optional[int] = None - self.in_progress_instance_count: Optional[int] = None - self.pending_instance_count: Optional[int] = None - - -class RollingUpgradeRunningStatus(_serialization.Model): - """Information about the current running state of the overall upgrade. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Code indicating the current status of the upgrade. Known values are: - "RollingForward", "Cancelled", "Completed", and "Faulted". - :vartype code: str or ~azure.mgmt.compute.v2019_07_01.models.RollingUpgradeStatusCode - :ivar start_time: Start time of the upgrade. - :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start" - and "Cancel". - :vartype last_action: str or ~azure.mgmt.compute.v2019_07_01.models.RollingUpgradeActionType - :ivar last_action_time: Last action time of the upgrade. - :vartype last_action_time: ~datetime.datetime - """ - - _validation = { - "code": {"readonly": True}, - "start_time": {"readonly": True}, - "last_action": {"readonly": True}, - "last_action_time": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "last_action": {"key": "lastAction", "type": "str"}, - "last_action_time": {"key": "lastActionTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[Union[str, "_models.RollingUpgradeStatusCode"]] = None - self.start_time: Optional[datetime.datetime] = None - self.last_action: Optional[Union[str, "_models.RollingUpgradeActionType"]] = None - self.last_action_time: Optional[datetime.datetime] = None - - -class RollingUpgradeStatusInfo(Resource): - """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. - :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] - :ivar policy: The rolling upgrade policies applied for this upgrade. - :vartype policy: ~azure.mgmt.compute.v2019_07_01.models.RollingUpgradePolicy - :ivar running_status: Information about the current running state of the overall upgrade. - :vartype running_status: ~azure.mgmt.compute.v2019_07_01.models.RollingUpgradeRunningStatus - :ivar progress: Information about the number of virtual machine instances in each upgrade - state. - :vartype progress: ~azure.mgmt.compute.v2019_07_01.models.RollingUpgradeProgressInfo - :ivar error: Error details for this upgrade, if there are any. - :vartype error: ~azure.mgmt.compute.v2019_07_01.models.ApiError - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "policy": {"readonly": True}, - "running_status": {"readonly": True}, - "progress": {"readonly": True}, - "error": {"readonly": 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}"}, - "policy": {"key": "properties.policy", "type": "RollingUpgradePolicy"}, - "running_status": {"key": "properties.runningStatus", "type": "RollingUpgradeRunningStatus"}, - "progress": {"key": "properties.progress", "type": "RollingUpgradeProgressInfo"}, - "error": {"key": "properties.error", "type": "ApiError"}, - } - - 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__(location=location, tags=tags, **kwargs) - self.policy: Optional["_models.RollingUpgradePolicy"] = None - self.running_status: Optional["_models.RollingUpgradeRunningStatus"] = None - self.progress: Optional["_models.RollingUpgradeProgressInfo"] = None - self.error: Optional["_models.ApiError"] = None - - -class RunCommandDocumentBase(_serialization.Model): - """Describes the properties of a Run Command metadata. - - All required parameters must be populated in order to send to server. - - :ivar schema: The VM run command schema. Required. - :vartype schema: str - :ivar id: The VM run command id. Required. - :vartype id: str - :ivar os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :ivar label: The VM run command label. Required. - :vartype label: str - :ivar description: The VM run command description. Required. - :vartype description: str - """ - - _validation = { - "schema": {"required": True}, - "id": {"required": True}, - "os_type": {"required": True}, - "label": {"required": True}, - "description": {"required": True}, - } - - _attribute_map = { - "schema": {"key": "$schema", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "os_type": {"key": "osType", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - schema: str, - id: str, # pylint: disable=redefined-builtin - os_type: Union[str, "_models.OperatingSystemTypes"], - label: str, - description: str, - **kwargs: Any - ) -> None: - """ - :keyword schema: The VM run command schema. Required. - :paramtype schema: str - :keyword id: The VM run command id. Required. - :paramtype id: str - :keyword os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :keyword label: The VM run command label. Required. - :paramtype label: str - :keyword description: The VM run command description. Required. - :paramtype description: str - """ - super().__init__(**kwargs) - self.schema = schema - self.id = id - self.os_type = os_type - self.label = label - self.description = description - - -class RunCommandDocument(RunCommandDocumentBase): - """Describes the properties of a Run Command. - - All required parameters must be populated in order to send to server. - - :ivar schema: The VM run command schema. Required. - :vartype schema: str - :ivar id: The VM run command id. Required. - :vartype id: str - :ivar os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :ivar label: The VM run command label. Required. - :vartype label: str - :ivar description: The VM run command description. Required. - :vartype description: str - :ivar script: The script to be executed. Required. - :vartype script: list[str] - :ivar parameters: The parameters used by the script. - :vartype parameters: list[~azure.mgmt.compute.v2019_07_01.models.RunCommandParameterDefinition] - """ - - _validation = { - "schema": {"required": True}, - "id": {"required": True}, - "os_type": {"required": True}, - "label": {"required": True}, - "description": {"required": True}, - "script": {"required": True}, - } - - _attribute_map = { - "schema": {"key": "$schema", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "os_type": {"key": "osType", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "script": {"key": "script", "type": "[str]"}, - "parameters": {"key": "parameters", "type": "[RunCommandParameterDefinition]"}, - } - - def __init__( - self, - *, - schema: str, - id: str, # pylint: disable=redefined-builtin - os_type: Union[str, "_models.OperatingSystemTypes"], - label: str, - description: str, - script: List[str], - parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword schema: The VM run command schema. Required. - :paramtype schema: str - :keyword id: The VM run command id. Required. - :paramtype id: str - :keyword os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :keyword label: The VM run command label. Required. - :paramtype label: str - :keyword description: The VM run command description. Required. - :paramtype description: str - :keyword script: The script to be executed. Required. - :paramtype script: list[str] - :keyword parameters: The parameters used by the script. - :paramtype parameters: - list[~azure.mgmt.compute.v2019_07_01.models.RunCommandParameterDefinition] - """ - super().__init__(schema=schema, id=id, os_type=os_type, label=label, description=description, **kwargs) - self.script = script - self.parameters = parameters - - -class RunCommandInput(_serialization.Model): - """Capture Virtual Machine parameters. - - All required parameters must be populated in order to send to server. - - :ivar command_id: The run command id. Required. - :vartype command_id: str - :ivar script: Optional. The script to be executed. When this value is given, the given script - will override the default script of the command. - :vartype script: list[str] - :ivar parameters: The run command parameters. - :vartype parameters: list[~azure.mgmt.compute.v2019_07_01.models.RunCommandInputParameter] - """ - - _validation = { - "command_id": {"required": True}, - } - - _attribute_map = { - "command_id": {"key": "commandId", "type": "str"}, - "script": {"key": "script", "type": "[str]"}, - "parameters": {"key": "parameters", "type": "[RunCommandInputParameter]"}, - } - - def __init__( - self, - *, - command_id: str, - script: Optional[List[str]] = None, - parameters: Optional[List["_models.RunCommandInputParameter"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword command_id: The run command id. Required. - :paramtype command_id: str - :keyword script: Optional. The script to be executed. When this value is given, the given - script will override the default script of the command. - :paramtype script: list[str] - :keyword parameters: The run command parameters. - :paramtype parameters: list[~azure.mgmt.compute.v2019_07_01.models.RunCommandInputParameter] - """ - super().__init__(**kwargs) - self.command_id = command_id - self.script = script - self.parameters = parameters - - -class RunCommandInputParameter(_serialization.Model): - """Describes the properties of a run command parameter. - - All required parameters must be populated in order to send to server. - - :ivar name: The run command parameter name. Required. - :vartype name: str - :ivar value: The run command parameter value. Required. - :vartype value: str - """ - - _validation = { - "name": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: - """ - :keyword name: The run command parameter name. Required. - :paramtype name: str - :keyword value: The run command parameter value. Required. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class RunCommandListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine run commands. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.RunCommandDocumentBase] - :ivar next_link: The uri to fetch the next page of run commands. Call ListNext() with this to - fetch the next page of run commands. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RunCommandDocumentBase]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine run commands. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.RunCommandDocumentBase] - :keyword next_link: The uri to fetch the next page of run commands. Call ListNext() with this - to fetch the next page of run commands. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RunCommandParameterDefinition(_serialization.Model): - """Describes the properties of a run command parameter. - - All required parameters must be populated in order to send to server. - - :ivar name: The run command parameter name. Required. - :vartype name: str - :ivar type: The run command parameter type. Required. - :vartype type: str - :ivar default_value: The run command parameter default value. - :vartype default_value: str - :ivar required: The run command parameter required. - :vartype required: bool - """ - - _validation = { - "name": {"required": True}, - "type": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "default_value": {"key": "defaultValue", "type": "str"}, - "required": {"key": "required", "type": "bool"}, - } - - def __init__( - self, *, name: str, type: str, default_value: Optional[str] = None, required: bool = False, **kwargs: Any - ) -> None: - """ - :keyword name: The run command parameter name. Required. - :paramtype name: str - :keyword type: The run command parameter type. Required. - :paramtype type: str - :keyword default_value: The run command parameter default value. - :paramtype default_value: str - :keyword required: The run command parameter required. - :paramtype required: bool - """ - super().__init__(**kwargs) - self.name = name - self.type = type - self.default_value = default_value - self.required = required - - -class RunCommandResult(_serialization.Model): - """RunCommandResult. - - :ivar value: Run command operation response. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[InstanceViewStatus]"}, - } - - def __init__(self, *, value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Run command operation response. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.value = value - - -class ScaleInPolicy(_serialization.Model): - """Describes a scale-in policy for a virtual machine scale set. - - :ivar rules: The rules to be followed when scaling-in a virtual machine scale set. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Default** When a - virtual machine scale set is scaled in, the scale set will first be balanced across zones if it - is a zonal scale set. Then, it will be balanced across Fault Domains as far as possible. Within - each Fault Domain, the virtual machines chosen for removal will be the newest ones that are not - protected from scale-in. :code:`
    `\\ :code:`
    ` **OldestVM** When a virtual machine scale - set is being scaled-in, the oldest virtual machines that are not protected from scale-in will - be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the oldest virtual machines that are not protected - will be chosen for removal. :code:`
    `\\ :code:`
    ` **NewestVM** When a virtual machine - scale set is being scaled-in, the newest virtual machines that are not protected from scale-in - will be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the newest virtual machines that are not protected - will be chosen for removal. :code:`
    `\\ :code:`
    `. - :vartype rules: list[str or - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetScaleInRules] - """ - - _attribute_map = { - "rules": {"key": "rules", "type": "[str]"}, - } - - def __init__( - self, *, rules: Optional[List[Union[str, "_models.VirtualMachineScaleSetScaleInRules"]]] = None, **kwargs: Any - ) -> None: - """ - :keyword rules: The rules to be followed when scaling-in a virtual machine scale set. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Default** When a - virtual machine scale set is scaled in, the scale set will first be balanced across zones if it - is a zonal scale set. Then, it will be balanced across Fault Domains as far as possible. Within - each Fault Domain, the virtual machines chosen for removal will be the newest ones that are not - protected from scale-in. :code:`
    `\\ :code:`
    ` **OldestVM** When a virtual machine scale - set is being scaled-in, the oldest virtual machines that are not protected from scale-in will - be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the oldest virtual machines that are not protected - will be chosen for removal. :code:`
    `\\ :code:`
    ` **NewestVM** When a virtual machine - scale set is being scaled-in, the newest virtual machines that are not protected from scale-in - will be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the newest virtual machines that are not protected - will be chosen for removal. :code:`
    `\\ :code:`
    `. - :paramtype rules: list[str or - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetScaleInRules] - """ - super().__init__(**kwargs) - self.rules = rules - - -class ScheduledEventsProfile(_serialization.Model): - """ScheduledEventsProfile. - - :ivar terminate_notification_profile: Specifies Terminate Scheduled Event related - configurations. - :vartype terminate_notification_profile: - ~azure.mgmt.compute.v2019_07_01.models.TerminateNotificationProfile - """ - - _attribute_map = { - "terminate_notification_profile": { - "key": "terminateNotificationProfile", - "type": "TerminateNotificationProfile", - }, - } - - def __init__( - self, *, terminate_notification_profile: Optional["_models.TerminateNotificationProfile"] = None, **kwargs: Any - ) -> None: - """ - :keyword terminate_notification_profile: Specifies Terminate Scheduled Event related - configurations. - :paramtype terminate_notification_profile: - ~azure.mgmt.compute.v2019_07_01.models.TerminateNotificationProfile - """ - super().__init__(**kwargs) - self.terminate_notification_profile = terminate_notification_profile - - -class Sku(_serialization.Model): - """Describes a virtual machine scale set sku. NOTE: If the new VM SKU is not supported on the - hardware the scale set is currently on, you need to deallocate the VMs in the scale set before - you modify the SKU name. - - :ivar name: The sku name. - :vartype name: str - :ivar tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
    `\\ - :code:`
    ` Possible Values:\\ :code:`
    `\\ :code:`
    ` **Standard**\\ :code:`
    `\\ :code:`
    ` **Basic**. - :vartype tier: str - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: int - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "capacity": {"key": "capacity", "type": "int"}, - } - - def __init__( - self, *, name: Optional[str] = None, tier: Optional[str] = None, capacity: Optional[int] = None, **kwargs: Any - ) -> None: - """ - :keyword name: The sku name. - :paramtype name: str - :keyword tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
    `\\ - :code:`
    ` Possible Values:\\ :code:`
    `\\ :code:`
    ` **Standard**\\ :code:`
    `\\ :code:`
    ` **Basic**. - :paramtype tier: str - :keyword capacity: Specifies the number of virtual machines in the scale set. - :paramtype capacity: int - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - self.capacity = capacity - - -class Snapshot(Resource): - """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. - :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] - :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. - :vartype sku: ~azure.mgmt.compute.v2019_07_01.models.SnapshotSku - :ivar time_created: The time when the disk was created. - :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGeneration - :ivar creation_data: Disk source information. CreationData information cannot be changed after - the disk has been created. - :vartype creation_data: ~azure.mgmt.compute.v2019_07_01.models.CreationData - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. - :vartype disk_size_bytes: int - :ivar unique_id: Unique Guid identifying the resource. - :vartype unique_id: str - :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2019_07_01.models.EncryptionSettingsCollection - :ivar provisioning_state: The disk provisioning state. - :vartype provisioning_state: str - :ivar incremental: Whether a snapshot is incremental. Incremental snapshots on the same disk - occupy less space than full snapshots and can be diffed. - :vartype incremental: bool - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2019_07_01.models.Encryption - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "managed_by": {"readonly": True}, - "time_created": {"readonly": True}, - "disk_size_bytes": {"readonly": True}, - "unique_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "sku": {"key": "sku", "type": "SnapshotSku"}, - "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "creation_data": {"key": "properties.creationData", "type": "CreationData"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "disk_size_bytes": {"key": "properties.diskSizeBytes", "type": "int"}, - "unique_id": {"key": "properties.uniqueId", "type": "str"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "incremental": {"key": "properties.incremental", "type": "bool"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.SnapshotSku"] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - creation_data: Optional["_models.CreationData"] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - incremental: Optional[bool] = None, - encryption: Optional["_models.Encryption"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. - :paramtype sku: ~azure.mgmt.compute.v2019_07_01.models.SnapshotSku - :keyword os_type: The Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :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.v2019_07_01.models.HyperVGeneration - :keyword creation_data: Disk source information. CreationData information cannot be changed - after the disk has been created. - :paramtype creation_data: ~azure.mgmt.compute.v2019_07_01.models.CreationData - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2019_07_01.models.EncryptionSettingsCollection - :keyword incremental: Whether a snapshot is incremental. Incremental snapshots on the same disk - occupy less space than full snapshots and can be diffed. - :paramtype incremental: bool - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2019_07_01.models.Encryption - """ - super().__init__(location=location, tags=tags, **kwargs) - self.managed_by: Optional[str] = None - self.sku = sku - self.time_created: Optional[datetime.datetime] = None - self.os_type = os_type - self.hyper_v_generation = hyper_v_generation - self.creation_data = creation_data - self.disk_size_gb = disk_size_gb - self.disk_size_bytes: Optional[int] = None - self.unique_id: Optional[str] = None - self.encryption_settings_collection = encryption_settings_collection - self.provisioning_state: Optional[str] = None - self.incremental = incremental - self.encryption = encryption - - -class SnapshotList(_serialization.Model): - """The List Snapshots operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of snapshots. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Snapshot]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of snapshots. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SnapshotSku(_serialization.Model): - """The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", and "Standard_ZRS". - :vartype name: str or ~azure.mgmt.compute.v2019_07_01.models.SnapshotStorageAccountTypes - :ivar tier: The sku tier. - :vartype tier: str - """ - - _validation = { - "tier": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__( - self, *, name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs: Any - ) -> None: - """ - :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", and - "Standard_ZRS". - :paramtype name: str or ~azure.mgmt.compute.v2019_07_01.models.SnapshotStorageAccountTypes - """ - super().__init__(**kwargs) - self.name = name - self.tier: Optional[str] = None - - -class SnapshotUpdate(_serialization.Model): - """Snapshot update resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. - :vartype sku: ~azure.mgmt.compute.v2019_07_01.models.SnapshotSku - :ivar os_type: the Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2019_07_01.models.EncryptionSettingsCollection - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2019_07_01.models.Encryption - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "SnapshotSku"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.SnapshotSku"] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - encryption: Optional["_models.Encryption"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. - :paramtype sku: ~azure.mgmt.compute.v2019_07_01.models.SnapshotSku - :keyword os_type: the Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2019_07_01.models.EncryptionSettingsCollection - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2019_07_01.models.Encryption - """ - super().__init__(**kwargs) - self.tags = tags - self.sku = sku - self.os_type = os_type - self.disk_size_gb = disk_size_gb - self.encryption_settings_collection = encryption_settings_collection - self.encryption = encryption - - -class SourceVault(_serialization.Model): - """The vault id is an Azure Resource Manager Resource id in the form - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class SshConfiguration(_serialization.Model): - """SSH configuration for Linux based VMs running on Azure. - - :ivar public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :vartype public_keys: list[~azure.mgmt.compute.v2019_07_01.models.SshPublicKey] - """ - - _attribute_map = { - "public_keys": {"key": "publicKeys", "type": "[SshPublicKey]"}, - } - - def __init__(self, *, public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs: Any) -> None: - """ - :keyword public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :paramtype public_keys: list[~azure.mgmt.compute.v2019_07_01.models.SshPublicKey] - """ - super().__init__(**kwargs) - self.public_keys = public_keys - - -class SshPublicKey(_serialization.Model): - """Contains information about SSH certificate public key and the path on the Linux VM where the - public key is placed. - - :ivar path: Specifies the full path on the created VM where ssh public key is stored. If the - file already exists, the specified key is appended to the file. Example: - /home/user/.ssh/authorized_keys. - :vartype path: str - :ivar key_data: SSH public key certificate used to authenticate with the VM through ssh. The - key needs to be at least 2048-bit and in ssh-rsa format. :code:`
    `\\ :code:`
    ` For - creating ssh keys, see `Create SSH keys on Linux and Mac for Linux VMs in Azure - `_. - :vartype key_data: str - """ - - _attribute_map = { - "path": {"key": "path", "type": "str"}, - "key_data": {"key": "keyData", "type": "str"}, - } - - def __init__(self, *, path: Optional[str] = None, key_data: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword path: Specifies the full path on the created VM where ssh public key is stored. If the - file already exists, the specified key is appended to the file. Example: - /home/user/.ssh/authorized_keys. - :paramtype path: str - :keyword key_data: SSH public key certificate used to authenticate with the VM through ssh. The - key needs to be at least 2048-bit and in ssh-rsa format. :code:`
    `\\ :code:`
    ` For - creating ssh keys, see `Create SSH keys on Linux and Mac for Linux VMs in Azure - `_. - :paramtype key_data: str - """ - super().__init__(**kwargs) - self.path = path - self.key_data = key_data - - -class StorageProfile(_serialization.Model): - """Specifies the storage settings for the virtual machine disks. - - :ivar image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :vartype image_reference: ~azure.mgmt.compute.v2019_07_01.models.ImageReference - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2019_07_01.models.OSDisk - :ivar data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype data_disks: list[~azure.mgmt.compute.v2019_07_01.models.DataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "OSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[DataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.OSDisk"] = None, - data_disks: Optional[List["_models.DataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :paramtype image_reference: ~azure.mgmt.compute.v2019_07_01.models.ImageReference - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2019_07_01.models.OSDisk - :keyword data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype data_disks: list[~azure.mgmt.compute.v2019_07_01.models.DataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class SubResourceReadOnly(_serialization.Model): - """SubResourceReadOnly. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class SubResourceWithColocationStatus(SubResource): - """SubResourceWithColocationStatus. - - :ivar id: Resource Id. - :vartype id: str - :ivar colocation_status: Describes colocation status of a resource in the Proximity Placement - Group. - :vartype colocation_status: ~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "colocation_status": {"key": "colocationStatus", "type": "InstanceViewStatus"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - colocation_status: Optional["_models.InstanceViewStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword colocation_status: Describes colocation status of a resource in the Proximity - Placement Group. - :paramtype colocation_status: ~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus - """ - super().__init__(id=id, **kwargs) - self.colocation_status = colocation_status - - -class TargetRegion(_serialization.Model): - """Describes the target region information. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the region. Required. - :vartype name: str - :ivar regional_replica_count: The number of replicas of the Image Version to be created per - region. This property is updatable. - :vartype regional_replica_count: int - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS" and "Standard_ZRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountType - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "regional_replica_count": {"key": "regionalReplicaCount", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - regional_replica_count: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the region. Required. - :paramtype name: str - :keyword regional_replica_count: The number of replicas of the Image Version to be created per - region. This property is updatable. - :paramtype regional_replica_count: int - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS" and "Standard_ZRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2019_07_01.models.StorageAccountType - """ - super().__init__(**kwargs) - self.name = name - self.regional_replica_count = regional_replica_count - self.storage_account_type = storage_account_type - - -class TerminateNotificationProfile(_serialization.Model): - """TerminateNotificationProfile. - - :ivar not_before_timeout: Configurable length of time a Virtual Machine being deleted will have - to potentially approve the Terminate Scheduled Event before the event is auto approved (timed - out). The configuration must be specified in ISO 8601 format, the default value is 5 minutes - (PT5M). - :vartype not_before_timeout: str - :ivar enable: Specifies whether the Terminate Scheduled event is enabled or disabled. - :vartype enable: bool - """ - - _attribute_map = { - "not_before_timeout": {"key": "notBeforeTimeout", "type": "str"}, - "enable": {"key": "enable", "type": "bool"}, - } - - def __init__( - self, *, not_before_timeout: Optional[str] = None, enable: Optional[bool] = None, **kwargs: Any - ) -> None: - """ - :keyword not_before_timeout: Configurable length of time a Virtual Machine being deleted will - have to potentially approve the Terminate Scheduled Event before the event is auto approved - (timed out). The configuration must be specified in ISO 8601 format, the default value is 5 - minutes (PT5M). - :paramtype not_before_timeout: str - :keyword enable: Specifies whether the Terminate Scheduled event is enabled or disabled. - :paramtype enable: bool - """ - super().__init__(**kwargs) - self.not_before_timeout = not_before_timeout - self.enable = enable - - -class ThrottledRequestsInput(LogAnalyticsInputBase): - """Api request input for LogAnalytics getThrottledRequests Api. - - All required parameters must be populated in order to send to server. - - :ivar blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api - writes output logs to. Required. - :vartype blob_container_sas_uri: str - :ivar from_time: From time of the query. Required. - :vartype from_time: ~datetime.datetime - :ivar to_time: To time of the query. Required. - :vartype to_time: ~datetime.datetime - :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. - :vartype group_by_throttle_policy: bool - :ivar group_by_operation_name: Group query result by Operation Name. - :vartype group_by_operation_name: bool - :ivar group_by_resource_name: Group query result by Resource Name. - :vartype group_by_resource_name: bool - """ - - -class UpgradeOperationHistoricalStatusInfo(_serialization.Model): - """Virtual Machine Scale Set OS Upgrade History operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar properties: Information about the properties of the upgrade operation. - :vartype properties: - ~azure.mgmt.compute.v2019_07_01.models.UpgradeOperationHistoricalStatusInfoProperties - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - """ - - _validation = { - "properties": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "properties": {"key": "properties", "type": "UpgradeOperationHistoricalStatusInfoProperties"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.properties: Optional["_models.UpgradeOperationHistoricalStatusInfoProperties"] = None - self.type: Optional[str] = None - self.location: Optional[str] = None - - -class UpgradeOperationHistoricalStatusInfoProperties(_serialization.Model): # pylint: disable=name-too-long - """Describes each OS upgrade on the Virtual Machine Scale Set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar running_status: Information about the overall status of the upgrade operation. - :vartype running_status: ~azure.mgmt.compute.v2019_07_01.models.UpgradeOperationHistoryStatus - :ivar progress: Counts of the VMs in each state. - :vartype progress: ~azure.mgmt.compute.v2019_07_01.models.RollingUpgradeProgressInfo - :ivar error: Error Details for this upgrade if there are any. - :vartype error: ~azure.mgmt.compute.v2019_07_01.models.ApiError - :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", and - "Platform". - :vartype started_by: str or ~azure.mgmt.compute.v2019_07_01.models.UpgradeOperationInvoker - :ivar target_image_reference: Image Reference details. - :vartype target_image_reference: ~azure.mgmt.compute.v2019_07_01.models.ImageReference - :ivar rollback_info: Information about OS rollback if performed. - :vartype rollback_info: ~azure.mgmt.compute.v2019_07_01.models.RollbackStatusInfo - """ - - _validation = { - "running_status": {"readonly": True}, - "progress": {"readonly": True}, - "error": {"readonly": True}, - "started_by": {"readonly": True}, - "target_image_reference": {"readonly": True}, - "rollback_info": {"readonly": True}, - } - - _attribute_map = { - "running_status": {"key": "runningStatus", "type": "UpgradeOperationHistoryStatus"}, - "progress": {"key": "progress", "type": "RollingUpgradeProgressInfo"}, - "error": {"key": "error", "type": "ApiError"}, - "started_by": {"key": "startedBy", "type": "str"}, - "target_image_reference": {"key": "targetImageReference", "type": "ImageReference"}, - "rollback_info": {"key": "rollbackInfo", "type": "RollbackStatusInfo"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.running_status: Optional["_models.UpgradeOperationHistoryStatus"] = None - self.progress: Optional["_models.RollingUpgradeProgressInfo"] = None - self.error: Optional["_models.ApiError"] = None - self.started_by: Optional[Union[str, "_models.UpgradeOperationInvoker"]] = None - self.target_image_reference: Optional["_models.ImageReference"] = None - self.rollback_info: Optional["_models.RollbackStatusInfo"] = None - - -class UpgradeOperationHistoryStatus(_serialization.Model): - """Information about the current running state of the overall upgrade. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Code indicating the current status of the upgrade. Known values are: - "RollingForward", "Cancelled", "Completed", and "Faulted". - :vartype code: str or ~azure.mgmt.compute.v2019_07_01.models.UpgradeState - :ivar start_time: Start time of the upgrade. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the upgrade. - :vartype end_time: ~datetime.datetime - """ - - _validation = { - "code": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[Union[str, "_models.UpgradeState"]] = None - self.start_time: Optional[datetime.datetime] = None - self.end_time: Optional[datetime.datetime] = None - - -class UpgradePolicy(_serialization.Model): - """Describes an upgrade policy - automatic, manual, or rolling. - - :ivar mode: Specifies the mode of an upgrade to virtual machines in the scale set.\\ :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Manual** - You - control the application of updates to virtual machines in the scale set. You do this by using - the manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - All virtual - machines in the scale set are automatically updated at the same time. Known values are: - "Automatic", "Manual", and "Rolling". - :vartype mode: str or ~azure.mgmt.compute.v2019_07_01.models.UpgradeMode - :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling - upgrade. - :vartype rolling_upgrade_policy: ~azure.mgmt.compute.v2019_07_01.models.RollingUpgradePolicy - :ivar automatic_os_upgrade_policy: Configuration parameters used for performing automatic OS - Upgrade. - :vartype automatic_os_upgrade_policy: - ~azure.mgmt.compute.v2019_07_01.models.AutomaticOSUpgradePolicy - """ - - _attribute_map = { - "mode": {"key": "mode", "type": "str"}, - "rolling_upgrade_policy": {"key": "rollingUpgradePolicy", "type": "RollingUpgradePolicy"}, - "automatic_os_upgrade_policy": {"key": "automaticOSUpgradePolicy", "type": "AutomaticOSUpgradePolicy"}, - } - - def __init__( - self, - *, - mode: Optional[Union[str, "_models.UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, - automatic_os_upgrade_policy: Optional["_models.AutomaticOSUpgradePolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword mode: Specifies the mode of an upgrade to virtual machines in the scale set.\\ - :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` - **Manual** - You control the application of updates to virtual machines in the scale set. You - do this by using the manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - - All virtual machines in the scale set are automatically updated at the same time. Known values - are: "Automatic", "Manual", and "Rolling". - :paramtype mode: str or ~azure.mgmt.compute.v2019_07_01.models.UpgradeMode - :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling - upgrade. - :paramtype rolling_upgrade_policy: ~azure.mgmt.compute.v2019_07_01.models.RollingUpgradePolicy - :keyword automatic_os_upgrade_policy: Configuration parameters used for performing automatic OS - Upgrade. - :paramtype automatic_os_upgrade_policy: - ~azure.mgmt.compute.v2019_07_01.models.AutomaticOSUpgradePolicy - """ - super().__init__(**kwargs) - self.mode = mode - self.rolling_upgrade_policy = rolling_upgrade_policy - self.automatic_os_upgrade_policy = automatic_os_upgrade_policy - - -class Usage(_serialization.Model): - """Describes Compute Resource Usage. - - 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 unit: An enum describing the unit of usage measurement. Required. Default value is - "Count". - :vartype unit: str - :ivar current_value: The current usage of the resource. Required. - :vartype current_value: int - :ivar limit: The maximum permitted usage of the resource. Required. - :vartype limit: int - :ivar name: The name of the type of usage. Required. - :vartype name: ~azure.mgmt.compute.v2019_07_01.models.UsageName - """ - - _validation = { - "unit": {"required": True, "constant": True}, - "current_value": {"required": True}, - "limit": {"required": True}, - "name": {"required": True}, - } - - _attribute_map = { - "unit": {"key": "unit", "type": "str"}, - "current_value": {"key": "currentValue", "type": "int"}, - "limit": {"key": "limit", "type": "int"}, - "name": {"key": "name", "type": "UsageName"}, - } - - unit = "Count" - - def __init__(self, *, current_value: int, limit: int, name: "_models.UsageName", **kwargs: Any) -> None: - """ - :keyword current_value: The current usage of the resource. Required. - :paramtype current_value: int - :keyword limit: The maximum permitted usage of the resource. Required. - :paramtype limit: int - :keyword name: The name of the type of usage. Required. - :paramtype name: ~azure.mgmt.compute.v2019_07_01.models.UsageName - """ - super().__init__(**kwargs) - self.current_value = current_value - self.limit = limit - self.name = name - - -class UsageName(_serialization.Model): - """The Usage Names. - - :ivar value: The name of the resource. - :vartype value: str - :ivar localized_value: The localized name of the resource. - :vartype localized_value: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, - } - - def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The name of the resource. - :paramtype value: str - :keyword localized_value: The localized name of the resource. - :paramtype localized_value: str - """ - super().__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - -class UserArtifactManage(_serialization.Model): - """UserArtifactManage. - - All required parameters must be populated in order to send to server. - - :ivar install: Required. The path and arguments to install the gallery application. This is - limited to 4096 characters. Required. - :vartype install: str - :ivar remove: Required. The path and arguments to remove the gallery application. This is - limited to 4096 characters. Required. - :vartype remove: str - :ivar update: Optional. The path and arguments to update the gallery application. If not - present, then update operation will invoke remove command on the previous version and install - command on the current version of the gallery application. This is limited to 4096 characters. - :vartype update: str - """ - - _validation = { - "install": {"required": True}, - "remove": {"required": True}, - } - - _attribute_map = { - "install": {"key": "install", "type": "str"}, - "remove": {"key": "remove", "type": "str"}, - "update": {"key": "update", "type": "str"}, - } - - def __init__(self, *, install: str, remove: str, update: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword install: Required. The path and arguments to install the gallery application. This is - limited to 4096 characters. Required. - :paramtype install: str - :keyword remove: Required. The path and arguments to remove the gallery application. This is - limited to 4096 characters. Required. - :paramtype remove: str - :keyword update: Optional. The path and arguments to update the gallery application. If not - present, then update operation will invoke remove command on the previous version and install - command on the current version of the gallery application. This is limited to 4096 characters. - :paramtype update: str - """ - super().__init__(**kwargs) - self.install = install - self.remove = remove - self.update = update - - -class UserArtifactSource(_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 media_link: Required. The mediaLink of the artifact, must be a readable storage page - blob. Required. - :vartype media_link: str - :ivar default_configuration_link: Optional. The defaultConfigurationLink of the artifact, must - be a readable storage page blob. - :vartype default_configuration_link: str - """ - - _validation = { - "media_link": {"required": True}, - } - - _attribute_map = { - "media_link": {"key": "mediaLink", "type": "str"}, - "default_configuration_link": {"key": "defaultConfigurationLink", "type": "str"}, - } - - def __init__(self, *, media_link: str, default_configuration_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword media_link: Required. The mediaLink of the artifact, must be a readable storage page - blob. Required. - :paramtype media_link: str - :keyword default_configuration_link: Optional. The defaultConfigurationLink of the artifact, - must be a readable storage page blob. - :paramtype default_configuration_link: str - """ - super().__init__(**kwargs) - self.media_link = media_link - self.default_configuration_link = default_configuration_link - - -class UserAssignedIdentitiesValue(_serialization.Model): - """UserAssignedIdentitiesValue. - - 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: Optional[str] = None - self.client_id: Optional[str] = None - - -class VaultCertificate(_serialization.Model): - """Describes a single certificate reference in a Key Vault, and where the certificate should - reside on the VM. - - :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as - a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :vartype certificate_url: str - :ivar certificate_store: For Windows VMs, specifies the certificate store on the Virtual - Machine to which the certificate should be added. The specified certificate store is implicitly - in the LocalMachine account. :code:`
    `\\ :code:`
    `For Linux VMs, the certificate file is - placed under the /var/lib/waagent directory, with the file name <UppercaseThumbprint>.crt - for the X509 certificate file and <UppercaseThumbprint>.prv for private key. Both of - these files are .pem formatted. - :vartype certificate_store: str - """ - - _attribute_map = { - "certificate_url": {"key": "certificateUrl", "type": "str"}, - "certificate_store": {"key": "certificateStore", "type": "str"}, - } - - def __init__( - self, *, certificate_url: Optional[str] = None, certificate_store: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault - as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :paramtype certificate_url: str - :keyword certificate_store: For Windows VMs, specifies the certificate store on the Virtual - Machine to which the certificate should be added. The specified certificate store is implicitly - in the LocalMachine account. :code:`
    `\\ :code:`
    `For Linux VMs, the certificate file is - placed under the /var/lib/waagent directory, with the file name <UppercaseThumbprint>.crt - for the X509 certificate file and <UppercaseThumbprint>.prv for private key. Both of - these files are .pem formatted. - :paramtype certificate_store: str - """ - super().__init__(**kwargs) - self.certificate_url = certificate_url - self.certificate_store = certificate_store - - -class VaultSecretGroup(_serialization.Model): - """Describes a set of certificates which are all in the same Key Vault. - - :ivar source_vault: The relative URL of the Key Vault containing all of the certificates in - VaultCertificates. - :vartype source_vault: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar vault_certificates: The list of key vault references in SourceVault which contain - certificates. - :vartype vault_certificates: list[~azure.mgmt.compute.v2019_07_01.models.VaultCertificate] - """ - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - "vault_certificates": {"key": "vaultCertificates", "type": "[VaultCertificate]"}, - } - - def __init__( - self, - *, - source_vault: Optional["_models.SubResource"] = None, - vault_certificates: Optional[List["_models.VaultCertificate"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source_vault: The relative URL of the Key Vault containing all of the certificates in - VaultCertificates. - :paramtype source_vault: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword vault_certificates: The list of key vault references in SourceVault which contain - certificates. - :paramtype vault_certificates: list[~azure.mgmt.compute.v2019_07_01.models.VaultCertificate] - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.vault_certificates = vault_certificates - - -class VirtualHardDisk(_serialization.Model): - """Describes the uri of a disk. - - :ivar uri: Specifies the virtual hard disk's uri. - :vartype uri: str - """ - - _attribute_map = { - "uri": {"key": "uri", "type": "str"}, - } - - def __init__(self, *, uri: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword uri: Specifies the virtual hard disk's uri. - :paramtype uri: str - """ - super().__init__(**kwargs) - self.uri = uri - - -class VirtualMachine(Resource): - """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. - :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] - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2019_07_01.models.Plan - :ivar resources: The virtual machine child extension resources. - :vartype resources: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] - :ivar identity: The identity of the virtual machine, if configured. - :vartype identity: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineIdentity - :ivar zones: The virtual machine zones. - :vartype zones: list[str] - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2019_07_01.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2019_07_01.models.StorageProfile - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine. - :vartype additional_capabilities: ~azure.mgmt.compute.v2019_07_01.models.AdditionalCapabilities - :ivar os_profile: Specifies the operating system settings used while creating the virtual - machine. Some of the settings cannot be changed once VM is provisioned. - :vartype os_profile: ~azure.mgmt.compute.v2019_07_01.models.OSProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2019_07_01.models.NetworkProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2019_07_01.models.DiagnosticsProfile - :ivar availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. The availability set to which the VM is being added should be under the same resource - group as the availability set resource. An existing VM cannot be added to an availability set. - :code:`
    `\\ :code:`
    `This property cannot exist along with a non-null - properties.virtualMachineScaleSet reference. - :vartype availability_set: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar virtual_machine_scale_set: Specifies information about the virtual machine scale set that - the virtual machine should be assigned to. Virtual machines specified in the same virtual - machine scale set are allocated to different nodes to maximize availability. Currently, a VM - can only be added to virtual machine scale set at creation time. An existing VM cannot be added - to a virtual machine scale set. :code:`
    `\\ :code:`
    `This property cannot exist along - with a non-null properties.availabilitySet reference. :code:`
    `\\ :code:`
    `Minimum - api‐version: 2019‐03‐01. - :vartype virtual_machine_scale_set: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the virtual machine should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar priority: Specifies the priority for the virtual machine. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :vartype priority: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachinePriorityTypes - :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, the only - supported value is 'Deallocate' and the minimum api-version is 2019-03-01. :code:`
    `\\ - :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported and the - minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and "Delete". - :vartype eviction_policy: str or - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineEvictionPolicyTypes - :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2019_07_01.models.BillingProfile - :ivar host: Specifies information about the dedicated host that the virtual machine resides in. - :code:`
    `\\ :code:`
    `Minimum api-version: 2018-10-01. - :vartype host: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineInstanceView - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar vm_id: Specifies the VM unique ID which is a 128-bits identifier that is encoded and - stored in all Azure IaaS VMs SMBIOS and can be read using platform BIOS commands. - :vartype vm_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "resources": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - "vm_id": {"readonly": 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}"}, - "plan": {"key": "plan", "type": "Plan"}, - "resources": {"key": "resources", "type": "[VirtualMachineExtension]"}, - "identity": {"key": "identity", "type": "VirtualMachineIdentity"}, - "zones": {"key": "zones", "type": "[str]"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "virtual_machine_scale_set": {"key": "properties.virtualMachineScaleSet", "type": "SubResource"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "priority": {"key": "properties.priority", "type": "str"}, - "eviction_policy": {"key": "properties.evictionPolicy", "type": "str"}, - "billing_profile": {"key": "properties.billingProfile", "type": "BillingProfile"}, - "host": {"key": "properties.host", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineInstanceView"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineIdentity"] = None, - zones: Optional[List[str]] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - os_profile: Optional["_models.OSProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - virtual_machine_scale_set: Optional["_models.SubResource"] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["_models.BillingProfile"] = None, - host: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2019_07_01.models.Plan - :keyword identity: The identity of the virtual machine, if configured. - :paramtype identity: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineIdentity - :keyword zones: The virtual machine zones. - :paramtype zones: list[str] - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2019_07_01.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2019_07_01.models.StorageProfile - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2019_07_01.models.AdditionalCapabilities - :keyword os_profile: Specifies the operating system settings used while creating the virtual - machine. Some of the settings cannot be changed once VM is provisioned. - :paramtype os_profile: ~azure.mgmt.compute.v2019_07_01.models.OSProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2019_07_01.models.NetworkProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2019_07_01.models.DiagnosticsProfile - :keyword availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. The availability set to which the VM is being added should be under the same resource - group as the availability set resource. An existing VM cannot be added to an availability set. - :code:`
    `\\ :code:`
    `This property cannot exist along with a non-null - properties.virtualMachineScaleSet reference. - :paramtype availability_set: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword virtual_machine_scale_set: Specifies information about the virtual machine scale set - that the virtual machine should be assigned to. Virtual machines specified in the same virtual - machine scale set are allocated to different nodes to maximize availability. Currently, a VM - can only be added to virtual machine scale set at creation time. An existing VM cannot be added - to a virtual machine scale set. :code:`
    `\\ :code:`
    `This property cannot exist along - with a non-null properties.availabilitySet reference. :code:`
    `\\ :code:`
    `Minimum - api‐version: 2019‐03‐01. - :paramtype virtual_machine_scale_set: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the virtual machine should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword priority: Specifies the priority for the virtual machine. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :paramtype priority: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachinePriorityTypes - :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, the only - supported value is 'Deallocate' and the minimum api-version is 2019-03-01. :code:`
    `\\ - :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported and the - minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and "Delete". - :paramtype eviction_policy: str or - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineEvictionPolicyTypes - :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual - machine. :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2019_07_01.models.BillingProfile - :keyword host: Specifies information about the dedicated host that the virtual machine resides - in. :code:`
    `\\ :code:`
    `Minimum api-version: 2018-10-01. - :paramtype host: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.plan = plan - self.resources: Optional[List["_models.VirtualMachineExtension"]] = None - self.identity = identity - self.zones = zones - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.additional_capabilities = additional_capabilities - self.os_profile = os_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.virtual_machine_scale_set = virtual_machine_scale_set - self.proximity_placement_group = proximity_placement_group - self.priority = priority - self.eviction_policy = eviction_policy - self.billing_profile = billing_profile - self.host = host - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineInstanceView"] = None - self.license_type = license_type - self.vm_id: Optional[str] = None - - -class VirtualMachineAgentInstanceView(_serialization.Model): - """The instance view of the VM Agent running on the virtual machine. - - :ivar vm_agent_version: The VM Agent full version. - :vartype vm_agent_version: str - :ivar extension_handlers: The virtual machine extension handler instance view. - :vartype extension_handlers: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionHandlerInstanceView] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "vm_agent_version": {"key": "vmAgentVersion", "type": "str"}, - "extension_handlers": {"key": "extensionHandlers", "type": "[VirtualMachineExtensionHandlerInstanceView]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword vm_agent_version: The VM Agent full version. - :paramtype vm_agent_version: str - :keyword extension_handlers: The virtual machine extension handler instance view. - :paramtype extension_handlers: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionHandlerInstanceView] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.vm_agent_version = vm_agent_version - self.extension_handlers = extension_handlers - self.statuses = statuses - - -class VirtualMachineCaptureParameters(_serialization.Model): - """Capture Virtual Machine parameters. - - All required parameters must be populated in order to send to server. - - :ivar vhd_prefix: The captured virtual hard disk's name prefix. Required. - :vartype vhd_prefix: str - :ivar destination_container_name: The destination container name. Required. - :vartype destination_container_name: str - :ivar overwrite_vhds: Specifies whether to overwrite the destination virtual hard disk, in case - of conflict. Required. - :vartype overwrite_vhds: bool - """ - - _validation = { - "vhd_prefix": {"required": True}, - "destination_container_name": {"required": True}, - "overwrite_vhds": {"required": True}, - } - - _attribute_map = { - "vhd_prefix": {"key": "vhdPrefix", "type": "str"}, - "destination_container_name": {"key": "destinationContainerName", "type": "str"}, - "overwrite_vhds": {"key": "overwriteVhds", "type": "bool"}, - } - - def __init__( - self, *, vhd_prefix: str, destination_container_name: str, overwrite_vhds: bool, **kwargs: Any - ) -> None: - """ - :keyword vhd_prefix: The captured virtual hard disk's name prefix. Required. - :paramtype vhd_prefix: str - :keyword destination_container_name: The destination container name. Required. - :paramtype destination_container_name: str - :keyword overwrite_vhds: Specifies whether to overwrite the destination virtual hard disk, in - case of conflict. Required. - :paramtype overwrite_vhds: bool - """ - super().__init__(**kwargs) - self.vhd_prefix = vhd_prefix - self.destination_container_name = destination_container_name - self.overwrite_vhds = overwrite_vhds - - -class VirtualMachineCaptureResult(SubResource): - """Output of virtual machine capture operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar schema: the schema of the captured virtual machine. - :vartype schema: str - :ivar content_version: the version of the content. - :vartype content_version: str - :ivar parameters: parameters of the captured virtual machine. - :vartype parameters: JSON - :ivar resources: a list of resource items of the captured virtual machine. - :vartype resources: list[JSON] - """ - - _validation = { - "schema": {"readonly": True}, - "content_version": {"readonly": True}, - "parameters": {"readonly": True}, - "resources": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "schema": {"key": "$schema", "type": "str"}, - "content_version": {"key": "contentVersion", "type": "str"}, - "parameters": {"key": "parameters", "type": "object"}, - "resources": {"key": "resources", "type": "[object]"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(id=id, **kwargs) - self.schema: Optional[str] = None - self.content_version: Optional[str] = None - self.parameters: Optional[JSON] = None - self.resources: Optional[List[JSON]] = None - - -class VirtualMachineExtension(Resource): - """Describes a Virtual Machine Extension. - - 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] - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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. - :vartype instance_view: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionInstanceView - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineExtensionInstanceView"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, 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, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :keyword instance_view: The virtual machine extension instance view. - :paramtype instance_view: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionInstanceView - """ - super().__init__(location=location, tags=tags, **kwargs) - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - self.instance_view = instance_view - - -class VirtualMachineExtensionHandlerInstanceView(_serialization.Model): # pylint: disable=name-too-long - """The instance view of a virtual machine extension handler. - - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar status: The extension handler status. - :vartype status: ~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "status": {"key": "status", "type": "InstanceViewStatus"}, - } - - def __init__( - self, - *, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - status: Optional["_models.InstanceViewStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword status: The extension handler status. - :paramtype status: ~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus - """ - super().__init__(**kwargs) - self.type = type - self.type_handler_version = type_handler_version - self.status = status - - -class VirtualMachineExtensionImage(Resource): - """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. - :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] - :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. - :vartype compute_role: str - :ivar handler_schema: The schema defined by publisher, where extension consumers should provide - settings in a matching schema. - :vartype handler_schema: str - :ivar vm_scale_set_enabled: Whether the extension can be used on xRP VMScaleSets. By default - existing extensions are usable on scalesets, but there might be cases where a publisher wants - to explicitly indicate the extension is only enabled for CRP VMs but not VMSS. - :vartype vm_scale_set_enabled: bool - :ivar supports_multiple_extensions: Whether the handler can support multiple extensions. - :vartype supports_multiple_extensions: bool - """ - - _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}"}, - "operating_system": {"key": "properties.operatingSystem", "type": "str"}, - "compute_role": {"key": "properties.computeRole", "type": "str"}, - "handler_schema": {"key": "properties.handlerSchema", "type": "str"}, - "vm_scale_set_enabled": {"key": "properties.vmScaleSetEnabled", "type": "bool"}, - "supports_multiple_extensions": {"key": "properties.supportsMultipleExtensions", "type": "bool"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - operating_system: Optional[str] = None, - compute_role: Optional[str] = None, - handler_schema: Optional[str] = None, - vm_scale_set_enabled: Optional[bool] = None, - supports_multiple_extensions: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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. - :paramtype compute_role: str - :keyword handler_schema: The schema defined by publisher, where extension consumers should - provide settings in a matching schema. - :paramtype handler_schema: str - :keyword vm_scale_set_enabled: Whether the extension can be used on xRP VMScaleSets. By default - existing extensions are usable on scalesets, but there might be cases where a publisher wants - to explicitly indicate the extension is only enabled for CRP VMs but not VMSS. - :paramtype vm_scale_set_enabled: bool - :keyword supports_multiple_extensions: Whether the handler can support multiple extensions. - :paramtype supports_multiple_extensions: bool - """ - super().__init__(location=location, tags=tags, **kwargs) - self.operating_system = operating_system - self.compute_role = compute_role - self.handler_schema = handler_schema - self.vm_scale_set_enabled = vm_scale_set_enabled - self.supports_multiple_extensions = supports_multiple_extensions - - -class VirtualMachineExtensionInstanceView(_serialization.Model): - """The instance view of a virtual machine extension. - - :ivar name: The virtual machine extension name. - :vartype name: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar substatuses: The resource status information. - :vartype substatuses: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "substatuses": {"key": "substatuses", "type": "[InstanceViewStatus]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - substatuses: Optional[List["_models.InstanceViewStatus"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The virtual machine extension name. - :paramtype name: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword substatuses: The resource status information. - :paramtype substatuses: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.name = name - self.type = type - self.type_handler_version = type_handler_version - self.substatuses = substatuses - self.statuses = statuses - - -class VirtualMachineExtensionsListResult(_serialization.Model): - """The List Extension operation response. - - :ivar value: The list of extensions. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineExtension]"}, - } - - def __init__(self, *, value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of extensions. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] - """ - super().__init__(**kwargs) - self.value = value - - -class VirtualMachineExtensionUpdate(UpdateResource): - """Describes a Virtual Machine Extension. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - force_update_tag: Optional[str] = None, - publisher: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - auto_upgrade_minor_version: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - """ - super().__init__(tags=tags, **kwargs) - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type = type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - - -class VirtualMachineHealthStatus(_serialization.Model): - """The health status of the VM. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The health status information for the VM. - :vartype status: ~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus - """ - - _validation = { - "status": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "InstanceViewStatus"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional["_models.InstanceViewStatus"] = None - - -class VirtualMachineIdentity(_serialization.Model): - """Identity for the virtual machine. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of virtual machine identity. This property will only be - provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the virtual machine. This property will only be - provided for a system assigned identity. - :vartype tenant_id: str - :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, - UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Known values - are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :vartype type: str or ~azure.mgmt.compute.v2019_07_01.models.ResourceIdentityType - :ivar user_assigned_identities: The list of user identities associated with the Virtual - Machine. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2019_07_01.models.UserAssignedIdentitiesValue] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentitiesValue}"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, - UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Known values - are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :paramtype type: str or ~azure.mgmt.compute.v2019_07_01.models.ResourceIdentityType - :keyword user_assigned_identities: The list of user identities associated with the Virtual - Machine. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2019_07_01.models.UserAssignedIdentitiesValue] - """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.type = type - self.user_assigned_identities = user_assigned_identities - - -class VirtualMachineImageResource(SubResource): - """Virtual machine image resource information. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar location: The supported Azure location of the resource. Required. - :vartype location: str - :ivar tags: Specifies the tags that are assigned to the virtual machine. For more information - about using tags, see `Using tags to organize your Azure resources - `_. - :vartype tags: dict[str, str] - """ - - _validation = { - "name": {"required": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__( - self, - *, - name: str, - location: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The name of the resource. Required. - :paramtype name: str - :keyword location: The supported Azure location of the resource. Required. - :paramtype location: str - :keyword tags: Specifies the tags that are assigned to the virtual machine. For more - information about using tags, see `Using tags to organize your Azure resources - `_. - :paramtype tags: dict[str, str] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.location = location - self.tags = tags - - -class VirtualMachineImage(VirtualMachineImageResource): - """Describes a Virtual Machine Image. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar location: The supported Azure location of the resource. Required. - :vartype location: str - :ivar tags: Specifies the tags that are assigned to the virtual machine. For more information - about using tags, see `Using tags to organize your Azure resources - `_. - :vartype tags: dict[str, str] - :ivar plan: Used for establishing the purchase context of any 3rd Party artifact through - MarketPlace. - :vartype plan: ~azure.mgmt.compute.v2019_07_01.models.PurchasePlan - :ivar os_disk_image: Contains the os disk image information. - :vartype os_disk_image: ~azure.mgmt.compute.v2019_07_01.models.OSDiskImage - :ivar data_disk_images: - :vartype data_disk_images: list[~azure.mgmt.compute.v2019_07_01.models.DataDiskImage] - :ivar automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. - :vartype automatic_os_upgrade_properties: - ~azure.mgmt.compute.v2019_07_01.models.AutomaticOSUpgradeProperties - :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or - ~azure.mgmt.compute.v2019_07_01.models.HyperVGenerationTypes - """ - - _validation = { - "name": {"required": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "plan": {"key": "properties.plan", "type": "PurchasePlan"}, - "os_disk_image": {"key": "properties.osDiskImage", "type": "OSDiskImage"}, - "data_disk_images": {"key": "properties.dataDiskImages", "type": "[DataDiskImage]"}, - "automatic_os_upgrade_properties": { - "key": "properties.automaticOSUpgradeProperties", - "type": "AutomaticOSUpgradeProperties", - }, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - location: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.PurchasePlan"] = None, - os_disk_image: Optional["_models.OSDiskImage"] = None, - data_disk_images: Optional[List["_models.DataDiskImage"]] = None, - automatic_os_upgrade_properties: Optional["_models.AutomaticOSUpgradeProperties"] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The name of the resource. Required. - :paramtype name: str - :keyword location: The supported Azure location of the resource. Required. - :paramtype location: str - :keyword tags: Specifies the tags that are assigned to the virtual machine. For more - information about using tags, see `Using tags to organize your Azure resources - `_. - :paramtype tags: dict[str, str] - :keyword plan: Used for establishing the purchase context of any 3rd Party artifact through - MarketPlace. - :paramtype plan: ~azure.mgmt.compute.v2019_07_01.models.PurchasePlan - :keyword os_disk_image: Contains the os disk image information. - :paramtype os_disk_image: ~azure.mgmt.compute.v2019_07_01.models.OSDiskImage - :keyword data_disk_images: - :paramtype data_disk_images: list[~azure.mgmt.compute.v2019_07_01.models.DataDiskImage] - :keyword automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the - image. - :paramtype automatic_os_upgrade_properties: - ~azure.mgmt.compute.v2019_07_01.models.AutomaticOSUpgradeProperties - :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1" and - "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2019_07_01.models.HyperVGenerationTypes - """ - super().__init__(id=id, name=name, location=location, tags=tags, **kwargs) - self.plan = plan - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - self.automatic_os_upgrade_properties = automatic_os_upgrade_properties - self.hyper_v_generation = hyper_v_generation - - -class VirtualMachineInstanceView(_serialization.Model): - """The instance view of a virtual machine. - - :ivar platform_update_domain: Specifies the update domain of the virtual machine. - :vartype platform_update_domain: int - :ivar platform_fault_domain: Specifies the fault domain of the virtual machine. - :vartype platform_fault_domain: int - :ivar computer_name: The computer name assigned to the virtual machine. - :vartype computer_name: str - :ivar os_name: The Operating System running on the virtual machine. - :vartype os_name: str - :ivar os_version: The version of Operating System running on the virtual machine. - :vartype os_version: str - :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. Known - values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGenerationType - :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. - :vartype rdp_thumb_print: str - :ivar vm_agent: The VM Agent running on the virtual machine. - :vartype vm_agent: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineAgentInstanceView - :ivar maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :vartype maintenance_redeploy_status: - ~azure.mgmt.compute.v2019_07_01.models.MaintenanceRedeployStatus - :ivar disks: The virtual machine disk information. - :vartype disks: list[~azure.mgmt.compute.v2019_07_01.models.DiskInstanceView] - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionInstanceView] - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2019_07_01.models.BootDiagnosticsInstanceView - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "platform_update_domain": {"key": "platformUpdateDomain", "type": "int"}, - "platform_fault_domain": {"key": "platformFaultDomain", "type": "int"}, - "computer_name": {"key": "computerName", "type": "str"}, - "os_name": {"key": "osName", "type": "str"}, - "os_version": {"key": "osVersion", "type": "str"}, - "hyper_v_generation": {"key": "hyperVGeneration", "type": "str"}, - "rdp_thumb_print": {"key": "rdpThumbPrint", "type": "str"}, - "vm_agent": {"key": "vmAgent", "type": "VirtualMachineAgentInstanceView"}, - "maintenance_redeploy_status": {"key": "maintenanceRedeployStatus", "type": "MaintenanceRedeployStatus"}, - "disks": {"key": "disks", "type": "[DiskInstanceView]"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineExtensionInstanceView]"}, - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnosticsInstanceView"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - platform_update_domain: Optional[int] = None, - platform_fault_domain: Optional[int] = None, - computer_name: Optional[str] = None, - os_name: Optional[str] = None, - os_version: Optional[str] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationType"]] = None, - rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, - disks: Optional[List["_models.DiskInstanceView"]] = None, - extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword platform_update_domain: Specifies the update domain of the virtual machine. - :paramtype platform_update_domain: int - :keyword platform_fault_domain: Specifies the fault domain of the virtual machine. - :paramtype platform_fault_domain: int - :keyword computer_name: The computer name assigned to the virtual machine. - :paramtype computer_name: str - :keyword os_name: The Operating System running on the virtual machine. - :paramtype os_name: str - :keyword os_version: The version of Operating System running on the virtual machine. - :paramtype os_version: str - :keyword hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2019_07_01.models.HyperVGenerationType - :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. - :paramtype rdp_thumb_print: str - :keyword vm_agent: The VM Agent running on the virtual machine. - :paramtype vm_agent: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineAgentInstanceView - :keyword maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :paramtype maintenance_redeploy_status: - ~azure.mgmt.compute.v2019_07_01.models.MaintenanceRedeployStatus - :keyword disks: The virtual machine disk information. - :paramtype disks: list[~azure.mgmt.compute.v2019_07_01.models.DiskInstanceView] - :keyword extensions: The extensions information. - :paramtype extensions: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionInstanceView] - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2019_07_01.models.BootDiagnosticsInstanceView - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.platform_update_domain = platform_update_domain - self.platform_fault_domain = platform_fault_domain - self.computer_name = computer_name - self.os_name = os_name - self.os_version = os_version - self.hyper_v_generation = hyper_v_generation - self.rdp_thumb_print = rdp_thumb_print - self.vm_agent = vm_agent - self.maintenance_redeploy_status = maintenance_redeploy_status - self.disks = disks - self.extensions = extensions - self.boot_diagnostics = boot_diagnostics - self.statuses = statuses - - -class VirtualMachineListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machines. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachine] - :ivar next_link: The URI to fetch the next page of VMs. Call ListNext() with this URI to fetch - the next page of Virtual Machines. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachine]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machines. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachine] - :keyword next_link: The URI to fetch the next page of VMs. Call ListNext() with this URI to - fetch the next page of Virtual Machines. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineReimageParameters(_serialization.Model): - """Parameters for Reimaging Virtual Machine. NOTE: Virtual Machine OS disk will always be - reimaged. - - :ivar temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This temp - disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :vartype temp_disk: bool - """ - - _attribute_map = { - "temp_disk": {"key": "tempDisk", "type": "bool"}, - } - - def __init__(self, *, temp_disk: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This - temp disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :paramtype temp_disk: bool - """ - super().__init__(**kwargs) - self.temp_disk = temp_disk - - -class VirtualMachineScaleSet(Resource): - """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. - :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] - :ivar sku: The virtual machine scale set sku. - :vartype sku: ~azure.mgmt.compute.v2019_07_01.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2019_07_01.models.Plan - :ivar identity: The identity of the virtual machine scale set, if configured. - :vartype identity: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetIdentity - :ivar zones: The virtual machine scale set zones. NOTE: Availability zones can only be set when - you create the scale set. - :vartype zones: list[str] - :ivar upgrade_policy: The upgrade policy. - :vartype upgrade_policy: ~azure.mgmt.compute.v2019_07_01.models.UpgradePolicy - :ivar automatic_repairs_policy: Policy for automatic repairs. - :vartype automatic_repairs_policy: - ~azure.mgmt.compute.v2019_07_01.models.AutomaticRepairsPolicy - :ivar virtual_machine_profile: The virtual machine profile. - :vartype virtual_machine_profile: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVMProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar overprovision: Specifies whether the Virtual Machine Scale Set should be overprovisioned. - :vartype overprovision: bool - :ivar do_not_run_extensions_on_overprovisioned_v_ms: When Overprovision is enabled, extensions - are launched only on the requested number of VMs which are finally kept. This property will - hence ensure that the extensions do not run on the extra overprovisioned VMs. - :vartype do_not_run_extensions_on_overprovisioned_v_ms: bool - :ivar unique_id: Specifies the ID which uniquely identifies a Virtual Machine Scale Set. - :vartype unique_id: str - :ivar single_placement_group: When true this limits the scale set to a single placement group, - of max size 100 virtual machines. - :vartype single_placement_group: bool - :ivar zone_balance: Whether to force strictly even Virtual Machine distribution cross x-zones - in case there is zone outage. - :vartype zone_balance: bool - :ivar platform_fault_domain_count: Fault Domain count for each placement group. - :vartype platform_fault_domain_count: int - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the virtual machine scale set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines - have the capability to support attaching managed data disks with UltraSSD_LRS storage account - type. - :vartype additional_capabilities: ~azure.mgmt.compute.v2019_07_01.models.AdditionalCapabilities - :ivar scale_in_policy: Specifies the scale-in policy that decides which virtual machines are - chosen for removal when a Virtual Machine Scale Set is scaled-in. - :vartype scale_in_policy: ~azure.mgmt.compute.v2019_07_01.models.ScaleInPolicy - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "unique_id": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "identity": {"key": "identity", "type": "VirtualMachineScaleSetIdentity"}, - "zones": {"key": "zones", "type": "[str]"}, - "upgrade_policy": {"key": "properties.upgradePolicy", "type": "UpgradePolicy"}, - "automatic_repairs_policy": {"key": "properties.automaticRepairsPolicy", "type": "AutomaticRepairsPolicy"}, - "virtual_machine_profile": { - "key": "properties.virtualMachineProfile", - "type": "VirtualMachineScaleSetVMProfile", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "overprovision": {"key": "properties.overprovision", "type": "bool"}, - "do_not_run_extensions_on_overprovisioned_v_ms": { - "key": "properties.doNotRunExtensionsOnOverprovisionedVMs", - "type": "bool", - }, - "unique_id": {"key": "properties.uniqueId", "type": "str"}, - "single_placement_group": {"key": "properties.singlePlacementGroup", "type": "bool"}, - "zone_balance": {"key": "properties.zoneBalance", "type": "bool"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "scale_in_policy": {"key": "properties.scaleInPolicy", "type": "ScaleInPolicy"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, - zones: Optional[List[str]] = None, - upgrade_policy: Optional["_models.UpgradePolicy"] = None, - automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, - overprovision: Optional[bool] = None, - do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, - single_placement_group: Optional[bool] = None, - zone_balance: Optional[bool] = None, - platform_fault_domain_count: Optional[int] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - scale_in_policy: Optional["_models.ScaleInPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The virtual machine scale set sku. - :paramtype sku: ~azure.mgmt.compute.v2019_07_01.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2019_07_01.models.Plan - :keyword identity: The identity of the virtual machine scale set, if configured. - :paramtype identity: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetIdentity - :keyword zones: The virtual machine scale set zones. NOTE: Availability zones can only be set - when you create the scale set. - :paramtype zones: list[str] - :keyword upgrade_policy: The upgrade policy. - :paramtype upgrade_policy: ~azure.mgmt.compute.v2019_07_01.models.UpgradePolicy - :keyword automatic_repairs_policy: Policy for automatic repairs. - :paramtype automatic_repairs_policy: - ~azure.mgmt.compute.v2019_07_01.models.AutomaticRepairsPolicy - :keyword virtual_machine_profile: The virtual machine profile. - :paramtype virtual_machine_profile: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVMProfile - :keyword overprovision: Specifies whether the Virtual Machine Scale Set should be - overprovisioned. - :paramtype overprovision: bool - :keyword do_not_run_extensions_on_overprovisioned_v_ms: When Overprovision is enabled, - extensions are launched only on the requested number of VMs which are finally kept. This - property will hence ensure that the extensions do not run on the extra overprovisioned VMs. - :paramtype do_not_run_extensions_on_overprovisioned_v_ms: bool - :keyword single_placement_group: When true this limits the scale set to a single placement - group, of max size 100 virtual machines. - :paramtype single_placement_group: bool - :keyword zone_balance: Whether to force strictly even Virtual Machine distribution cross - x-zones in case there is zone outage. - :paramtype zone_balance: bool - :keyword platform_fault_domain_count: Fault Domain count for each placement group. - :paramtype platform_fault_domain_count: int - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the virtual machine scale set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines - have the capability to support attaching managed data disks with UltraSSD_LRS storage account - type. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2019_07_01.models.AdditionalCapabilities - :keyword scale_in_policy: Specifies the scale-in policy that decides which virtual machines are - chosen for removal when a Virtual Machine Scale Set is scaled-in. - :paramtype scale_in_policy: ~azure.mgmt.compute.v2019_07_01.models.ScaleInPolicy - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.plan = plan - self.identity = identity - self.zones = zones - self.upgrade_policy = upgrade_policy - self.automatic_repairs_policy = automatic_repairs_policy - self.virtual_machine_profile = virtual_machine_profile - self.provisioning_state: Optional[str] = None - self.overprovision = overprovision - self.do_not_run_extensions_on_overprovisioned_v_ms = do_not_run_extensions_on_overprovisioned_v_ms - self.unique_id: Optional[str] = None - self.single_placement_group = single_placement_group - self.zone_balance = zone_balance - self.platform_fault_domain_count = platform_fault_domain_count - self.proximity_placement_group = proximity_placement_group - self.additional_capabilities = additional_capabilities - self.scale_in_policy = scale_in_policy - - -class VirtualMachineScaleSetDataDisk(_serialization.Model): - """Describes a virtual machine scale set data disk. - - All required parameters must be populated in order to send to server. - - :ivar name: The disk name. - :vartype name: str - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar create_option: The create option. Required. Known values are: "FromImage", "Empty", and - "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetManagedDiskParameters - :ivar disk_iops_read_write: Specifies the Read-Write IOPS for the managed disk. Should be used - only when StorageAccountType is UltraSSD_LRS. If not specified, a default value would be - assigned based on diskSizeGB. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: Specifies the bandwidth in MB per second for the managed disk. - Should be used only when StorageAccountType is UltraSSD_LRS. If not specified, a default value - would be assigned based on diskSizeGB. - :vartype disk_m_bps_read_write: int - """ - - _validation = { - "lun": {"required": True}, - "create_option": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "VirtualMachineScaleSetManagedDiskParameters"}, - "disk_iops_read_write": {"key": "diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "diskMBpsReadWrite", "type": "int"}, - } - - def __init__( - self, - *, - lun: int, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, - disk_iops_read_write: Optional[int] = None, - disk_m_bps_read_write: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword create_option: The create option. Required. Known values are: "FromImage", "Empty", - and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetManagedDiskParameters - :keyword disk_iops_read_write: Specifies the Read-Write IOPS for the managed disk. Should be - used only when StorageAccountType is UltraSSD_LRS. If not specified, a default value would be - assigned based on diskSizeGB. - :paramtype disk_iops_read_write: int - :keyword disk_m_bps_read_write: Specifies the bandwidth in MB per second for the managed disk. - Should be used only when StorageAccountType is UltraSSD_LRS. If not specified, a default value - would be assigned based on diskSizeGB. - :paramtype disk_m_bps_read_write: int - """ - super().__init__(**kwargs) - self.name = name - self.lun = lun - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - self.disk_iops_read_write = disk_iops_read_write - self.disk_m_bps_read_write = disk_m_bps_read_write - - -class VirtualMachineScaleSetExtension(SubResourceReadOnly): - """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. - :vartype id: str - :ivar name: The name of the extension. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar force_update_tag: If a value is provided and is different from the previous value, the - extension handler will be forced to update even if the extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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 - needs to be provisioned. - :vartype provision_after_extensions: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "provision_after_extensions": {"key": "properties.provisionAfterExtensions", "type": "[str]"}, - } - - 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, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - provision_after_extensions: Optional[List[str]] = 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :keyword provision_after_extensions: Collection of extension names after which this extension - needs to be provisioned. - :paramtype provision_after_extensions: list[str] - """ - super().__init__(**kwargs) - self.name = name - self.type: Optional[str] = None - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - self.provision_after_extensions = provision_after_extensions - - -class VirtualMachineScaleSetExtensionListResult(_serialization.Model): # pylint: disable=name-too-long - """The List VM scale set extension operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of VM scale set extensions. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtension] - :ivar next_link: The uri to fetch the next page of VM scale set extensions. Call ListNext() - with this to fetch the next page of VM scale set extensions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetExtension]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of VM scale set extensions. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtension] - :keyword next_link: The uri to fetch the next page of VM scale set extensions. Call ListNext() - with this to fetch the next page of VM scale set extensions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetExtensionProfile(_serialization.Model): - """Describes a virtual machine scale set extension profile. - - :ivar extensions: The virtual machine scale set child extension resources. - :vartype extensions: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtension] - """ - - _attribute_map = { - "extensions": {"key": "extensions", "type": "[VirtualMachineScaleSetExtension]"}, - } - - def __init__( - self, *, extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, **kwargs: Any - ) -> None: - """ - :keyword extensions: The virtual machine scale set child extension resources. - :paramtype extensions: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtension] - """ - super().__init__(**kwargs) - self.extensions = extensions - - -class VirtualMachineScaleSetExtensionUpdate(SubResourceReadOnly): - """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. - :vartype id: str - :ivar name: The name of the extension. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar force_update_tag: If a value is provided and is different from the previous value, the - extension handler will be forced to update even if the extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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 - needs to be provisioned. - :vartype provision_after_extensions: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "provision_after_extensions": {"key": "properties.provisionAfterExtensions", "type": "[str]"}, - } - - def __init__( - self, - *, - 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, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - provision_after_extensions: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword force_update_tag: If a value is provided and is different from the previous value, the - extension handler will be forced to update even if the extension configuration has not changed. - :paramtype force_update_tag: str - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :keyword provision_after_extensions: Collection of extension names after which this extension - needs to be provisioned. - :paramtype provision_after_extensions: list[str] - """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.type: Optional[str] = None - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - self.provision_after_extensions = provision_after_extensions - - -class VirtualMachineScaleSetIdentity(_serialization.Model): - """Identity for the virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of virtual machine scale set identity. This property will - only be provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the virtual machine scale set. This property - will only be provided for a system assigned identity. - :vartype tenant_id: str - :ivar type: The type of identity used for the virtual machine scale set. The type - 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user - assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and - "None". - :vartype type: str or ~azure.mgmt.compute.v2019_07_01.models.ResourceIdentityType - :ivar user_assigned_identities: The list of user identities associated with the virtual machine - scale set. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": { - "key": "userAssignedIdentities", - "type": "{VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue}", - }, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, - user_assigned_identities: Optional[ - Dict[str, "_models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of identity used for the virtual machine scale set. The type - 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user - assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and - "None". - :paramtype type: str or ~azure.mgmt.compute.v2019_07_01.models.ResourceIdentityType - :keyword user_assigned_identities: The list of user identities associated with the virtual - machine scale set. The user identity dictionary key references will be ARM resource ids in the - form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue] - """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.type = type - self.user_assigned_identities = user_assigned_identities - - -class VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue(_serialization.Model): # pylint: disable=name-too-long - """VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue. - - 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: Optional[str] = None - self.client_id: Optional[str] = None - - -class VirtualMachineScaleSetInstanceView(_serialization.Model): - """The instance view of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar virtual_machine: The instance view status summary for the virtual machine scale set. - :vartype virtual_machine: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetInstanceViewStatusesSummary - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVMExtensionsSummary] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - """ - - _validation = { - "virtual_machine": {"readonly": True}, - "extensions": {"readonly": True}, - } - - _attribute_map = { - "virtual_machine": {"key": "virtualMachine", "type": "VirtualMachineScaleSetInstanceViewStatusesSummary"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineScaleSetVMExtensionsSummary]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__(self, *, statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs: Any) -> None: - """ - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.virtual_machine: Optional["_models.VirtualMachineScaleSetInstanceViewStatusesSummary"] = None - self.extensions: Optional[List["_models.VirtualMachineScaleSetVMExtensionsSummary"]] = None - self.statuses = statuses - - -class VirtualMachineScaleSetInstanceViewStatusesSummary(_serialization.Model): # pylint: disable=name-too-long - """Instance view statuses summary for virtual machines of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar statuses_summary: The extensions information. - :vartype statuses_summary: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineStatusCodeCount] - """ - - _validation = { - "statuses_summary": {"readonly": True}, - } - - _attribute_map = { - "statuses_summary": {"key": "statusesSummary", "type": "[VirtualMachineStatusCodeCount]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.statuses_summary: Optional[List["_models.VirtualMachineStatusCodeCount"]] = None - - -class VirtualMachineScaleSetIPConfiguration(SubResource): - """Describes a virtual machine scale set network profile's IP configuration. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The IP configuration name. Required. - :vartype name: str - :ivar subnet: Specifies the identifier of the subnet. - :vartype subnet: ~azure.mgmt.compute.v2019_07_01.models.ApiEntityReference - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - :ivar public_ip_address_configuration: The publicIPAddressConfiguration. - :vartype public_ip_address_configuration: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration - :ivar private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2019_07_01.models.IPVersion - :ivar application_gateway_backend_address_pools: Specifies an array of references to backend - address pools of application gateways. A scale set can reference backend address pools of - multiple application gateways. Multiple scale sets cannot use the same application gateway. - :vartype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - :ivar application_security_groups: Specifies an array of references to application security - group. - :vartype application_security_groups: list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - :ivar load_balancer_backend_address_pools: Specifies an array of references to backend address - pools of load balancers. A scale set can reference backend address pools of one public and one - internal load balancer. Multiple scale sets cannot use the same load balancer. - :vartype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - :ivar load_balancer_inbound_nat_pools: Specifies an array of references to inbound Nat pools of - the load balancers. A scale set can reference inbound nat pools of one public and one internal - load balancer. Multiple scale sets cannot use the same load balancer. - :vartype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subnet": {"key": "properties.subnet", "type": "ApiEntityReference"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "public_ip_address_configuration": { - "key": "properties.publicIPAddressConfiguration", - "type": "VirtualMachineScaleSetPublicIPAddressConfiguration", - }, - "private_ip_address_version": {"key": "properties.privateIPAddressVersion", "type": "str"}, - "application_gateway_backend_address_pools": { - "key": "properties.applicationGatewayBackendAddressPools", - "type": "[SubResource]", - }, - "application_security_groups": {"key": "properties.applicationSecurityGroups", "type": "[SubResource]"}, - "load_balancer_backend_address_pools": { - "key": "properties.loadBalancerBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_inbound_nat_pools": {"key": "properties.loadBalancerInboundNatPools", "type": "[SubResource]"}, - } - - def __init__( - self, - *, - name: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - subnet: Optional["_models.ApiEntityReference"] = None, - primary: Optional[bool] = None, - public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, - application_security_groups: Optional[List["_models.SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The IP configuration name. Required. - :paramtype name: str - :keyword subnet: Specifies the identifier of the subnet. - :paramtype subnet: ~azure.mgmt.compute.v2019_07_01.models.ApiEntityReference - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - :keyword public_ip_address_configuration: The publicIPAddressConfiguration. - :paramtype public_ip_address_configuration: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration - :keyword private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2019_07_01.models.IPVersion - :keyword application_gateway_backend_address_pools: Specifies an array of references to backend - address pools of application gateways. A scale set can reference backend address pools of - multiple application gateways. Multiple scale sets cannot use the same application gateway. - :paramtype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - :keyword application_security_groups: Specifies an array of references to application security - group. - :paramtype application_security_groups: - list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - :keyword load_balancer_backend_address_pools: Specifies an array of references to backend - address pools of load balancers. A scale set can reference backend address pools of one public - and one internal load balancer. Multiple scale sets cannot use the same load balancer. - :paramtype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - :keyword load_balancer_inbound_nat_pools: Specifies an array of references to inbound Nat pools - of the load balancers. A scale set can reference inbound nat pools of one public and one - internal load balancer. Multiple scale sets cannot use the same load balancer. - :paramtype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.subnet = subnet - self.primary = primary - self.public_ip_address_configuration = public_ip_address_configuration - self.private_ip_address_version = private_ip_address_version - self.application_gateway_backend_address_pools = application_gateway_backend_address_pools - self.application_security_groups = application_security_groups - self.load_balancer_backend_address_pools = load_balancer_backend_address_pools - self.load_balancer_inbound_nat_pools = load_balancer_inbound_nat_pools - - -class VirtualMachineScaleSetIpTag(_serialization.Model): - """Contains the IP tag associated with the public IP address. - - :ivar ip_tag_type: IP tag type. Example: FirstPartyUsage. - :vartype ip_tag_type: str - :ivar tag: IP tag associated with the public IP. Example: SQL, Storage etc. - :vartype tag: str - """ - - _attribute_map = { - "ip_tag_type": {"key": "ipTagType", "type": "str"}, - "tag": {"key": "tag", "type": "str"}, - } - - def __init__(self, *, ip_tag_type: Optional[str] = None, tag: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword ip_tag_type: IP tag type. Example: FirstPartyUsage. - :paramtype ip_tag_type: str - :keyword tag: IP tag associated with the public IP. Example: SQL, Storage etc. - :paramtype tag: str - """ - super().__init__(**kwargs) - self.ip_tag_type = ip_tag_type - self.tag = tag - - -class VirtualMachineScaleSetListOSUpgradeHistory(_serialization.Model): # pylint: disable=name-too-long - """List of Virtual Machine Scale Set OS Upgrade History operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of OS upgrades performed on the virtual machine scale set. Required. - :vartype value: - list[~azure.mgmt.compute.v2019_07_01.models.UpgradeOperationHistoricalStatusInfo] - :ivar next_link: The uri to fetch the next page of OS Upgrade History. Call ListNext() with - this to fetch the next page of history of upgrades. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[UpgradeOperationHistoricalStatusInfo]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: List["_models.UpgradeOperationHistoricalStatusInfo"], - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of OS upgrades performed on the virtual machine scale set. Required. - :paramtype value: - list[~azure.mgmt.compute.v2019_07_01.models.UpgradeOperationHistoricalStatusInfo] - :keyword next_link: The uri to fetch the next page of OS Upgrade History. Call ListNext() with - this to fetch the next page of history of upgrades. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSet] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call ListNext() - with this to fetch the next page of VMSS. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSet] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call - ListNext() with this to fetch the next page of VMSS. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListSkusResult(_serialization.Model): - """The Virtual Machine Scale Set List Skus operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of skus available for the virtual machine scale set. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetSku] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Set Skus. Call - ListNext() with this to fetch the next page of VMSS Skus. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetSku]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of skus available for the virtual machine scale set. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetSku] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Set Skus. Call - ListNext() with this to fetch the next page of VMSS Skus. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListWithLinkResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSet] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call ListNext() - with this to fetch the next page of Virtual Machine Scale Sets. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSet] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call - ListNext() with this to fetch the next page of Virtual Machine Scale Sets. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetManagedDiskParameters(_serialization.Model): # pylint: disable=name-too-long - """Describes the parameters of a ScaleSet managed disk. - - :ivar storage_account_type: Specifies the storage account type for the managed disk. Managed OS - disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS can - only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", - "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetParameters - """ - - _attribute_map = { - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - } - - def __init__( - self, - *, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword storage_account_type: Specifies the storage account type for the managed disk. Managed - OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS - can only be used with data disks, it cannot be used with OS Disk. Known values are: - "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetParameters - """ - super().__init__(**kwargs) - self.storage_account_type = storage_account_type - self.disk_encryption_set = disk_encryption_set - - -class VirtualMachineScaleSetNetworkConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's network configurations. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The network configuration name. Required. - :vartype name: str - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :vartype enable_accelerated_networking: bool - :ivar network_security_group: The network security group. - :vartype network_security_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar dns_settings: The dns settings to be applied on the network interfaces. - :vartype dns_settings: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :ivar ip_configurations: Specifies the IP configurations of the network interface. - :vartype ip_configurations: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetIPConfiguration] - :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :vartype enable_ip_forwarding: bool - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "enable_accelerated_networking": {"key": "properties.enableAcceleratedNetworking", "type": "bool"}, - "network_security_group": {"key": "properties.networkSecurityGroup", "type": "SubResource"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetNetworkConfigurationDnsSettings", - }, - "ip_configurations": {"key": "properties.ipConfigurations", "type": "[VirtualMachineScaleSetIPConfiguration]"}, - "enable_ip_forwarding": {"key": "properties.enableIPForwarding", "type": "bool"}, - } - - def __init__( - self, - *, - name: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - primary: Optional[bool] = None, - enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["_models.SubResource"] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, - enable_ip_forwarding: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The network configuration name. Required. - :paramtype name: str - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :paramtype enable_accelerated_networking: bool - :keyword network_security_group: The network security group. - :paramtype network_security_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword dns_settings: The dns settings to be applied on the network interfaces. - :paramtype dns_settings: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :keyword ip_configurations: Specifies the IP configurations of the network interface. - :paramtype ip_configurations: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetIPConfiguration] - :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :paramtype enable_ip_forwarding: bool - """ - super().__init__(id=id, **kwargs) - self.name = name - self.primary = primary - self.enable_accelerated_networking = enable_accelerated_networking - self.network_security_group = network_security_group - self.dns_settings = dns_settings - self.ip_configurations = ip_configurations - self.enable_ip_forwarding = enable_ip_forwarding - - -class VirtualMachineScaleSetNetworkConfigurationDnsSettings(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines scale sets network configuration's DNS settings. - - :ivar dns_servers: List of DNS servers IP addresses. - :vartype dns_servers: list[str] - """ - - _attribute_map = { - "dns_servers": {"key": "dnsServers", "type": "[str]"}, - } - - def __init__(self, *, dns_servers: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword dns_servers: List of DNS servers IP addresses. - :paramtype dns_servers: list[str] - """ - super().__init__(**kwargs) - self.dns_servers = dns_servers - - -class VirtualMachineScaleSetNetworkProfile(_serialization.Model): - """Describes a virtual machine scale set network profile. - - :ivar health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :vartype health_probe: ~azure.mgmt.compute.v2019_07_01.models.ApiEntityReference - :ivar network_interface_configurations: The list of network configurations. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetNetworkConfiguration] - """ - - _attribute_map = { - "health_probe": {"key": "healthProbe", "type": "ApiEntityReference"}, - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineScaleSetNetworkConfiguration]", - }, - } - - def __init__( - self, - *, - health_probe: Optional["_models.ApiEntityReference"] = None, - network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :paramtype health_probe: ~azure.mgmt.compute.v2019_07_01.models.ApiEntityReference - :keyword network_interface_configurations: The list of network configurations. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetNetworkConfiguration] - """ - super().__init__(**kwargs) - self.health_probe = health_probe - self.network_interface_configurations = network_interface_configurations - - -class VirtualMachineScaleSetOSDisk(_serialization.Model): - """Describes a virtual machine scale set operating system disk. - - All required parameters must be populated in order to send to server. - - :ivar name: The disk name. - :vartype name: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar create_option: Specifies how the virtual machines in the scale set should be created.\\ - :code:`
    `\\ :code:`
    ` The only allowed value is: **FromImage** \\u2013 This value is used - when you are using an image to create the virtual machine. If you are using a platform image, - you also use the imageReference element described above. If you are using a marketplace image, - you also use the plan element previously described. Required. Known values are: "FromImage", - "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOptionTypes - :ivar diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk - used by the virtual machine scale set. - :vartype diff_disk_settings: ~azure.mgmt.compute.v2019_07_01.models.DiffDiskSettings - :ivar disk_size_gb: Specifies the size of the operating system disk in gigabytes. This element - can be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :ivar image: Specifies information about the unmanaged user image to base the scale set on. - :vartype image: ~azure.mgmt.compute.v2019_07_01.models.VirtualHardDisk - :ivar vhd_containers: Specifies the container urls that are used to store operating system - disks for the scale set. - :vartype vhd_containers: list[str] - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - - _validation = { - "create_option": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "create_option": {"key": "createOption", "type": "str"}, - "diff_disk_settings": {"key": "diffDiskSettings", "type": "DiffDiskSettings"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "os_type": {"key": "osType", "type": "str"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "vhd_containers": {"key": "vhdContainers", "type": "[str]"}, - "managed_disk": {"key": "managedDisk", "type": "VirtualMachineScaleSetManagedDiskParameters"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, - disk_size_gb: Optional[int] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - image: Optional["_models.VirtualHardDisk"] = None, - vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword create_option: Specifies how the virtual machines in the scale set should be - created.\\ :code:`
    `\\ :code:`
    ` The only allowed value is: **FromImage** \\u2013 This - value is used when you are using an image to create the virtual machine. If you are using a - platform image, you also use the imageReference element described above. If you are using a - marketplace image, you also use the plan element previously described. Required. Known values - are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOptionTypes - :keyword diff_disk_settings: Specifies the ephemeral disk Settings for the operating system - disk used by the virtual machine scale set. - :paramtype diff_disk_settings: ~azure.mgmt.compute.v2019_07_01.models.DiffDiskSettings - :keyword disk_size_gb: Specifies the size of the operating system disk in gigabytes. This - element can be used to overwrite the size of the disk in a virtual machine image. - :code:`
    `\\ :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :keyword image: Specifies information about the unmanaged user image to base the scale set on. - :paramtype image: ~azure.mgmt.compute.v2019_07_01.models.VirtualHardDisk - :keyword vhd_containers: Specifies the container urls that are used to store operating system - disks for the scale set. - :paramtype vhd_containers: list[str] - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - super().__init__(**kwargs) - self.name = name - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.create_option = create_option - self.diff_disk_settings = diff_disk_settings - self.disk_size_gb = disk_size_gb - self.os_type = os_type - self.image = image - self.vhd_containers = vhd_containers - self.managed_disk = managed_disk - - -class VirtualMachineScaleSetOSProfile(_serialization.Model): - """Describes a virtual machine scale set OS profile. - - :ivar computer_name_prefix: Specifies the computer name prefix for all of the virtual machines - in the scale set. Computer name prefixes must be 1 to 15 characters long. - :vartype computer_name_prefix: str - :ivar admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :vartype admin_username: str - :ivar admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :vartype admin_password: str - :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` For using cloud-init for - your VM, see `Using cloud-init to customize a Linux VM during creation - `_. - :vartype custom_data: str - :ivar windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :vartype windows_configuration: ~azure.mgmt.compute.v2019_07_01.models.WindowsConfiguration - :ivar linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :vartype linux_configuration: ~azure.mgmt.compute.v2019_07_01.models.LinuxConfiguration - :ivar secrets: Specifies set of certificates that should be installed onto the virtual machines - in the scale set. - :vartype secrets: list[~azure.mgmt.compute.v2019_07_01.models.VaultSecretGroup] - """ - - _attribute_map = { - "computer_name_prefix": {"key": "computerNamePrefix", "type": "str"}, - "admin_username": {"key": "adminUsername", "type": "str"}, - "admin_password": {"key": "adminPassword", "type": "str"}, - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - } - - def __init__( - self, - *, - computer_name_prefix: Optional[str] = None, - admin_username: Optional[str] = None, - admin_password: Optional[str] = None, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword computer_name_prefix: Specifies the computer name prefix for all of the virtual - machines in the scale set. Computer name prefixes must be 1 to 15 characters long. - :paramtype computer_name_prefix: str - :keyword admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :paramtype admin_username: str - :keyword admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :paramtype admin_password: str - :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` For using cloud-init for - your VM, see `Using cloud-init to customize a Linux VM during creation - `_. - :paramtype custom_data: str - :keyword windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :paramtype windows_configuration: ~azure.mgmt.compute.v2019_07_01.models.WindowsConfiguration - :keyword linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :paramtype linux_configuration: ~azure.mgmt.compute.v2019_07_01.models.LinuxConfiguration - :keyword secrets: Specifies set of certificates that should be installed onto the virtual - machines in the scale set. - :paramtype secrets: list[~azure.mgmt.compute.v2019_07_01.models.VaultSecretGroup] - """ - super().__init__(**kwargs) - self.computer_name_prefix = computer_name_prefix - self.admin_username = admin_username - self.admin_password = admin_password - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - - -class VirtualMachineScaleSetPublicIPAddressConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines scale set IP Configuration's PublicIPAddress configuration. - - All required parameters must be populated in order to send to server. - - :ivar name: The publicIP address configuration name. Required. - :vartype name: str - :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. - :vartype idle_timeout_in_minutes: int - :ivar dns_settings: The dns settings to be applied on the publicIP addresses . - :vartype dns_settings: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - :ivar ip_tags: The list of IP tags associated with the public IP address. - :vartype ip_tags: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetIpTag] - :ivar public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. - :vartype public_ip_prefix: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar public_ip_address_version: 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 'IPv6'. Known values are: "IPv4" and "IPv6". - :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2019_07_01.models.IPVersion - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "idle_timeout_in_minutes": {"key": "properties.idleTimeoutInMinutes", "type": "int"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings", - }, - "ip_tags": {"key": "properties.ipTags", "type": "[VirtualMachineScaleSetIpTag]"}, - "public_ip_prefix": {"key": "properties.publicIPPrefix", "type": "SubResource"}, - "public_ip_address_version": {"key": "properties.publicIPAddressVersion", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - ip_tags: Optional[List["_models.VirtualMachineScaleSetIpTag"]] = None, - public_ip_prefix: Optional["_models.SubResource"] = None, - public_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The publicIP address configuration name. Required. - :paramtype name: str - :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. - :paramtype idle_timeout_in_minutes: int - :keyword dns_settings: The dns settings to be applied on the publicIP addresses . - :paramtype dns_settings: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - :keyword ip_tags: The list of IP tags associated with the public IP address. - :paramtype ip_tags: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetIpTag] - :keyword public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. - :paramtype public_ip_prefix: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword public_ip_address_version: 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 'IPv6'. Known values are: "IPv4" and "IPv6". - :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2019_07_01.models.IPVersion - """ - super().__init__(**kwargs) - self.name = name - self.idle_timeout_in_minutes = idle_timeout_in_minutes - self.dns_settings = dns_settings - self.ip_tags = ip_tags - self.public_ip_prefix = public_ip_prefix - self.public_ip_address_version = public_ip_address_version - - -class VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings( - _serialization.Model -): # pylint: disable=name-too-long - """Describes a virtual machines scale sets network configuration's DNS settings. - - All required parameters must be populated in order to send to server. - - :ivar domain_name_label: The Domain name label.The concatenation of the domain name label and - vm index will be the domain name labels of the PublicIPAddress resources that will be created. - Required. - :vartype domain_name_label: str - """ - - _validation = { - "domain_name_label": {"required": True}, - } - - _attribute_map = { - "domain_name_label": {"key": "domainNameLabel", "type": "str"}, - } - - def __init__(self, *, domain_name_label: str, **kwargs: Any) -> None: - """ - :keyword domain_name_label: The Domain name label.The concatenation of the domain name label - and vm index will be the domain name labels of the PublicIPAddress resources that will be - created. Required. - :paramtype domain_name_label: str - """ - super().__init__(**kwargs) - self.domain_name_label = domain_name_label - - -class VirtualMachineScaleSetVMReimageParameters(VirtualMachineReimageParameters): # pylint: disable=name-too-long - """Describes a Virtual Machine Scale Set VM Reimage Parameters. - - :ivar temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This temp - disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :vartype temp_disk: bool - """ - - -class VirtualMachineScaleSetReimageParameters(VirtualMachineScaleSetVMReimageParameters): - """Describes a Virtual Machine Scale Set VM Reimage Parameters. - - :ivar temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This temp - disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :vartype temp_disk: bool - :ivar instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :vartype instance_ids: list[str] - """ - - _attribute_map = { - "temp_disk": {"key": "tempDisk", "type": "bool"}, - "instance_ids": {"key": "instanceIds", "type": "[str]"}, - } - - def __init__( - self, *, temp_disk: Optional[bool] = None, instance_ids: Optional[List[str]] = None, **kwargs: Any - ) -> None: - """ - :keyword temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This - temp disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :paramtype temp_disk: bool - :keyword instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :paramtype instance_ids: list[str] - """ - super().__init__(temp_disk=temp_disk, **kwargs) - self.instance_ids = instance_ids - - -class VirtualMachineScaleSetSku(_serialization.Model): - """Describes an available virtual machine scale set sku. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of resource the sku applies to. - :vartype resource_type: str - :ivar sku: The Sku. - :vartype sku: ~azure.mgmt.compute.v2019_07_01.models.Sku - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetSkuCapacity - """ - - _validation = { - "resource_type": {"readonly": True}, - "sku": {"readonly": True}, - "capacity": {"readonly": True}, - } - - _attribute_map = { - "resource_type": {"key": "resourceType", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "capacity": {"key": "capacity", "type": "VirtualMachineScaleSetSkuCapacity"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_type: Optional[str] = None - self.sku: Optional["_models.Sku"] = None - self.capacity: Optional["_models.VirtualMachineScaleSetSkuCapacity"] = None - - -class VirtualMachineScaleSetSkuCapacity(_serialization.Model): - """Describes scaling information of a sku. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar minimum: The minimum capacity. - :vartype minimum: int - :ivar maximum: The maximum capacity that can be set. - :vartype maximum: int - :ivar default_capacity: The default capacity. - :vartype default_capacity: int - :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic" and - "None". - :vartype scale_type: str or - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetSkuScaleType - """ - - _validation = { - "minimum": {"readonly": True}, - "maximum": {"readonly": True}, - "default_capacity": {"readonly": True}, - "scale_type": {"readonly": True}, - } - - _attribute_map = { - "minimum": {"key": "minimum", "type": "int"}, - "maximum": {"key": "maximum", "type": "int"}, - "default_capacity": {"key": "defaultCapacity", "type": "int"}, - "scale_type": {"key": "scaleType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.minimum: Optional[int] = None - self.maximum: Optional[int] = None - self.default_capacity: Optional[int] = None - self.scale_type: Optional[Union[str, "_models.VirtualMachineScaleSetSkuScaleType"]] = None - - -class VirtualMachineScaleSetStorageProfile(_serialization.Model): - """Describes a virtual machine scale set storage profile. - - :ivar image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :vartype image_reference: ~azure.mgmt.compute.v2019_07_01.models.ImageReference - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetOSDisk - :ivar data_disks: Specifies the parameters that are used to add data disks to the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :vartype data_disks: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetDataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "VirtualMachineScaleSetOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[VirtualMachineScaleSetDataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :paramtype image_reference: ~azure.mgmt.compute.v2019_07_01.models.ImageReference - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetOSDisk - :keyword data_disks: Specifies the parameters that are used to add data disks to the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :paramtype data_disks: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetDataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class VirtualMachineScaleSetUpdate(UpdateResource): - """Describes a Virtual Machine Scale Set. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The virtual machine scale set sku. - :vartype sku: ~azure.mgmt.compute.v2019_07_01.models.Sku - :ivar plan: The purchase plan when deploying a virtual machine scale set from VM Marketplace - images. - :vartype plan: ~azure.mgmt.compute.v2019_07_01.models.Plan - :ivar identity: The identity of the virtual machine scale set, if configured. - :vartype identity: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetIdentity - :ivar upgrade_policy: The upgrade policy. - :vartype upgrade_policy: ~azure.mgmt.compute.v2019_07_01.models.UpgradePolicy - :ivar automatic_repairs_policy: Policy for automatic repairs. - :vartype automatic_repairs_policy: - ~azure.mgmt.compute.v2019_07_01.models.AutomaticRepairsPolicy - :ivar virtual_machine_profile: The virtual machine profile. - :vartype virtual_machine_profile: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetUpdateVMProfile - :ivar overprovision: Specifies whether the Virtual Machine Scale Set should be overprovisioned. - :vartype overprovision: bool - :ivar do_not_run_extensions_on_overprovisioned_v_ms: When Overprovision is enabled, extensions - are launched only on the requested number of VMs which are finally kept. This property will - hence ensure that the extensions do not run on the extra overprovisioned VMs. - :vartype do_not_run_extensions_on_overprovisioned_v_ms: bool - :ivar single_placement_group: When true this limits the scale set to a single placement group, - of max size 100 virtual machines.NOTE: If singlePlacementGroup is true, it may be modified to - false. However, if singlePlacementGroup is false, it may not be modified to true. - :vartype single_placement_group: bool - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines - have the capability to support attaching managed data disks with UltraSSD_LRS storage account - type. - :vartype additional_capabilities: ~azure.mgmt.compute.v2019_07_01.models.AdditionalCapabilities - :ivar scale_in_policy: Specifies the scale-in policy that decides which virtual machines are - chosen for removal when a Virtual Machine Scale Set is scaled-in. - :vartype scale_in_policy: ~azure.mgmt.compute.v2019_07_01.models.ScaleInPolicy - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the virtual machine scale set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "identity": {"key": "identity", "type": "VirtualMachineScaleSetIdentity"}, - "upgrade_policy": {"key": "properties.upgradePolicy", "type": "UpgradePolicy"}, - "automatic_repairs_policy": {"key": "properties.automaticRepairsPolicy", "type": "AutomaticRepairsPolicy"}, - "virtual_machine_profile": { - "key": "properties.virtualMachineProfile", - "type": "VirtualMachineScaleSetUpdateVMProfile", - }, - "overprovision": {"key": "properties.overprovision", "type": "bool"}, - "do_not_run_extensions_on_overprovisioned_v_ms": { - "key": "properties.doNotRunExtensionsOnOverprovisionedVMs", - "type": "bool", - }, - "single_placement_group": {"key": "properties.singlePlacementGroup", "type": "bool"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "scale_in_policy": {"key": "properties.scaleInPolicy", "type": "ScaleInPolicy"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["_models.UpgradePolicy"] = None, - automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, - overprovision: Optional[bool] = None, - do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, - single_placement_group: Optional[bool] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - scale_in_policy: Optional["_models.ScaleInPolicy"] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The virtual machine scale set sku. - :paramtype sku: ~azure.mgmt.compute.v2019_07_01.models.Sku - :keyword plan: The purchase plan when deploying a virtual machine scale set from VM Marketplace - images. - :paramtype plan: ~azure.mgmt.compute.v2019_07_01.models.Plan - :keyword identity: The identity of the virtual machine scale set, if configured. - :paramtype identity: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetIdentity - :keyword upgrade_policy: The upgrade policy. - :paramtype upgrade_policy: ~azure.mgmt.compute.v2019_07_01.models.UpgradePolicy - :keyword automatic_repairs_policy: Policy for automatic repairs. - :paramtype automatic_repairs_policy: - ~azure.mgmt.compute.v2019_07_01.models.AutomaticRepairsPolicy - :keyword virtual_machine_profile: The virtual machine profile. - :paramtype virtual_machine_profile: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetUpdateVMProfile - :keyword overprovision: Specifies whether the Virtual Machine Scale Set should be - overprovisioned. - :paramtype overprovision: bool - :keyword do_not_run_extensions_on_overprovisioned_v_ms: When Overprovision is enabled, - extensions are launched only on the requested number of VMs which are finally kept. This - property will hence ensure that the extensions do not run on the extra overprovisioned VMs. - :paramtype do_not_run_extensions_on_overprovisioned_v_ms: bool - :keyword single_placement_group: When true this limits the scale set to a single placement - group, of max size 100 virtual machines.NOTE: If singlePlacementGroup is true, it may be - modified to false. However, if singlePlacementGroup is false, it may not be modified to true. - :paramtype single_placement_group: bool - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines - have the capability to support attaching managed data disks with UltraSSD_LRS storage account - type. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2019_07_01.models.AdditionalCapabilities - :keyword scale_in_policy: Specifies the scale-in policy that decides which virtual machines are - chosen for removal when a Virtual Machine Scale Set is scaled-in. - :paramtype scale_in_policy: ~azure.mgmt.compute.v2019_07_01.models.ScaleInPolicy - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the virtual machine scale set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource - """ - super().__init__(tags=tags, **kwargs) - self.sku = sku - self.plan = plan - self.identity = identity - self.upgrade_policy = upgrade_policy - self.automatic_repairs_policy = automatic_repairs_policy - self.virtual_machine_profile = virtual_machine_profile - self.overprovision = overprovision - self.do_not_run_extensions_on_overprovisioned_v_ms = do_not_run_extensions_on_overprovisioned_v_ms - self.single_placement_group = single_placement_group - self.additional_capabilities = additional_capabilities - self.scale_in_policy = scale_in_policy - self.proximity_placement_group = proximity_placement_group - - -class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's IP configuration. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The IP configuration name. - :vartype name: str - :ivar subnet: The subnet. - :vartype subnet: ~azure.mgmt.compute.v2019_07_01.models.ApiEntityReference - :ivar primary: Specifies the primary IP Configuration in case the network interface has more - than one IP Configuration. - :vartype primary: bool - :ivar public_ip_address_configuration: The publicIPAddressConfiguration. - :vartype public_ip_address_configuration: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration - :ivar private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2019_07_01.models.IPVersion - :ivar application_gateway_backend_address_pools: The application gateway backend address pools. - :vartype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - :ivar application_security_groups: Specifies an array of references to application security - group. - :vartype application_security_groups: list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - :ivar load_balancer_backend_address_pools: The load balancer backend address pools. - :vartype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - :ivar load_balancer_inbound_nat_pools: The load balancer inbound nat pools. - :vartype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subnet": {"key": "properties.subnet", "type": "ApiEntityReference"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "public_ip_address_configuration": { - "key": "properties.publicIPAddressConfiguration", - "type": "VirtualMachineScaleSetUpdatePublicIPAddressConfiguration", - }, - "private_ip_address_version": {"key": "properties.privateIPAddressVersion", "type": "str"}, - "application_gateway_backend_address_pools": { - "key": "properties.applicationGatewayBackendAddressPools", - "type": "[SubResource]", - }, - "application_security_groups": {"key": "properties.applicationSecurityGroups", "type": "[SubResource]"}, - "load_balancer_backend_address_pools": { - "key": "properties.loadBalancerBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_inbound_nat_pools": {"key": "properties.loadBalancerInboundNatPools", "type": "[SubResource]"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - subnet: Optional["_models.ApiEntityReference"] = None, - primary: Optional[bool] = None, - public_ip_address_configuration: Optional[ - "_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration" - ] = None, - private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, - application_security_groups: Optional[List["_models.SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The IP configuration name. - :paramtype name: str - :keyword subnet: The subnet. - :paramtype subnet: ~azure.mgmt.compute.v2019_07_01.models.ApiEntityReference - :keyword primary: Specifies the primary IP Configuration in case the network interface has more - than one IP Configuration. - :paramtype primary: bool - :keyword public_ip_address_configuration: The publicIPAddressConfiguration. - :paramtype public_ip_address_configuration: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration - :keyword private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2019_07_01.models.IPVersion - :keyword application_gateway_backend_address_pools: The application gateway backend address - pools. - :paramtype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - :keyword application_security_groups: Specifies an array of references to application security - group. - :paramtype application_security_groups: - list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - :keyword load_balancer_backend_address_pools: The load balancer backend address pools. - :paramtype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - :keyword load_balancer_inbound_nat_pools: The load balancer inbound nat pools. - :paramtype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2019_07_01.models.SubResource] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.subnet = subnet - self.primary = primary - self.public_ip_address_configuration = public_ip_address_configuration - self.private_ip_address_version = private_ip_address_version - self.application_gateway_backend_address_pools = application_gateway_backend_address_pools - self.application_security_groups = application_security_groups - self.load_balancer_backend_address_pools = load_balancer_backend_address_pools - self.load_balancer_inbound_nat_pools = load_balancer_inbound_nat_pools - - -class VirtualMachineScaleSetUpdateNetworkConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's network configurations. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The network configuration name. - :vartype name: str - :ivar primary: Whether this is a primary NIC on a virtual machine. - :vartype primary: bool - :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :vartype enable_accelerated_networking: bool - :ivar network_security_group: The network security group. - :vartype network_security_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar dns_settings: The dns settings to be applied on the network interfaces. - :vartype dns_settings: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :ivar ip_configurations: The virtual machine scale set IP Configuration. - :vartype ip_configurations: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetUpdateIPConfiguration] - :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :vartype enable_ip_forwarding: bool - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "enable_accelerated_networking": {"key": "properties.enableAcceleratedNetworking", "type": "bool"}, - "network_security_group": {"key": "properties.networkSecurityGroup", "type": "SubResource"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetNetworkConfigurationDnsSettings", - }, - "ip_configurations": { - "key": "properties.ipConfigurations", - "type": "[VirtualMachineScaleSetUpdateIPConfiguration]", - }, - "enable_ip_forwarding": {"key": "properties.enableIPForwarding", "type": "bool"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - primary: Optional[bool] = None, - enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["_models.SubResource"] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, - enable_ip_forwarding: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The network configuration name. - :paramtype name: str - :keyword primary: Whether this is a primary NIC on a virtual machine. - :paramtype primary: bool - :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :paramtype enable_accelerated_networking: bool - :keyword network_security_group: The network security group. - :paramtype network_security_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword dns_settings: The dns settings to be applied on the network interfaces. - :paramtype dns_settings: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :keyword ip_configurations: The virtual machine scale set IP Configuration. - :paramtype ip_configurations: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetUpdateIPConfiguration] - :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :paramtype enable_ip_forwarding: bool - """ - super().__init__(id=id, **kwargs) - self.name = name - self.primary = primary - self.enable_accelerated_networking = enable_accelerated_networking - self.network_security_group = network_security_group - self.dns_settings = dns_settings - self.ip_configurations = ip_configurations - self.enable_ip_forwarding = enable_ip_forwarding - - -class VirtualMachineScaleSetUpdateNetworkProfile(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile. - - :ivar health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :vartype health_probe: ~azure.mgmt.compute.v2019_07_01.models.ApiEntityReference - :ivar network_interface_configurations: The list of network configurations. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] - """ - - _attribute_map = { - "health_probe": {"key": "healthProbe", "type": "ApiEntityReference"}, - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineScaleSetUpdateNetworkConfiguration]", - }, - } - - def __init__( - self, - *, - health_probe: Optional["_models.ApiEntityReference"] = None, - network_interface_configurations: Optional[ - List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :paramtype health_probe: ~azure.mgmt.compute.v2019_07_01.models.ApiEntityReference - :keyword network_interface_configurations: The list of network configurations. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] - """ - super().__init__(**kwargs) - self.health_probe = health_probe - self.network_interface_configurations = network_interface_configurations - - -class VirtualMachineScaleSetUpdateOSDisk(_serialization.Model): - """Describes virtual machine scale set operating system disk Update Object. This should be used - for Updating VMSS OS Disk. - - :ivar caching: The caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar disk_size_gb: Specifies the size of the operating system disk in gigabytes. This element - can be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before - using it to attach to the Virtual Machine. If SourceImage is provided, the destination - VirtualHardDisk should not exist. - :vartype image: ~azure.mgmt.compute.v2019_07_01.models.VirtualHardDisk - :ivar vhd_containers: The list of virtual hard disk container uris. - :vartype vhd_containers: list[str] - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - - _attribute_map = { - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "vhd_containers": {"key": "vhdContainers", "type": "[str]"}, - "managed_disk": {"key": "managedDisk", "type": "VirtualMachineScaleSetManagedDiskParameters"}, - } - - def __init__( - self, - *, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - disk_size_gb: Optional[int] = None, - image: Optional["_models.VirtualHardDisk"] = None, - vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword caching: The caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword disk_size_gb: Specifies the size of the operating system disk in gigabytes. This - element can be used to overwrite the size of the disk in a virtual machine image. - :code:`
    `\\ :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied - before using it to attach to the Virtual Machine. If SourceImage is provided, the destination - VirtualHardDisk should not exist. - :paramtype image: ~azure.mgmt.compute.v2019_07_01.models.VirtualHardDisk - :keyword vhd_containers: The list of virtual hard disk container uris. - :paramtype vhd_containers: list[str] - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - super().__init__(**kwargs) - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.disk_size_gb = disk_size_gb - self.image = image - self.vhd_containers = vhd_containers - self.managed_disk = managed_disk - - -class VirtualMachineScaleSetUpdateOSProfile(_serialization.Model): - """Describes a virtual machine scale set OS profile. - - :ivar custom_data: A base-64 encoded string of custom data. - :vartype custom_data: str - :ivar windows_configuration: The Windows Configuration of the OS profile. - :vartype windows_configuration: ~azure.mgmt.compute.v2019_07_01.models.WindowsConfiguration - :ivar linux_configuration: The Linux Configuration of the OS profile. - :vartype linux_configuration: ~azure.mgmt.compute.v2019_07_01.models.LinuxConfiguration - :ivar secrets: The List of certificates for addition to the VM. - :vartype secrets: list[~azure.mgmt.compute.v2019_07_01.models.VaultSecretGroup] - """ - - _attribute_map = { - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - } - - def __init__( - self, - *, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword custom_data: A base-64 encoded string of custom data. - :paramtype custom_data: str - :keyword windows_configuration: The Windows Configuration of the OS profile. - :paramtype windows_configuration: ~azure.mgmt.compute.v2019_07_01.models.WindowsConfiguration - :keyword linux_configuration: The Linux Configuration of the OS profile. - :paramtype linux_configuration: ~azure.mgmt.compute.v2019_07_01.models.LinuxConfiguration - :keyword secrets: The List of certificates for addition to the VM. - :paramtype secrets: list[~azure.mgmt.compute.v2019_07_01.models.VaultSecretGroup] - """ - super().__init__(**kwargs) - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - - -class VirtualMachineScaleSetUpdatePublicIPAddressConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines scale set IP Configuration's PublicIPAddress configuration. - - :ivar name: The publicIP address configuration name. - :vartype name: str - :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. - :vartype idle_timeout_in_minutes: int - :ivar dns_settings: The dns settings to be applied on the publicIP addresses . - :vartype dns_settings: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "idle_timeout_in_minutes": {"key": "properties.idleTimeoutInMinutes", "type": "int"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings", - }, - } - - def __init__( - self, - *, - name: Optional[str] = None, - idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The publicIP address configuration name. - :paramtype name: str - :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. - :paramtype idle_timeout_in_minutes: int - :keyword dns_settings: The dns settings to be applied on the publicIP addresses . - :paramtype dns_settings: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - """ - super().__init__(**kwargs) - self.name = name - self.idle_timeout_in_minutes = idle_timeout_in_minutes - self.dns_settings = dns_settings - - -class VirtualMachineScaleSetUpdateStorageProfile(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machine scale set storage profile. - - :ivar image_reference: The image reference. - :vartype image_reference: ~azure.mgmt.compute.v2019_07_01.models.ImageReference - :ivar os_disk: The OS disk. - :vartype os_disk: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetUpdateOSDisk - :ivar data_disks: The data disks. - :vartype data_disks: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetDataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "VirtualMachineScaleSetUpdateOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[VirtualMachineScaleSetDataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: The image reference. - :paramtype image_reference: ~azure.mgmt.compute.v2019_07_01.models.ImageReference - :keyword os_disk: The OS disk. - :paramtype os_disk: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetUpdateOSDisk - :keyword data_disks: The data disks. - :paramtype data_disks: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetDataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class VirtualMachineScaleSetUpdateVMProfile(_serialization.Model): - """Describes a virtual machine scale set virtual machine profile. - - :ivar os_profile: The virtual machine scale set OS profile. - :vartype os_profile: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetUpdateOSProfile - :ivar storage_profile: The virtual machine scale set storage profile. - :vartype storage_profile: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetUpdateStorageProfile - :ivar network_profile: The virtual machine scale set network profile. - :vartype network_profile: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetUpdateNetworkProfile - :ivar diagnostics_profile: The virtual machine scale set diagnostics profile. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2019_07_01.models.DiagnosticsProfile - :ivar extension_profile: The virtual machine scale set extension profile. - :vartype extension_profile: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtensionProfile - :ivar license_type: The license type, which is for bring your own license scenario. - :vartype license_type: str - :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2019_07_01.models.BillingProfile - :ivar scheduled_events_profile: Specifies Scheduled Event related configurations. - :vartype scheduled_events_profile: - ~azure.mgmt.compute.v2019_07_01.models.ScheduledEventsProfile - """ - - _attribute_map = { - "os_profile": {"key": "osProfile", "type": "VirtualMachineScaleSetUpdateOSProfile"}, - "storage_profile": {"key": "storageProfile", "type": "VirtualMachineScaleSetUpdateStorageProfile"}, - "network_profile": {"key": "networkProfile", "type": "VirtualMachineScaleSetUpdateNetworkProfile"}, - "diagnostics_profile": {"key": "diagnosticsProfile", "type": "DiagnosticsProfile"}, - "extension_profile": {"key": "extensionProfile", "type": "VirtualMachineScaleSetExtensionProfile"}, - "license_type": {"key": "licenseType", "type": "str"}, - "billing_profile": {"key": "billingProfile", "type": "BillingProfile"}, - "scheduled_events_profile": {"key": "scheduledEventsProfile", "type": "ScheduledEventsProfile"}, - } - - def __init__( - self, - *, - os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, - license_type: Optional[str] = None, - billing_profile: Optional["_models.BillingProfile"] = None, - scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_profile: The virtual machine scale set OS profile. - :paramtype os_profile: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetUpdateOSProfile - :keyword storage_profile: The virtual machine scale set storage profile. - :paramtype storage_profile: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetUpdateStorageProfile - :keyword network_profile: The virtual machine scale set network profile. - :paramtype network_profile: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetUpdateNetworkProfile - :keyword diagnostics_profile: The virtual machine scale set diagnostics profile. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2019_07_01.models.DiagnosticsProfile - :keyword extension_profile: The virtual machine scale set extension profile. - :paramtype extension_profile: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtensionProfile - :keyword license_type: The license type, which is for bring your own license scenario. - :paramtype license_type: str - :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2019_07_01.models.BillingProfile - :keyword scheduled_events_profile: Specifies Scheduled Event related configurations. - :paramtype scheduled_events_profile: - ~azure.mgmt.compute.v2019_07_01.models.ScheduledEventsProfile - """ - super().__init__(**kwargs) - self.os_profile = os_profile - self.storage_profile = storage_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.extension_profile = extension_profile - self.license_type = license_type - self.billing_profile = billing_profile - self.scheduled_events_profile = scheduled_events_profile - - -class VirtualMachineScaleSetVM(Resource): - """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. - :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] - :ivar instance_id: The virtual machine instance ID. - :vartype instance_id: str - :ivar sku: The virtual machine SKU. - :vartype sku: ~azure.mgmt.compute.v2019_07_01.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2019_07_01.models.Plan - :ivar resources: The virtual machine child extension resources. - :vartype resources: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] - :ivar zones: The virtual machine zones. - :vartype zones: list[str] - :ivar latest_model_applied: Specifies whether the latest model has been applied to the virtual - machine. - :vartype latest_model_applied: bool - :ivar vm_id: Azure VM unique ID. - :vartype vm_id: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVMInstanceView - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2019_07_01.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2019_07_01.models.StorageProfile - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine in the scale set. For instance: whether the virtual machine has the capability - to support attaching managed data disks with UltraSSD_LRS storage account type. - :vartype additional_capabilities: ~azure.mgmt.compute.v2019_07_01.models.AdditionalCapabilities - :ivar os_profile: Specifies the operating system settings for the virtual machine. - :vartype os_profile: ~azure.mgmt.compute.v2019_07_01.models.OSProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2019_07_01.models.NetworkProfile - :ivar network_profile_configuration: Specifies the network profile configuration of the virtual - machine. - :vartype network_profile_configuration: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVMNetworkProfileConfiguration - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2019_07_01.models.DiagnosticsProfile - :ivar availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :vartype availability_set: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar model_definition_applied: Specifies whether the model applied to the virtual machine is - the model of the virtual machine scale set or the customized model for the virtual machine. - :vartype model_definition_applied: str - :ivar protection_policy: Specifies the protection policy of the virtual machine. - :vartype protection_policy: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVMProtectionPolicy - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "instance_id": {"readonly": True}, - "sku": {"readonly": True}, - "resources": {"readonly": True}, - "zones": {"readonly": True}, - "latest_model_applied": {"readonly": True}, - "vm_id": {"readonly": True}, - "instance_view": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "model_definition_applied": {"readonly": 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}"}, - "instance_id": {"key": "instanceId", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "resources": {"key": "resources", "type": "[VirtualMachineExtension]"}, - "zones": {"key": "zones", "type": "[str]"}, - "latest_model_applied": {"key": "properties.latestModelApplied", "type": "bool"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineScaleSetVMInstanceView"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "network_profile_configuration": { - "key": "properties.networkProfileConfiguration", - "type": "VirtualMachineScaleSetVMNetworkProfileConfiguration", - }, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "model_definition_applied": {"key": "properties.modelDefinitionApplied", "type": "str"}, - "protection_policy": {"key": "properties.protectionPolicy", "type": "VirtualMachineScaleSetVMProtectionPolicy"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - os_profile: Optional["_models.OSProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - network_profile_configuration: Optional["_models.VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - protection_policy: Optional["_models.VirtualMachineScaleSetVMProtectionPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2019_07_01.models.Plan - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2019_07_01.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2019_07_01.models.StorageProfile - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine in the scale set. For instance: whether the virtual machine has the capability - to support attaching managed data disks with UltraSSD_LRS storage account type. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2019_07_01.models.AdditionalCapabilities - :keyword os_profile: Specifies the operating system settings for the virtual machine. - :paramtype os_profile: ~azure.mgmt.compute.v2019_07_01.models.OSProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2019_07_01.models.NetworkProfile - :keyword network_profile_configuration: Specifies the network profile configuration of the - virtual machine. - :paramtype network_profile_configuration: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVMNetworkProfileConfiguration - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2019_07_01.models.DiagnosticsProfile - :keyword availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :paramtype availability_set: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - :keyword protection_policy: Specifies the protection policy of the virtual machine. - :paramtype protection_policy: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVMProtectionPolicy - """ - super().__init__(location=location, tags=tags, **kwargs) - self.instance_id: Optional[str] = None - self.sku: Optional["_models.Sku"] = None - self.plan = plan - self.resources: Optional[List["_models.VirtualMachineExtension"]] = None - self.zones: Optional[List[str]] = None - self.latest_model_applied: Optional[bool] = None - self.vm_id: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineScaleSetVMInstanceView"] = None - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.additional_capabilities = additional_capabilities - self.os_profile = os_profile - self.network_profile = network_profile - self.network_profile_configuration = network_profile_configuration - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.provisioning_state: Optional[str] = None - self.license_type = license_type - self.model_definition_applied: Optional[str] = None - self.protection_policy = protection_policy - - -class VirtualMachineScaleSetVMExtensionsSummary(_serialization.Model): # pylint: disable=name-too-long - """Extensions summary for virtual machines of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The extension name. - :vartype name: str - :ivar statuses_summary: The extensions information. - :vartype statuses_summary: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineStatusCodeCount] - """ - - _validation = { - "name": {"readonly": True}, - "statuses_summary": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "statuses_summary": {"key": "statusesSummary", "type": "[VirtualMachineStatusCodeCount]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.statuses_summary: Optional[List["_models.VirtualMachineStatusCodeCount"]] = None - - -class VirtualMachineScaleSetVMInstanceIDs(_serialization.Model): - """Specifies a list of virtual machine instance IDs from the VM scale set. - - :ivar instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :vartype instance_ids: list[str] - """ - - _attribute_map = { - "instance_ids": {"key": "instanceIds", "type": "[str]"}, - } - - def __init__(self, *, instance_ids: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :paramtype instance_ids: list[str] - """ - super().__init__(**kwargs) - self.instance_ids = instance_ids - - -class VirtualMachineScaleSetVMInstanceRequiredIDs(_serialization.Model): # pylint: disable=name-too-long - """Specifies a list of virtual machine instance IDs from the VM scale set. - - All required parameters must be populated in order to send to server. - - :ivar instance_ids: The virtual machine scale set instance ids. Required. - :vartype instance_ids: list[str] - """ - - _validation = { - "instance_ids": {"required": True}, - } - - _attribute_map = { - "instance_ids": {"key": "instanceIds", "type": "[str]"}, - } - - def __init__(self, *, instance_ids: List[str], **kwargs: Any) -> None: - """ - :keyword instance_ids: The virtual machine scale set instance ids. Required. - :paramtype instance_ids: list[str] - """ - super().__init__(**kwargs) - self.instance_ids = instance_ids - - -class VirtualMachineScaleSetVMInstanceView(_serialization.Model): - """The instance view of a virtual machine scale set VM. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar platform_update_domain: The Update Domain count. - :vartype platform_update_domain: int - :ivar platform_fault_domain: The Fault Domain count. - :vartype platform_fault_domain: int - :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. - :vartype rdp_thumb_print: str - :ivar vm_agent: The VM Agent running on the virtual machine. - :vartype vm_agent: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineAgentInstanceView - :ivar maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :vartype maintenance_redeploy_status: - ~azure.mgmt.compute.v2019_07_01.models.MaintenanceRedeployStatus - :ivar disks: The disks information. - :vartype disks: list[~azure.mgmt.compute.v2019_07_01.models.DiskInstanceView] - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionInstanceView] - :ivar vm_health: The health status for the VM. - :vartype vm_health: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineHealthStatus - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2019_07_01.models.BootDiagnosticsInstanceView - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - :ivar placement_group_id: The placement group in which the VM is running. If the VM is - deallocated it will not have a placementGroupId. - :vartype placement_group_id: str - """ - - _validation = { - "vm_health": {"readonly": True}, - } - - _attribute_map = { - "platform_update_domain": {"key": "platformUpdateDomain", "type": "int"}, - "platform_fault_domain": {"key": "platformFaultDomain", "type": "int"}, - "rdp_thumb_print": {"key": "rdpThumbPrint", "type": "str"}, - "vm_agent": {"key": "vmAgent", "type": "VirtualMachineAgentInstanceView"}, - "maintenance_redeploy_status": {"key": "maintenanceRedeployStatus", "type": "MaintenanceRedeployStatus"}, - "disks": {"key": "disks", "type": "[DiskInstanceView]"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineExtensionInstanceView]"}, - "vm_health": {"key": "vmHealth", "type": "VirtualMachineHealthStatus"}, - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnosticsInstanceView"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - "placement_group_id": {"key": "placementGroupId", "type": "str"}, - } - - def __init__( - self, - *, - platform_update_domain: Optional[int] = None, - platform_fault_domain: Optional[int] = None, - rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, - disks: Optional[List["_models.DiskInstanceView"]] = None, - extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - placement_group_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword platform_update_domain: The Update Domain count. - :paramtype platform_update_domain: int - :keyword platform_fault_domain: The Fault Domain count. - :paramtype platform_fault_domain: int - :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. - :paramtype rdp_thumb_print: str - :keyword vm_agent: The VM Agent running on the virtual machine. - :paramtype vm_agent: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineAgentInstanceView - :keyword maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :paramtype maintenance_redeploy_status: - ~azure.mgmt.compute.v2019_07_01.models.MaintenanceRedeployStatus - :keyword disks: The disks information. - :paramtype disks: list[~azure.mgmt.compute.v2019_07_01.models.DiskInstanceView] - :keyword extensions: The extensions information. - :paramtype extensions: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionInstanceView] - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2019_07_01.models.BootDiagnosticsInstanceView - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2019_07_01.models.InstanceViewStatus] - :keyword placement_group_id: The placement group in which the VM is running. If the VM is - deallocated it will not have a placementGroupId. - :paramtype placement_group_id: str - """ - super().__init__(**kwargs) - self.platform_update_domain = platform_update_domain - self.platform_fault_domain = platform_fault_domain - self.rdp_thumb_print = rdp_thumb_print - self.vm_agent = vm_agent - self.maintenance_redeploy_status = maintenance_redeploy_status - self.disks = disks - self.extensions = extensions - self.vm_health: Optional["_models.VirtualMachineHealthStatus"] = None - self.boot_diagnostics = boot_diagnostics - self.statuses = statuses - self.placement_group_id = placement_group_id - - -class VirtualMachineScaleSetVMListResult(_serialization.Model): - """The List Virtual Machine Scale Set VMs operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets VMs. Required. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVM] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Set VMs. Call - ListNext() with this to fetch the next page of VMSS VMs. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetVM]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets VMs. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVM] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Set VMs. Call - ListNext() with this to fetch the next page of VMSS VMs. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetVMNetworkProfileConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machine scale set VM network profile. - - :ivar network_interface_configurations: The list of network configurations. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetNetworkConfiguration] - """ - - _attribute_map = { - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineScaleSetNetworkConfiguration]", - }, - } - - def __init__( - self, - *, - network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword network_interface_configurations: The list of network configurations. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetNetworkConfiguration] - """ - super().__init__(**kwargs) - self.network_interface_configurations = network_interface_configurations - - -class VirtualMachineScaleSetVMProfile(_serialization.Model): - """Describes a virtual machine scale set virtual machine profile. - - :ivar os_profile: Specifies the operating system settings for the virtual machines in the scale - set. - :vartype os_profile: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetOSProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetStorageProfile - :ivar network_profile: Specifies properties of the network interfaces of the virtual machines - in the scale set. - :vartype network_profile: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetNetworkProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2019_07_01.models.DiagnosticsProfile - :ivar extension_profile: Specifies a collection of settings for extensions installed on virtual - machines in the scale set. - :vartype extension_profile: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtensionProfile - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
    `\\ :code:`
    `Minimum api-version: 2017-10-30-preview. Known values are: - "Regular", "Low", and "Spot". - :vartype priority: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachinePriorityTypes - :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, the only - supported value is 'Deallocate' and the minimum api-version is 2019-03-01. :code:`
    `\\ - :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported and the - minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and "Delete". - :vartype eviction_policy: str or - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineEvictionPolicyTypes - :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2019_07_01.models.BillingProfile - :ivar scheduled_events_profile: Specifies Scheduled Event related configurations. - :vartype scheduled_events_profile: - ~azure.mgmt.compute.v2019_07_01.models.ScheduledEventsProfile - """ - - _attribute_map = { - "os_profile": {"key": "osProfile", "type": "VirtualMachineScaleSetOSProfile"}, - "storage_profile": {"key": "storageProfile", "type": "VirtualMachineScaleSetStorageProfile"}, - "network_profile": {"key": "networkProfile", "type": "VirtualMachineScaleSetNetworkProfile"}, - "diagnostics_profile": {"key": "diagnosticsProfile", "type": "DiagnosticsProfile"}, - "extension_profile": {"key": "extensionProfile", "type": "VirtualMachineScaleSetExtensionProfile"}, - "license_type": {"key": "licenseType", "type": "str"}, - "priority": {"key": "priority", "type": "str"}, - "eviction_policy": {"key": "evictionPolicy", "type": "str"}, - "billing_profile": {"key": "billingProfile", "type": "BillingProfile"}, - "scheduled_events_profile": {"key": "scheduledEventsProfile", "type": "ScheduledEventsProfile"}, - } - - def __init__( - self, - *, - os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, - license_type: Optional[str] = None, - priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["_models.BillingProfile"] = None, - scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_profile: Specifies the operating system settings for the virtual machines in the - scale set. - :paramtype os_profile: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetOSProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetStorageProfile - :keyword network_profile: Specifies properties of the network interfaces of the virtual - machines in the scale set. - :paramtype network_profile: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetNetworkProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2019_07_01.models.DiagnosticsProfile - :keyword extension_profile: Specifies a collection of settings for extensions installed on - virtual machines in the scale set. - :paramtype extension_profile: - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtensionProfile - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
    `\\ :code:`
    `Minimum api-version: 2017-10-30-preview. Known values are: - "Regular", "Low", and "Spot". - :paramtype priority: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachinePriorityTypes - :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, the only - supported value is 'Deallocate' and the minimum api-version is 2019-03-01. :code:`
    `\\ - :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported and the - minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and "Delete". - :paramtype eviction_policy: str or - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineEvictionPolicyTypes - :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2019_07_01.models.BillingProfile - :keyword scheduled_events_profile: Specifies Scheduled Event related configurations. - :paramtype scheduled_events_profile: - ~azure.mgmt.compute.v2019_07_01.models.ScheduledEventsProfile - """ - super().__init__(**kwargs) - self.os_profile = os_profile - self.storage_profile = storage_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.extension_profile = extension_profile - self.license_type = license_type - self.priority = priority - self.eviction_policy = eviction_policy - self.billing_profile = billing_profile - self.scheduled_events_profile = scheduled_events_profile - - -class VirtualMachineScaleSetVMProtectionPolicy(_serialization.Model): - """The protection policy of a virtual machine scale set VM. - - :ivar protect_from_scale_in: Indicates that the virtual machine scale set VM shouldn't be - considered for deletion during a scale-in operation. - :vartype protect_from_scale_in: bool - :ivar protect_from_scale_set_actions: Indicates that model updates or actions (including - scale-in) initiated on the virtual machine scale set should not be applied to the virtual - machine scale set VM. - :vartype protect_from_scale_set_actions: bool - """ - - _attribute_map = { - "protect_from_scale_in": {"key": "protectFromScaleIn", "type": "bool"}, - "protect_from_scale_set_actions": {"key": "protectFromScaleSetActions", "type": "bool"}, - } - - def __init__( - self, - *, - protect_from_scale_in: Optional[bool] = None, - protect_from_scale_set_actions: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword protect_from_scale_in: Indicates that the virtual machine scale set VM shouldn't be - considered for deletion during a scale-in operation. - :paramtype protect_from_scale_in: bool - :keyword protect_from_scale_set_actions: Indicates that model updates or actions (including - scale-in) initiated on the virtual machine scale set should not be applied to the virtual - machine scale set VM. - :paramtype protect_from_scale_set_actions: bool - """ - super().__init__(**kwargs) - self.protect_from_scale_in = protect_from_scale_in - self.protect_from_scale_set_actions = protect_from_scale_set_actions - - -class VirtualMachineSize(_serialization.Model): - """Describes the properties of a VM size. - - :ivar name: The name of the virtual machine size. - :vartype name: str - :ivar number_of_cores: The number of cores supported by the virtual machine size. - :vartype number_of_cores: int - :ivar os_disk_size_in_mb: The OS disk size, in MB, allowed by the virtual machine size. - :vartype os_disk_size_in_mb: int - :ivar resource_disk_size_in_mb: The resource disk size, in MB, allowed by the virtual machine - size. - :vartype resource_disk_size_in_mb: int - :ivar memory_in_mb: The amount of memory, in MB, supported by the virtual machine size. - :vartype memory_in_mb: int - :ivar max_data_disk_count: The maximum number of data disks that can be attached to the virtual - machine size. - :vartype max_data_disk_count: int - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "number_of_cores": {"key": "numberOfCores", "type": "int"}, - "os_disk_size_in_mb": {"key": "osDiskSizeInMB", "type": "int"}, - "resource_disk_size_in_mb": {"key": "resourceDiskSizeInMB", "type": "int"}, - "memory_in_mb": {"key": "memoryInMB", "type": "int"}, - "max_data_disk_count": {"key": "maxDataDiskCount", "type": "int"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - number_of_cores: Optional[int] = None, - os_disk_size_in_mb: Optional[int] = None, - resource_disk_size_in_mb: Optional[int] = None, - memory_in_mb: Optional[int] = None, - max_data_disk_count: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the virtual machine size. - :paramtype name: str - :keyword number_of_cores: The number of cores supported by the virtual machine size. - :paramtype number_of_cores: int - :keyword os_disk_size_in_mb: The OS disk size, in MB, allowed by the virtual machine size. - :paramtype os_disk_size_in_mb: int - :keyword resource_disk_size_in_mb: The resource disk size, in MB, allowed by the virtual - machine size. - :paramtype resource_disk_size_in_mb: int - :keyword memory_in_mb: The amount of memory, in MB, supported by the virtual machine size. - :paramtype memory_in_mb: int - :keyword max_data_disk_count: The maximum number of data disks that can be attached to the - virtual machine size. - :paramtype max_data_disk_count: int - """ - super().__init__(**kwargs) - self.name = name - self.number_of_cores = number_of_cores - self.os_disk_size_in_mb = os_disk_size_in_mb - self.resource_disk_size_in_mb = resource_disk_size_in_mb - self.memory_in_mb = memory_in_mb - self.max_data_disk_count = max_data_disk_count - - -class VirtualMachineSizeListResult(_serialization.Model): - """The List Virtual Machine operation response. - - :ivar value: The list of virtual machine sizes. - :vartype value: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineSize] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineSize]"}, - } - - def __init__(self, *, value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of virtual machine sizes. - :paramtype value: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineSize] - """ - super().__init__(**kwargs) - self.value = value - - -class VirtualMachineStatusCodeCount(_serialization.Model): - """The status code and count of the virtual machine scale set instance view status summary. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The instance view status code. - :vartype code: str - :ivar count: The number of instances having a particular status code. - :vartype count: int - """ - - _validation = { - "code": {"readonly": True}, - "count": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "count": {"key": "count", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.count: Optional[int] = None - - -class VirtualMachineUpdate(UpdateResource): - """Describes a Virtual Machine Update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2019_07_01.models.Plan - :ivar identity: The identity of the virtual machine, if configured. - :vartype identity: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineIdentity - :ivar zones: The virtual machine zones. - :vartype zones: list[str] - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2019_07_01.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2019_07_01.models.StorageProfile - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine. - :vartype additional_capabilities: ~azure.mgmt.compute.v2019_07_01.models.AdditionalCapabilities - :ivar os_profile: Specifies the operating system settings used while creating the virtual - machine. Some of the settings cannot be changed once VM is provisioned. - :vartype os_profile: ~azure.mgmt.compute.v2019_07_01.models.OSProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2019_07_01.models.NetworkProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2019_07_01.models.DiagnosticsProfile - :ivar availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. The availability set to which the VM is being added should be under the same resource - group as the availability set resource. An existing VM cannot be added to an availability set. - :code:`
    `\\ :code:`
    `This property cannot exist along with a non-null - properties.virtualMachineScaleSet reference. - :vartype availability_set: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar virtual_machine_scale_set: Specifies information about the virtual machine scale set that - the virtual machine should be assigned to. Virtual machines specified in the same virtual - machine scale set are allocated to different nodes to maximize availability. Currently, a VM - can only be added to virtual machine scale set at creation time. An existing VM cannot be added - to a virtual machine scale set. :code:`
    `\\ :code:`
    `This property cannot exist along - with a non-null properties.availabilitySet reference. :code:`
    `\\ :code:`
    `Minimum - api‐version: 2019‐03‐01. - :vartype virtual_machine_scale_set: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the virtual machine should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar priority: Specifies the priority for the virtual machine. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :vartype priority: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachinePriorityTypes - :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, the only - supported value is 'Deallocate' and the minimum api-version is 2019-03-01. :code:`
    `\\ - :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported and the - minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and "Delete". - :vartype eviction_policy: str or - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineEvictionPolicyTypes - :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2019_07_01.models.BillingProfile - :ivar host: Specifies information about the dedicated host that the virtual machine resides in. - :code:`
    `\\ :code:`
    `Minimum api-version: 2018-10-01. - :vartype host: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineInstanceView - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar vm_id: Specifies the VM unique ID which is a 128-bits identifier that is encoded and - stored in all Azure IaaS VMs SMBIOS and can be read using platform BIOS commands. - :vartype vm_id: str - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - "vm_id": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "plan": {"key": "plan", "type": "Plan"}, - "identity": {"key": "identity", "type": "VirtualMachineIdentity"}, - "zones": {"key": "zones", "type": "[str]"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "virtual_machine_scale_set": {"key": "properties.virtualMachineScaleSet", "type": "SubResource"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "priority": {"key": "properties.priority", "type": "str"}, - "eviction_policy": {"key": "properties.evictionPolicy", "type": "str"}, - "billing_profile": {"key": "properties.billingProfile", "type": "BillingProfile"}, - "host": {"key": "properties.host", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineInstanceView"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineIdentity"] = None, - zones: Optional[List[str]] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - os_profile: Optional["_models.OSProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - virtual_machine_scale_set: Optional["_models.SubResource"] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["_models.BillingProfile"] = None, - host: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2019_07_01.models.Plan - :keyword identity: The identity of the virtual machine, if configured. - :paramtype identity: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineIdentity - :keyword zones: The virtual machine zones. - :paramtype zones: list[str] - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2019_07_01.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2019_07_01.models.StorageProfile - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2019_07_01.models.AdditionalCapabilities - :keyword os_profile: Specifies the operating system settings used while creating the virtual - machine. Some of the settings cannot be changed once VM is provisioned. - :paramtype os_profile: ~azure.mgmt.compute.v2019_07_01.models.OSProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2019_07_01.models.NetworkProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2019_07_01.models.DiagnosticsProfile - :keyword availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. The availability set to which the VM is being added should be under the same resource - group as the availability set resource. An existing VM cannot be added to an availability set. - :code:`
    `\\ :code:`
    `This property cannot exist along with a non-null - properties.virtualMachineScaleSet reference. - :paramtype availability_set: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword virtual_machine_scale_set: Specifies information about the virtual machine scale set - that the virtual machine should be assigned to. Virtual machines specified in the same virtual - machine scale set are allocated to different nodes to maximize availability. Currently, a VM - can only be added to virtual machine scale set at creation time. An existing VM cannot be added - to a virtual machine scale set. :code:`
    `\\ :code:`
    `This property cannot exist along - with a non-null properties.availabilitySet reference. :code:`
    `\\ :code:`
    `Minimum - api‐version: 2019‐03‐01. - :paramtype virtual_machine_scale_set: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the virtual machine should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword priority: Specifies the priority for the virtual machine. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :paramtype priority: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachinePriorityTypes - :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, the only - supported value is 'Deallocate' and the minimum api-version is 2019-03-01. :code:`
    `\\ - :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported and the - minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and "Delete". - :paramtype eviction_policy: str or - ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineEvictionPolicyTypes - :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual - machine. :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2019_07_01.models.BillingProfile - :keyword host: Specifies information about the dedicated host that the virtual machine resides - in. :code:`
    `\\ :code:`
    `Minimum api-version: 2018-10-01. - :paramtype host: ~azure.mgmt.compute.v2019_07_01.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - """ - super().__init__(tags=tags, **kwargs) - self.plan = plan - self.identity = identity - self.zones = zones - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.additional_capabilities = additional_capabilities - self.os_profile = os_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.virtual_machine_scale_set = virtual_machine_scale_set - self.proximity_placement_group = proximity_placement_group - self.priority = priority - self.eviction_policy = eviction_policy - self.billing_profile = billing_profile - self.host = host - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineInstanceView"] = None - self.license_type = license_type - self.vm_id: Optional[str] = None - - -class VMScaleSetConvertToSinglePlacementGroupInput(_serialization.Model): # pylint: disable=name-too-long - """VMScaleSetConvertToSinglePlacementGroupInput. - - :ivar active_placement_group_id: Id of the placement group in which you want future virtual - machine instances to be placed. To query placement group Id, please use Virtual Machine Scale - Set VMs - Get API. If not provided, the platform will choose one with maximum number of virtual - machine instances. - :vartype active_placement_group_id: str - """ - - _attribute_map = { - "active_placement_group_id": {"key": "activePlacementGroupId", "type": "str"}, - } - - def __init__(self, *, active_placement_group_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword active_placement_group_id: Id of the placement group in which you want future virtual - machine instances to be placed. To query placement group Id, please use Virtual Machine Scale - Set VMs - Get API. If not provided, the platform will choose one with maximum number of virtual - machine instances. - :paramtype active_placement_group_id: str - """ - super().__init__(**kwargs) - self.active_placement_group_id = active_placement_group_id - - -class WindowsConfiguration(_serialization.Model): - """Specifies Windows operating system settings on the virtual machine. - - :ivar provision_vm_agent: Indicates whether virtual machine agent should be provisioned on the - virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the request - body, default behavior is to set it to true. This will ensure that VM Agent is installed on - the VM so that extensions can be added to the VM later. - :vartype provision_vm_agent: bool - :ivar enable_automatic_updates: Indicates whether Automatic Updates is enabled for the Windows - virtual machine. Default value is true. :code:`
    `\\ :code:`
    ` For virtual machine scale - sets, this property can be updated and updates will take effect on OS reprovisioning. - :vartype enable_automatic_updates: bool - :ivar time_zone: Specifies the time zone of the virtual machine. e.g. "Pacific Standard Time". - :code:`
    `\\ :code:`
    ` Possible values can be `TimeZoneInfo.Id - `_ - value from time zones returned by `TimeZoneInfo.GetSystemTimeZones - `_. - :vartype time_zone: str - :ivar additional_unattend_content: Specifies additional base-64 encoded XML formatted - information that can be included in the Unattend.xml file, which is used by Windows Setup. - :vartype additional_unattend_content: - list[~azure.mgmt.compute.v2019_07_01.models.AdditionalUnattendContent] - :ivar win_rm: Specifies the Windows Remote Management listeners. This enables remote Windows - PowerShell. - :vartype win_rm: ~azure.mgmt.compute.v2019_07_01.models.WinRMConfiguration - """ - - _attribute_map = { - "provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"}, - "enable_automatic_updates": {"key": "enableAutomaticUpdates", "type": "bool"}, - "time_zone": {"key": "timeZone", "type": "str"}, - "additional_unattend_content": {"key": "additionalUnattendContent", "type": "[AdditionalUnattendContent]"}, - "win_rm": {"key": "winRM", "type": "WinRMConfiguration"}, - } - - def __init__( - self, - *, - provision_vm_agent: Optional[bool] = None, - enable_automatic_updates: Optional[bool] = None, - time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, - win_rm: Optional["_models.WinRMConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword provision_vm_agent: Indicates whether virtual machine agent should be provisioned on - the virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the - request body, default behavior is to set it to true. This will ensure that VM Agent is - installed on the VM so that extensions can be added to the VM later. - :paramtype provision_vm_agent: bool - :keyword enable_automatic_updates: Indicates whether Automatic Updates is enabled for the - Windows virtual machine. Default value is true. :code:`
    `\\ :code:`
    ` For virtual machine - scale sets, this property can be updated and updates will take effect on OS reprovisioning. - :paramtype enable_automatic_updates: bool - :keyword time_zone: Specifies the time zone of the virtual machine. e.g. "Pacific Standard - Time". :code:`
    `\\ :code:`
    ` Possible values can be `TimeZoneInfo.Id - `_ - value from time zones returned by `TimeZoneInfo.GetSystemTimeZones - `_. - :paramtype time_zone: str - :keyword additional_unattend_content: Specifies additional base-64 encoded XML formatted - information that can be included in the Unattend.xml file, which is used by Windows Setup. - :paramtype additional_unattend_content: - list[~azure.mgmt.compute.v2019_07_01.models.AdditionalUnattendContent] - :keyword win_rm: Specifies the Windows Remote Management listeners. This enables remote Windows - PowerShell. - :paramtype win_rm: ~azure.mgmt.compute.v2019_07_01.models.WinRMConfiguration - """ - super().__init__(**kwargs) - self.provision_vm_agent = provision_vm_agent - self.enable_automatic_updates = enable_automatic_updates - self.time_zone = time_zone - self.additional_unattend_content = additional_unattend_content - self.win_rm = win_rm - - -class WinRMConfiguration(_serialization.Model): - """Describes Windows Remote Management configuration of the VM. - - :ivar listeners: The list of Windows Remote Management listeners. - :vartype listeners: list[~azure.mgmt.compute.v2019_07_01.models.WinRMListener] - """ - - _attribute_map = { - "listeners": {"key": "listeners", "type": "[WinRMListener]"}, - } - - def __init__(self, *, listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs: Any) -> None: - """ - :keyword listeners: The list of Windows Remote Management listeners. - :paramtype listeners: list[~azure.mgmt.compute.v2019_07_01.models.WinRMListener] - """ - super().__init__(**kwargs) - self.listeners = listeners - - -class WinRMListener(_serialization.Model): - """Describes Protocol and thumbprint of Windows Remote Management listener. - - :ivar protocol: Specifies the protocol of WinRM listener. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. Known values are: - "Http" and "Https". - :vartype protocol: str or ~azure.mgmt.compute.v2019_07_01.models.ProtocolTypes - :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as - a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :vartype certificate_url: str - """ - - _attribute_map = { - "protocol": {"key": "protocol", "type": "str"}, - "certificate_url": {"key": "certificateUrl", "type": "str"}, - } - - def __init__( - self, - *, - protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, - certificate_url: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword protocol: Specifies the protocol of WinRM listener. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. Known - values are: "Http" and "Https". - :paramtype protocol: str or ~azure.mgmt.compute.v2019_07_01.models.ProtocolTypes - :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault - as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :paramtype certificate_url: str - """ - super().__init__(**kwargs) - self.protocol = protocol - self.certificate_url = certificate_url diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/__init__.py deleted file mode 100644 index 8dd8f5ede493..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/__init__.py +++ /dev/null @@ -1,77 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import Operations # type: ignore -from ._operations import AvailabilitySetsOperations # type: ignore -from ._operations import ProximityPlacementGroupsOperations # type: ignore -from ._operations import DedicatedHostGroupsOperations # type: ignore -from ._operations import DedicatedHostsOperations # type: ignore -from ._operations import VirtualMachineExtensionImagesOperations # type: ignore -from ._operations import VirtualMachineExtensionsOperations # type: ignore -from ._operations import VirtualMachineImagesOperations # type: ignore -from ._operations import UsageOperations # type: ignore -from ._operations import VirtualMachinesOperations # type: ignore -from ._operations import VirtualMachineSizesOperations # type: ignore -from ._operations import ImagesOperations # 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 LogAnalyticsOperations # type: ignore -from ._operations import DisksOperations # type: ignore -from ._operations import SnapshotsOperations # type: ignore -from ._operations import DiskEncryptionSetsOperations # type: ignore -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 VirtualMachineRunCommandsOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AvailabilitySetsOperations", - "ProximityPlacementGroupsOperations", - "DedicatedHostGroupsOperations", - "DedicatedHostsOperations", - "VirtualMachineExtensionImagesOperations", - "VirtualMachineExtensionsOperations", - "VirtualMachineImagesOperations", - "UsageOperations", - "VirtualMachinesOperations", - "VirtualMachineSizesOperations", - "ImagesOperations", - "VirtualMachineScaleSetsOperations", - "VirtualMachineScaleSetExtensionsOperations", - "VirtualMachineScaleSetRollingUpgradesOperations", - "VirtualMachineScaleSetVMExtensionsOperations", - "VirtualMachineScaleSetVMsOperations", - "LogAnalyticsOperations", - "DisksOperations", - "SnapshotsOperations", - "DiskEncryptionSetsOperations", - "GalleriesOperations", - "GalleryImagesOperations", - "GalleryImageVersionsOperations", - "GalleryApplicationsOperations", - "GalleryApplicationVersionsOperations", - "VirtualMachineRunCommandsOperations", -] -__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/v2019_07_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_operations.py deleted file mode 100644 index 29c38f85c470..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_operations.py +++ /dev/null @@ -1,25949 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterator, List, Literal, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import ComputeManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_operations_list_request(**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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/operations") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-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}", - ) - 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"), - } - - _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_availability_sets_delete_request( - resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_availability_sets_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes", - ) - 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"), - } - - _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_proximity_placement_groups_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-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}", - ) - 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"), - } - - _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_proximity_placement_groups_update_request( # pylint: disable=name-too-long - resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-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}", - ) - 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"), - } - - _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_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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 -) -> 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", - ) - 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"), - } - - _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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dedicated_host_groups_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2019-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}", - ) - 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"), - } - - _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_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", "2019-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}", - ) - 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"), - } - - _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_dedicated_host_groups_delete_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_dedicated_host_groups_get_request( - 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dedicated_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dedicated_hosts_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2019-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}", - ) - 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"), - } - - _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_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", "2019-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}", - ) - 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"), - } - - _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_dedicated_hosts_delete_request( - resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_dedicated_hosts_get_request( - resource_group_name: str, - host_group_name: str, - host_name: str, - subscription_id: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", - ) - 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"), - } - - _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) - - -def build_dedicated_hosts_list_by_host_group_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts", - ) - 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"), - } - - _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_extension_images_get_request( # pylint: disable=name-too-long - location: str, publisher_name: str, type: str, version: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types", - ) - 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"), - } - - _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_extension_images_list_versions_request( # pylint: disable=name-too-long - location: str, - publisher_name: str, - type: str, - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - if orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2019-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-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}", - ) - 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"), - } - - _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_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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 -) -> 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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) - - -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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", - ) - 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"), - } - - _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) - - -def build_virtual_machine_images_list_offers_request( # pylint: disable=name-too-long - location: str, publisher_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers" - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_images_list_skus_request( # pylint: disable=name-too-long - location: str, publisher_name: str, offer: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages" - ) - 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines", - ) - 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_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", "2019-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}/capture", - ) - 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"), - } - - _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_machines_create_or_update_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", "2019-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_update_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", "2019-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}", - ) - 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"), - } - - _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_virtual_machines_delete_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_get_request( - resource_group_name: str, - vm_name: str, - subscription_id: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", - ) - 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"), - } - - _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) - - -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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView", - ) - 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"), - } - - _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_machines_convert_to_managed_disks_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_deallocate_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_generalize_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_list_all_request( - subscription_id: str, *, status_only: 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if status_only is not None: - _params["statusOnly"] = _SERIALIZER.query("status_only", status_only, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes", - ) - 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"), - } - - _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_machines_power_off_request( - resource_group_name: str, vm_name: str, subscription_id: str, *, skip_shutdown: bool = False, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reapply", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_restart_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_start_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_redeploy_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_perform_maintenance_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_run_command_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand", - ) - 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"), - } - - _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_sizes_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes" - ) - 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-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}", - ) - 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"), - } - - _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_images_delete_request( - resource_group_name: str, image_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", - ) - 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"), - } - - _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) - - -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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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, **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", "2019-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_update_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", "2019-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}", - ) - 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"), - } - - _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_virtual_machine_scale_sets_delete_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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, **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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", - ) - 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"), - } - - _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_scale_sets_deallocate_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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_delete_instances_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_get_instance_view_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_list_all_request( # pylint: disable=name-too-long - subscription_id: str, **kwargs: Any -) -> 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_list_skus_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory", - ) - 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"), - } - - _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_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 -) -> 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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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, - **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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk", - ) - 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"), - } - - _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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", 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 -) -> 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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2019-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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", "2019-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}", - ) - 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"), - } - - _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_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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 -) -> 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions", - ) - 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"), - } - - _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_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest", - ) - 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"), - } - - _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_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", "2019-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}/extensions/{vmExtensionName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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", "2019-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}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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) - - -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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions", - ) - 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"), - } - - _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) - - -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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_set_vms_reimage_all_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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, **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", "2019-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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: Literal["instanceView"] = "instanceView", - **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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView", - ) - 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"), - } - - _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_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines", - ) - 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"), - } - - _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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machine_scale_set_vms_redeploy_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> 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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand", - ) - 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"), - } - - _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_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", "2019-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", - ) - 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 -) -> 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", "2019-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", - ) - 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_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", "2019-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/disks/{diskName}", - ) - 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"), - } - - _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_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", "2019-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/disks/{diskName}", - ) - 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"), - } - - _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_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", - ) - 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"), - } - - _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_disks_delete_request( - resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2019-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/disks/{diskName}/beginGetAccess", - ) - 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"), - } - - _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_disks_revoke_access_request( - resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -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", "2019-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/snapshots/{snapshotName}", - ) - 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"), - } - - _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_snapshots_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", "2019-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/snapshots/{snapshotName}", - ) - 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"), - } - - _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_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", - ) - 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"), - } - - _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_snapshots_delete_request( - resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2019-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/snapshots/{snapshotName}/beginGetAccess", - ) - 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"), - } - - _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_snapshots_revoke_access_request( - resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> 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", "2019-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/diskEncryptionSets/{diskEncryptionSetName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-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/diskEncryptionSets/{diskEncryptionSetName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", - ) - 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"), - } - - _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) - - -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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2019-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/galleries/{galleryName}", - ) - 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"), - } - - _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_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", "2019-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/galleries/{galleryName}", - ) - 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"), - } - - _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_galleries_get_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", - ) - 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"), - } - - _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) - - -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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2019-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/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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_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", "2019-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/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images", - ) - 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"), - } - - _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_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, - **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", "2019-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/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", - ) - 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"), - } - - _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_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", "2019-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/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", - ) - 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"), - } - - _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_image_versions_get_request( - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image_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", "2019-07-01")) - 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}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - 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}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - 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", - ) - 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"), - } - - _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_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", "2019-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/galleries/{galleryName}/applications/{galleryApplicationName}", - ) - 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"), - } - - _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", "2019-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/galleries/{galleryName}/applications/{galleryApplicationName}", - ) - 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"), - } - - _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_get_request( - 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", - ) - 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"), - } - - _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_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", - ) - 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"), - } - - _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) - - -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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications", - ) - 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"), - } - - _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_gallery_application_versions_create_or_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, - **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", "2019-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/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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_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, - **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", "2019-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/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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) - - -def build_gallery_application_versions_delete_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, - **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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions", - ) - 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"), - } - - _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_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", "2019-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" - ) - 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", "2019-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}", - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"), - "commandId": _SERIALIZER.url("command_id", command_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.ComputeOperationValue"]: - """Gets a list of compute operations. - - :return: An iterator like instance of either ComputeOperationValue or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.ComputeOperationValue] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[_models.ComputeOperationListResult] = 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_operations_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def 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) - - 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 AvailabilitySetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`availability_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: _models.AvailabilitySet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_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: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySet, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Is either a - AvailabilitySet type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySet") - - _request = build_availability_sets_create_or_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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, - availability_set_name: str, - parameters: _models.AvailabilitySetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_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: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Is either a - AvailabilitySetUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.AvailabilitySetUpdate or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySetUpdate") - - _request = build_availability_sets_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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 "2019-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.v2019_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 = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", 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) - - _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("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription( - self, *, expand: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. - - :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.v2019_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 "2019-07-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets 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 AvailabilitySet or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_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 "2019-07-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - 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_available_sizes( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes that can be used to create a new virtual machine in - an existing availability set. - - :param resource_group_name: The name of the resource group. Required. - :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.v2019_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 "2019-07-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_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 - - if response.status_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 ProximityPlacementGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`proximity_placement_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - resource_group_name: str, - proximity_placement_group_name: str, - parameters: _models.ProximityPlacementGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Create or update a proximity placement group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Create Proximity Placement Group operation. - Required. - :type parameters: ~azure.mgmt.compute.v2019_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.v2019_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. 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.v2019_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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 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. Is - either a ProximityPlacementGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroup or IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("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. 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.v2019_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.v2019_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. 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.v2019_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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 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. Is - either a ProximityPlacementGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroupUpdate or - IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ProximityPlacementGroupUpdate") - - _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, - ) - _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("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any - ) -> None: - """Delete a proximity placement group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - 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 "2019-07-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _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, - 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 - - @distributed_trace - 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. 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.v2019_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - _request = build_proximity_placement_groups_get_request( - resource_group_name=resource_group_name, - proximity_placement_group_name=proximity_placement_group_name, - subscription_id=self._config.subscription_id, - include_colocation_status=include_colocation_status, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a subscription. - - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_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 "2019-07-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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 - ) -> ItemPaged["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a resource group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_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 "2019-07-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProximityPlacementGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class DedicatedHostGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`dedicated_host_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: _models.DedicatedHostGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: ~azure.mgmt.compute.v2019_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: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroup, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Is either a - DedicatedHostGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroup or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-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, "DedicatedHostGroup") - - _request = build_dedicated_host_groups_create_or_update_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: _models.DedicatedHostGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_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: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :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: IO[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.v2019_07_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroupUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Is either - a DedicatedHostGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroupUpdate or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-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") - - _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) - - _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("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: - """ - 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 "2019-07-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_dedicated_host_groups_delete_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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, host_group_name: str, **kwargs: Any) -> _models.DedicatedHostGroup: - """Retrieves information about a dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-07-01")) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", 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, - 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("DedicatedHostGroup", 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 - ) -> ItemPaged["_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. - :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.v2019_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 "2019-07-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 - - if response.status_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, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2019_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 "2019-07-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_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 - - if response.status_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 DedicatedHostsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`dedicated_hosts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, 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 "2019-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, "DedicatedHost") - - _request = build_dedicated_hosts_create_or_update_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHost, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHost - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. 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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. Is either a DedicatedHost - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHost or IO[bytes] - :return: An instance of LROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.DedicatedHost] - :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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, 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 "2019-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, "DedicatedHostUpdate") - - _request = build_dedicated_hosts_update_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, - 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]: - 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, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHostUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostUpdate - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host 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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Is either a - DedicatedHostUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostUpdate or IO[bytes] - :return: An instance of LROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.DedicatedHost] - :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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_delete_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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, host_group_name: str, host_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete 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 - :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 "2019-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, - host_group_name=host_group_name, - host_name=host_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: DedicatedHost or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-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 - ) -> ItemPaged["_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. - :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.v2019_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 "2019-07-01")) - cls: ClsType[_models.DedicatedHostListResult] = 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_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, - 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("DedicatedHostListResult", 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 VirtualMachineExtensionImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_extension_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, type: str, version: str, **kwargs: Any - ) -> _models.VirtualMachineExtensionImage: - """Gets a virtual machine extension image. - - :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.v2019_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 "2019-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 - - @distributed_trace - def list_types( - self, location: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineExtensionImage]: - """Gets a list of virtual machine extension image types. - - :param location: The name of 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.v2019_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 "2019-07-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - - _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) - - _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 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 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.v2019_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 "2019-07-01")) - 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 - - -class VirtualMachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, 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 "2019-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, "VirtualMachineExtension") - - _request = build_virtual_machine_extensions_create_or_update_request( - resource_group_name=resource_group_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2019_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 VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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] - :keyword content_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.v2019_07_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2019_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.v2019_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - 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 "2019-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, "VirtualMachineExtensionUpdate") - - _request = build_virtual_machine_extensions_update_request( - resource_group_name=resource_group_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, - 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]: - 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, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to update the extension. - - :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: - ~azure.mgmt.compute.v2019_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 VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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 - ) -> 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_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 LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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.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.v2019_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.v2019_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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) - - _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, vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The operation to delete the extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the extension should be deleted. - 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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, - 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) - - 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_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.v2019_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 "2019-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) - - deserialized = self._deserialize("VirtualMachineExtension", 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_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.v2019_07_01.models.VirtualMachineExtensionsListResult - :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 "2019-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) - - deserialized = self._deserialize("VirtualMachineExtensionsListResult", 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.v2019_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.v2019_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 "2019-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.v2019_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 "2019-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. - - :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.v2019_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 "2019-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) - 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.v2019_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 "2019-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 = 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_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 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.v2019_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 "2019-07-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _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) - - _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 - - -class UsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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 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.v2019_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 "2019-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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -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.v2019_07_01.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.VirtualMachine"]: - """Gets all the virtual machines under the specified subscription for the specified location. - - :param location: The location for which virtual machines under the subscription are queried. - Required. - :type location: str - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_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 "2019-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 - - 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) - - def _capture_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-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 - - 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_capture( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachineCaptureParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. - - :param resource_group_name: The name of the resource group. Required. - :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.v2019_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.v2019_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. - - :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.v2019_07_01.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_capture( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. - - :param resource_group_name: The name of the resource group. 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.v2019_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.v2019_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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) - - 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 - - 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 - ) - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, 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 "2019-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, "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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachine, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :param resource_group_name: The name of the resource group. 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.v2019_07_01.models.VirtualMachine - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :param resource_group_name: The name of the resource group. 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 content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :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 Create Virtual Machine operation. Is either a - VirtualMachine type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachine or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_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 "2019-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._create_or_update_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("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 _update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineUpdate, 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 "2019-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, "VirtualMachineUpdate") - - _request = build_virtual_machines_update_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 - - 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 = 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, - vm_name: str, - parameters: _models.VirtualMachineUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. - - :param resource_group_name: The name of the resource group. 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.v2019_07_01.models.VirtualMachineUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. - - :param resource_group_name: The name of the resource group. 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 content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_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]], - **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.v2019_07_01.models.VirtualMachineUpdate or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_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 "2019-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, - 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, **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 "2019-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, - 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, vm_name: str, **kwargs: Any) -> LROPoller[None]: - """The operation to delete 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 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 "2019-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, - 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_name: str, *, expand: Literal["instanceView"] = "instanceView", **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-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.v2019_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 "2019-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 - ) - - response = pipeline_response.http_response - - if response.status_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 - ) -> 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 "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_convert_to_managed_disks_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. :code:`
    `For Windows, please refer to - `Convert a virtual machine from unmanaged disks to managed disks. - `_.\\ - :code:`
    `For Linux, please refer to `Convert a virtual machine from unmanaged disks to - managed disks. - `_. - - :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 "2019-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._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 - ) - 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 _deallocate_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[Iterator[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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_deallocate(self, resource_group_name: str, vm_name: str, **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. - :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 "2019-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._deallocate_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 - - @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. :code:`
    `For Windows, please refer to - `Create a managed image of a generalized VM in Azure - `_.\\ - :code:`
    `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 "2019-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 - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_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 "2019-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, - 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, **kwargs: Any) -> ItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_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 "2019-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, - 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_available_sizes( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes to which the specified virtual machine can be - resized. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_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 "2019-07-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_available_sizes_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _power_off_initial( - self, resource_group_name: str, vm_name: str, *, skip_shutdown: bool = False, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_power_off_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_power_off( - self, resource_group_name: str, vm_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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool - :return: An instance of 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 "2019-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, **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, - 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 "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_reapply_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. - :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 "2019-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_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 _restart_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_restart_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. - :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 "2019-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._restart_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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_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 "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_start(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[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 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 "2019-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, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_redeploy_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_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 "2019-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]: - 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 "2019-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( - 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 - - 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_reimage( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[_models.VirtualMachineReimageParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: ~azure.mgmt.compute.v2019_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 the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. 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 the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. 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.v2019_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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # 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_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 "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_perform_maintenance(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: - """Shuts down the virtual machine, moves it to an already updated node, and powers it back on - during the self-service phase of planned maintenance. - - :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 "2019-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._perform_maintenance_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 _run_command_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, 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 "2019-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, "RunCommandInput") - - _request = build_virtual_machines_run_command_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 - - 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_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_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 RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_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.v2019_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._run_command_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineSizesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.VirtualMachineSize"]: - """This API is deprecated. Use `Resources Skus - `_. - - :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.v2019_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 "2019-07-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_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 - - 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 - - if response.status_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 ImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any - ) -> 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 "2019-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, "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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: _models.Image, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Create or update 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 - :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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.Image] - :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. - - :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 - :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.v2019_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.v2019_07_01.models.Image] - :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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._create_or_update_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: 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.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Image]( - 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]], - **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 "2019-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, "ImageUpdate") - - _request = build_images_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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, - image_name: str, - parameters: _models.ImageUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Update 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 - :param parameters: Parameters supplied to the Update Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Update 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 - :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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Update 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 - :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.v2019_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.v2019_07_01.models.Image] - :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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: 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.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Image]( - 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]: - 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 "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_images_delete_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, image_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes an Image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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, - image_name=image_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, resource_group_name: str, image_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.Image: - """Gets an image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: Image or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-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 - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Image", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Image"]: - """Gets the list of images 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 Image or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_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 "2019-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 - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_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.v2019_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 "2019-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_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class 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.v2019_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, 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 "2019-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") - - _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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSet - :keyword content_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.v2019_07_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. 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 VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 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.v2019_07_01.models.VirtualMachineScaleSet or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_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 "2019-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, - 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]], - **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 "2019-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, "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, - 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]: - 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, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. - - :param resource_group_name: The name of the resource group. 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.v2019_07_01.models.VirtualMachineScaleSetUpdate - :keyword content_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.v2019_07_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. - - :param resource_group_name: The name of the resource group. 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: IO[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 VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_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]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update 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 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.v2019_07_01.models.VirtualMachineScaleSetUpdate or - IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_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 "2019-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, - 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, **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 "2019-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, - 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, vm_scale_set_name: str, **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 - :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 "2019-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, - 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, **kwargs: Any) -> _models.VirtualMachineScaleSet: - """Display information about a 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 - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _deallocate_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 "2019-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 - - _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, - 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_deallocate( - 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]: - """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. - :type 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.v2019_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_deallocate( - 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]: - """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. - :type 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_deallocate( - 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]: - """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. - :type 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.v2019_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 "2019-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, - 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 _delete_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-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") - - _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, - 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_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """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. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2019_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: - """ - - @overload - def begin_delete_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]: - """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. - 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_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, 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.v2019_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 "2019-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, - 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. - - :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.v2019_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 "2019-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 - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_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 - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_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 "2019-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_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: - 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) -> ItemPaged["_models.VirtualMachineScaleSet"]: - """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource - group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this - till nextLink is null to fetch all the VM Scale Sets. - - :return: An iterator like instance of either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_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 "2019-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = 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_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("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) - - 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_skus( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineScaleSetSku"]: - """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM - instances allowed for each SKU. - - :param resource_group_name: The name of the resource group. Required. - :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.v2019_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 "2019-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) - - @distributed_trace - def get_os_upgrade_history( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.UpgradeOperationHistoricalStatusInfo"]: - """Gets list of OS upgrades 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 - :return: An iterator like instance of either UpgradeOperationHistoricalStatusInfo or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_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 "2019-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 - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListOSUpgradeHistory", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _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 - ) -> 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 "2019-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 - - _request = build_virtual_machine_scale_sets_power_off_request( - resource_group_name=resource_group_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, - 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_power_off( - self, - resource_group_name: str, - vm_scale_set_name: 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) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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.v2019_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 - :keyword content_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: 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. - - :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 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 - :keyword content_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_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: bool = False, - **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. Required. - :type 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.v2019_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] - :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 "2019-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, - 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 "2019-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 - - _request = build_virtual_machine_scale_sets_restart_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2019_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_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :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.v2019_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 "2019-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, - 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 "2019-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 - - _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 - 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_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.v2019_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. - - :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.v2019_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 "2019-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 _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]: - 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 "2019-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 - - _request = build_virtual_machine_scale_sets_redeploy_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_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.v2019_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.v2019_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 "2019-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 - ) -> 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 "2019-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 - - _request = build_virtual_machine_scale_sets_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_perform_maintenance( - 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]: - """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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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.v2019_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_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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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_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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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.v2019_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 "2019-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( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-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") - - _request = build_virtual_machine_scale_sets_update_instances_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :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.v2019_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: - """ - - @overload - def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2019_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 "2019-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._update_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _reimage_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-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( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_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.v2019_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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Is either a - VirtualMachineScaleSetReimageParameters type or a IO[bytes] type. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2019_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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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, - vm_scale_set_reimage_input=vm_scale_set_reimage_input, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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_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 "2019-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 - - _request = build_virtual_machine_scale_sets_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_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.v2019_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. - - :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.v2019_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 "2019-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 - - @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, **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 - :return: RecoveryWalkResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-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, - 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("RecoveryWalkResponse", 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 true 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.v2019_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 true 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 - 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 true 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. Is either a - VMScaleSetConvertToSinglePlacementGroupInput type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.compute.v2019_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 "2019-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 = 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 - - -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.v2019_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtension, 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 "2019-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") - - _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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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. - - :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.v2019_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.v2019_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.v2019_07_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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.v2019_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.v2019_07_01.models.VirtualMachineScaleSetExtension] - :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 "2019-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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - 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 "2019-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, "VirtualMachineScaleSetExtensionUpdate") - - _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, - 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]: - 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, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2019_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 VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :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.v2019_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.v2019_07_01.models.VirtualMachineScaleSetExtension] - :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 "2019-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._update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-07-01")) - 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, - 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, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The operation to delete the extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be deleted. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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, - vmss_extension_name=vmss_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSetExtension: - """The operation to get the extension. - - :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.v2019_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 "2019-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 - - @distributed_trace - def list( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_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.v2019_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 "2019-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) - - -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.v2019_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_rolling_upgrades_cancel_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - 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 - - 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. - - :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 "2019-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 - - 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_os_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request( - resource_group_name=resource_group_name, - 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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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 "2019-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 - ) -> 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 "2019-07-01")) - cls: ClsType[Iterator[bytes]] = 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, - 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 - - return deserialized # type: ignore - - @distributed_trace - def begin_start_extension_upgrade( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Starts a rolling upgrade to move all extensions for all virtual machine scale set instances to - the latest available extension version. Instances which are already running the latest - extension versions are not affected. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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 - - 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_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.v2019_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 "2019-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 - ) - - response = pipeline_response.http_response - - if response.status_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.v2019_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vm_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, 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 "2019-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, "VirtualMachineExtension") - - _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) - - _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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """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.v2019_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 VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] - :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.VirtualMachineExtension]: - """The operation to create or update the VMSS VM extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] - :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.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """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 VirtualMachineExtension type or a IO[bytes] type. Required. - :type extension_parameters: ~azure.mgmt.compute.v2019_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.v2019_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.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, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, 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 "2019-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, "VirtualMachineExtensionUpdate") - - _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, - 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]: - 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, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to 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 Update Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2019_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 VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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.VirtualMachineExtension]: - """The operation to 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 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 VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_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, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to 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 Update Virtual Machine Extension - operation. Is either a VirtualMachineExtensionUpdate type or a IO[bytes] type. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2019_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.v2019_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.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, vm_extension_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 "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_extensions_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - 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, 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 resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :return: An instance of 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 "2019-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) - - 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, - instance_id: str, - vm_extension_name: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineExtension: - """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: VirtualMachineExtension or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-07-01")) - cls: ClsType[_models.VirtualMachineExtension] = 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("VirtualMachineExtension", 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 - ) -> _models.VirtualMachineExtensionsListResult: - """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: VirtualMachineExtensionsListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionsListResult - :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 "2019-07-01")) - cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_extensions_list_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_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 VirtualMachineScaleSetVMsOperations: # 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.v2019_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _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 - ) -> 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 "2019-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_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, - 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 - 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_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Default value is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2019_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: - """ - - @overload - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Default value is None. - :type vm_scale_set_vm_reimage_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[ - Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] - ] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Is either a VirtualMachineScaleSetVMReimageParameters type or a IO[bytes] type. Default value - is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2019_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 "2019-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, **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, - 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 "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_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. - :type 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 "2019-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._reimage_all_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - 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 "2019-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) - - 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_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. - :type 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 "2019-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._deallocate_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, 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 "2019-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, "VirtualMachineScaleSetVM") - - _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, - 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, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.VirtualMachineScaleSetVM, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVM - :keyword content_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.v2019_07_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - 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 VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. - Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVM or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVM] - :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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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, - 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("VirtualMachineScaleSetVM", 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.VirtualMachineScaleSetVM].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetVM]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, 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 "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - 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, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes 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: 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 "2019-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, - 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, - instance_id: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_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 "2019-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.v2019_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 "2019-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 - ) -> ItemPaged["_models.VirtualMachineScaleSetVM"]: - """Gets a list of all virtual machines in a VM scale sets. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param virtual_machine_scale_set_name: The name of the VM scale set. Required. - :type virtual_machine_scale_set_name: str - :keyword filter: The filter to apply to the operation. Allowed values are - 'startswith(instanceView/statuses/code, 'PowerState') eq true', 'properties/latestModelApplied - eq true', 'properties/latestModelApplied eq false'. Default value is None. - :paramtype filter: str - :keyword select: The list parameters. Allowed values are 'instanceView', - 'instanceView/statuses'. Default value is None. - :paramtype select: str - :keyword expand: The expand expression to apply to the operation. Allowed values are - 'instanceView'. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_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 "2019-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 - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVMListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _power_off_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - skip_shutdown: bool = False, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_power_off_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - skip_shutdown: bool = False, - **kwargs: Any - ) -> LROPoller[None]: - """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached - and you are getting charged for the resources. Instead, use deallocate to release resources and - avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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 "2019-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 - - return deserialized # type: ignore - - @distributed_trace - def begin_restart( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Restarts a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type 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 "2019-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._restart_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 - - 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, - 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 "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_start_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 - - return deserialized # type: ignore - - @distributed_trace - def begin_start( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Starts a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM 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 "2019-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_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 - - 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, - 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 "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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 vm_scale_set_name: The name of the VM 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 "2019-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) - - 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, 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 "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_perform_maintenance( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Shuts down the virtual machine in a VMScaleSet, moves it to an already updated node, and powers - it back on during the self-service phase of planned maintenance. - - :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 "2019-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._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _run_command_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, 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 "2019-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, "RunCommandInput") - - _request = build_virtual_machine_scale_set_vms_run_command_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 - 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_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - :type 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.v2019_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 RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> 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. - :type 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.v2019_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.v2019_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._run_command_initial( - resource_group_name=resource_group_name, - vm_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("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, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class LogAnalyticsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`log_analytics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - 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 "2019-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, "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, - ) - _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_export_request_rate_by_interval( - self, - location: str, - parameters: _models.RequestRateByIntervalInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. - - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. - Required. - :type parameters: ~azure.mgmt.compute.v2019_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 LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.LogAnalyticsOperationResult] - :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. - - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_export_request_rate_by_interval( - self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. - - :param location: The 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.v2019_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.v2019_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 "2019-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, 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, - 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("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, 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.LogAnalyticsOperationResult].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 - ) - - def _export_throttled_requests_initial( - self, location: str, parameters: Union[_models.ThrottledRequestsInput, 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 "2019-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, - 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_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.v2019_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.v2019_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.v2019_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. - - :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.v2019_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.v2019_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 "2019-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, 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, - 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("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, 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.LogAnalyticsOperationResult].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 - ) - - -class DisksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`disks` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_name: str, disk: Union[_models.Disk, 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 "2019-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(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_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) - - _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_create_or_update( - self, - resource_group_name: str, - disk_name: str, - disk: _models.Disk, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Creates or updates 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 - :param disk: Disk object supplied in the body of the Put disk operation. Required. - :type disk: ~azure.mgmt.compute.v2019_07_01.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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.Disk] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_name: str, - disk: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Creates or updates 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 - :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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.Disk] - :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. - - :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 - :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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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._create_or_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, **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 _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, - 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 "2019-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(disk, (IOBase, bytes)): - _content = disk - else: - _json = self._serialize.body(disk, "DiskUpdate") - - _request = build_disks_update_request( - resource_group_name=resource_group_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) - - _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, - disk_name: str, - disk: _models.DiskUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Updates (patches) a disk. - - :param resource_group_name: The name of the resource group. Required. - :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.v2019_07_01.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.v2019_07_01.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. 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.v2019_07_01.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. 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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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, **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 - ) - - @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.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) - - _request = build_disks_get_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) - - _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("Disk", 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_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 "2019-07-01")) - 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. - :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 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 "2019-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, - disk_name=disk_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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Disk"]: - """Lists all the disks 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 Disk or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - 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 list(self, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disks_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) - - 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, - 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 "2019-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disks_grant_access_request( - resource_group_name=resource_group_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) - - _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_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_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.v2019_07_01.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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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, - disk_name=disk_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, 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disks_revoke_access_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]: - 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_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. - :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 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 "2019-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._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 - ) - 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 SnapshotsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`snapshots` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, snapshot_name: str, snapshot: Union[_models.Snapshot, 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 "2019-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(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "Snapshot") - - _request = build_snapshots_create_or_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.Snapshot, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: ~azure.mgmt.compute.v2019_07_01.models.Snapshot - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :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.v2019_07_01.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.v2019_07_01.models.Snapshot] - :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 "2019-07-01")) - 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._create_or_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, **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 _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, - 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 "2019-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(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "SnapshotUpdate") - - _request = build_snapshots_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, - snapshot_name: str, - snapshot: _models.SnapshotUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. 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.v2019_07_01.models.SnapshotUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. - Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. Is - either a SnapshotUpdate type or a IO[bytes] type. Required. - :type snapshot: ~azure.mgmt.compute.v2019_07_01.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.v2019_07_01.models.Snapshot] - :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 "2019-07-01")) - 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, **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 - ) - - @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.v2019_07_01.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 "2019-07-01")) - 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]: - 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 "2019-07-01")) - 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) - - 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, snapshot_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes 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: 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 "2019-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, - snapshot_name=snapshot_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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Snapshot"]: - """Lists snapshots 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 Snapshot or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.Snapshot"]: - """Lists snapshots under a subscription. - - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _grant_access_initial( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, 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 "2019-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_snapshots_grant_access_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param grant_access_data: Access data object supplied in the body of the get snapshot access - operation. Required. - :type grant_access_data: ~azure.mgmt.compute.v2019_07_01.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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param 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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The - max name length is 80 characters. Required. - :type snapshot_name: str - :param 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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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, - snapshot_name=snapshot_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, 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 "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_snapshots_revoke_access_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]: - 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_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. - :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 "2019-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._revoke_access_initial( - resource_group_name=resource_group_name, - snapshot_name=snapshot_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 DiskEncryptionSetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`disk_encryption_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 "2019-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(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set - else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") - - _request = build_disk_encryption_sets_create_or_update_request( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9 and _. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9 and _. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9 and _. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Is either a DiskEncryptionSet type or a IO[bytes] type. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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._create_or_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 - ) - - 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, - 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 "2019-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(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_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, - 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. - :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.v2019_07_01.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.v2019_07_01.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.v2019_07_01.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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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.v2019_07_01.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 "2019-07-01")) - 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 "2019-07-01")) - 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 - :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 "2019-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, - 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, **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) -> ItemPaged["_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.v2019_07_01.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 "2019-07-01")) - 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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_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.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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 GalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2019-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(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 - - 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) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: _models.Gallery, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_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. - Required. - :type gallery_name: str - :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. - Required. - :type gallery: ~azure.mgmt.compute.v2019_07_01.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.v2019_07_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2019_07_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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. Is - either a Gallery type or a IO[bytes] type. Required. - :type gallery: ~azure.mgmt.compute.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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) - - 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, **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 _update_initial( - self, - resource_group_name: str, - gallery_name: str, - gallery: Union[_models.GalleryUpdate, 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 "2019-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(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) - - _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]: - 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, - 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. 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 update Shared Image Gallery operation. Required. - :type gallery: ~azure.mgmt.compute.v2019_07_01.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.v2019_07_01.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. 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 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.v2019_07_01.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. 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 update Shared Image Gallery operation. Is either a - GalleryUpdate type or a IO[bytes] type. Required. - :type gallery: ~azure.mgmt.compute.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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, **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 - ) - - @distributed_trace - def get(self, resource_group_name: str, gallery_name: str, **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 - :return: Gallery or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - 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, - 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("Gallery", 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, **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 "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_galleries_delete_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) - - _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, gallery_name: str, **kwargs: Any) -> LROPoller[None]: - """Delete 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 to be deleted. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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, - gallery_name=gallery_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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - 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 - - 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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_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.v2019_07_01.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 "2019-07-01")) - 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 - - 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) - - 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 GalleryImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_image_name: str, - gallery_image: Union[_models.GalleryImage, 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 "2019-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(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 = 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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.v2019_07_01.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.v2019_07_01.models.GalleryImage] - :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: IO[bytes], - *, - 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: IO[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.v2019_07_01.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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) - - 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: 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, - ) - return LROPoller[_models.GalleryImage]( - 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: Union[_models.GalleryImageUpdate, 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 "2019-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(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 = 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: - 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, - 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.v2019_07_01.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.v2019_07_01.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2019_07_01.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image: Union[_models.GalleryImageUpdate, IO[bytes]], - **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. Is either a - GalleryImageUpdate type or a IO[bytes] type. Required. - :type gallery_image: ~azure.mgmt.compute.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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) - - 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: 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, - ) - 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_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.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.GalleryImage] = kwargs.pop("cls", None) - - _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) - raise HttpResponseError(response=response, 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 _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 "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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) - - _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, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> LROPoller[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 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 "2019-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, - 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 - ) -> ItemPaged["_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.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.GalleryImageList] = 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_images_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("GalleryImageList", 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 GalleryImageVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_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 "2019-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(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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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.v2019_07_01.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.v2019_07_01.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. 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.v2019_07_01.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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, **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, - 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 "2019-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(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) - - _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]: - 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, - 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. - - :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.v2019_07_01.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.v2019_07_01.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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 LROPoller that returns either GalleryImageVersion or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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 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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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) - - 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, **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 - ) - - @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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2019_07_01.models.ReplicationStatusTypes - :return: GalleryImageVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - 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( - 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, - 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 "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - **kwargs: Any - ) -> LROPoller[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 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 "2019-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, - 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 - - 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_image( - self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> ItemPaged["_models.GalleryImageVersion"]: - """List gallery Image Versions in 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 - resides. 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) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.GalleryImageVersionList] = 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_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, - 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("GalleryImageVersionList", 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 GalleryApplicationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`gallery_applications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application: Union[_models.GalleryApplication, 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 "2019-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(gallery_application, (IOBase, bytes)): - _content = gallery_application - else: - _json = self._serialize.body(gallery_application, "GalleryApplication") - - _request = build_gallery_applications_create_or_update_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, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: _models.GalleryApplication, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2019_07_01.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 GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_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]: - """Create or update 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 is to be created. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the create or 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.v2019_07_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplication, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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._create_or_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, **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 _update_initial( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, 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 "2019-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(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_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, - ) - _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]: - 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, - gallery_application_name: str, - gallery_application: _models.GalleryApplicationUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the update gallery Application operation. - Required. - :type gallery_application: ~azure.mgmt.compute.v2019_07_01.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.v2019_07_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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 is to be updated. 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. - :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.v2019_07_01.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. 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. - :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. - :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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - 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, **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 - ) - - @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.v2019_07_01.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 "2019-07-01")) - 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 - ) -> 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 "2019-07-01")) - 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) - 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, 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. 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. - :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be deleted. - 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 "2019-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, - 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, **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 - ) -> ItemPaged["_models.GalleryApplication"]: - """List gallery Application 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 Application Gallery from which Application - Definitions are to be listed. 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.v2019_07_01.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 "2019-07-01")) - cls: ClsType[_models.GalleryApplicationList] = 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_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: - 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 GalleryApplicationVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`gallery_application_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: Union[_models.GalleryApplicationVersion, 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 "2019-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(gallery_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersion") - - _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, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersion, - *, - 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. - :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 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.v2019_07_01.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 GalleryApplicationVersion or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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], - *, - 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. - :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 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] - :keyword content_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.v2019_07_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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]], - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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) - if cont_token is None: - 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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.GalleryApplicationVersion]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - 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]], - **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 "2019-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(gallery_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersionUpdate") - - _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, - 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]: - 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, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2019_07_01.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 GalleryApplicationVersion or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update 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 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] - :keyword content_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.v2019_07_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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]], - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2019_07_01.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.v2019_07_01.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 "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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) - 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_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 - ) - 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: 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.GalleryApplicationVersion].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - 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, - 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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2019_07_01.models.ReplicationStatusTypes - :return: GalleryApplicationVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_07_01.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 "2019-07-01")) - 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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Delete 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 - deleted. 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-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, - 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, - 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_application( - self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> ItemPaged["_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.v2019_07_01.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 "2019-07-01")) - 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 VirtualMachineRunCommandsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.RunCommandDocumentBase"]: - """Lists all available run commands for a subscription in a location. - - :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 - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_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 "2019-07-01")) - cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_run_commands_list_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RunCommandListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - 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, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: - """Gets specific run command for a subscription in a location. - - :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.v2019_07_01.models.RunCommandDocument - :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 "2019-07-01")) - cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) - - _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, - 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("RunCommandDocument", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2019_12_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_compute_management_client.py deleted file mode 100644 index 865ff826045c..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_compute_management_client.py +++ /dev/null @@ -1,277 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ( - AvailabilitySetsOperations, - DedicatedHostGroupsOperations, - DedicatedHostsOperations, - GalleriesOperations, - GalleryApplicationVersionsOperations, - GalleryApplicationsOperations, - GalleryImageVersionsOperations, - GalleryImagesOperations, - ImagesOperations, - LogAnalyticsOperations, - Operations, - ProximityPlacementGroupsOperations, - SshPublicKeysOperations, - UsageOperations, - VirtualMachineExtensionImagesOperations, - VirtualMachineExtensionsOperations, - VirtualMachineImagesOperations, - VirtualMachineRunCommandsOperations, - VirtualMachineScaleSetExtensionsOperations, - VirtualMachineScaleSetRollingUpgradesOperations, - VirtualMachineScaleSetVMExtensionsOperations, - VirtualMachineScaleSetVMsOperations, - VirtualMachineScaleSetsOperations, - VirtualMachineSizesOperations, - VirtualMachinesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.compute.v2019_12_01.operations.Operations - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2019_12_01.operations.AvailabilitySetsOperations - :ivar proximity_placement_groups: ProximityPlacementGroupsOperations operations - :vartype proximity_placement_groups: - azure.mgmt.compute.v2019_12_01.operations.ProximityPlacementGroupsOperations - :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations - :vartype dedicated_host_groups: - azure.mgmt.compute.v2019_12_01.operations.DedicatedHostGroupsOperations - :ivar dedicated_hosts: DedicatedHostsOperations operations - :vartype dedicated_hosts: azure.mgmt.compute.v2019_12_01.operations.DedicatedHostsOperations - :ivar ssh_public_keys: SshPublicKeysOperations operations - :vartype ssh_public_keys: azure.mgmt.compute.v2019_12_01.operations.SshPublicKeysOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2019_12_01.operations.VirtualMachineExtensionImagesOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2019_12_01.operations.VirtualMachineExtensionsOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2019_12_01.operations.VirtualMachineImagesOperations - :ivar usage: UsageOperations operations - :vartype usage: azure.mgmt.compute.v2019_12_01.operations.UsageOperations - :ivar virtual_machines: VirtualMachinesOperations operations - :vartype virtual_machines: azure.mgmt.compute.v2019_12_01.operations.VirtualMachinesOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2019_12_01.operations.VirtualMachineSizesOperations - :ivar images: ImagesOperations operations - :vartype images: azure.mgmt.compute.v2019_12_01.operations.ImagesOperations - :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations - :vartype virtual_machine_scale_sets: - azure.mgmt.compute.v2019_12_01.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations - operations - :vartype virtual_machine_scale_set_extensions: - azure.mgmt.compute.v2019_12_01.operations.VirtualMachineScaleSetExtensionsOperations - :ivar virtual_machine_scale_set_rolling_upgrades: - VirtualMachineScaleSetRollingUpgradesOperations operations - :vartype virtual_machine_scale_set_rolling_upgrades: - azure.mgmt.compute.v2019_12_01.operations.VirtualMachineScaleSetRollingUpgradesOperations - :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations - operations - :vartype virtual_machine_scale_set_vm_extensions: - azure.mgmt.compute.v2019_12_01.operations.VirtualMachineScaleSetVMExtensionsOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2019_12_01.operations.VirtualMachineScaleSetVMsOperations - :ivar log_analytics: LogAnalyticsOperations operations - :vartype log_analytics: azure.mgmt.compute.v2019_12_01.operations.LogAnalyticsOperations - :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations - :vartype virtual_machine_run_commands: - azure.mgmt.compute.v2019_12_01.operations.VirtualMachineRunCommandsOperations - :ivar galleries: GalleriesOperations operations - :vartype galleries: azure.mgmt.compute.v2019_12_01.operations.GalleriesOperations - :ivar gallery_images: GalleryImagesOperations operations - :vartype gallery_images: azure.mgmt.compute.v2019_12_01.operations.GalleryImagesOperations - :ivar gallery_image_versions: GalleryImageVersionsOperations operations - :vartype gallery_image_versions: - azure.mgmt.compute.v2019_12_01.operations.GalleryImageVersionsOperations - :ivar gallery_applications: GalleryApplicationsOperations operations - :vartype gallery_applications: - azure.mgmt.compute.v2019_12_01.operations.GalleryApplicationsOperations - :ivar gallery_application_versions: GalleryApplicationVersionsOperations operations - :vartype gallery_application_versions: - azure.mgmt.compute.v2019_12_01.operations.GalleryApplicationVersionsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2019-12-01") - self.availability_sets = AvailabilitySetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.proximity_placement_groups = ProximityPlacementGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.dedicated_host_groups = DedicatedHostGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.dedicated_hosts = DedicatedHostsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.ssh_public_keys = SshPublicKeysOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.virtual_machine_images = VirtualMachineImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2019-12-01") - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2019-12-01") - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.log_analytics = LogAnalyticsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.galleries = GalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.gallery_images = GalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.gallery_image_versions = GalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.gallery_applications = GalleryApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.gallery_application_versions = GalleryApplicationVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_configuration.py deleted file mode 100644 index 79ff481ff18a..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2019-12-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_metadata.json deleted file mode 100644 index 6352bfb5fb78..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_metadata.json +++ /dev/null @@ -1,134 +0,0 @@ -{ - "chosen_version": "2019-12-01", - "total_api_version_list": ["2019-12-01"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "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.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "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.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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": { - "operations": "Operations", - "availability_sets": "AvailabilitySetsOperations", - "proximity_placement_groups": "ProximityPlacementGroupsOperations", - "dedicated_host_groups": "DedicatedHostGroupsOperations", - "dedicated_hosts": "DedicatedHostsOperations", - "ssh_public_keys": "SshPublicKeysOperations", - "virtual_machine_extension_images": "VirtualMachineExtensionImagesOperations", - "virtual_machine_extensions": "VirtualMachineExtensionsOperations", - "virtual_machine_images": "VirtualMachineImagesOperations", - "usage": "UsageOperations", - "virtual_machines": "VirtualMachinesOperations", - "virtual_machine_sizes": "VirtualMachineSizesOperations", - "images": "ImagesOperations", - "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", - "log_analytics": "LogAnalyticsOperations", - "virtual_machine_run_commands": "VirtualMachineRunCommandsOperations", - "galleries": "GalleriesOperations", - "gallery_images": "GalleryImagesOperations", - "gallery_image_versions": "GalleryImageVersionsOperations", - "gallery_applications": "GalleryApplicationsOperations", - "gallery_application_versions": "GalleryApplicationVersionsOperations" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node
    is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj 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 deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2019_12_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/_compute_management_client.py deleted file mode 100644 index 4f4e70f369d7..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/_compute_management_client.py +++ /dev/null @@ -1,283 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ( - AvailabilitySetsOperations, - DedicatedHostGroupsOperations, - DedicatedHostsOperations, - GalleriesOperations, - GalleryApplicationVersionsOperations, - GalleryApplicationsOperations, - GalleryImageVersionsOperations, - GalleryImagesOperations, - ImagesOperations, - LogAnalyticsOperations, - Operations, - ProximityPlacementGroupsOperations, - SshPublicKeysOperations, - UsageOperations, - VirtualMachineExtensionImagesOperations, - VirtualMachineExtensionsOperations, - VirtualMachineImagesOperations, - VirtualMachineRunCommandsOperations, - VirtualMachineScaleSetExtensionsOperations, - VirtualMachineScaleSetRollingUpgradesOperations, - VirtualMachineScaleSetVMExtensionsOperations, - VirtualMachineScaleSetVMsOperations, - VirtualMachineScaleSetsOperations, - VirtualMachineSizesOperations, - VirtualMachinesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.compute.v2019_12_01.aio.operations.Operations - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2019_12_01.aio.operations.AvailabilitySetsOperations - :ivar proximity_placement_groups: ProximityPlacementGroupsOperations operations - :vartype proximity_placement_groups: - azure.mgmt.compute.v2019_12_01.aio.operations.ProximityPlacementGroupsOperations - :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations - :vartype dedicated_host_groups: - azure.mgmt.compute.v2019_12_01.aio.operations.DedicatedHostGroupsOperations - :ivar dedicated_hosts: DedicatedHostsOperations operations - :vartype dedicated_hosts: - azure.mgmt.compute.v2019_12_01.aio.operations.DedicatedHostsOperations - :ivar ssh_public_keys: SshPublicKeysOperations operations - :vartype ssh_public_keys: azure.mgmt.compute.v2019_12_01.aio.operations.SshPublicKeysOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2019_12_01.aio.operations.VirtualMachineExtensionImagesOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2019_12_01.aio.operations.VirtualMachineExtensionsOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2019_12_01.aio.operations.VirtualMachineImagesOperations - :ivar usage: UsageOperations operations - :vartype usage: azure.mgmt.compute.v2019_12_01.aio.operations.UsageOperations - :ivar virtual_machines: VirtualMachinesOperations operations - :vartype virtual_machines: - azure.mgmt.compute.v2019_12_01.aio.operations.VirtualMachinesOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2019_12_01.aio.operations.VirtualMachineSizesOperations - :ivar images: ImagesOperations operations - :vartype images: azure.mgmt.compute.v2019_12_01.aio.operations.ImagesOperations - :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations - :vartype virtual_machine_scale_sets: - azure.mgmt.compute.v2019_12_01.aio.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations - operations - :vartype virtual_machine_scale_set_extensions: - azure.mgmt.compute.v2019_12_01.aio.operations.VirtualMachineScaleSetExtensionsOperations - :ivar virtual_machine_scale_set_rolling_upgrades: - VirtualMachineScaleSetRollingUpgradesOperations operations - :vartype virtual_machine_scale_set_rolling_upgrades: - azure.mgmt.compute.v2019_12_01.aio.operations.VirtualMachineScaleSetRollingUpgradesOperations - :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations - operations - :vartype virtual_machine_scale_set_vm_extensions: - azure.mgmt.compute.v2019_12_01.aio.operations.VirtualMachineScaleSetVMExtensionsOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2019_12_01.aio.operations.VirtualMachineScaleSetVMsOperations - :ivar log_analytics: LogAnalyticsOperations operations - :vartype log_analytics: azure.mgmt.compute.v2019_12_01.aio.operations.LogAnalyticsOperations - :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations - :vartype virtual_machine_run_commands: - azure.mgmt.compute.v2019_12_01.aio.operations.VirtualMachineRunCommandsOperations - :ivar galleries: GalleriesOperations operations - :vartype galleries: azure.mgmt.compute.v2019_12_01.aio.operations.GalleriesOperations - :ivar gallery_images: GalleryImagesOperations operations - :vartype gallery_images: azure.mgmt.compute.v2019_12_01.aio.operations.GalleryImagesOperations - :ivar gallery_image_versions: GalleryImageVersionsOperations operations - :vartype gallery_image_versions: - azure.mgmt.compute.v2019_12_01.aio.operations.GalleryImageVersionsOperations - :ivar gallery_applications: GalleryApplicationsOperations operations - :vartype gallery_applications: - azure.mgmt.compute.v2019_12_01.aio.operations.GalleryApplicationsOperations - :ivar gallery_application_versions: GalleryApplicationVersionsOperations operations - :vartype gallery_application_versions: - azure.mgmt.compute.v2019_12_01.aio.operations.GalleryApplicationVersionsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2019-12-01") - self.availability_sets = AvailabilitySetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.proximity_placement_groups = ProximityPlacementGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.dedicated_host_groups = DedicatedHostGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.dedicated_hosts = DedicatedHostsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.ssh_public_keys = SshPublicKeysOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.virtual_machine_images = VirtualMachineImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2019-12-01") - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2019-12-01") - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.log_analytics = LogAnalyticsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.galleries = GalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.gallery_images = GalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.gallery_image_versions = GalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.gallery_applications = GalleryApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - self.gallery_application_versions = GalleryApplicationVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/_configuration.py deleted file mode 100644 index 4e590f8abf0e..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-12-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2019-12-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/__init__.py deleted file mode 100644 index b79bc7bf3104..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/__init__.py +++ /dev/null @@ -1,73 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import Operations # type: ignore -from ._operations import AvailabilitySetsOperations # 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 VirtualMachineExtensionImagesOperations # type: ignore -from ._operations import VirtualMachineExtensionsOperations # type: ignore -from ._operations import VirtualMachineImagesOperations # type: ignore -from ._operations import UsageOperations # type: ignore -from ._operations import VirtualMachinesOperations # type: ignore -from ._operations import VirtualMachineSizesOperations # type: ignore -from ._operations import ImagesOperations # 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 LogAnalyticsOperations # type: ignore -from ._operations import VirtualMachineRunCommandsOperations # type: ignore -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 ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AvailabilitySetsOperations", - "ProximityPlacementGroupsOperations", - "DedicatedHostGroupsOperations", - "DedicatedHostsOperations", - "SshPublicKeysOperations", - "VirtualMachineExtensionImagesOperations", - "VirtualMachineExtensionsOperations", - "VirtualMachineImagesOperations", - "UsageOperations", - "VirtualMachinesOperations", - "VirtualMachineSizesOperations", - "ImagesOperations", - "VirtualMachineScaleSetsOperations", - "VirtualMachineScaleSetExtensionsOperations", - "VirtualMachineScaleSetRollingUpgradesOperations", - "VirtualMachineScaleSetVMExtensionsOperations", - "VirtualMachineScaleSetVMsOperations", - "LogAnalyticsOperations", - "VirtualMachineRunCommandsOperations", - "GalleriesOperations", - "GalleryImagesOperations", - "GalleryImageVersionsOperations", - "GalleryApplicationsOperations", - "GalleryApplicationVersionsOperations", -] -__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/v2019_12_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_operations.py deleted file mode 100644 index 155acb814123..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_operations.py +++ /dev/null @@ -1,18970 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, Dict, IO, List, Literal, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import ( - build_availability_sets_create_or_update_request, - build_availability_sets_delete_request, - build_availability_sets_get_request, - build_availability_sets_list_available_sizes_request, - build_availability_sets_list_by_subscription_request, - build_availability_sets_list_request, - build_availability_sets_update_request, - build_dedicated_host_groups_create_or_update_request, - build_dedicated_host_groups_delete_request, - build_dedicated_host_groups_get_request, - build_dedicated_host_groups_list_by_resource_group_request, - build_dedicated_host_groups_list_by_subscription_request, - build_dedicated_host_groups_update_request, - build_dedicated_hosts_create_or_update_request, - build_dedicated_hosts_delete_request, - build_dedicated_hosts_get_request, - build_dedicated_hosts_list_by_host_group_request, - build_dedicated_hosts_update_request, - build_galleries_create_or_update_request, - build_galleries_delete_request, - build_galleries_get_request, - build_galleries_list_by_resource_group_request, - build_galleries_list_request, - build_galleries_update_request, - build_gallery_application_versions_create_or_update_request, - build_gallery_application_versions_delete_request, - build_gallery_application_versions_get_request, - build_gallery_application_versions_list_by_gallery_application_request, - build_gallery_application_versions_update_request, - build_gallery_applications_create_or_update_request, - build_gallery_applications_delete_request, - build_gallery_applications_get_request, - build_gallery_applications_list_by_gallery_request, - build_gallery_applications_update_request, - build_gallery_image_versions_create_or_update_request, - build_gallery_image_versions_delete_request, - build_gallery_image_versions_get_request, - build_gallery_image_versions_list_by_gallery_image_request, - build_gallery_image_versions_update_request, - build_gallery_images_create_or_update_request, - build_gallery_images_delete_request, - build_gallery_images_get_request, - build_gallery_images_list_by_gallery_request, - build_gallery_images_update_request, - build_images_create_or_update_request, - build_images_delete_request, - build_images_get_request, - build_images_list_by_resource_group_request, - build_images_list_request, - build_images_update_request, - build_log_analytics_export_request_rate_by_interval_request, - build_log_analytics_export_throttled_requests_request, - build_operations_list_request, - build_proximity_placement_groups_create_or_update_request, - build_proximity_placement_groups_delete_request, - build_proximity_placement_groups_get_request, - build_proximity_placement_groups_list_by_resource_group_request, - build_proximity_placement_groups_list_by_subscription_request, - build_proximity_placement_groups_update_request, - build_ssh_public_keys_create_request, - build_ssh_public_keys_delete_request, - build_ssh_public_keys_generate_key_pair_request, - build_ssh_public_keys_get_request, - build_ssh_public_keys_list_by_resource_group_request, - build_ssh_public_keys_list_by_subscription_request, - build_ssh_public_keys_update_request, - build_usage_list_request, - build_virtual_machine_extension_images_get_request, - build_virtual_machine_extension_images_list_types_request, - build_virtual_machine_extension_images_list_versions_request, - build_virtual_machine_extensions_create_or_update_request, - build_virtual_machine_extensions_delete_request, - build_virtual_machine_extensions_get_request, - build_virtual_machine_extensions_list_request, - build_virtual_machine_extensions_update_request, - build_virtual_machine_images_get_request, - build_virtual_machine_images_list_offers_request, - build_virtual_machine_images_list_publishers_request, - build_virtual_machine_images_list_request, - build_virtual_machine_images_list_skus_request, - build_virtual_machine_run_commands_get_request, - build_virtual_machine_run_commands_list_request, - build_virtual_machine_scale_set_extensions_create_or_update_request, - build_virtual_machine_scale_set_extensions_delete_request, - build_virtual_machine_scale_set_extensions_get_request, - build_virtual_machine_scale_set_extensions_list_request, - build_virtual_machine_scale_set_extensions_update_request, - build_virtual_machine_scale_set_rolling_upgrades_cancel_request, - build_virtual_machine_scale_set_rolling_upgrades_get_latest_request, - build_virtual_machine_scale_set_rolling_upgrades_start_extension_upgrade_request, - build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request, - build_virtual_machine_scale_set_vm_extensions_create_or_update_request, - build_virtual_machine_scale_set_vm_extensions_delete_request, - build_virtual_machine_scale_set_vm_extensions_get_request, - build_virtual_machine_scale_set_vm_extensions_list_request, - build_virtual_machine_scale_set_vm_extensions_update_request, - build_virtual_machine_scale_set_vms_deallocate_request, - build_virtual_machine_scale_set_vms_delete_request, - build_virtual_machine_scale_set_vms_get_instance_view_request, - build_virtual_machine_scale_set_vms_get_request, - build_virtual_machine_scale_set_vms_list_request, - build_virtual_machine_scale_set_vms_perform_maintenance_request, - build_virtual_machine_scale_set_vms_power_off_request, - build_virtual_machine_scale_set_vms_redeploy_request, - build_virtual_machine_scale_set_vms_reimage_all_request, - build_virtual_machine_scale_set_vms_reimage_request, - build_virtual_machine_scale_set_vms_restart_request, - build_virtual_machine_scale_set_vms_run_command_request, - build_virtual_machine_scale_set_vms_simulate_eviction_request, - build_virtual_machine_scale_set_vms_start_request, - build_virtual_machine_scale_set_vms_update_request, - build_virtual_machine_scale_sets_convert_to_single_placement_group_request, - build_virtual_machine_scale_sets_create_or_update_request, - build_virtual_machine_scale_sets_deallocate_request, - build_virtual_machine_scale_sets_delete_instances_request, - build_virtual_machine_scale_sets_delete_request, - build_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk_request, - build_virtual_machine_scale_sets_get_instance_view_request, - build_virtual_machine_scale_sets_get_os_upgrade_history_request, - build_virtual_machine_scale_sets_get_request, - build_virtual_machine_scale_sets_list_all_request, - build_virtual_machine_scale_sets_list_request, - build_virtual_machine_scale_sets_list_skus_request, - build_virtual_machine_scale_sets_perform_maintenance_request, - build_virtual_machine_scale_sets_power_off_request, - build_virtual_machine_scale_sets_redeploy_request, - build_virtual_machine_scale_sets_reimage_all_request, - build_virtual_machine_scale_sets_reimage_request, - build_virtual_machine_scale_sets_restart_request, - build_virtual_machine_scale_sets_set_orchestration_service_state_request, - build_virtual_machine_scale_sets_start_request, - build_virtual_machine_scale_sets_update_instances_request, - build_virtual_machine_scale_sets_update_request, - build_virtual_machine_sizes_list_request, - build_virtual_machines_capture_request, - build_virtual_machines_convert_to_managed_disks_request, - build_virtual_machines_create_or_update_request, - build_virtual_machines_deallocate_request, - build_virtual_machines_delete_request, - build_virtual_machines_generalize_request, - build_virtual_machines_get_request, - build_virtual_machines_instance_view_request, - build_virtual_machines_list_all_request, - build_virtual_machines_list_available_sizes_request, - build_virtual_machines_list_by_location_request, - build_virtual_machines_list_request, - build_virtual_machines_perform_maintenance_request, - build_virtual_machines_power_off_request, - build_virtual_machines_reapply_request, - build_virtual_machines_redeploy_request, - build_virtual_machines_reimage_request, - build_virtual_machines_restart_request, - build_virtual_machines_run_command_request, - build_virtual_machines_simulate_eviction_request, - build_virtual_machines_start_request, - build_virtual_machines_update_request, -) -from .._configuration import ComputeManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.ComputeOperationValue"]: - """Gets a list of compute operations. - - :return: An iterator like instance of either ComputeOperationValue or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.ComputeOperationValue] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[_models.ComputeOperationListResult] = 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_operations_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async 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, 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 AvailabilitySetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`availability_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySet, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Is either a - AvailabilitySet type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySet") - - _request = build_availability_sets_create_or_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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, - availability_set_name: str, - parameters: _models.AvailabilitySetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySetUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Is either a - AvailabilitySetUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySetUpdate or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySetUpdate") - - _request = build_availability_sets_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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: - """ - 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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_availability_sets_delete_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get(self, resource_group_name: str, availability_set_name: str, **kwargs: Any) -> _models.AvailabilitySet: - """Retrieves information about an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", 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) - - _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("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription( - self, *, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. - - :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.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, 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(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets 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 AvailabilitySet or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, 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_available_sizes( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes that can be used to create a new virtual machine in - an existing availability set. - - :param resource_group_name: The name of the resource group. Required. - :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.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_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 - - if response.status_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 ProximityPlacementGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`proximity_placement_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - 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. 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.v2019_12_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.v2019_12_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. 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.v2019_12_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - 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 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. Is - either a ProximityPlacementGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroup or IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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. 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.v2019_12_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.v2019_12_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. 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.v2019_12_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - 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 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. Is - either a ProximityPlacementGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroupUpdate or - IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ProximityPlacementGroupUpdate") - - _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, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete(self, resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any) -> None: - """Delete a proximity placement group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _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, - 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_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. 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.v2019_12_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - _request = build_proximity_placement_groups_get_request( - resource_group_name=resource_group_name, - proximity_placement_group_name=proximity_placement_group_name, - subscription_id=self._config.subscription_id, - include_colocation_status=include_colocation_status, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a subscription. - - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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 - ) -> AsyncItemPaged["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a resource group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) - - -class DedicatedHostGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`dedicated_host_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - host_group_name: str, - parameters: _models.DedicatedHostGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroup, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Is either a - DedicatedHostGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroup or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DedicatedHostGroup") - - _request = build_dedicated_host_groups_create_or_update_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DedicatedHostGroup", 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, - host_group_name: str, - parameters: _models.DedicatedHostGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroupUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :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: IO[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.v2019_12_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroupUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Is either - a DedicatedHostGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroupUpdate or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-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") - - _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) - - _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("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: - """ - 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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_dedicated_host_groups_delete_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get(self, resource_group_name: str, host_group_name: str, **kwargs: Any) -> _models.DedicatedHostGroup: - """Retrieves information about a dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", 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, - 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("DedicatedHostGroup", 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 - ) -> AsyncItemPaged["_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. - :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.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 - def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_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.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_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 - - if response.status_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 DedicatedHostsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`dedicated_hosts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, 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 "2019-12-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, "DedicatedHost") - - _request = build_dedicated_hosts_create_or_update_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, - 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) - - 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, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHost, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHost - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. 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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. Is either a DedicatedHost - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHost or IO[bytes] - :return: An instance of AsyncLROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.DedicatedHost] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, 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 "2019-12-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, "DedicatedHostUpdate") - - _request = build_dedicated_hosts_update_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, - 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, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHostUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostUpdate - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host 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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Is either a - DedicatedHostUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.DedicatedHost] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_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 "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_delete_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 [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, host_group_name: str, host_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete 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 - :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 "2019-12-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, - 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_async - async def get( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: DedicatedHost or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.DedicatedHost] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_get_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DedicatedHost", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_host_group( - self, resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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. - :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.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.DedicatedHostListResult] = 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_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, - 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("DedicatedHostListResult", 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 SshPublicKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`ssh_public_keys` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-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_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("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) - - 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 - ) -> AsyncItemPaged["_models.SshPublicKeyResource"]: - """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in - the response to get the next page of SSH public keys. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either SshPublicKeyResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-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 - - 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) - - 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) - - @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.v2019_12_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.v2019_12_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2019_12_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2019_12_01.models.SshPublicKeyResource or IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.SshPublicKeyResource - :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 "2019-12-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") - - _request = build_ssh_public_keys_create_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, - 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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # 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. - - :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: ~azure.mgmt.compute.v2019_12_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.v2019_12_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2019_12_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2019_12_01.models.SshPublicKeyUpdateResource or - IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.SshPublicKeyResource - :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 "2019-12-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( - resource_group_name=resource_group_name, - ssh_public_key_name=ssh_public_key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("SshPublicKeyResource", 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, ssh_public_key_name: str, **kwargs: Any) -> None: - """Delete an SSH public key. - - :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: - """ - 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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_ssh_public_keys_delete_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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, 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. - :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.v2019_12_01.models.SshPublicKeyResource - :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 "2019-12-01")) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - - _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) - - _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("SshPublicKeyResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def generate_key_pair( - self, resource_group_name: str, ssh_public_key_name: str, **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. 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: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.SshPublicKeyGenerateKeyPairResult - :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 "2019-12-01")) - cls: ClsType[_models.SshPublicKeyGenerateKeyPairResult] = kwargs.pop("cls", None) - - _request = build_ssh_public_keys_generate_key_pair_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) - - _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("SshPublicKeyGenerateKeyPairResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class VirtualMachineExtensionImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_extension_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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. - - :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.v2019_12_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 "2019-12-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 = 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 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 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.v2019_12_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 "2019-12-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - - _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) - - _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 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 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.v2019_12_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 "2019-12-01")) - 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 = 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 - - -class VirtualMachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, 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 "2019-12-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, "VirtualMachineExtension") - - _request = build_virtual_machine_extensions_create_or_update_request( - resource_group_name=resource_group_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, - 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) - - 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, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2019_12_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 VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_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 create or 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 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] - :keyword content_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.v2019_12_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2019_12_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.v2019_12_01.models.VirtualMachineExtension] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2019-12-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( - resource_group_name=resource_group_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, - 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, - 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. - - :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: - ~azure.mgmt.compute.v2019_12_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.v2019_12_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.v2019_12_01.models.VirtualMachineExtension] - :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.v2019_12_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.v2019_12_01.models.VirtualMachineExtension] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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) - - _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, vm_name: str, vm_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_name: The name of the virtual machine where the extension should be deleted. - 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-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, - vm_extension_name=vm_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - 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.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_get_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list( - self, resource_group_name: str, vm_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.VirtualMachineExtensionsListResult: - """The operation to get all extensions of a Virtual Machine. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine containing the extension. Required. - :type vm_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineExtensionsListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionsListResult - :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 "2019-12-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 VirtualMachineImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.v2019_12_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 "2019-12-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.v2019_12_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 "2019-12-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.v2019_12_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 "2019-12-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. - - :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.v2019_12_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 "2019-12-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) - 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. - - :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.v2019_12_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 "2019-12-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _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) - - _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 - - -class UsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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 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.v2019_12_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 "2019-12-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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ListUsagesResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class 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.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.VirtualMachine"]: - """Gets all the virtual machines under the specified subscription for the specified location. - - :param location: The location for which virtual machines under the subscription are queried. - Required. - :type location: str - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-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 - - 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) - - 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 _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, - 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 "2019-12-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, "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 = 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_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. 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.v2019_12_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.v2019_12_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. 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.v2019_12_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. 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.v2019_12_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.v2019_12_01.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-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 - ) - 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) - 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.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 _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, 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 "2019-12-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, - 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) - - 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, - vm_name: str, - parameters: _models.VirtualMachine, - *, - 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. 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.v2019_12_01.models.VirtualMachine - :keyword content_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.v2019_12_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], - *, - 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. 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 content_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.v2019_12_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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :param resource_group_name: The name of the resource group. Required. - :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.v2019_12_01.models.VirtualMachine or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_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 "2019-12-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, - 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, **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]], - **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 "2019-12-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, - 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) - - 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, - vm_name: str, - parameters: _models.VirtualMachineUpdate, - *, - 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. 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.v2019_12_01.models.VirtualMachineUpdate - :keyword content_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.v2019_12_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - 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. 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 content_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.v2019_12_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]], - **kwargs: Any - ) -> AsyncLROPoller[_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.v2019_12_01.models.VirtualMachineUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_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 "2019-12-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, - 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, **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, **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 "2019-12-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, - 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, vm_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """The operation to delete 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 "2019-12-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, - 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_name: str, *, expand: Literal["instanceView"] = "instanceView", **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) - - _request = build_virtual_machines_get_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def instance_view( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> _models.VirtualMachineInstanceView: - """Retrieves information about the run-time state of a virtual machine. - - :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.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) - - _request = build_virtual_machines_instance_view_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineInstanceView", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _convert_to_managed_disks_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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_convert_to_managed_disks_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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. :code:`
    `For Windows, please refer to - `Convert a virtual machine from unmanaged disks to managed disks. - `_.\\ - :code:`
    `For Linux, please refer to `Convert a virtual machine from unmanaged disks to - managed disks. - `_. - - :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 "2019-12-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, **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 "2019-12-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, - 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, **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 - :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 "2019-12-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, - 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. :code:`
    `For Windows, please refer to - `Create a managed image of a generalized VM in Azure - `_.\\ - :code:`
    `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 "2019-12-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, **kwargs: Any) -> AsyncItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-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, - 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("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) - - 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, *, status_only: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-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, - 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("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) - - 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_available_sizes( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes to which the specified virtual machine can be - resized. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_available_sizes_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 - - if response.status_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_name: 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 "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_power_off_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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_name: str, *, skip_shutdown: bool = False, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with - the same provisioned resources. You are still charged for this virtual machine. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._power_off_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - skip_shutdown=skip_shutdown, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reapply_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - 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 "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_reapply_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - 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_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. - :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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reapply_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **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_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 "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_restart_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - 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_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. - :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 "2019-12-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._restart_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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_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 "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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_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 "2019-12-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]: - 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 "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_redeploy_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_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. - :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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._redeploy_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reimage_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-12-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( - 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) - - 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 the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: ~azure.mgmt.compute.v2019_12_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 the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. 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.v2019_12_01.models.VirtualMachineReimageParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **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 _perform_maintenance_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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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_perform_maintenance( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Shuts down the virtual machine, moves it to an already updated node, and powers it back on - during the self-service phase of planned maintenance. - - :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 "2019-12-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_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 - - @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. The eviction will occur within - 30 minutes of calling the API. - - :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 "2019-12-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 _run_command_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, 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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RunCommandInput") - - _request = build_virtual_machines_run_command_request( - 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) - - 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_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.RunCommandInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_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.v2019_12_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._run_command_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineSizesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """This API is deprecated. Use `Resources Skus - `_. - - :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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_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 - - 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 - - if response.status_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 ImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> 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 "2019-12-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) - - 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, - image_name: str, - parameters: _models.Image, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Create or update an image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param 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.v2019_12_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Create or update an image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param 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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.Image] - :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. - - :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 - :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.v2019_12_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.v2019_12_01.models.Image] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._create_or_update_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Image]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, 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 "2019-12-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, "ImageUpdate") - - _request = build_images_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) - - 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, - image_name: str, - parameters: _models.ImageUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Update 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 - :param parameters: Parameters supplied to the Update Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Update 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 - :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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Update 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 - :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.v2019_12_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.v2019_12_01.models.Image] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Image]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial(self, resource_group_name: str, image_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_images_delete_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, image_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes 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 - :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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - image_name=image_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - 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.v2019_12_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 "2019-12-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 = 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("Image", 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) -> AsyncItemPaged["_models.Image"]: - """Gets the list of images 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 Image or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-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 - - 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) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - parameters: Union[_models.VirtualMachineScaleSet, 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 "2019-12-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, - 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) - - 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, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. 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.v2019_12_01.models.VirtualMachineScaleSet - :keyword content_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.v2019_12_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. 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: IO[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 VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 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.v2019_12_01.models.VirtualMachineScaleSet or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_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 "2019-12-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, - 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]], - **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 "2019-12-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, "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, - 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, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSetUpdate, - *, - 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. 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.v2019_12_01.models.VirtualMachineScaleSetUpdate - :keyword content_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.v2019_12_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], - *, - 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. 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: IO[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 VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Update 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 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.v2019_12_01.models.VirtualMachineScaleSetUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_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 "2019-12-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, - 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 _delete_initial( - self, resource_group_name: str, vm_scale_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 "2019-12-01")) - cls: ClsType[AsyncIterator[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, - 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, vm_scale_set_name: str, **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 - :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 "2019-12-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, - 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, **kwargs: Any - ) -> _models.VirtualMachineScaleSet: - """Display information about a 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 - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-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, - 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 _deallocate_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 "2019-12-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_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_deallocate( - 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]: - """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. - :type 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.v2019_12_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_deallocate( - 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]: - """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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_deallocate( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and - releases the compute resources. You are not billed for the compute resources that this virtual - machine scale set deallocates. - - :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.v2019_12_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 "2019-12-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, - 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 _delete_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-12-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: - _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, - 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_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """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. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :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], - *, - 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. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **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.v2019_12_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-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, - 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.v2019_12_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 "2019-12-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) -> AsyncItemPaged["_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 - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-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_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("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 - def list_all(self, **kwargs: Any) -> AsyncItemPaged["_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.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = 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_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("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) - - 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_skus( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineScaleSetSku"]: - """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM - instances allowed for each SKU. - - :param resource_group_name: The name of the resource group. Required. - :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.v2019_12_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 "2019-12-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 - - 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) - - @distributed_trace - def get_os_upgrade_history( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.UpgradeOperationHistoricalStatusInfo"]: - """Gets list of OS upgrades 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 - :return: An iterator like instance of either UpgradeOperationHistoricalStatusInfo or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-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 _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]: - 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 "2019-12-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_power_off_request( - resource_group_name=resource_group_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, - 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_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - 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. - - :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.v2019_12_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 - :keyword content_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_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - 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. - - :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 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 - :keyword content_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_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: bool = False, - **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. - - :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.v2019_12_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] - :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 "2019-12-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 "2019-12-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_restart_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :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.v2019_12_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 "2019-12-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, - 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 "2019-12-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 - 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_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. Required. - :type 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.v2019_12_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. Required. - :type 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.v2019_12_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 "2019-12-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 _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, - 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 "2019-12-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_redeploy_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_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. - - :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.v2019_12_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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_redeploy( - self, - resource_group_name: str, - vm_scale_set_name: str, - 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. Required. - :type 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.v2019_12_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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._redeploy_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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 _perform_maintenance_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-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_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_perform_maintenance( - 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]: - """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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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.v2019_12_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_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 - ) -> 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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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_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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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.v2019_12_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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-12-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: - _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, - 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_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :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.v2019_12_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reimage_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_scale_set_reimage_input, (IOBase, bytes)): - _content = vm_scale_set_reimage_input - else: - if vm_scale_set_reimage_input is not None: - _json = self._serialize.body(vm_scale_set_reimage_input, "VirtualMachineScaleSetReimageParameters") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which - don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual - machine is reset to initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetReimageParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which - don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual - machine is reset to initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. - :type vm_scale_set_reimage_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which - don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual - machine is reset to initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Is either a - VirtualMachineScaleSetReimageParameters type or a IO[bytes] type. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetReimageParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_scale_set_reimage_input=vm_scale_set_reimage_input, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reimage_all_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_all_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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, **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 - :return: RecoveryWalkResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RecoveryWalkResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 true 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.v2019_12_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 true 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 true 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. Is either a - VMScaleSetConvertToSinglePlacementGroupInput type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.compute.v2019_12_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 "2019-12-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 _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 "2019-12-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, - 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_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.v2019_12_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.v2019_12_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 "2019-12-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 - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2019-12-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") - - _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, - 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) - - 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, - 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. - - :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.v2019_12_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.v2019_12_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2019_12_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtension, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to create or update an extension. - - :param resource_group_name: The name of the resource group. Required. - :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.v2019_12_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.v2019_12_01.models.VirtualMachineScaleSetExtension] - :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 "2019-12-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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _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]: - 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 "2019-12-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") - - _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, - 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) - - 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, - 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.v2019_12_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.v2019_12_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :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.v2019_12_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.v2019_12_01.models.VirtualMachineScaleSetExtension] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-12-01")) - cls: ClsType[AsyncIterator[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, - 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, 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 "2019-12-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.v2019_12_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 "2019-12-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 - ) -> AsyncItemPaged["_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.v2019_12_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 "2019-12-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. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> 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 "2019-12-01")) - 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, - 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 - - @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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._cancel_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _start_os_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-12-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, - 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) - - _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_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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._start_os_upgrade_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _start_extension_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - 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 - - @distributed_trace_async - async def begin_start_extension_upgrade( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Starts a rolling upgrade to move all extensions for all virtual machine scale set instances to - the latest available extension version. Instances which are already running the latest - extension versions are not affected. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._start_extension_upgrade_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get_latest( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> _models.RollingUpgradeStatusInfo: - """Gets the status of the latest virtual machine scale set rolling upgrade. - - :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.v2019_12_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 "2019-12-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 = 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("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.v2019_12_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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.VirtualMachineExtension, 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 "2019-12-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, "VirtualMachineExtension") - - _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) - - _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) - - 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, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """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.v2019_12_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 VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] - :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.VirtualMachineExtension]: - """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 VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] - :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.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """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 VirtualMachineExtension type or a IO[bytes] type. Required. - :type extension_parameters: ~azure.mgmt.compute.v2019_12_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.v2019_12_01.models.VirtualMachineExtension] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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, - 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("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)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_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.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, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, 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 "2019-12-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_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, - 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, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """The operation to 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 Update Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2019_12_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.v2019_12_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """The operation to 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 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.v2019_12_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, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """The operation to 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 Update Virtual Machine Extension - operation. Is either a VirtualMachineExtensionUpdate type or a IO[bytes] type. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2019_12_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.v2019_12_01.models.VirtualMachineExtension] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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, - 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("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)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_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.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, vm_extension_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 "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_extensions_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - 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, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to delete the VMSS VM extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineExtension: - """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: VirtualMachineExtension or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.VirtualMachineExtension] = 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 = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineExtensionsListResult: - """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: VirtualMachineExtensionsListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionsListResult - :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 "2019-12-01")) - cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_extensions_list_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_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 VirtualMachineScaleSetVMsOperations: # 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.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _reimage_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[ - Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] - ] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - 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 "2019-12-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( - 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 - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - 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.v2019_12_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 - ) -> 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. - Is either a VirtualMachineScaleSetVMReimageParameters type or a IO[bytes] type. Default value - is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMReimageParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_scale_set_vm_reimage_input=vm_scale_set_vm_reimage_input, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reimage_all_initial( - self, resource_group_name: str, vm_scale_set_name: str, 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 "2019-12-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) - - 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_reimage_all( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. - This operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_all_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _deallocate_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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. - - :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 "2019-12-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 - - async def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, 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 "2019-12-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, "VirtualMachineScaleSetVM") - - _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, - 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( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.VirtualMachineScaleSetVM, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM - :keyword content_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) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - 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 VirtualMachineScaleSetVM or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM] - :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, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. - Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVM or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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, - 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("VirtualMachineScaleSetVM", 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.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 - ) - - async def _delete_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 "2019-12-01")) - 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, - 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, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes 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: 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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - 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, - instance_id: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-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 = 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("VirtualMachineScaleSetVM", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_instance_view( - self, resource_group_name: str, vm_scale_set_name: str, 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.v2019_12_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 "2019-12-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 - ) -> AsyncItemPaged["_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.v2019_12_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 "2019-12-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 "2019-12-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. - - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._power_off_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **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, - 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 "2019-12-01")) - cls: ClsType[AsyncIterator[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 = 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_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. - :type 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 "2019-12-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._restart_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _start_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 "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_start_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - 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 - :param vm_scale_set_name: The name of the VM 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 "2019-12-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_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _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, - 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 "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_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, - 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_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. - :type 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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._redeploy_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **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 _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 "2019-12-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) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_perform_maintenance( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Shuts down the virtual machine in a VMScaleSet, moves it to an already updated node, and powers - it back on during the self-service phase of planned maintenance. - - :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 "2019-12-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. The eviction - will occur within 30 minutes of calling the API. - - :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 "2019-12-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 _run_command_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, 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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RunCommandInput") - - _request = build_virtual_machine_scale_set_vms_run_command_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 - 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_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - :type 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.v2019_12_01.models.RunCommandInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> 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. - :type 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.v2019_12_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.v2019_12_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._run_command_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class LogAnalyticsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`log_analytics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _export_request_rate_by_interval_initial( - self, location: str, parameters: Union[_models.RequestRateByIntervalInput, 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 "2019-12-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, "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, - ) - _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_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 location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. - Required. - :type parameters: ~azure.mgmt.compute.v2019_12_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.v2019_12_01.models.LogAnalyticsOperationResult] - :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. - - :param location: The location upon which virtual-machine-sizes is queried. 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.v2019_12_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 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.v2019_12_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.v2019_12_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 "2019-12-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._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, - **kwargs - ) - 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) - 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LogAnalyticsOperationResult]( - 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 - ) -> 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 "2019-12-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, - 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_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.v2019_12_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.v2019_12_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.v2019_12_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. - - :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.v2019_12_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.v2019_12_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 "2019-12-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._export_throttled_requests_initial( - location=location, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - 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) - 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LogAnalyticsOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineRunCommandsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.RunCommandDocumentBase"]: - """Lists all available run commands for a subscription in a location. - - :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 - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_run_commands_list_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RunCommandListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, location: str, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: - """Gets specific run command for a subscription in a location. - - :param location: The 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.v2019_12_01.models.RunCommandDocument - :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 "2019-12-01")) - cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) - - _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, - 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("RunCommandDocument", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class GalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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: Union[_models.Gallery, 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 "2019-12-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(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 = 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: _models.Gallery, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - Required. - :type gallery_name: str - :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. - Required. - :type gallery: ~azure.mgmt.compute.v2019_12_01.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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - 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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, gallery_name: str, gallery: Union[_models.Gallery, IO[bytes]], **kwargs: Any - ) -> 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. - 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.v2019_12_01.models.Gallery or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Gallery] = 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=gallery, - 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("Gallery", 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.Gallery].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Gallery]( - 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: Union[_models.GalleryUpdate, 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 "2019-12-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(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) - - _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: _models.GalleryUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - Required. - :type gallery_name: str - :param gallery: Parameters supplied to the update Shared Image Gallery operation. Required. - :type gallery: ~azure.mgmt.compute.v2019_12_01.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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - 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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: Union[_models.GalleryUpdate, IO[bytes]], - **kwargs: Any - ) -> 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. - 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.v2019_12_01.models.GalleryUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Gallery] = 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=gallery, - 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("Gallery", 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.Gallery].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Gallery]( - 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, **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 - :return: Gallery or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.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 "2019-12-01")) - 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, - 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, - 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 "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_galleries_delete_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) - - _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, gallery_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Delete 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 to be deleted. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-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, - gallery_name=gallery_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) -> AsyncItemPaged["_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.v2019_12_01.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 "2019-12-01")) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2019_12_01.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 "2019-12-01")) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class GalleryImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 "2019-12-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(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.v2019_12_01.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.v2019_12_01.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.v2019_12_01.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.v2019_12_01.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.v2019_12_01.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 "2019-12-01")) - 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 "2019-12-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(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.v2019_12_01.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.v2019_12_01.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.v2019_12_01.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.v2019_12_01.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.v2019_12_01.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 "2019-12-01")) - 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.v2019_12_01.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 "2019-12-01")) - cls: ClsType[_models.GalleryImage] = kwargs.pop("cls", None) - - _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 = 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("GalleryImage", 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]: - 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 "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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) - - _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, 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-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, - 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, **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_gallery( - self, resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.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 "2019-12-01")) - cls: ClsType[_models.GalleryImageList] = 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_images_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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryImageList", 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 GalleryImageVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 "2019-12-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(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.v2019_12_01.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.v2019_12_01.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.v2019_12_01.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.v2019_12_01.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.v2019_12_01.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 "2019-12-01")) - 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]: - 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 "2019-12-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(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) - - _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_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.v2019_12_01.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.v2019_12_01.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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 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.v2019_12_01.models.GalleryImageVersion] - :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_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. 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.v2019_12_01.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.v2019_12_01.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 "2019-12-01")) - 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) - - 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 - ) - - @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. - - :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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2019_12_01.models.ReplicationStatusTypes - :return: GalleryImageVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.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 "2019-12-01")) - 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) - 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 - - 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, - 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 "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-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, - 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) - - 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_gallery_image( - self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.GalleryImageVersion"]: - """List gallery Image Versions in 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 - resides. 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) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.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 "2019-12-01")) - cls: ClsType[_models.GalleryImageVersionList] = 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_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, - 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("GalleryImageVersionList", 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 GalleryApplicationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`gallery_applications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application: Union[_models.GalleryApplication, 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 "2019-12-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(gallery_application, (IOBase, bytes)): - _content = gallery_application - else: - _json = self._serialize.body(gallery_application, "GalleryApplication") - - _request = build_gallery_applications_create_or_update_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, - 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_application_name: str, - gallery_application: _models.GalleryApplication, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2019_12_01.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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the create or 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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplication, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2019_12_01.models.GalleryApplication or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryApplication] = 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_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 - ) - await 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: 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.GalleryApplication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GalleryApplication]( - 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_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, 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 "2019-12-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(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_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, - ) - _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_application_name: str, - gallery_application: _models.GalleryApplicationUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the update gallery Application operation. - Required. - :type gallery_application: ~azure.mgmt.compute.v2019_12_01.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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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 - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :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.v2019_12_01.models.GalleryApplicationUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryApplication] = 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=gallery_application, - 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("GalleryApplication", 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.GalleryApplication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GalleryApplication]( - 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.v2019_12_01.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 "2019-12-01")) - 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]: - 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 "2019-12-01")) - cls: ClsType[AsyncIterator[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 = 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, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete a gallery Application. - - :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 is to be deleted. Required. - :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be deleted. - 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-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, - 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 - ) - 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_gallery( - self, resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.GalleryApplication"]: - """List gallery Application 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 Application Gallery from which Application - Definitions are to be listed. Required. - :type gallery_name: str - :return: An iterator like instance of either GalleryApplication or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.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 "2019-12-01")) - cls: ClsType[_models.GalleryApplicationList] = 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_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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryApplicationList", 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 GalleryApplicationVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.aio.ComputeManagementClient`'s - :attr:`gallery_application_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: Union[_models.GalleryApplicationVersion, 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 "2019-12-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(gallery_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersion") - - _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, - 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersion, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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.v2019_12_01.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 AsyncLROPoller that returns either GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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] - :keyword content_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 GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async 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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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.v2019_12_01.models.GalleryApplicationVersion 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.v2019_12_01.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 "2019-12-01")) - 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._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, - 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 - ) - - async 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]], - **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 "2019-12-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(gallery_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersionUpdate") - - _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, - 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2019_12_01.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 AsyncLROPoller that returns either GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Update 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 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] - :keyword content_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 GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async 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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2019_12_01.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.v2019_12_01.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 "2019-12-01")) - 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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2019_12_01.models.ReplicationStatusTypes - :return: GalleryApplicationVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.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 "2019-12-01")) - 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) - - deserialized = self._deserialize("GalleryApplicationVersion", 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, - gallery_application_version_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 "2019-12-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete 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 - deleted. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-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, - 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, - 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_gallery_application( - self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.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 "2019-12-01")) - 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 - - async 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, 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/v2019_12_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/__init__.py deleted file mode 100644 index 4a81e1c71bab..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/__init__.py +++ /dev/null @@ -1,548 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - AdditionalCapabilities, - AdditionalUnattendContent, - ApiEntityReference, - ApiError, - ApiErrorBase, - AutomaticOSUpgradePolicy, - AutomaticOSUpgradeProperties, - AutomaticRepairsPolicy, - AvailabilitySet, - AvailabilitySetListResult, - AvailabilitySetUpdate, - BillingProfile, - BootDiagnostics, - BootDiagnosticsInstanceView, - ComputeOperationListResult, - ComputeOperationValue, - DataDisk, - DataDiskImage, - DataDiskImageEncryption, - DedicatedHost, - DedicatedHostAllocatableVM, - DedicatedHostAvailableCapacity, - DedicatedHostGroup, - DedicatedHostGroupListResult, - DedicatedHostGroupUpdate, - DedicatedHostInstanceView, - DedicatedHostListResult, - DedicatedHostUpdate, - DiagnosticsProfile, - DiffDiskSettings, - Disallowed, - DiskEncryptionSetParameters, - DiskEncryptionSettings, - DiskImageEncryption, - DiskInstanceView, - EncryptionImages, - Gallery, - GalleryApplication, - GalleryApplicationList, - GalleryApplicationUpdate, - GalleryApplicationVersion, - GalleryApplicationVersionList, - GalleryApplicationVersionPublishingProfile, - GalleryApplicationVersionUpdate, - GalleryArtifactPublishingProfileBase, - GalleryArtifactSource, - GalleryArtifactVersionSource, - GalleryDataDiskImage, - GalleryDiskImage, - GalleryIdentifier, - GalleryImage, - GalleryImageIdentifier, - GalleryImageList, - GalleryImageUpdate, - GalleryImageVersion, - GalleryImageVersionList, - GalleryImageVersionPublishingProfile, - GalleryImageVersionStorageProfile, - GalleryImageVersionUpdate, - GalleryList, - GalleryOSDiskImage, - GalleryUpdate, - HardwareProfile, - Image, - ImageDataDisk, - ImageDisk, - ImageListResult, - ImageOSDisk, - ImagePurchasePlan, - ImageReference, - ImageStorageProfile, - ImageUpdate, - InnerError, - InstanceViewStatus, - KeyVaultKeyReference, - KeyVaultSecretReference, - LinuxConfiguration, - ListUsagesResult, - LogAnalyticsInputBase, - LogAnalyticsOperationResult, - LogAnalyticsOutput, - MaintenanceRedeployStatus, - ManagedArtifact, - ManagedDiskParameters, - NetworkInterfaceReference, - NetworkProfile, - OSDisk, - OSDiskImage, - OSDiskImageEncryption, - OSProfile, - OrchestrationServiceStateInput, - OrchestrationServiceSummary, - Plan, - ProximityPlacementGroup, - ProximityPlacementGroupListResult, - ProximityPlacementGroupUpdate, - PurchasePlan, - RecommendedMachineConfiguration, - RecoveryWalkResponse, - RegionalReplicationStatus, - ReplicationStatus, - RequestRateByIntervalInput, - Resource, - ResourceRange, - RollbackStatusInfo, - RollingUpgradePolicy, - RollingUpgradeProgressInfo, - RollingUpgradeRunningStatus, - RollingUpgradeStatusInfo, - RunCommandDocument, - RunCommandDocumentBase, - RunCommandInput, - RunCommandInputParameter, - RunCommandListResult, - RunCommandParameterDefinition, - RunCommandResult, - ScaleInPolicy, - ScheduledEventsProfile, - Sku, - SshConfiguration, - SshPublicKey, - SshPublicKeyGenerateKeyPairResult, - SshPublicKeyResource, - SshPublicKeyUpdateResource, - SshPublicKeysGroupListResult, - StorageProfile, - SubResource, - SubResourceReadOnly, - SubResourceWithColocationStatus, - TargetRegion, - TerminateNotificationProfile, - ThrottledRequestsInput, - UpdateResource, - UpdateResourceDefinition, - UpgradeOperationHistoricalStatusInfo, - UpgradeOperationHistoricalStatusInfoProperties, - UpgradeOperationHistoryStatus, - UpgradePolicy, - Usage, - UsageName, - UserArtifactManage, - UserArtifactSource, - UserAssignedIdentitiesValue, - VMScaleSetConvertToSinglePlacementGroupInput, - VaultCertificate, - VaultSecretGroup, - VirtualHardDisk, - VirtualMachine, - VirtualMachineAgentInstanceView, - VirtualMachineCaptureParameters, - VirtualMachineCaptureResult, - VirtualMachineExtension, - VirtualMachineExtensionHandlerInstanceView, - VirtualMachineExtensionImage, - VirtualMachineExtensionInstanceView, - VirtualMachineExtensionUpdate, - VirtualMachineExtensionsListResult, - VirtualMachineHealthStatus, - VirtualMachineIdentity, - VirtualMachineImage, - VirtualMachineImageResource, - VirtualMachineInstanceView, - VirtualMachineListResult, - VirtualMachineReimageParameters, - VirtualMachineScaleSet, - VirtualMachineScaleSetDataDisk, - VirtualMachineScaleSetExtension, - VirtualMachineScaleSetExtensionListResult, - VirtualMachineScaleSetExtensionProfile, - VirtualMachineScaleSetExtensionUpdate, - VirtualMachineScaleSetIPConfiguration, - VirtualMachineScaleSetIdentity, - VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue, - VirtualMachineScaleSetInstanceView, - VirtualMachineScaleSetInstanceViewStatusesSummary, - VirtualMachineScaleSetIpTag, - VirtualMachineScaleSetListOSUpgradeHistory, - VirtualMachineScaleSetListResult, - VirtualMachineScaleSetListSkusResult, - VirtualMachineScaleSetListWithLinkResult, - VirtualMachineScaleSetManagedDiskParameters, - VirtualMachineScaleSetNetworkConfiguration, - VirtualMachineScaleSetNetworkConfigurationDnsSettings, - VirtualMachineScaleSetNetworkProfile, - VirtualMachineScaleSetOSDisk, - VirtualMachineScaleSetOSProfile, - VirtualMachineScaleSetPublicIPAddressConfiguration, - VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings, - VirtualMachineScaleSetReimageParameters, - VirtualMachineScaleSetSku, - VirtualMachineScaleSetSkuCapacity, - VirtualMachineScaleSetStorageProfile, - VirtualMachineScaleSetUpdate, - VirtualMachineScaleSetUpdateIPConfiguration, - VirtualMachineScaleSetUpdateNetworkConfiguration, - VirtualMachineScaleSetUpdateNetworkProfile, - VirtualMachineScaleSetUpdateOSDisk, - VirtualMachineScaleSetUpdateOSProfile, - VirtualMachineScaleSetUpdatePublicIPAddressConfiguration, - VirtualMachineScaleSetUpdateStorageProfile, - VirtualMachineScaleSetUpdateVMProfile, - VirtualMachineScaleSetVM, - VirtualMachineScaleSetVMExtensionsSummary, - VirtualMachineScaleSetVMInstanceIDs, - VirtualMachineScaleSetVMInstanceRequiredIDs, - VirtualMachineScaleSetVMInstanceView, - VirtualMachineScaleSetVMListResult, - VirtualMachineScaleSetVMNetworkProfileConfiguration, - VirtualMachineScaleSetVMProfile, - VirtualMachineScaleSetVMProtectionPolicy, - VirtualMachineScaleSetVMReimageParameters, - VirtualMachineSize, - VirtualMachineSizeListResult, - VirtualMachineStatusCodeCount, - VirtualMachineUpdate, - WinRMConfiguration, - WinRMListener, - WindowsConfiguration, -) - -from ._compute_management_client_enums import ( # type: ignore - AggregatedReplicationState, - AvailabilitySetSkuTypes, - CachingTypes, - DedicatedHostLicenseTypes, - DiffDiskOptions, - DiffDiskPlacement, - DiskCreateOptionTypes, - GalleryApplicationVersionPropertiesProvisioningState, - GalleryImagePropertiesProvisioningState, - GalleryImageVersionPropertiesProvisioningState, - GalleryPropertiesProvisioningState, - HostCaching, - HyperVGeneration, - HyperVGenerationType, - HyperVGenerationTypes, - IPVersion, - IntervalInMins, - MaintenanceOperationResultCodeTypes, - OperatingSystemStateTypes, - OperatingSystemTypes, - OrchestrationServiceNames, - OrchestrationServiceState, - OrchestrationServiceStateAction, - ProtocolTypes, - ProximityPlacementGroupType, - ReplicationState, - ReplicationStatusTypes, - ResourceIdentityType, - RollingUpgradeActionType, - RollingUpgradeStatusCode, - SettingNames, - StatusLevelTypes, - StorageAccountType, - StorageAccountTypes, - UpgradeMode, - UpgradeOperationInvoker, - UpgradeState, - VirtualMachineEvictionPolicyTypes, - VirtualMachinePriorityTypes, - VirtualMachineScaleSetScaleInRules, - VirtualMachineScaleSetSkuScaleType, - VirtualMachineSizeTypes, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AdditionalCapabilities", - "AdditionalUnattendContent", - "ApiEntityReference", - "ApiError", - "ApiErrorBase", - "AutomaticOSUpgradePolicy", - "AutomaticOSUpgradeProperties", - "AutomaticRepairsPolicy", - "AvailabilitySet", - "AvailabilitySetListResult", - "AvailabilitySetUpdate", - "BillingProfile", - "BootDiagnostics", - "BootDiagnosticsInstanceView", - "ComputeOperationListResult", - "ComputeOperationValue", - "DataDisk", - "DataDiskImage", - "DataDiskImageEncryption", - "DedicatedHost", - "DedicatedHostAllocatableVM", - "DedicatedHostAvailableCapacity", - "DedicatedHostGroup", - "DedicatedHostGroupListResult", - "DedicatedHostGroupUpdate", - "DedicatedHostInstanceView", - "DedicatedHostListResult", - "DedicatedHostUpdate", - "DiagnosticsProfile", - "DiffDiskSettings", - "Disallowed", - "DiskEncryptionSetParameters", - "DiskEncryptionSettings", - "DiskImageEncryption", - "DiskInstanceView", - "EncryptionImages", - "Gallery", - "GalleryApplication", - "GalleryApplicationList", - "GalleryApplicationUpdate", - "GalleryApplicationVersion", - "GalleryApplicationVersionList", - "GalleryApplicationVersionPublishingProfile", - "GalleryApplicationVersionUpdate", - "GalleryArtifactPublishingProfileBase", - "GalleryArtifactSource", - "GalleryArtifactVersionSource", - "GalleryDataDiskImage", - "GalleryDiskImage", - "GalleryIdentifier", - "GalleryImage", - "GalleryImageIdentifier", - "GalleryImageList", - "GalleryImageUpdate", - "GalleryImageVersion", - "GalleryImageVersionList", - "GalleryImageVersionPublishingProfile", - "GalleryImageVersionStorageProfile", - "GalleryImageVersionUpdate", - "GalleryList", - "GalleryOSDiskImage", - "GalleryUpdate", - "HardwareProfile", - "Image", - "ImageDataDisk", - "ImageDisk", - "ImageListResult", - "ImageOSDisk", - "ImagePurchasePlan", - "ImageReference", - "ImageStorageProfile", - "ImageUpdate", - "InnerError", - "InstanceViewStatus", - "KeyVaultKeyReference", - "KeyVaultSecretReference", - "LinuxConfiguration", - "ListUsagesResult", - "LogAnalyticsInputBase", - "LogAnalyticsOperationResult", - "LogAnalyticsOutput", - "MaintenanceRedeployStatus", - "ManagedArtifact", - "ManagedDiskParameters", - "NetworkInterfaceReference", - "NetworkProfile", - "OSDisk", - "OSDiskImage", - "OSDiskImageEncryption", - "OSProfile", - "OrchestrationServiceStateInput", - "OrchestrationServiceSummary", - "Plan", - "ProximityPlacementGroup", - "ProximityPlacementGroupListResult", - "ProximityPlacementGroupUpdate", - "PurchasePlan", - "RecommendedMachineConfiguration", - "RecoveryWalkResponse", - "RegionalReplicationStatus", - "ReplicationStatus", - "RequestRateByIntervalInput", - "Resource", - "ResourceRange", - "RollbackStatusInfo", - "RollingUpgradePolicy", - "RollingUpgradeProgressInfo", - "RollingUpgradeRunningStatus", - "RollingUpgradeStatusInfo", - "RunCommandDocument", - "RunCommandDocumentBase", - "RunCommandInput", - "RunCommandInputParameter", - "RunCommandListResult", - "RunCommandParameterDefinition", - "RunCommandResult", - "ScaleInPolicy", - "ScheduledEventsProfile", - "Sku", - "SshConfiguration", - "SshPublicKey", - "SshPublicKeyGenerateKeyPairResult", - "SshPublicKeyResource", - "SshPublicKeyUpdateResource", - "SshPublicKeysGroupListResult", - "StorageProfile", - "SubResource", - "SubResourceReadOnly", - "SubResourceWithColocationStatus", - "TargetRegion", - "TerminateNotificationProfile", - "ThrottledRequestsInput", - "UpdateResource", - "UpdateResourceDefinition", - "UpgradeOperationHistoricalStatusInfo", - "UpgradeOperationHistoricalStatusInfoProperties", - "UpgradeOperationHistoryStatus", - "UpgradePolicy", - "Usage", - "UsageName", - "UserArtifactManage", - "UserArtifactSource", - "UserAssignedIdentitiesValue", - "VMScaleSetConvertToSinglePlacementGroupInput", - "VaultCertificate", - "VaultSecretGroup", - "VirtualHardDisk", - "VirtualMachine", - "VirtualMachineAgentInstanceView", - "VirtualMachineCaptureParameters", - "VirtualMachineCaptureResult", - "VirtualMachineExtension", - "VirtualMachineExtensionHandlerInstanceView", - "VirtualMachineExtensionImage", - "VirtualMachineExtensionInstanceView", - "VirtualMachineExtensionUpdate", - "VirtualMachineExtensionsListResult", - "VirtualMachineHealthStatus", - "VirtualMachineIdentity", - "VirtualMachineImage", - "VirtualMachineImageResource", - "VirtualMachineInstanceView", - "VirtualMachineListResult", - "VirtualMachineReimageParameters", - "VirtualMachineScaleSet", - "VirtualMachineScaleSetDataDisk", - "VirtualMachineScaleSetExtension", - "VirtualMachineScaleSetExtensionListResult", - "VirtualMachineScaleSetExtensionProfile", - "VirtualMachineScaleSetExtensionUpdate", - "VirtualMachineScaleSetIPConfiguration", - "VirtualMachineScaleSetIdentity", - "VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue", - "VirtualMachineScaleSetInstanceView", - "VirtualMachineScaleSetInstanceViewStatusesSummary", - "VirtualMachineScaleSetIpTag", - "VirtualMachineScaleSetListOSUpgradeHistory", - "VirtualMachineScaleSetListResult", - "VirtualMachineScaleSetListSkusResult", - "VirtualMachineScaleSetListWithLinkResult", - "VirtualMachineScaleSetManagedDiskParameters", - "VirtualMachineScaleSetNetworkConfiguration", - "VirtualMachineScaleSetNetworkConfigurationDnsSettings", - "VirtualMachineScaleSetNetworkProfile", - "VirtualMachineScaleSetOSDisk", - "VirtualMachineScaleSetOSProfile", - "VirtualMachineScaleSetPublicIPAddressConfiguration", - "VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings", - "VirtualMachineScaleSetReimageParameters", - "VirtualMachineScaleSetSku", - "VirtualMachineScaleSetSkuCapacity", - "VirtualMachineScaleSetStorageProfile", - "VirtualMachineScaleSetUpdate", - "VirtualMachineScaleSetUpdateIPConfiguration", - "VirtualMachineScaleSetUpdateNetworkConfiguration", - "VirtualMachineScaleSetUpdateNetworkProfile", - "VirtualMachineScaleSetUpdateOSDisk", - "VirtualMachineScaleSetUpdateOSProfile", - "VirtualMachineScaleSetUpdatePublicIPAddressConfiguration", - "VirtualMachineScaleSetUpdateStorageProfile", - "VirtualMachineScaleSetUpdateVMProfile", - "VirtualMachineScaleSetVM", - "VirtualMachineScaleSetVMExtensionsSummary", - "VirtualMachineScaleSetVMInstanceIDs", - "VirtualMachineScaleSetVMInstanceRequiredIDs", - "VirtualMachineScaleSetVMInstanceView", - "VirtualMachineScaleSetVMListResult", - "VirtualMachineScaleSetVMNetworkProfileConfiguration", - "VirtualMachineScaleSetVMProfile", - "VirtualMachineScaleSetVMProtectionPolicy", - "VirtualMachineScaleSetVMReimageParameters", - "VirtualMachineSize", - "VirtualMachineSizeListResult", - "VirtualMachineStatusCodeCount", - "VirtualMachineUpdate", - "WinRMConfiguration", - "WinRMListener", - "WindowsConfiguration", - "AggregatedReplicationState", - "AvailabilitySetSkuTypes", - "CachingTypes", - "DedicatedHostLicenseTypes", - "DiffDiskOptions", - "DiffDiskPlacement", - "DiskCreateOptionTypes", - "GalleryApplicationVersionPropertiesProvisioningState", - "GalleryImagePropertiesProvisioningState", - "GalleryImageVersionPropertiesProvisioningState", - "GalleryPropertiesProvisioningState", - "HostCaching", - "HyperVGeneration", - "HyperVGenerationType", - "HyperVGenerationTypes", - "IPVersion", - "IntervalInMins", - "MaintenanceOperationResultCodeTypes", - "OperatingSystemStateTypes", - "OperatingSystemTypes", - "OrchestrationServiceNames", - "OrchestrationServiceState", - "OrchestrationServiceStateAction", - "ProtocolTypes", - "ProximityPlacementGroupType", - "ReplicationState", - "ReplicationStatusTypes", - "ResourceIdentityType", - "RollingUpgradeActionType", - "RollingUpgradeStatusCode", - "SettingNames", - "StatusLevelTypes", - "StorageAccountType", - "StorageAccountTypes", - "UpgradeMode", - "UpgradeOperationInvoker", - "UpgradeState", - "VirtualMachineEvictionPolicyTypes", - "VirtualMachinePriorityTypes", - "VirtualMachineScaleSetScaleInRules", - "VirtualMachineScaleSetSkuScaleType", - "VirtualMachineSizeTypes", -] -__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/v2019_12_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/_compute_management_client_enums.py deleted file mode 100644 index 4b5b90346ec3..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/_compute_management_client_enums.py +++ /dev/null @@ -1,576 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AggregatedReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is the aggregated replication status based on all the regional replication status flags.""" - - UNKNOWN = "Unknown" - IN_PROGRESS = "InProgress" - COMPLETED = "Completed" - FAILED = "Failed" - - -class AvailabilitySetSkuTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the sku of an Availability Set. Use 'Aligned' for virtual machines with managed disks - and 'Classic' for virtual machines with unmanaged disks. Default value is 'Classic'. - """ - - CLASSIC = "Classic" - ALIGNED = "Aligned" - - -class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** :code:`
    `\\ - :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for Standard storage. - ReadOnly for Premium storage**. - """ - - NONE = "None" - READ_ONLY = "ReadOnly" - READ_WRITE = "ReadWrite" - - -class DedicatedHostLicenseTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the software license type that will be applied to the VMs deployed on the dedicated - host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **None** - :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ :code:`
    ` - **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. - """ - - NONE = "None" - WINDOWS_SERVER_HYBRID = "Windows_Server_Hybrid" - WINDOWS_SERVER_PERPETUAL = "Windows_Server_Perpetual" - - -class DiffDiskOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the ephemeral disk option for operating system disk.""" - - LOCAL = "Local" - - -class DiffDiskPlacement(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the ephemeral disk placement for operating system disk. This property can be used by - user in the request to choose the location i.e, cache disk or resource disk space for Ephemeral - OS disk provisioning. For more information on Ephemeral OS disk size requirements, please refer - Ephemeral OS disk size requirements for Windows VM at - https://docs.microsoft.com/en-us/azure/virtual-machines/windows/ephemeral-os-disks#size-requirements - and Linux VM at - https://docs.microsoft.com/en-us/azure/virtual-machines/linux/ephemeral-os-disks#size-requirements. - """ - - CACHE_DISK = "CacheDisk" - RESOURCE_DISK = "ResourceDisk" - - -class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies how the virtual machine should be created.\\ :code:`
    `\\ :code:`
    ` Possible - values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value is used when you are - using a specialized disk to create the virtual machine.\\ :code:`
    `\\ :code:`
    ` - **FromImage** \\u2013 This value is used when you are using an image to create the virtual - machine. If you are using a platform image, you also use the imageReference element described - above. If you are using a marketplace image, you also use the plan element previously - described. - """ - - FROM_IMAGE = "FromImage" - EMPTY = "Empty" - ATTACH = "Attach" - - -class GalleryApplicationVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state, which only appears in the response.""" - - CREATING = "Creating" - UPDATING = "Updating" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - MIGRATING = "Migrating" - - -class GalleryImagePropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state, which only appears in the response.""" - - CREATING = "Creating" - UPDATING = "Updating" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - MIGRATING = "Migrating" - - -class GalleryImageVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state, which only appears in the response.""" - - CREATING = "Creating" - UPDATING = "Updating" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - MIGRATING = "Migrating" - - -class GalleryPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state, which only appears in the response.""" - - CREATING = "Creating" - UPDATING = "Updating" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - MIGRATING = "Migrating" - - -class HostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'.""" - - NONE = "None" - READ_ONLY = "ReadOnly" - READ_WRITE = "ReadWrite" - - -class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The hypervisor generation of the Virtual Machine. Applicable to OS disks only.""" - - V1 = "V1" - V2 = "V2" - - -class HyperVGenerationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the HyperVGeneration Type associated with a resource.""" - - V1 = "V1" - V2 = "V2" - - -class HyperVGenerationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the HyperVGeneration Type.""" - - V1 = "V1" - V2 = "V2" - - -class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Interval value in minutes used to create LogAnalytics call rate logs.""" - - THREE_MINS = "ThreeMins" - FIVE_MINS = "FiveMins" - THIRTY_MINS = "ThirtyMins" - SIXTY_MINS = "SixtyMins" - - -class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """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'. - """ - - I_PV4 = "IPv4" - I_PV6 = "IPv6" - - -class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The Last Maintenance Operation Result Code.""" - - NONE = "None" - RETRY_LATER = "RetryLater" - MAINTENANCE_ABORTED = "MaintenanceAborted" - MAINTENANCE_COMPLETED = "MaintenanceCompleted" - - -class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The OS State.""" - - GENERALIZED = "Generalized" - """Generalized image. Needs to be provisioned during deployment time.""" - SPECIALIZED = "Specialized" - """Specialized image. Contains already provisioned OS Disk.""" - - -class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The operating system of the osDiskImage.""" - - WINDOWS = "Windows" - LINUX = "Linux" - - -class OrchestrationServiceNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The name of the service.""" - - AUTOMATIC_REPAIRS = "AutomaticRepairs" - - -class OrchestrationServiceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current state of the service.""" - - NOT_RUNNING = "NotRunning" - RUNNING = "Running" - SUSPENDED = "Suspended" - - -class OrchestrationServiceStateAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The action to be performed.""" - - RESUME = "Resume" - SUSPEND = "Suspend" - - -class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the protocol of WinRM listener. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. - """ - - HTTP = "Http" - HTTPS = "Https" - - -class ProximityPlacementGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the type of the proximity placement group. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **Standard** : Co-locate resources within an Azure - region or Availability Zone. :code:`
    `\\ :code:`
    ` **Ultra** : For future use. - """ - - STANDARD = "Standard" - ULTRA = "Ultra" - - -class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is the regional replication state.""" - - UNKNOWN = "Unknown" - REPLICATING = "Replicating" - COMPLETED = "Completed" - FAILED = "Failed" - - -class ReplicationStatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ReplicationStatusTypes.""" - - REPLICATION_STATUS = "ReplicationStatus" - - -class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' - includes both an implicitly created identity and a set of user assigned identities. The type - 'None' will remove any identities from the virtual machine. - """ - - SYSTEM_ASSIGNED = "SystemAssigned" - USER_ASSIGNED = "UserAssigned" - SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" - NONE = "None" - - -class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The last action performed on the rolling upgrade.""" - - START = "Start" - CANCEL = "Cancel" - - -class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Code indicating the current status of the upgrade.""" - - ROLLING_FORWARD = "RollingForward" - CANCELLED = "Cancelled" - COMPLETED = "Completed" - FAULTED = "Faulted" - - -class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the name of the setting to which the content applies. Possible values are: - FirstLogonCommands and AutoLogon. - """ - - AUTO_LOGON = "AutoLogon" - FIRST_LOGON_COMMANDS = "FirstLogonCommands" - - -class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The level code.""" - - INFO = "Info" - WARNING = "Warning" - ERROR = "Error" - - -class StorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the storage account type to be used to store the image. This property is not - updatable. - """ - - STANDARD_LRS = "Standard_LRS" - STANDARD_ZRS = "Standard_ZRS" - PREMIUM_LRS = "Premium_LRS" - - -class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used - with data disks. It cannot be used with OS Disk. Standard_LRS uses Standard HDD. - StandardSSD_LRS uses Standard SSD. Premium_LRS uses Premium SSD. UltraSSD_LRS uses Ultra disk. - For more information regarding disks supported for Windows Virtual Machines, refer to - https://docs.microsoft.com/en-us/azure/virtual-machines/windows/disks-types and, for Linux - Virtual Machines, refer to - https://docs.microsoft.com/en-us/azure/virtual-machines/linux/disks-types. - """ - - STANDARD_LRS = "Standard_LRS" - PREMIUM_LRS = "Premium_LRS" - STANDARD_SSD_LRS = "StandardSSD_LRS" - ULTRA_SSD_LRS = "UltraSSD_LRS" - - -class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the mode of an upgrade to virtual machines in the scale set.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Manual** - You control - the application of updates to virtual machines in the scale set. You do this by using the - manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - All virtual machines in - the scale set are automatically updated at the same time. - """ - - AUTOMATIC = "Automatic" - MANUAL = "Manual" - ROLLING = "Rolling" - - -class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Invoker of the Upgrade Operation.""" - - UNKNOWN = "Unknown" - USER = "User" - PLATFORM = "Platform" - - -class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Code indicating the current status of the upgrade.""" - - ROLLING_FORWARD = "RollingForward" - CANCELLED = "Cancelled" - COMPLETED = "Completed" - FAULTED = "Faulted" - - -class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the eviction policy for the Azure Spot VM/VMSS.""" - - DEALLOCATE = "Deallocate" - DELETE = "Delete" - - -class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the priority for a standalone virtual machine or the virtual machines in the scale - set. :code:`
    `\\ :code:`
    ` 'Low' enum will be deprecated in the future, please use 'Spot' - as the enum to deploy Azure Spot VM/VMSS. - """ - - REGULAR = "Regular" - LOW = "Low" - SPOT = "Spot" - - -class VirtualMachineScaleSetScaleInRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """VirtualMachineScaleSetScaleInRules.""" - - DEFAULT = "Default" - OLDEST_VM = "OldestVM" - NEWEST_VM = "NewestVM" - - -class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scale type applicable to the sku.""" - - AUTOMATIC = "Automatic" - NONE = "None" - - -class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the size of the virtual machine. For more information about virtual machine sizes, - see `Sizes for virtual machines - `_. - :code:`
    `\\ :code:`
    ` The available VM sizes depend on region and availability set. For a - list of available sizes use these APIs: :code:`
    `\\ :code:`
    ` `List all available - virtual machine sizes in an availability set - `_ - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in a region - `_ :code:`
    `\\ - :code:`
    ` `List all available virtual machine sizes for resizing - `_. - """ - - BASIC_A0 = "Basic_A0" - BASIC_A1 = "Basic_A1" - BASIC_A2 = "Basic_A2" - BASIC_A3 = "Basic_A3" - BASIC_A4 = "Basic_A4" - STANDARD_A0 = "Standard_A0" - STANDARD_A1 = "Standard_A1" - STANDARD_A2 = "Standard_A2" - STANDARD_A3 = "Standard_A3" - STANDARD_A4 = "Standard_A4" - STANDARD_A5 = "Standard_A5" - STANDARD_A6 = "Standard_A6" - STANDARD_A7 = "Standard_A7" - STANDARD_A8 = "Standard_A8" - STANDARD_A9 = "Standard_A9" - STANDARD_A10 = "Standard_A10" - STANDARD_A11 = "Standard_A11" - STANDARD_A1_V2 = "Standard_A1_v2" - STANDARD_A2_V2 = "Standard_A2_v2" - STANDARD_A4_V2 = "Standard_A4_v2" - STANDARD_A8_V2 = "Standard_A8_v2" - STANDARD_A2_M_V2 = "Standard_A2m_v2" - STANDARD_A4_M_V2 = "Standard_A4m_v2" - STANDARD_A8_M_V2 = "Standard_A8m_v2" - STANDARD_B1_S = "Standard_B1s" - STANDARD_B1_MS = "Standard_B1ms" - STANDARD_B2_S = "Standard_B2s" - STANDARD_B2_MS = "Standard_B2ms" - STANDARD_B4_MS = "Standard_B4ms" - STANDARD_B8_MS = "Standard_B8ms" - STANDARD_D1 = "Standard_D1" - STANDARD_D2 = "Standard_D2" - STANDARD_D3 = "Standard_D3" - STANDARD_D4 = "Standard_D4" - STANDARD_D11 = "Standard_D11" - STANDARD_D12 = "Standard_D12" - STANDARD_D13 = "Standard_D13" - STANDARD_D14 = "Standard_D14" - STANDARD_D1_V2 = "Standard_D1_v2" - STANDARD_D2_V2 = "Standard_D2_v2" - STANDARD_D3_V2 = "Standard_D3_v2" - STANDARD_D4_V2 = "Standard_D4_v2" - STANDARD_D5_V2 = "Standard_D5_v2" - STANDARD_D2_V3 = "Standard_D2_v3" - STANDARD_D4_V3 = "Standard_D4_v3" - STANDARD_D8_V3 = "Standard_D8_v3" - STANDARD_D16_V3 = "Standard_D16_v3" - STANDARD_D32_V3 = "Standard_D32_v3" - STANDARD_D64_V3 = "Standard_D64_v3" - STANDARD_D2_S_V3 = "Standard_D2s_v3" - STANDARD_D4_S_V3 = "Standard_D4s_v3" - STANDARD_D8_S_V3 = "Standard_D8s_v3" - STANDARD_D16_S_V3 = "Standard_D16s_v3" - STANDARD_D32_S_V3 = "Standard_D32s_v3" - STANDARD_D64_S_V3 = "Standard_D64s_v3" - STANDARD_D11_V2 = "Standard_D11_v2" - STANDARD_D12_V2 = "Standard_D12_v2" - STANDARD_D13_V2 = "Standard_D13_v2" - STANDARD_D14_V2 = "Standard_D14_v2" - STANDARD_D15_V2 = "Standard_D15_v2" - STANDARD_DS1 = "Standard_DS1" - STANDARD_DS2 = "Standard_DS2" - STANDARD_DS3 = "Standard_DS3" - STANDARD_DS4 = "Standard_DS4" - STANDARD_DS11 = "Standard_DS11" - STANDARD_DS12 = "Standard_DS12" - STANDARD_DS13 = "Standard_DS13" - STANDARD_DS14 = "Standard_DS14" - STANDARD_DS1_V2 = "Standard_DS1_v2" - STANDARD_DS2_V2 = "Standard_DS2_v2" - STANDARD_DS3_V2 = "Standard_DS3_v2" - STANDARD_DS4_V2 = "Standard_DS4_v2" - STANDARD_DS5_V2 = "Standard_DS5_v2" - STANDARD_DS11_V2 = "Standard_DS11_v2" - STANDARD_DS12_V2 = "Standard_DS12_v2" - STANDARD_DS13_V2 = "Standard_DS13_v2" - STANDARD_DS14_V2 = "Standard_DS14_v2" - STANDARD_DS15_V2 = "Standard_DS15_v2" - STANDARD_DS13_4_V2 = "Standard_DS13-4_v2" - STANDARD_DS13_2_V2 = "Standard_DS13-2_v2" - STANDARD_DS14_8_V2 = "Standard_DS14-8_v2" - STANDARD_DS14_4_V2 = "Standard_DS14-4_v2" - STANDARD_E2_V3 = "Standard_E2_v3" - STANDARD_E4_V3 = "Standard_E4_v3" - STANDARD_E8_V3 = "Standard_E8_v3" - STANDARD_E16_V3 = "Standard_E16_v3" - STANDARD_E32_V3 = "Standard_E32_v3" - STANDARD_E64_V3 = "Standard_E64_v3" - STANDARD_E2_S_V3 = "Standard_E2s_v3" - STANDARD_E4_S_V3 = "Standard_E4s_v3" - STANDARD_E8_S_V3 = "Standard_E8s_v3" - STANDARD_E16_S_V3 = "Standard_E16s_v3" - STANDARD_E32_S_V3 = "Standard_E32s_v3" - STANDARD_E64_S_V3 = "Standard_E64s_v3" - STANDARD_E32_16_V3 = "Standard_E32-16_v3" - STANDARD_E32_8_S_V3 = "Standard_E32-8s_v3" - STANDARD_E64_32_S_V3 = "Standard_E64-32s_v3" - STANDARD_E64_16_S_V3 = "Standard_E64-16s_v3" - STANDARD_F1 = "Standard_F1" - STANDARD_F2 = "Standard_F2" - STANDARD_F4 = "Standard_F4" - STANDARD_F8 = "Standard_F8" - STANDARD_F16 = "Standard_F16" - STANDARD_F1_S = "Standard_F1s" - STANDARD_F2_S = "Standard_F2s" - STANDARD_F4_S = "Standard_F4s" - STANDARD_F8_S = "Standard_F8s" - STANDARD_F16_S = "Standard_F16s" - STANDARD_F2_S_V2 = "Standard_F2s_v2" - STANDARD_F4_S_V2 = "Standard_F4s_v2" - STANDARD_F8_S_V2 = "Standard_F8s_v2" - STANDARD_F16_S_V2 = "Standard_F16s_v2" - STANDARD_F32_S_V2 = "Standard_F32s_v2" - STANDARD_F64_S_V2 = "Standard_F64s_v2" - STANDARD_F72_S_V2 = "Standard_F72s_v2" - STANDARD_G1 = "Standard_G1" - STANDARD_G2 = "Standard_G2" - STANDARD_G3 = "Standard_G3" - STANDARD_G4 = "Standard_G4" - STANDARD_G5 = "Standard_G5" - STANDARD_GS1 = "Standard_GS1" - STANDARD_GS2 = "Standard_GS2" - STANDARD_GS3 = "Standard_GS3" - STANDARD_GS4 = "Standard_GS4" - STANDARD_GS5 = "Standard_GS5" - STANDARD_GS4_8 = "Standard_GS4-8" - STANDARD_GS4_4 = "Standard_GS4-4" - STANDARD_GS5_16 = "Standard_GS5-16" - STANDARD_GS5_8 = "Standard_GS5-8" - STANDARD_H8 = "Standard_H8" - STANDARD_H16 = "Standard_H16" - STANDARD_H8_M = "Standard_H8m" - STANDARD_H16_M = "Standard_H16m" - STANDARD_H16_R = "Standard_H16r" - STANDARD_H16_MR = "Standard_H16mr" - STANDARD_L4_S = "Standard_L4s" - STANDARD_L8_S = "Standard_L8s" - STANDARD_L16_S = "Standard_L16s" - STANDARD_L32_S = "Standard_L32s" - STANDARD_M64_S = "Standard_M64s" - STANDARD_M64_MS = "Standard_M64ms" - STANDARD_M128_S = "Standard_M128s" - STANDARD_M128_MS = "Standard_M128ms" - STANDARD_M64_32_MS = "Standard_M64-32ms" - STANDARD_M64_16_MS = "Standard_M64-16ms" - STANDARD_M128_64_MS = "Standard_M128-64ms" - STANDARD_M128_32_MS = "Standard_M128-32ms" - STANDARD_NC6 = "Standard_NC6" - STANDARD_NC12 = "Standard_NC12" - STANDARD_NC24 = "Standard_NC24" - STANDARD_NC24_R = "Standard_NC24r" - STANDARD_NC6_S_V2 = "Standard_NC6s_v2" - STANDARD_NC12_S_V2 = "Standard_NC12s_v2" - STANDARD_NC24_S_V2 = "Standard_NC24s_v2" - STANDARD_NC24_RS_V2 = "Standard_NC24rs_v2" - STANDARD_NC6_S_V3 = "Standard_NC6s_v3" - STANDARD_NC12_S_V3 = "Standard_NC12s_v3" - STANDARD_NC24_S_V3 = "Standard_NC24s_v3" - STANDARD_NC24_RS_V3 = "Standard_NC24rs_v3" - STANDARD_ND6_S = "Standard_ND6s" - STANDARD_ND12_S = "Standard_ND12s" - STANDARD_ND24_S = "Standard_ND24s" - STANDARD_ND24_RS = "Standard_ND24rs" - STANDARD_NV6 = "Standard_NV6" - STANDARD_NV12 = "Standard_NV12" - STANDARD_NV24 = "Standard_NV24" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/_models_py3.py deleted file mode 100644 index bf564e36a9b1..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/_models_py3.py +++ /dev/null @@ -1,12221 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from collections.abc import MutableMapping -import datetime -from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models -JSON = MutableMapping[str, Any] - - -class AdditionalCapabilities(_serialization.Model): - """Enables or disables a capability on the virtual machine or virtual machine scale set. - - :ivar ultra_ssd_enabled: The flag that enables or disables a capability to have one or more - managed data disks with UltraSSD_LRS storage account type on the VM or VMSS. Managed disks with - storage account type UltraSSD_LRS can be added to a virtual machine or virtual machine scale - set only if this property is enabled. - :vartype ultra_ssd_enabled: bool - """ - - _attribute_map = { - "ultra_ssd_enabled": {"key": "ultraSSDEnabled", "type": "bool"}, - } - - def __init__(self, *, ultra_ssd_enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword ultra_ssd_enabled: The flag that enables or disables a capability to have one or more - managed data disks with UltraSSD_LRS storage account type on the VM or VMSS. Managed disks with - storage account type UltraSSD_LRS can be added to a virtual machine or virtual machine scale - set only if this property is enabled. - :paramtype ultra_ssd_enabled: bool - """ - super().__init__(**kwargs) - self.ultra_ssd_enabled = ultra_ssd_enabled - - -class AdditionalUnattendContent(_serialization.Model): - """Specifies additional XML formatted information that can be included in the Unattend.xml file, - which is used by Windows Setup. Contents are defined by setting name, component name, and the - pass in which the content is applied. - - :ivar pass_name: The pass name. Currently, the only allowable value is OobeSystem. Default - value is "OobeSystem". - :vartype pass_name: str - :ivar component_name: The component name. Currently, the only allowable value is - Microsoft-Windows-Shell-Setup. Default value is "Microsoft-Windows-Shell-Setup". - :vartype component_name: str - :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon" and - "FirstLogonCommands". - :vartype setting_name: str or ~azure.mgmt.compute.v2019_12_01.models.SettingNames - :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for - the specified path and component. The XML must be less than 4KB and must include the root - element for the setting or feature that is being inserted. - :vartype content: str - """ - - _attribute_map = { - "pass_name": {"key": "passName", "type": "str"}, - "component_name": {"key": "componentName", "type": "str"}, - "setting_name": {"key": "settingName", "type": "str"}, - "content": {"key": "content", "type": "str"}, - } - - def __init__( - self, - *, - pass_name: Optional[Literal["OobeSystem"]] = None, - component_name: Optional[Literal["Microsoft-Windows-Shell-Setup"]] = None, - setting_name: Optional[Union[str, "_models.SettingNames"]] = None, - content: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword pass_name: The pass name. Currently, the only allowable value is OobeSystem. Default - value is "OobeSystem". - :paramtype pass_name: str - :keyword component_name: The component name. Currently, the only allowable value is - Microsoft-Windows-Shell-Setup. Default value is "Microsoft-Windows-Shell-Setup". - :paramtype component_name: str - :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon" and - "FirstLogonCommands". - :paramtype setting_name: str or ~azure.mgmt.compute.v2019_12_01.models.SettingNames - :keyword content: Specifies the XML formatted content that is added to the unattend.xml file - for the specified path and component. The XML must be less than 4KB and must include the root - element for the setting or feature that is being inserted. - :paramtype content: str - """ - super().__init__(**kwargs) - self.pass_name = pass_name - self.component_name = component_name - self.setting_name = setting_name - self.content = content - - -class ApiEntityReference(_serialization.Model): - """The API entity reference. - - :ivar id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class ApiError(_serialization.Model): - """Api error. - - :ivar details: The Api error details. - :vartype details: list[~azure.mgmt.compute.v2019_12_01.models.ApiErrorBase] - :ivar innererror: The Api inner error. - :vartype innererror: ~azure.mgmt.compute.v2019_12_01.models.InnerError - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "details": {"key": "details", "type": "[ApiErrorBase]"}, - "innererror": {"key": "innererror", "type": "InnerError"}, - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - details: Optional[List["_models.ApiErrorBase"]] = None, - innererror: Optional["_models.InnerError"] = None, - code: Optional[str] = None, - target: Optional[str] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword details: The Api error details. - :paramtype details: list[~azure.mgmt.compute.v2019_12_01.models.ApiErrorBase] - :keyword innererror: The Api inner error. - :paramtype innererror: ~azure.mgmt.compute.v2019_12_01.models.InnerError - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.details = details - self.innererror = innererror - self.code = code - self.target = target - self.message = message - - -class ApiErrorBase(_serialization.Model): - """Api error base. - - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.target = target - self.message = message - - -class AutomaticOSUpgradePolicy(_serialization.Model): - """The configuration parameters used for performing automatic OS upgrade. - - :ivar enable_automatic_os_upgrade: Indicates whether OS upgrades should automatically be - applied to scale set instances in a rolling fashion when a newer version of the OS image - becomes available. Default value is false. :code:`
    `\\ :code:`
    ` If this is set to true - for Windows based scale sets, `enableAutomaticUpdates - `_ - is automatically set to false and cannot be set to true. - :vartype enable_automatic_os_upgrade: bool - :ivar disable_automatic_rollback: Whether OS image rollback feature should be disabled. Default - value is false. - :vartype disable_automatic_rollback: bool - """ - - _attribute_map = { - "enable_automatic_os_upgrade": {"key": "enableAutomaticOSUpgrade", "type": "bool"}, - "disable_automatic_rollback": {"key": "disableAutomaticRollback", "type": "bool"}, - } - - def __init__( - self, - *, - enable_automatic_os_upgrade: Optional[bool] = None, - disable_automatic_rollback: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword enable_automatic_os_upgrade: Indicates whether OS upgrades should automatically be - applied to scale set instances in a rolling fashion when a newer version of the OS image - becomes available. Default value is false. :code:`
    `\\ :code:`
    ` If this is set to true - for Windows based scale sets, `enableAutomaticUpdates - `_ - is automatically set to false and cannot be set to true. - :paramtype enable_automatic_os_upgrade: bool - :keyword disable_automatic_rollback: Whether OS image rollback feature should be disabled. - Default value is false. - :paramtype disable_automatic_rollback: bool - """ - super().__init__(**kwargs) - self.enable_automatic_os_upgrade = enable_automatic_os_upgrade - self.disable_automatic_rollback = disable_automatic_rollback - - -class AutomaticOSUpgradeProperties(_serialization.Model): - """Describes automatic OS upgrade properties on the image. - - All required parameters must be populated in order to send to server. - - :ivar automatic_os_upgrade_supported: Specifies whether automatic OS upgrade is supported on - the image. Required. - :vartype automatic_os_upgrade_supported: bool - """ - - _validation = { - "automatic_os_upgrade_supported": {"required": True}, - } - - _attribute_map = { - "automatic_os_upgrade_supported": {"key": "automaticOSUpgradeSupported", "type": "bool"}, - } - - def __init__(self, *, automatic_os_upgrade_supported: bool, **kwargs: Any) -> None: - """ - :keyword automatic_os_upgrade_supported: Specifies whether automatic OS upgrade is supported on - the image. Required. - :paramtype automatic_os_upgrade_supported: bool - """ - super().__init__(**kwargs) - self.automatic_os_upgrade_supported = automatic_os_upgrade_supported - - -class AutomaticRepairsPolicy(_serialization.Model): - """Specifies the configuration parameters for automatic repairs on the virtual machine scale set. - - :ivar enabled: Specifies whether automatic repairs should be enabled on the virtual machine - scale set. The default value is false. - :vartype enabled: bool - :ivar grace_period: The amount of time for which automatic repairs are suspended due to a state - change on VM. The grace time starts after the state change has completed. This helps avoid - premature or accidental repairs. The time duration should be specified in ISO 8601 format. The - minimum allowed grace period is 30 minutes (PT30M), which is also the default value. The - maximum allowed grace period is 90 minutes (PT90M). - :vartype grace_period: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "grace_period": {"key": "gracePeriod", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, grace_period: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Specifies whether automatic repairs should be enabled on the virtual machine - scale set. The default value is false. - :paramtype enabled: bool - :keyword grace_period: The amount of time for which automatic repairs are suspended due to a - state change on VM. The grace time starts after the state change has completed. This helps - avoid premature or accidental repairs. The time duration should be specified in ISO 8601 - format. The minimum allowed grace period is 30 minutes (PT30M), which is also the default - value. The maximum allowed grace period is 90 minutes (PT90M). - :paramtype grace_period: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.grace_period = grace_period - - -class Resource(_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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - - -class AvailabilitySet(Resource): - """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 `Manage the - availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability 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. - :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] - :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 - 'Classic'. - :vartype sku: ~azure.mgmt.compute.v2019_12_01.models.Sku - :ivar platform_update_domain_count: Update Domain count. - :vartype platform_update_domain_count: int - :ivar platform_fault_domain_count: Fault Domain count. - :vartype platform_fault_domain_count: int - :ivar virtual_machines: A list of references to all virtual machines in the availability set. - :vartype virtual_machines: list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the availability set should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "statuses": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "Sku"}, - "platform_update_domain_count": {"key": "properties.platformUpdateDomainCount", "type": "int"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResource]"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "statuses": {"key": "properties.statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - platform_update_domain_count: Optional[int] = None, - platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["_models.SubResource"]] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - 'Classic'. - :paramtype sku: ~azure.mgmt.compute.v2019_12_01.models.Sku - :keyword platform_update_domain_count: Update Domain count. - :paramtype platform_update_domain_count: int - :keyword platform_fault_domain_count: Fault Domain count. - :paramtype platform_fault_domain_count: int - :keyword virtual_machines: A list of references to all virtual machines in the availability - set. - :paramtype virtual_machines: list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the availability set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.platform_update_domain_count = platform_update_domain_count - self.platform_fault_domain_count = platform_fault_domain_count - self.virtual_machines = virtual_machines - self.proximity_placement_group = proximity_placement_group - self.statuses: Optional[List["_models.InstanceViewStatus"]] = None - - -class AvailabilitySetListResult(_serialization.Model): - """The List Availability Set operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of availability sets. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet] - :ivar next_link: The URI to fetch the next page of AvailabilitySets. Call ListNext() with this - URI to fetch the next page of AvailabilitySets. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AvailabilitySet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of availability sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet] - :keyword next_link: The URI to fetch the next page of AvailabilitySets. Call ListNext() with - this URI to fetch the next page of AvailabilitySets. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class UpdateResource(_serialization.Model): - """The Update Resource model definition. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class AvailabilitySetUpdate(UpdateResource): - """Specifies information about the availability set that the virtual machine should be assigned - to. Only tags may be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: Sku of the availability set. - :vartype sku: ~azure.mgmt.compute.v2019_12_01.models.Sku - :ivar platform_update_domain_count: Update Domain count. - :vartype platform_update_domain_count: int - :ivar platform_fault_domain_count: Fault Domain count. - :vartype platform_fault_domain_count: int - :ivar virtual_machines: A list of references to all virtual machines in the availability set. - :vartype virtual_machines: list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the availability set should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - """ - - _validation = { - "statuses": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "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"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResource]"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "statuses": {"key": "properties.statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - platform_update_domain_count: Optional[int] = None, - platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["_models.SubResource"]] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: Sku of the availability set. - :paramtype sku: ~azure.mgmt.compute.v2019_12_01.models.Sku - :keyword platform_update_domain_count: Update Domain count. - :paramtype platform_update_domain_count: int - :keyword platform_fault_domain_count: Fault Domain count. - :paramtype platform_fault_domain_count: int - :keyword virtual_machines: A list of references to all virtual machines in the availability - set. - :paramtype virtual_machines: list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the availability set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource - """ - super().__init__(tags=tags, **kwargs) - self.sku = sku - self.platform_update_domain_count = platform_update_domain_count - self.platform_fault_domain_count = platform_fault_domain_count - self.virtual_machines = virtual_machines - self.proximity_placement_group = proximity_placement_group - self.statuses: Optional[List["_models.InstanceViewStatus"]] = None - - -class BillingProfile(_serialization.Model): - """Specifies the billing related details of a Azure Spot VM or VMSS. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. - - :ivar max_price: Specifies the maximum price you are willing to pay for a Azure Spot VM/VMSS. - This price is in US Dollars. :code:`
    `\\ :code:`
    ` This price will be compared with the - current Azure Spot price for the VM size. Also, the prices are compared at the time of - create/update of Azure Spot VM/VMSS and the operation will only succeed if the maxPrice is - greater than the current Azure Spot price. :code:`
    `\\ :code:`
    ` The maxPrice will also - be used for evicting a Azure Spot VM/VMSS if the current Azure Spot price goes beyond the - maxPrice after creation of VM/VMSS. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` - Any decimal value greater than zero. Example: 0.01538 - :code:`
    `\\ :code:`
    ` -1 – indicates default price to be up-to on-demand. :code:`
    `\\ - :code:`
    ` You can set the maxPrice to -1 to indicate that the Azure Spot VM/VMSS should not - be evicted for price reasons. Also, the default max price is -1 if it is not provided by you. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype max_price: float - """ - - _attribute_map = { - "max_price": {"key": "maxPrice", "type": "float"}, - } - - def __init__(self, *, max_price: Optional[float] = None, **kwargs: Any) -> None: - """ - :keyword max_price: Specifies the maximum price you are willing to pay for a Azure Spot - VM/VMSS. This price is in US Dollars. :code:`
    `\\ :code:`
    ` This price will be compared - with the current Azure Spot price for the VM size. Also, the prices are compared at the time of - create/update of Azure Spot VM/VMSS and the operation will only succeed if the maxPrice is - greater than the current Azure Spot price. :code:`
    `\\ :code:`
    ` The maxPrice will also - be used for evicting a Azure Spot VM/VMSS if the current Azure Spot price goes beyond the - maxPrice after creation of VM/VMSS. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` - Any decimal value greater than zero. Example: 0.01538 - :code:`
    `\\ :code:`
    ` -1 – indicates default price to be up-to on-demand. :code:`
    `\\ - :code:`
    ` You can set the maxPrice to -1 to indicate that the Azure Spot VM/VMSS should not - be evicted for price reasons. Also, the default max price is -1 if it is not provided by you. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype max_price: float - """ - super().__init__(**kwargs) - self.max_price = max_price - - -class BootDiagnostics(_serialization.Model): - """Boot Diagnostics is a debugging feature which allows you to view Console Output and Screenshot - to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily view the output of your - console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see a screenshot of the VM - from the hypervisor. - - :ivar enabled: Whether boot diagnostics should be enabled on the Virtual Machine. - :vartype enabled: bool - :ivar storage_uri: Uri of the storage account to use for placing the console output and - screenshot. - :vartype storage_uri: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "storage_uri": {"key": "storageUri", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, storage_uri: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Whether boot diagnostics should be enabled on the Virtual Machine. - :paramtype enabled: bool - :keyword storage_uri: Uri of the storage account to use for placing the console output and - screenshot. - :paramtype storage_uri: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.storage_uri = storage_uri - - -class BootDiagnosticsInstanceView(_serialization.Model): - """The instance view of a virtual machine boot diagnostics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar console_screenshot_blob_uri: The console screenshot blob URI. - :vartype console_screenshot_blob_uri: str - :ivar serial_console_log_blob_uri: The Linux serial console log blob Uri. - :vartype serial_console_log_blob_uri: str - :ivar status: The boot diagnostics status information for the VM. :code:`
    `\\ :code:`
    ` - NOTE: It will be set only if there are errors encountered in enabling boot diagnostics. - :vartype status: ~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus - """ - - _validation = { - "console_screenshot_blob_uri": {"readonly": True}, - "serial_console_log_blob_uri": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "console_screenshot_blob_uri": {"key": "consoleScreenshotBlobUri", "type": "str"}, - "serial_console_log_blob_uri": {"key": "serialConsoleLogBlobUri", "type": "str"}, - "status": {"key": "status", "type": "InstanceViewStatus"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.console_screenshot_blob_uri: Optional[str] = None - self.serial_console_log_blob_uri: Optional[str] = None - self.status: Optional["_models.InstanceViewStatus"] = 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.v2019_12_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: Optional[List["_models.ComputeOperationValue"]] = None - - -class ComputeOperationValue(_serialization.Model): - """Describes the properties of a Compute Operation value. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar origin: The origin of the compute operation. - :vartype origin: str - :ivar name: The name of the compute operation. - :vartype name: str - :ivar operation: The display name of the compute operation. - :vartype operation: str - :ivar resource: The display name of the resource the operation applies to. - :vartype resource: str - :ivar description: The description of the operation. - :vartype description: str - :ivar provider: The resource provider for the operation. - :vartype provider: str - """ - - _validation = { - "origin": {"readonly": True}, - "name": {"readonly": True}, - "operation": {"readonly": True}, - "resource": {"readonly": True}, - "description": {"readonly": True}, - "provider": {"readonly": True}, - } - - _attribute_map = { - "origin": {"key": "origin", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "operation": {"key": "display.operation", "type": "str"}, - "resource": {"key": "display.resource", "type": "str"}, - "description": {"key": "display.description", "type": "str"}, - "provider": {"key": "display.provider", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.origin: Optional[str] = None - self.name: Optional[str] = None - self.operation: Optional[str] = None - self.resource: Optional[str] = None - self.description: Optional[str] = None - self.provider: Optional[str] = None - - -class DataDisk(_serialization.Model): - """Describes a data disk. - - 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 lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - :ivar name: The disk name. - :vartype name: str - :ivar vhd: The virtual hard disk. - :vartype vhd: ~azure.mgmt.compute.v2019_12_01.models.VirtualHardDisk - :ivar image: 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. - :vartype image: ~azure.mgmt.compute.v2019_12_01.models.VirtualHardDisk - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2019_12_01.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: ~azure.mgmt.compute.v2019_12_01.models.ManagedDiskParameters - :ivar to_be_detached: Specifies whether the data disk is in process of detachment from the - VirtualMachine/VirtualMachineScaleset. - :vartype to_be_detached: bool - :ivar disk_iops_read_write: Specifies the Read-Write IOPS for the managed disk when - StorageAccountType is UltraSSD_LRS. Returned only for VirtualMachine ScaleSet VM disks. Can be - updated only via updates to the VirtualMachine Scale Set. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: Specifies the bandwidth in MB per second for the managed disk when - StorageAccountType is UltraSSD_LRS. Returned only for VirtualMachine ScaleSet VM disks. Can be - updated only via updates to the VirtualMachine Scale Set. - :vartype disk_m_bps_read_write: int - """ - - _validation = { - "lun": {"required": True}, - "create_option": {"required": True}, - "disk_iops_read_write": {"readonly": True}, - "disk_m_bps_read_write": {"readonly": True}, - } - - _attribute_map = { - "lun": {"key": "lun", "type": "int"}, - "name": {"key": "name", "type": "str"}, - "vhd": {"key": "vhd", "type": "VirtualHardDisk"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, - "to_be_detached": {"key": "toBeDetached", "type": "bool"}, - "disk_iops_read_write": {"key": "diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "diskMBpsReadWrite", "type": "int"}, - } - - def __init__( - self, - *, - lun: int, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - vhd: Optional["_models.VirtualHardDisk"] = None, - image: Optional["_models.VirtualHardDisk"] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.ManagedDiskParameters"] = None, - to_be_detached: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - :keyword name: The disk name. - :paramtype name: str - :keyword vhd: The virtual hard disk. - :paramtype vhd: ~azure.mgmt.compute.v2019_12_01.models.VirtualHardDisk - :keyword image: 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. - :paramtype image: ~azure.mgmt.compute.v2019_12_01.models.VirtualHardDisk - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2019_12_01.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: ~azure.mgmt.compute.v2019_12_01.models.ManagedDiskParameters - :keyword to_be_detached: Specifies whether the data disk is in process of detachment from the - VirtualMachine/VirtualMachineScaleset. - :paramtype to_be_detached: bool - """ - super().__init__(**kwargs) - self.lun = lun - self.name = name - self.vhd = vhd - self.image = image - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - self.to_be_detached = to_be_detached - self.disk_iops_read_write: Optional[int] = None - self.disk_m_bps_read_write: Optional[int] = None - - -class DataDiskImage(_serialization.Model): - """Contains the data disk images information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - :vartype lun: int - """ - - _validation = { - "lun": {"readonly": True}, - } - - _attribute_map = { - "lun": {"key": "lun", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.lun: Optional[int] = None - - -class DiskImageEncryption(_serialization.Model): - """This is the disk image encryption base class. - - :ivar disk_encryption_set_id: A relative URI containing the resource ID of the disk encryption - set. - :vartype disk_encryption_set_id: str - """ - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - } - - def __init__(self, *, disk_encryption_set_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword disk_encryption_set_id: A relative URI containing the resource ID of the disk - encryption set. - :paramtype disk_encryption_set_id: str - """ - super().__init__(**kwargs) - self.disk_encryption_set_id = disk_encryption_set_id - - -class DataDiskImageEncryption(DiskImageEncryption): - """Contains encryption settings for a data disk image. - - All required parameters must be populated in order to send to server. - - :ivar disk_encryption_set_id: A relative URI containing the resource ID of the disk encryption - set. - :vartype disk_encryption_set_id: str - :ivar 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. - :vartype lun: int - """ - - _validation = { - "lun": {"required": True}, - } - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__(self, *, lun: int, disk_encryption_set_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword disk_encryption_set_id: A relative URI containing the resource ID of the disk - encryption set. - :paramtype disk_encryption_set_id: str - :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__(disk_encryption_set_id=disk_encryption_set_id, **kwargs) - self.lun = lun - - -class DedicatedHost(Resource): - """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. - :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] - :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.v2019_12_01.models.Sku - :ivar platform_fault_domain: Fault domain of the dedicated host within a dedicated host group. - :vartype platform_fault_domain: int - :ivar auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :vartype auto_replace_on_failure: bool - :ivar host_id: A unique id generated and assigned to the dedicated host by the platform. - :code:`
    `\\ :code:`
    ` Does not change throughout the lifetime of the host. - :vartype host_id: str - :ivar virtual_machines: A list of references to all virtual machines in the Dedicated Host. - :vartype virtual_machines: list[~azure.mgmt.compute.v2019_12_01.models.SubResourceReadOnly] - :ivar license_type: Specifies the software license type that will be applied to the VMs - deployed on the dedicated host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ - :code:`
    ` **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. Known - values are: "None", "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :vartype license_type: str or ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostLicenseTypes - :ivar provisioning_time: The date when the host was first provisioned. - :vartype provisioning_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The dedicated host instance view. - :vartype instance_view: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostInstanceView - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "sku": {"required": True}, - "platform_fault_domain": {"maximum": 2, "minimum": 0}, - "host_id": {"readonly": True}, - "virtual_machines": {"readonly": True}, - "provisioning_time": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "Sku"}, - "platform_fault_domain": {"key": "properties.platformFaultDomain", "type": "int"}, - "auto_replace_on_failure": {"key": "properties.autoReplaceOnFailure", "type": "bool"}, - "host_id": {"key": "properties.hostId", "type": "str"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResourceReadOnly]"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "provisioning_time": {"key": "properties.provisioningTime", "type": "iso-8601"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostInstanceView"}, - } - - def __init__( - self, - *, - location: str, - sku: "_models.Sku", - tags: Optional[Dict[str, str]] = None, - platform_fault_domain: Optional[int] = None, - auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2019_12_01.models.Sku - :keyword platform_fault_domain: Fault domain of the dedicated host within a dedicated host - group. - :paramtype platform_fault_domain: int - :keyword auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :paramtype auto_replace_on_failure: bool - :keyword license_type: Specifies the software license type that will be applied to the VMs - deployed on the dedicated host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ - :code:`
    ` **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. Known - values are: "None", "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :paramtype license_type: str or - ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostLicenseTypes - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.platform_fault_domain = platform_fault_domain - self.auto_replace_on_failure = auto_replace_on_failure - self.host_id: Optional[str] = None - self.virtual_machines: Optional[List["_models.SubResourceReadOnly"]] = None - self.license_type = license_type - self.provisioning_time: Optional[datetime.datetime] = None - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.DedicatedHostInstanceView"] = None - - -class DedicatedHostAllocatableVM(_serialization.Model): - """Represents the dedicated host unutilized capacity in terms of a specific VM size. - - :ivar vm_size: VM size in terms of which the unutilized capacity is represented. - :vartype vm_size: str - :ivar count: Maximum number of VMs of size vmSize that can fit in the dedicated host's - remaining capacity. - :vartype count: float - """ - - _attribute_map = { - "vm_size": {"key": "vmSize", "type": "str"}, - "count": {"key": "count", "type": "float"}, - } - - def __init__(self, *, vm_size: Optional[str] = None, count: Optional[float] = None, **kwargs: Any) -> None: - """ - :keyword vm_size: VM size in terms of which the unutilized capacity is represented. - :paramtype vm_size: str - :keyword count: Maximum number of VMs of size vmSize that can fit in the dedicated host's - remaining capacity. - :paramtype count: float - """ - super().__init__(**kwargs) - self.vm_size = vm_size - self.count = count - - -class DedicatedHostAvailableCapacity(_serialization.Model): - """Dedicated host unutilized capacity. - - :ivar allocatable_v_ms: The unutilized capacity of the dedicated host represented in terms of - each VM size that is allowed to be deployed to the dedicated host. - :vartype allocatable_v_ms: - list[~azure.mgmt.compute.v2019_12_01.models.DedicatedHostAllocatableVM] - """ - - _attribute_map = { - "allocatable_v_ms": {"key": "allocatableVMs", "type": "[DedicatedHostAllocatableVM]"}, - } - - def __init__( - self, *, allocatable_v_ms: Optional[List["_models.DedicatedHostAllocatableVM"]] = None, **kwargs: Any - ) -> None: - """ - :keyword allocatable_v_ms: The unutilized capacity of the dedicated host represented in terms - of each VM size that is allowed to be deployed to the dedicated host. - :paramtype allocatable_v_ms: - list[~azure.mgmt.compute.v2019_12_01.models.DedicatedHostAllocatableVM] - """ - super().__init__(**kwargs) - self.allocatable_v_ms = allocatable_v_ms - - -class DedicatedHostGroup(Resource): - """Specifies information about the dedicated host group that the dedicated hosts should be - assigned to. :code:`
    `\\ :code:`
    ` 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. - - 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] - :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. - :vartype zones: list[str] - :ivar platform_fault_domain_count: Number of fault domains that the host group can span. - :vartype platform_fault_domain_count: int - :ivar hosts: A list of references to all dedicated hosts in the dedicated host group. - :vartype hosts: list[~azure.mgmt.compute.v2019_12_01.models.SubResourceReadOnly] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "platform_fault_domain_count": {"maximum": 3, "minimum": 1}, - "hosts": {"readonly": 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}"}, - "zones": {"key": "zones", "type": "[str]"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "hosts": {"key": "properties.hosts", "type": "[SubResourceReadOnly]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - zones: Optional[List[str]] = None, - platform_fault_domain_count: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword zones: Availability Zone to use for this host group. Only single zone is supported. - The zone can be assigned only during creation. If not provided, the group supports all zones in - the region. If provided, enforces each host in the group to be in the same zone. - :paramtype zones: list[str] - :keyword platform_fault_domain_count: Number of fault domains that the host group can span. - :paramtype platform_fault_domain_count: int - """ - super().__init__(location=location, tags=tags, **kwargs) - self.zones = zones - self.platform_fault_domain_count = platform_fault_domain_count - self.hosts: Optional[List["_models.SubResourceReadOnly"]] = None - - -class DedicatedHostGroupListResult(_serialization.Model): - """The List Dedicated Host Group with resource group response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of dedicated host groups. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroup] - :ivar next_link: The URI to fetch the next page of Dedicated Host Groups. Call ListNext() with - this URI to fetch the next page of Dedicated Host Groups. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DedicatedHostGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DedicatedHostGroup"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of dedicated host groups. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroup] - :keyword next_link: The URI to fetch the next page of Dedicated Host Groups. Call ListNext() - with this URI to fetch the next page of Dedicated Host Groups. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DedicatedHostGroupUpdate(UpdateResource): - """Specifies information about the dedicated host group that the dedicated host should be assigned - to. Only tags may be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar zones: Availability Zone to use for this host group. Only single zone is supported. The - zone can be assigned only during creation. If not provided, the group supports all zones in the - region. If provided, enforces each host in the group to be in the same zone. - :vartype zones: list[str] - :ivar platform_fault_domain_count: Number of fault domains that the host group can span. - :vartype platform_fault_domain_count: int - :ivar hosts: A list of references to all dedicated hosts in the dedicated host group. - :vartype hosts: list[~azure.mgmt.compute.v2019_12_01.models.SubResourceReadOnly] - """ - - _validation = { - "platform_fault_domain_count": {"maximum": 3, "minimum": 1}, - "hosts": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "zones": {"key": "zones", "type": "[str]"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "hosts": {"key": "properties.hosts", "type": "[SubResourceReadOnly]"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - zones: Optional[List[str]] = None, - platform_fault_domain_count: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword zones: Availability Zone to use for this host group. Only single zone is supported. - The zone can be assigned only during creation. If not provided, the group supports all zones in - the region. If provided, enforces each host in the group to be in the same zone. - :paramtype zones: list[str] - :keyword platform_fault_domain_count: Number of fault domains that the host group can span. - :paramtype platform_fault_domain_count: int - """ - super().__init__(tags=tags, **kwargs) - self.zones = zones - self.platform_fault_domain_count = platform_fault_domain_count - self.hosts: Optional[List["_models.SubResourceReadOnly"]] = None - - -class DedicatedHostInstanceView(_serialization.Model): - """The instance view of a dedicated host. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar asset_id: Specifies the unique id of the dedicated physical machine on which the - dedicated host resides. - :vartype asset_id: str - :ivar available_capacity: Unutilized capacity of the dedicated host. - :vartype available_capacity: - ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostAvailableCapacity - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - """ - - _validation = { - "asset_id": {"readonly": True}, - } - - _attribute_map = { - "asset_id": {"key": "assetId", "type": "str"}, - "available_capacity": {"key": "availableCapacity", "type": "DedicatedHostAvailableCapacity"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword available_capacity: Unutilized capacity of the dedicated host. - :paramtype available_capacity: - ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostAvailableCapacity - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.asset_id: Optional[str] = None - self.available_capacity = available_capacity - self.statuses = statuses - - -class DedicatedHostListResult(_serialization.Model): - """The list dedicated host operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of dedicated hosts. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.DedicatedHost] - :ivar next_link: The URI to fetch the next page of dedicated hosts. Call ListNext() with this - URI to fetch the next page of dedicated hosts. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DedicatedHost]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.DedicatedHost"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of dedicated hosts. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.DedicatedHost] - :keyword next_link: The URI to fetch the next page of dedicated hosts. Call ListNext() with - this URI to fetch the next page of dedicated hosts. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DedicatedHostUpdate(UpdateResource): - """Specifies information about the dedicated host. Only tags, autoReplaceOnFailure and licenseType - may be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar platform_fault_domain: Fault domain of the dedicated host within a dedicated host group. - :vartype platform_fault_domain: int - :ivar auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :vartype auto_replace_on_failure: bool - :ivar host_id: A unique id generated and assigned to the dedicated host by the platform. - :code:`
    `\\ :code:`
    ` Does not change throughout the lifetime of the host. - :vartype host_id: str - :ivar virtual_machines: A list of references to all virtual machines in the Dedicated Host. - :vartype virtual_machines: list[~azure.mgmt.compute.v2019_12_01.models.SubResourceReadOnly] - :ivar license_type: Specifies the software license type that will be applied to the VMs - deployed on the dedicated host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ - :code:`
    ` **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. Known - values are: "None", "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :vartype license_type: str or ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostLicenseTypes - :ivar provisioning_time: The date when the host was first provisioned. - :vartype provisioning_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The dedicated host instance view. - :vartype instance_view: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostInstanceView - """ - - _validation = { - "platform_fault_domain": {"maximum": 2, "minimum": 0}, - "host_id": {"readonly": True}, - "virtual_machines": {"readonly": True}, - "provisioning_time": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "platform_fault_domain": {"key": "properties.platformFaultDomain", "type": "int"}, - "auto_replace_on_failure": {"key": "properties.autoReplaceOnFailure", "type": "bool"}, - "host_id": {"key": "properties.hostId", "type": "str"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResourceReadOnly]"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "provisioning_time": {"key": "properties.provisioningTime", "type": "iso-8601"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostInstanceView"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - platform_fault_domain: Optional[int] = None, - auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword platform_fault_domain: Fault domain of the dedicated host within a dedicated host - group. - :paramtype platform_fault_domain: int - :keyword auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :paramtype auto_replace_on_failure: bool - :keyword license_type: Specifies the software license type that will be applied to the VMs - deployed on the dedicated host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ - :code:`
    ` **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. Known - values are: "None", "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :paramtype license_type: str or - ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostLicenseTypes - """ - super().__init__(tags=tags, **kwargs) - self.platform_fault_domain = platform_fault_domain - self.auto_replace_on_failure = auto_replace_on_failure - self.host_id: Optional[str] = None - self.virtual_machines: Optional[List["_models.SubResourceReadOnly"]] = None - self.license_type = license_type - self.provisioning_time: Optional[datetime.datetime] = None - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.DedicatedHostInstanceView"] = None - - -class DiagnosticsProfile(_serialization.Model): - """Specifies the boot diagnostic settings state. :code:`
    `\\ :code:`
    `Minimum api-version: - 2015-06-15. - - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2019_12_01.models.BootDiagnostics - """ - - _attribute_map = { - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnostics"}, - } - - def __init__(self, *, boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs: Any) -> None: - """ - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2019_12_01.models.BootDiagnostics - """ - super().__init__(**kwargs) - self.boot_diagnostics = boot_diagnostics - - -class DiffDiskSettings(_serialization.Model): - """Describes the parameters of ephemeral disk settings that can be specified for operating system - disk. :code:`
    `\\ :code:`
    ` NOTE: The ephemeral disk settings can only be specified for - managed disk. - - :ivar option: Specifies the ephemeral disk settings for operating system disk. "Local" - :vartype option: str or ~azure.mgmt.compute.v2019_12_01.models.DiffDiskOptions - :ivar placement: Specifies the ephemeral disk placement for operating system disk.\\ - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **CacheDisk** - :code:`
    `\\ :code:`
    ` **ResourceDisk** :code:`
    `\\ :code:`
    ` Default: **CacheDisk** - if one is configured for the VM size otherwise **ResourceDisk** is used.\\ :code:`
    `\\ - :code:`
    ` Refer to VM size documentation for Windows VM at - https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sizes and Linux VM at - https://docs.microsoft.com/en-us/azure/virtual-machines/linux/sizes to check which VM sizes - exposes a cache disk. Known values are: "CacheDisk" and "ResourceDisk". - :vartype placement: str or ~azure.mgmt.compute.v2019_12_01.models.DiffDiskPlacement - """ - - _attribute_map = { - "option": {"key": "option", "type": "str"}, - "placement": {"key": "placement", "type": "str"}, - } - - def __init__( - self, - *, - option: Optional[Union[str, "_models.DiffDiskOptions"]] = None, - placement: Optional[Union[str, "_models.DiffDiskPlacement"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword option: Specifies the ephemeral disk settings for operating system disk. "Local" - :paramtype option: str or ~azure.mgmt.compute.v2019_12_01.models.DiffDiskOptions - :keyword placement: Specifies the ephemeral disk placement for operating system disk.\\ - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **CacheDisk** - :code:`
    `\\ :code:`
    ` **ResourceDisk** :code:`
    `\\ :code:`
    ` Default: **CacheDisk** - if one is configured for the VM size otherwise **ResourceDisk** is used.\\ :code:`
    `\\ - :code:`
    ` Refer to VM size documentation for Windows VM at - https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sizes and Linux VM at - https://docs.microsoft.com/en-us/azure/virtual-machines/linux/sizes to check which VM sizes - exposes a cache disk. Known values are: "CacheDisk" and "ResourceDisk". - :paramtype placement: str or ~azure.mgmt.compute.v2019_12_01.models.DiffDiskPlacement - """ - super().__init__(**kwargs) - self.option = option - self.placement = placement - - -class Disallowed(_serialization.Model): - """Describes the disallowed disk types. - - :ivar disk_types: A list of disk types. - :vartype disk_types: list[str] - """ - - _attribute_map = { - "disk_types": {"key": "diskTypes", "type": "[str]"}, - } - - def __init__(self, *, disk_types: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword disk_types: A list of disk types. - :paramtype disk_types: list[str] - """ - super().__init__(**kwargs) - self.disk_types = disk_types - - -class SubResource(_serialization.Model): - """SubResource. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class DiskEncryptionSetParameters(SubResource): - """Describes the parameter of customer managed disk encryption set resource id that can be - specified for disk. :code:`
    `\\ :code:`
    ` NOTE: The disk encryption set resource id can - only be specified for managed disk. Please refer https://aka.ms/mdssewithcmkoverview for more - details. - - :ivar id: Resource Id. - :vartype id: str - """ - - -class DiskEncryptionSettings(_serialization.Model): - """Describes a Encryption Settings for a Disk. - - :ivar disk_encryption_key: Specifies the location of the disk encryption key, which is a Key - Vault Secret. - :vartype disk_encryption_key: ~azure.mgmt.compute.v2019_12_01.models.KeyVaultSecretReference - :ivar key_encryption_key: Specifies the location of the key encryption key in Key Vault. - :vartype key_encryption_key: ~azure.mgmt.compute.v2019_12_01.models.KeyVaultKeyReference - :ivar enabled: Specifies whether disk encryption should be enabled on the virtual machine. - :vartype enabled: bool - """ - - _attribute_map = { - "disk_encryption_key": {"key": "diskEncryptionKey", "type": "KeyVaultSecretReference"}, - "key_encryption_key": {"key": "keyEncryptionKey", "type": "KeyVaultKeyReference"}, - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__( - self, - *, - disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, - key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, - enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_key: Specifies the location of the disk encryption key, which is a Key - Vault Secret. - :paramtype disk_encryption_key: ~azure.mgmt.compute.v2019_12_01.models.KeyVaultSecretReference - :keyword key_encryption_key: Specifies the location of the key encryption key in Key Vault. - :paramtype key_encryption_key: ~azure.mgmt.compute.v2019_12_01.models.KeyVaultKeyReference - :keyword enabled: Specifies whether disk encryption should be enabled on the virtual machine. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.disk_encryption_key = disk_encryption_key - self.key_encryption_key = key_encryption_key - self.enabled = enabled - - -class DiskInstanceView(_serialization.Model): - """The instance view of the disk. - - :ivar name: The disk name. - :vartype name: str - :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :vartype encryption_settings: - list[~azure.mgmt.compute.v2019_12_01.models.DiskEncryptionSettings] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "encryption_settings": {"key": "encryptionSettings", "type": "[DiskEncryptionSettings]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype encryption_settings: - list[~azure.mgmt.compute.v2019_12_01.models.DiskEncryptionSettings] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.name = name - self.encryption_settings = encryption_settings - self.statuses = statuses - - -class EncryptionImages(_serialization.Model): - """Optional. Allows users to provide customer managed keys for encrypting the OS and data disks in - the gallery artifact. - - :ivar os_disk_image: Contains encryption settings for an OS disk image. - :vartype os_disk_image: ~azure.mgmt.compute.v2019_12_01.models.OSDiskImageEncryption - :ivar data_disk_images: A list of encryption specifications for data disk images. - :vartype data_disk_images: list[~azure.mgmt.compute.v2019_12_01.models.DataDiskImageEncryption] - """ - - _attribute_map = { - "os_disk_image": {"key": "osDiskImage", "type": "OSDiskImageEncryption"}, - "data_disk_images": {"key": "dataDiskImages", "type": "[DataDiskImageEncryption]"}, - } - - def __init__( - self, - *, - os_disk_image: Optional["_models.OSDiskImageEncryption"] = None, - data_disk_images: Optional[List["_models.DataDiskImageEncryption"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_disk_image: Contains encryption settings for an OS disk image. - :paramtype os_disk_image: ~azure.mgmt.compute.v2019_12_01.models.OSDiskImageEncryption - :keyword data_disk_images: A list of encryption specifications for data disk images. - :paramtype data_disk_images: - list[~azure.mgmt.compute.v2019_12_01.models.DataDiskImageEncryption] - """ - super().__init__(**kwargs) - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - - -class Gallery(Resource): - """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. - :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] - :ivar description: The description of this Shared Image Gallery resource. This property is - updatable. - :vartype description: str - :ivar identifier: Describes the gallery unique name. - :vartype identifier: ~azure.mgmt.compute.v2019_12_01.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2019_12_01.models.GalleryPropertiesProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "identifier": {"key": "properties.identifier", "type": "GalleryIdentifier"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - identifier: Optional["_models.GalleryIdentifier"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this Shared Image Gallery resource. This property is - updatable. - :paramtype description: str - :keyword identifier: Describes the gallery unique name. - :paramtype identifier: ~azure.mgmt.compute.v2019_12_01.models.GalleryIdentifier - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.identifier = identifier - self.provisioning_state: Optional[Union[str, "_models.GalleryPropertiesProvisioningState"]] = None - - -class GalleryApplication(Resource): - """Specifies information about the gallery Application 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. - :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] - :ivar description: The description of this gallery Application Definition resource. This - property is updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery Application Definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar supported_os_type: This property allows you to specify the supported type of the OS that - application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :vartype supported_os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - """ - - _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}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "supported_os_type": {"key": "properties.supportedOSType", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery Application Definition resource. This - property is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery Application Definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: str - :keyword end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword supported_os_type: This property allows you to specify the supported type of the OS - that application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :paramtype supported_os_type: str or - ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.end_of_life_date = end_of_life_date - self.supported_os_type = supported_os_type - - -class GalleryApplicationList(_serialization.Model): - """The List Gallery Applications operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of Gallery Applications. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryApplication]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.GalleryApplication"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of Gallery Applications. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class UpdateResourceDefinition(_serialization.Model): - """The Update Resource model definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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 = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.tags = tags - - -class GalleryApplicationUpdate(UpdateResourceDefinition): - """Specifies information about the gallery Application Definition that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar description: The description of this gallery Application Definition resource. This - property is updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery Application Definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar supported_os_type: This property allows you to specify the supported type of the OS that - application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :vartype supported_os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - """ - - _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"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "supported_os_type": {"key": "properties.supportedOSType", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery Application Definition resource. This - property is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery Application Definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: str - :keyword end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword supported_os_type: This property allows you to specify the supported type of the OS - that application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :paramtype supported_os_type: str or - ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - """ - super().__init__(tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.end_of_life_date = end_of_life_date - self.supported_os_type = supported_os_type - - -class GalleryApplicationVersion(Resource): - """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. - :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] - :ivar publishing_profile: The publishing profile of a gallery image version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersionPropertiesProvisioningState - :ivar replication_status: This is the replication status of the gallery Image Version. - :vartype replication_status: ~azure.mgmt.compute.v2019_12_01.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": 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}"}, - "publishing_profile": { - "key": "properties.publishingProfile", - "type": "GalleryApplicationVersionPublishingProfile", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersionPublishingProfile - """ - super().__init__(location=location, tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[ - Union[str, "_models.GalleryApplicationVersionPropertiesProvisioningState"] - ] = None - self.replication_status: Optional["_models.ReplicationStatus"] = None - - -class GalleryApplicationVersionList(_serialization.Model): - """The List Gallery Application version operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of gallery Application Versions. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersion] - :ivar next_link: The uri to fetch the next page of gallery Application Versions. Call - ListNext() with this to fetch the next page of gallery Application Versions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryApplicationVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.GalleryApplicationVersion"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of gallery Application Versions. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersion] - :keyword next_link: The uri to fetch the next page of gallery Application Versions. Call - ListNext() with this to fetch the next page of gallery Application Versions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryArtifactPublishingProfileBase(_serialization.Model): - """Describes the basic gallery artifact publishing profile. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar target_regions: The target regions where the Image Version is going to be replicated to. - This property is updatable. - :vartype target_regions: list[~azure.mgmt.compute.v2019_12_01.models.TargetRegion] - :ivar replica_count: The number of replicas of the Image Version to be created per region. This - property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :vartype replica_count: int - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar published_date: The timestamp for when the gallery Image Version is published. - :vartype published_date: ~datetime.datetime - :ivar end_of_life_date: The end of life date of the gallery Image Version. This property can be - used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountType - """ - - _validation = { - "published_date": {"readonly": True}, - } - - _attribute_map = { - "target_regions": {"key": "targetRegions", "type": "[TargetRegion]"}, - "replica_count": {"key": "replicaCount", "type": "int"}, - "exclude_from_latest": {"key": "excludeFromLatest", "type": "bool"}, - "published_date": {"key": "publishedDate", "type": "iso-8601"}, - "end_of_life_date": {"key": "endOfLifeDate", "type": "iso-8601"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - } - - def __init__( - self, - *, - target_regions: Optional[List["_models.TargetRegion"]] = None, - replica_count: Optional[int] = None, - exclude_from_latest: Optional[bool] = None, - end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword target_regions: The target regions where the Image Version is going to be replicated - to. This property is updatable. - :paramtype target_regions: list[~azure.mgmt.compute.v2019_12_01.models.TargetRegion] - :keyword replica_count: The number of replicas of the Image Version to be created per region. - This property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :paramtype replica_count: int - :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 end_of_life_date: The end of life date of the gallery Image Version. This property can - be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2019_12_01.models.StorageAccountType - """ - super().__init__(**kwargs) - self.target_regions = target_regions - self.replica_count = replica_count - self.exclude_from_latest = exclude_from_latest - self.published_date: Optional[datetime.datetime] = None - self.end_of_life_date = end_of_life_date - self.storage_account_type = storage_account_type - - -class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfileBase): # pylint: disable=name-too-long - """The publishing profile of a gallery image version. - - 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 target_regions: The target regions where the Image Version is going to be replicated to. - This property is updatable. - :vartype target_regions: list[~azure.mgmt.compute.v2019_12_01.models.TargetRegion] - :ivar replica_count: The number of replicas of the Image Version to be created per region. This - property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :vartype replica_count: int - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar published_date: The timestamp for when the gallery Image Version is published. - :vartype published_date: ~datetime.datetime - :ivar end_of_life_date: The end of life date of the gallery Image Version. This property can be - used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountType - :ivar source: The source image from which the Image Version is going to be created. Required. - :vartype source: ~azure.mgmt.compute.v2019_12_01.models.UserArtifactSource - :ivar manage_actions: - :vartype manage_actions: ~azure.mgmt.compute.v2019_12_01.models.UserArtifactManage - :ivar enable_health_check: Optional. Whether or not this application reports health. - :vartype enable_health_check: bool - """ - - _validation = { - "published_date": {"readonly": True}, - "source": {"required": True}, - } - - _attribute_map = { - "target_regions": {"key": "targetRegions", "type": "[TargetRegion]"}, - "replica_count": {"key": "replicaCount", "type": "int"}, - "exclude_from_latest": {"key": "excludeFromLatest", "type": "bool"}, - "published_date": {"key": "publishedDate", "type": "iso-8601"}, - "end_of_life_date": {"key": "endOfLifeDate", "type": "iso-8601"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "source": {"key": "source", "type": "UserArtifactSource"}, - "manage_actions": {"key": "manageActions", "type": "UserArtifactManage"}, - "enable_health_check": {"key": "enableHealthCheck", "type": "bool"}, - } - - def __init__( - self, - *, - source: "_models.UserArtifactSource", - target_regions: Optional[List["_models.TargetRegion"]] = None, - replica_count: Optional[int] = None, - exclude_from_latest: Optional[bool] = None, - end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - manage_actions: Optional["_models.UserArtifactManage"] = None, - enable_health_check: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword target_regions: The target regions where the Image Version is going to be replicated - to. This property is updatable. - :paramtype target_regions: list[~azure.mgmt.compute.v2019_12_01.models.TargetRegion] - :keyword replica_count: The number of replicas of the Image Version to be created per region. - This property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :paramtype replica_count: int - :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 end_of_life_date: The end of life date of the gallery Image Version. This property can - be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2019_12_01.models.StorageAccountType - :keyword source: The source image from which the Image Version is going to be created. - Required. - :paramtype source: ~azure.mgmt.compute.v2019_12_01.models.UserArtifactSource - :keyword manage_actions: - :paramtype manage_actions: ~azure.mgmt.compute.v2019_12_01.models.UserArtifactManage - :keyword enable_health_check: Optional. Whether or not this application reports health. - :paramtype enable_health_check: bool - """ - super().__init__( - target_regions=target_regions, - replica_count=replica_count, - exclude_from_latest=exclude_from_latest, - end_of_life_date=end_of_life_date, - storage_account_type=storage_account_type, - **kwargs - ) - self.source = source - self.manage_actions = manage_actions - self.enable_health_check = enable_health_check - - -class GalleryApplicationVersionUpdate(UpdateResourceDefinition): - """Specifies information about the gallery Application Version that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar publishing_profile: The publishing profile of a gallery image version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersionPropertiesProvisioningState - :ivar replication_status: This is the replication status of the gallery Image Version. - :vartype replication_status: ~azure.mgmt.compute.v2019_12_01.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "publishing_profile": { - "key": "properties.publishingProfile", - "type": "GalleryApplicationVersionPublishingProfile", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersionPublishingProfile - """ - super().__init__(tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[ - Union[str, "_models.GalleryApplicationVersionPropertiesProvisioningState"] - ] = None - self.replication_status: Optional["_models.ReplicationStatus"] = 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.v2019_12_01.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.v2019_12_01.models.ManagedArtifact - """ - super().__init__(**kwargs) - self.managed_image = managed_image - - -class GalleryArtifactVersionSource(_serialization.Model): - """The gallery artifact version source. - - :ivar id: The id of the gallery artifact version source. Can specify a disk uri, snapshot uri, - or user image. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: The id of the gallery artifact version source. Can specify a disk uri, snapshot - uri, or user image. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class GalleryDiskImage(_serialization.Model): - """This is the disk image base class. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar size_in_gb: This property indicates the size of the VHD to be created. - :vartype size_in_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2019_12_01.models.HostCaching - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2019_12_01.models.GalleryArtifactVersionSource - """ - - _validation = { - "size_in_gb": {"readonly": True}, - } - - _attribute_map = { - "size_in_gb": {"key": "sizeInGB", "type": "int"}, - "host_caching": {"key": "hostCaching", "type": "str"}, - "source": {"key": "source", "type": "GalleryArtifactVersionSource"}, - } - - def __init__( - self, - *, - host_caching: Optional[Union[str, "_models.HostCaching"]] = None, - source: Optional["_models.GalleryArtifactVersionSource"] = 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.v2019_12_01.models.HostCaching - :keyword source: The gallery artifact version source. - :paramtype source: ~azure.mgmt.compute.v2019_12_01.models.GalleryArtifactVersionSource - """ - super().__init__(**kwargs) - self.size_in_gb: Optional[int] = None - self.host_caching = host_caching - self.source = source - - -class GalleryDataDiskImage(GalleryDiskImage): - """This is the data disk 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 size_in_gb: This property indicates the size of the VHD to be created. - :vartype size_in_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2019_12_01.models.HostCaching - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2019_12_01.models.GalleryArtifactVersionSource - :ivar 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. - :vartype lun: int - """ - - _validation = { - "size_in_gb": {"readonly": True}, - "lun": {"required": True}, - } - - _attribute_map = { - "size_in_gb": {"key": "sizeInGB", "type": "int"}, - "host_caching": {"key": "hostCaching", "type": "str"}, - "source": {"key": "source", "type": "GalleryArtifactVersionSource"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__( - self, - *, - lun: int, - host_caching: Optional[Union[str, "_models.HostCaching"]] = None, - source: Optional["_models.GalleryArtifactVersionSource"] = 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.v2019_12_01.models.HostCaching - :keyword source: The gallery artifact version source. - :paramtype source: ~azure.mgmt.compute.v2019_12_01.models.GalleryArtifactVersionSource - :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, source=source, **kwargs) - self.lun = lun - - -class GalleryIdentifier(_serialization.Model): - """Describes the gallery unique name. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar unique_name: The unique name of the Shared Image Gallery. This name is generated - automatically by Azure. - :vartype unique_name: str - """ - - _validation = { - "unique_name": {"readonly": True}, - } - - _attribute_map = { - "unique_name": {"key": "uniqueName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.unique_name: Optional[str] = None - - -class GalleryImage(Resource): - """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. - :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] - :ivar description: The description of this gallery Image Definition resource. This property is - updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery Image Definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar 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. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values - are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - :ivar 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". - :vartype os_state: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemStateTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_12_01.models.HyperVGeneration - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar identifier: This is the gallery Image Definition identifier. - :vartype identifier: ~azure.mgmt.compute.v2019_12_01.models.GalleryImageIdentifier - :ivar recommended: The properties describe the recommended machine configuration for this Image - Definition. These properties are updatable. - :vartype recommended: ~azure.mgmt.compute.v2019_12_01.models.RecommendedMachineConfiguration - :ivar disallowed: Describes the disallowed disk types. - :vartype disallowed: ~azure.mgmt.compute.v2019_12_01.models.Disallowed - :ivar purchase_plan: Describes the gallery Image Definition purchase plan. This is used by - marketplace images. - :vartype purchase_plan: ~azure.mgmt.compute.v2019_12_01.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2019_12_01.models.GalleryImagePropertiesProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "os_state": {"key": "properties.osState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, - "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["_models.GalleryImageIdentifier"] = None, - recommended: Optional["_models.RecommendedMachineConfiguration"] = None, - disallowed: Optional["_models.Disallowed"] = None, - purchase_plan: Optional["_models.ImagePurchasePlan"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery Image Definition resource. This property - is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery Image Definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: 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. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2019_12_01.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.v2019_12_01.models.OperatingSystemStateTypes - :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.v2019_12_01.models.HyperVGeneration - :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.v2019_12_01.models.GalleryImageIdentifier - :keyword recommended: The properties describe the recommended machine configuration for this - Image Definition. These properties are updatable. - :paramtype recommended: ~azure.mgmt.compute.v2019_12_01.models.RecommendedMachineConfiguration - :keyword disallowed: Describes the disallowed disk types. - :paramtype disallowed: ~azure.mgmt.compute.v2019_12_01.models.Disallowed - :keyword purchase_plan: Describes the gallery Image Definition purchase plan. This is used by - marketplace images. - :paramtype purchase_plan: ~azure.mgmt.compute.v2019_12_01.models.ImagePurchasePlan - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.os_type = os_type - self.os_state = os_state - self.hyper_v_generation = hyper_v_generation - self.end_of_life_date = end_of_life_date - self.identifier = identifier - self.recommended = recommended - self.disallowed = disallowed - self.purchase_plan = purchase_plan - self.provisioning_state: Optional[Union[str, "_models.GalleryImagePropertiesProvisioningState"]] = None - - -class GalleryImageIdentifier(_serialization.Model): - """This is the gallery Image Definition identifier. - - All required parameters must be populated in order to send to server. - - :ivar publisher: The name of the gallery Image Definition publisher. Required. - :vartype publisher: str - :ivar offer: The name of the gallery Image Definition offer. Required. - :vartype offer: str - :ivar sku: The name of the gallery Image Definition SKU. Required. - :vartype sku: str - """ - - _validation = { - "publisher": {"required": True}, - "offer": {"required": True}, - "sku": {"required": True}, - } - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "offer": {"key": "offer", "type": "str"}, - "sku": {"key": "sku", "type": "str"}, - } - - def __init__(self, *, publisher: str, offer: str, sku: str, **kwargs: Any) -> None: - """ - :keyword publisher: The name of the gallery Image Definition publisher. Required. - :paramtype publisher: str - :keyword offer: The name of the gallery Image Definition offer. Required. - :paramtype offer: str - :keyword sku: The name of the gallery Image Definition SKU. Required. - :paramtype sku: str - """ - super().__init__(**kwargs) - self.publisher = publisher - self.offer = offer - self.sku = sku - - -class GalleryImageList(_serialization.Model): - """The List Gallery Images operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of Shared Image Gallery images. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.GalleryImage] - :ivar next_link: The uri to fetch the next page of Image Definitions in the Shared Image - Gallery. Call ListNext() with this to fetch the next page of gallery Image Definitions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryImage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.GalleryImage"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of Shared Image Gallery images. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.GalleryImage] - :keyword next_link: The uri to fetch the next page of Image Definitions in the Shared Image - Gallery. Call ListNext() with this to fetch the next page of gallery Image Definitions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryImageUpdate(UpdateResourceDefinition): - """Specifies information about the gallery Image Definition that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar description: The description of this gallery Image Definition resource. This property is - updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery Image Definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar 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. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values - are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - :ivar 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". - :vartype os_state: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemStateTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_12_01.models.HyperVGeneration - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar identifier: This is the gallery Image Definition identifier. - :vartype identifier: ~azure.mgmt.compute.v2019_12_01.models.GalleryImageIdentifier - :ivar recommended: The properties describe the recommended machine configuration for this Image - Definition. These properties are updatable. - :vartype recommended: ~azure.mgmt.compute.v2019_12_01.models.RecommendedMachineConfiguration - :ivar disallowed: Describes the disallowed disk types. - :vartype disallowed: ~azure.mgmt.compute.v2019_12_01.models.Disallowed - :ivar purchase_plan: Describes the gallery Image Definition purchase plan. This is used by - marketplace images. - :vartype purchase_plan: ~azure.mgmt.compute.v2019_12_01.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2019_12_01.models.GalleryImagePropertiesProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "os_state": {"key": "properties.osState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, - "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["_models.GalleryImageIdentifier"] = None, - recommended: Optional["_models.RecommendedMachineConfiguration"] = None, - disallowed: Optional["_models.Disallowed"] = None, - purchase_plan: Optional["_models.ImagePurchasePlan"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery Image Definition resource. This property - is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery Image Definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: 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. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2019_12_01.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.v2019_12_01.models.OperatingSystemStateTypes - :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.v2019_12_01.models.HyperVGeneration - :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.v2019_12_01.models.GalleryImageIdentifier - :keyword recommended: The properties describe the recommended machine configuration for this - Image Definition. These properties are updatable. - :paramtype recommended: ~azure.mgmt.compute.v2019_12_01.models.RecommendedMachineConfiguration - :keyword disallowed: Describes the disallowed disk types. - :paramtype disallowed: ~azure.mgmt.compute.v2019_12_01.models.Disallowed - :keyword purchase_plan: Describes the gallery Image Definition purchase plan. This is used by - marketplace images. - :paramtype purchase_plan: ~azure.mgmt.compute.v2019_12_01.models.ImagePurchasePlan - """ - super().__init__(tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.os_type = os_type - self.os_state = os_state - self.hyper_v_generation = hyper_v_generation - self.end_of_life_date = end_of_life_date - self.identifier = identifier - self.recommended = recommended - self.disallowed = disallowed - self.purchase_plan = purchase_plan - self.provisioning_state: Optional[Union[str, "_models.GalleryImagePropertiesProvisioningState"]] = None - - -class GalleryImageVersion(Resource): - """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. - :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] - :ivar publishing_profile: The publishing profile of a gallery Image Version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersionPropertiesProvisioningState - :ivar storage_profile: This is the storage profile of a Gallery Image Version. - :vartype storage_profile: - ~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersionStorageProfile - :ivar replication_status: This is the replication status of the gallery Image Version. - :vartype replication_status: ~azure.mgmt.compute.v2019_12_01.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": 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}"}, - "publishing_profile": {"key": "properties.publishingProfile", "type": "GalleryImageVersionPublishingProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery Image Version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersionPublishingProfile - :keyword storage_profile: This is the storage profile of a Gallery Image Version. - :paramtype storage_profile: - ~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersionStorageProfile - """ - super().__init__(location=location, tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[Union[str, "_models.GalleryImageVersionPropertiesProvisioningState"]] = None - self.storage_profile = storage_profile - self.replication_status: Optional["_models.ReplicationStatus"] = None - - -class GalleryImageVersionList(_serialization.Model): - """The List Gallery Image version operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of gallery Image Versions. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersion] - :ivar next_link: The uri to fetch the next page of gallery Image Versions. Call ListNext() with - this to fetch the next page of gallery Image Versions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryImageVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.GalleryImageVersion"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of gallery Image Versions. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersion] - :keyword next_link: The uri to fetch the next page of gallery Image Versions. Call ListNext() - with this to fetch the next page of gallery Image Versions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase): - """The publishing profile of a gallery Image Version. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar target_regions: The target regions where the Image Version is going to be replicated to. - This property is updatable. - :vartype target_regions: list[~azure.mgmt.compute.v2019_12_01.models.TargetRegion] - :ivar replica_count: The number of replicas of the Image Version to be created per region. This - property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :vartype replica_count: int - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar published_date: The timestamp for when the gallery Image Version is published. - :vartype published_date: ~datetime.datetime - :ivar end_of_life_date: The end of life date of the gallery Image Version. This property can be - used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountType - """ - - -class GalleryImageVersionStorageProfile(_serialization.Model): - """This is the storage profile of a Gallery Image Version. - - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2019_12_01.models.GalleryArtifactVersionSource - :ivar os_disk_image: This is the OS disk image. - :vartype os_disk_image: ~azure.mgmt.compute.v2019_12_01.models.GalleryOSDiskImage - :ivar data_disk_images: A list of data disk images. - :vartype data_disk_images: list[~azure.mgmt.compute.v2019_12_01.models.GalleryDataDiskImage] - """ - - _attribute_map = { - "source": {"key": "source", "type": "GalleryArtifactVersionSource"}, - "os_disk_image": {"key": "osDiskImage", "type": "GalleryOSDiskImage"}, - "data_disk_images": {"key": "dataDiskImages", "type": "[GalleryDataDiskImage]"}, - } - - def __init__( - self, - *, - source: Optional["_models.GalleryArtifactVersionSource"] = None, - os_disk_image: Optional["_models.GalleryOSDiskImage"] = None, - data_disk_images: Optional[List["_models.GalleryDataDiskImage"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source: The gallery artifact version source. - :paramtype source: ~azure.mgmt.compute.v2019_12_01.models.GalleryArtifactVersionSource - :keyword os_disk_image: This is the OS disk image. - :paramtype os_disk_image: ~azure.mgmt.compute.v2019_12_01.models.GalleryOSDiskImage - :keyword data_disk_images: A list of data disk images. - :paramtype data_disk_images: list[~azure.mgmt.compute.v2019_12_01.models.GalleryDataDiskImage] - """ - super().__init__(**kwargs) - self.source = source - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - - -class GalleryImageVersionUpdate(UpdateResourceDefinition): - """Specifies information about the gallery Image Version that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar publishing_profile: The publishing profile of a gallery Image Version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersionPropertiesProvisioningState - :ivar storage_profile: This is the storage profile of a Gallery Image Version. - :vartype storage_profile: - ~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersionStorageProfile - :ivar replication_status: This is the replication status of the gallery Image Version. - :vartype replication_status: ~azure.mgmt.compute.v2019_12_01.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "publishing_profile": {"key": "properties.publishingProfile", "type": "GalleryImageVersionPublishingProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery Image Version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersionPublishingProfile - :keyword storage_profile: This is the storage profile of a Gallery Image Version. - :paramtype storage_profile: - ~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersionStorageProfile - """ - super().__init__(tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[Union[str, "_models.GalleryImageVersionPropertiesProvisioningState"]] = None - self.storage_profile = storage_profile - self.replication_status: Optional["_models.ReplicationStatus"] = None - - -class GalleryList(_serialization.Model): - """The List Galleries operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of galleries. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.Gallery] - :ivar next_link: The uri to fetch the next page of galleries. Call ListNext() with this to - fetch the next page of galleries. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Gallery]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Gallery"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of galleries. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.Gallery] - :keyword next_link: The uri to fetch the next page of galleries. Call ListNext() with this to - fetch the next page of galleries. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryOSDiskImage(GalleryDiskImage): - """This is the OS disk image. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar size_in_gb: This property indicates the size of the VHD to be created. - :vartype size_in_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2019_12_01.models.HostCaching - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2019_12_01.models.GalleryArtifactVersionSource - """ - - -class GalleryUpdate(UpdateResourceDefinition): - """Specifies information about the Shared Image Gallery that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar description: The description of this Shared Image Gallery resource. This property is - updatable. - :vartype description: str - :ivar identifier: Describes the gallery unique name. - :vartype identifier: ~azure.mgmt.compute.v2019_12_01.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2019_12_01.models.GalleryPropertiesProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "identifier": {"key": "properties.identifier", "type": "GalleryIdentifier"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - identifier: Optional["_models.GalleryIdentifier"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this Shared Image Gallery resource. This property is - updatable. - :paramtype description: str - :keyword identifier: Describes the gallery unique name. - :paramtype identifier: ~azure.mgmt.compute.v2019_12_01.models.GalleryIdentifier - """ - super().__init__(tags=tags, **kwargs) - self.description = description - self.identifier = identifier - self.provisioning_state: Optional[Union[str, "_models.GalleryPropertiesProvisioningState"]] = None - - -class HardwareProfile(_serialization.Model): - """Specifies the hardware settings for the virtual machine. - - :ivar vm_size: Specifies the size of the virtual machine. For more information about virtual - machine sizes, see `Sizes for virtual machines - `_. - :code:`
    `\\ :code:`
    ` The available VM sizes depend on region and availability set. For a - list of available sizes use these APIs: :code:`
    `\\ :code:`
    ` `List all available - virtual machine sizes in an availability set - `_ - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in a region - `_ :code:`
    `\\ - :code:`
    ` `List all available virtual machine sizes for resizing - `_. Known - values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", - "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", - "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", - "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", - "Standard_A8m_v2", "Standard_B1s", "Standard_B1ms", "Standard_B2s", "Standard_B2ms", - "Standard_B4ms", "Standard_B8ms", "Standard_D1", "Standard_D2", "Standard_D3", "Standard_D4", - "Standard_D11", "Standard_D12", "Standard_D13", "Standard_D14", "Standard_D1_v2", - "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", "Standard_D5_v2", "Standard_D2_v3", - "Standard_D4_v3", "Standard_D8_v3", "Standard_D16_v3", "Standard_D32_v3", "Standard_D64_v3", - "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", "Standard_D16s_v3", - "Standard_D32s_v3", "Standard_D64s_v3", "Standard_D11_v2", "Standard_D12_v2", - "Standard_D13_v2", "Standard_D14_v2", "Standard_D15_v2", "Standard_DS1", "Standard_DS2", - "Standard_DS3", "Standard_DS4", "Standard_DS11", "Standard_DS12", "Standard_DS13", - "Standard_DS14", "Standard_DS1_v2", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", - "Standard_DS5_v2", "Standard_DS11_v2", "Standard_DS12_v2", "Standard_DS13_v2", - "Standard_DS14_v2", "Standard_DS15_v2", "Standard_DS13-4_v2", "Standard_DS13-2_v2", - "Standard_DS14-8_v2", "Standard_DS14-4_v2", "Standard_E2_v3", "Standard_E4_v3", - "Standard_E8_v3", "Standard_E16_v3", "Standard_E32_v3", "Standard_E64_v3", "Standard_E2s_v3", - "Standard_E4s_v3", "Standard_E8s_v3", "Standard_E16s_v3", "Standard_E32s_v3", - "Standard_E64s_v3", "Standard_E32-16_v3", "Standard_E32-8s_v3", "Standard_E64-32s_v3", - "Standard_E64-16s_v3", "Standard_F1", "Standard_F2", "Standard_F4", "Standard_F8", - "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", - "Standard_F16s", "Standard_F2s_v2", "Standard_F4s_v2", "Standard_F8s_v2", "Standard_F16s_v2", - "Standard_F32s_v2", "Standard_F64s_v2", "Standard_F72s_v2", "Standard_G1", "Standard_G2", - "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", "Standard_GS3", - "Standard_GS4", "Standard_GS5", "Standard_GS4-8", "Standard_GS4-4", "Standard_GS5-16", - "Standard_GS5-8", "Standard_H8", "Standard_H16", "Standard_H8m", "Standard_H16m", - "Standard_H16r", "Standard_H16mr", "Standard_L4s", "Standard_L8s", "Standard_L16s", - "Standard_L32s", "Standard_M64s", "Standard_M64ms", "Standard_M128s", "Standard_M128ms", - "Standard_M64-32ms", "Standard_M64-16ms", "Standard_M128-64ms", "Standard_M128-32ms", - "Standard_NC6", "Standard_NC12", "Standard_NC24", "Standard_NC24r", "Standard_NC6s_v2", - "Standard_NC12s_v2", "Standard_NC24s_v2", "Standard_NC24rs_v2", "Standard_NC6s_v3", - "Standard_NC12s_v3", "Standard_NC24s_v3", "Standard_NC24rs_v3", "Standard_ND6s", - "Standard_ND12s", "Standard_ND24s", "Standard_ND24rs", "Standard_NV6", "Standard_NV12", and - "Standard_NV24". - :vartype vm_size: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineSizeTypes - """ - - _attribute_map = { - "vm_size": {"key": "vmSize", "type": "str"}, - } - - def __init__( - self, *, vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs: Any - ) -> None: - """ - :keyword vm_size: Specifies the size of the virtual machine. For more information about virtual - machine sizes, see `Sizes for virtual machines - `_. - :code:`
    `\\ :code:`
    ` The available VM sizes depend on region and availability set. For a - list of available sizes use these APIs: :code:`
    `\\ :code:`
    ` `List all available - virtual machine sizes in an availability set - `_ - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in a region - `_ :code:`
    `\\ - :code:`
    ` `List all available virtual machine sizes for resizing - `_. Known - values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", - "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", - "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", - "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", - "Standard_A8m_v2", "Standard_B1s", "Standard_B1ms", "Standard_B2s", "Standard_B2ms", - "Standard_B4ms", "Standard_B8ms", "Standard_D1", "Standard_D2", "Standard_D3", "Standard_D4", - "Standard_D11", "Standard_D12", "Standard_D13", "Standard_D14", "Standard_D1_v2", - "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", "Standard_D5_v2", "Standard_D2_v3", - "Standard_D4_v3", "Standard_D8_v3", "Standard_D16_v3", "Standard_D32_v3", "Standard_D64_v3", - "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", "Standard_D16s_v3", - "Standard_D32s_v3", "Standard_D64s_v3", "Standard_D11_v2", "Standard_D12_v2", - "Standard_D13_v2", "Standard_D14_v2", "Standard_D15_v2", "Standard_DS1", "Standard_DS2", - "Standard_DS3", "Standard_DS4", "Standard_DS11", "Standard_DS12", "Standard_DS13", - "Standard_DS14", "Standard_DS1_v2", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", - "Standard_DS5_v2", "Standard_DS11_v2", "Standard_DS12_v2", "Standard_DS13_v2", - "Standard_DS14_v2", "Standard_DS15_v2", "Standard_DS13-4_v2", "Standard_DS13-2_v2", - "Standard_DS14-8_v2", "Standard_DS14-4_v2", "Standard_E2_v3", "Standard_E4_v3", - "Standard_E8_v3", "Standard_E16_v3", "Standard_E32_v3", "Standard_E64_v3", "Standard_E2s_v3", - "Standard_E4s_v3", "Standard_E8s_v3", "Standard_E16s_v3", "Standard_E32s_v3", - "Standard_E64s_v3", "Standard_E32-16_v3", "Standard_E32-8s_v3", "Standard_E64-32s_v3", - "Standard_E64-16s_v3", "Standard_F1", "Standard_F2", "Standard_F4", "Standard_F8", - "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", - "Standard_F16s", "Standard_F2s_v2", "Standard_F4s_v2", "Standard_F8s_v2", "Standard_F16s_v2", - "Standard_F32s_v2", "Standard_F64s_v2", "Standard_F72s_v2", "Standard_G1", "Standard_G2", - "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", "Standard_GS3", - "Standard_GS4", "Standard_GS5", "Standard_GS4-8", "Standard_GS4-4", "Standard_GS5-16", - "Standard_GS5-8", "Standard_H8", "Standard_H16", "Standard_H8m", "Standard_H16m", - "Standard_H16r", "Standard_H16mr", "Standard_L4s", "Standard_L8s", "Standard_L16s", - "Standard_L32s", "Standard_M64s", "Standard_M64ms", "Standard_M128s", "Standard_M128ms", - "Standard_M64-32ms", "Standard_M64-16ms", "Standard_M128-64ms", "Standard_M128-32ms", - "Standard_NC6", "Standard_NC12", "Standard_NC24", "Standard_NC24r", "Standard_NC6s_v2", - "Standard_NC12s_v2", "Standard_NC24s_v2", "Standard_NC24rs_v2", "Standard_NC6s_v3", - "Standard_NC12s_v3", "Standard_NC24s_v3", "Standard_NC24rs_v3", "Standard_ND6s", - "Standard_ND12s", "Standard_ND24s", "Standard_ND24rs", "Standard_NV6", "Standard_NV12", and - "Standard_NV24". - :paramtype vm_size: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineSizeTypes - """ - super().__init__(**kwargs) - self.vm_size = vm_size - - -class Image(Resource): - """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. - - 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] - :ivar source_virtual_machine: The source virtual machine from which Image is created. - :vartype source_virtual_machine: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2019_12_01.models.ImageStorageProfile - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str - :ivar hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from the - image. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or - ~azure.mgmt.compute.v2019_12_01.models.HyperVGenerationTypes - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "source_virtual_machine": {"key": "properties.sourceVirtualMachine", "type": "SubResource"}, - "storage_profile": {"key": "properties.storageProfile", "type": "ImageStorageProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["_models.SubResource"] = None, - storage_profile: Optional["_models.ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword source_virtual_machine: The source virtual machine from which Image is created. - :paramtype source_virtual_machine: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2019_12_01.models.ImageStorageProfile - :keyword hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from - the image. Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2019_12_01.models.HyperVGenerationTypes - """ - super().__init__(location=location, tags=tags, **kwargs) - self.source_virtual_machine = source_virtual_machine - self.storage_profile = storage_profile - self.provisioning_state: Optional[str] = None - self.hyper_v_generation = hyper_v_generation - - -class ImageDisk(_serialization.Model): - """Describes a image disk. - - :ivar snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed image disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2019_12_01.models.DiskEncryptionSetParameters - """ - - _attribute_map = { - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - } - - def __init__( - self, - *, - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed image disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2019_12_01.models.DiskEncryptionSetParameters - """ - super().__init__(**kwargs) - self.snapshot = snapshot - self.managed_disk = managed_disk - self.blob_uri = blob_uri - self.caching = caching - self.disk_size_gb = disk_size_gb - self.storage_account_type = storage_account_type - self.disk_encryption_set = disk_encryption_set - - -class ImageDataDisk(ImageDisk): - """Describes a data disk. - - All required parameters must be populated in order to send to server. - - :ivar snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed image disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2019_12_01.models.DiskEncryptionSetParameters - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - """ - - _validation = { - "lun": {"required": True}, - } - - _attribute_map = { - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__( - self, - *, - lun: int, - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed image disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2019_12_01.models.DiskEncryptionSetParameters - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - """ - super().__init__( - snapshot=snapshot, - managed_disk=managed_disk, - blob_uri=blob_uri, - caching=caching, - disk_size_gb=disk_size_gb, - storage_account_type=storage_account_type, - disk_encryption_set=disk_encryption_set, - **kwargs - ) - self.lun = lun - - -class ImageListResult(_serialization.Model): - """The List Image operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of Images. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.Image] - :ivar next_link: The uri to fetch the next page of Images. Call ListNext() with this to fetch - the next page of Images. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Image]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Image"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of Images. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.Image] - :keyword next_link: The uri to fetch the next page of Images. Call ListNext() with this to - fetch the next page of Images. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ImageOSDisk(ImageDisk): - """Describes an Operating System disk. - - All required parameters must be populated in order to send to server. - - :ivar snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed image disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2019_12_01.models.DiskEncryptionSetParameters - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from a custom image. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Required. Known - values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - :ivar os_state: The OS State. Required. Known values are: "Generalized" and "Specialized". - :vartype os_state: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemStateTypes - """ - - _validation = { - "os_type": {"required": True}, - "os_state": {"required": True}, - } - - _attribute_map = { - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - "os_type": {"key": "osType", "type": "str"}, - "os_state": {"key": "osState", "type": "str"}, - } - - def __init__( - self, - *, - os_type: Union[str, "_models.OperatingSystemTypes"], - os_state: Union[str, "_models.OperatingSystemStateTypes"], - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed image disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2019_12_01.models.DiskEncryptionSetParameters - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from a custom image. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Required. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - :keyword os_state: The OS State. Required. Known values are: "Generalized" and "Specialized". - :paramtype os_state: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemStateTypes - """ - super().__init__( - snapshot=snapshot, - managed_disk=managed_disk, - blob_uri=blob_uri, - caching=caching, - disk_size_gb=disk_size_gb, - storage_account_type=storage_account_type, - disk_encryption_set=disk_encryption_set, - **kwargs - ) - self.os_type = os_type - self.os_state = os_state - - -class ImagePurchasePlan(_serialization.Model): - """Describes the gallery Image Definition purchase plan. This is used by marketplace images. - - :ivar name: The plan ID. - :vartype name: str - :ivar publisher: The publisher ID. - :vartype publisher: str - :ivar product: The product ID. - :vartype product: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - publisher: Optional[str] = None, - product: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The plan ID. - :paramtype name: str - :keyword publisher: The publisher ID. - :paramtype publisher: str - :keyword product: The product ID. - :paramtype product: str - """ - super().__init__(**kwargs) - self.name = name - self.publisher = publisher - self.product = product - - -class ImageReference(SubResource): - """Specifies information about the image to use. You can specify information about platform - images, marketplace images, or virtual machine images. This element is required when you want - to use a platform image, marketplace image, or virtual machine image, but is not used in other - creation operations. NOTE: Image reference publisher and offer can only be set when you create - the scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar publisher: The image publisher. - :vartype publisher: str - :ivar offer: Specifies the offer of the platform image or marketplace image used to create the - virtual machine. - :vartype offer: str - :ivar sku: The image SKU. - :vartype sku: str - :ivar version: Specifies the version of the platform image or marketplace image used to create - the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and - Build are decimal numbers. Specify 'latest' to use the latest version of an image available at - deploy time. Even if you use 'latest', the VM image will not automatically update after deploy - time even if a new version becomes available. - :vartype version: str - :ivar exact_version: Specifies in decimal numbers, the version of platform image or marketplace - image used to create the virtual machine. This readonly field differs from 'version', only if - the value specified in 'version' field is 'latest'. - :vartype exact_version: str - """ - - _validation = { - "exact_version": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "offer": {"key": "offer", "type": "str"}, - "sku": {"key": "sku", "type": "str"}, - "version": {"key": "version", "type": "str"}, - "exact_version": {"key": "exactVersion", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - publisher: Optional[str] = None, - offer: Optional[str] = None, - sku: Optional[str] = None, - version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword publisher: The image publisher. - :paramtype publisher: str - :keyword offer: Specifies the offer of the platform image or marketplace image used to create - the virtual machine. - :paramtype offer: str - :keyword sku: The image SKU. - :paramtype sku: str - :keyword version: Specifies the version of the platform image or marketplace image used to - create the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, - Minor, and Build are decimal numbers. Specify 'latest' to use the latest version of an image - available at deploy time. Even if you use 'latest', the VM image will not automatically update - after deploy time even if a new version becomes available. - :paramtype version: str - """ - super().__init__(id=id, **kwargs) - self.publisher = publisher - self.offer = offer - self.sku = sku - self.version = version - self.exact_version: Optional[str] = None - - -class ImageStorageProfile(_serialization.Model): - """Describes a storage profile. - - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2019_12_01.models.ImageOSDisk - :ivar data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype data_disks: list[~azure.mgmt.compute.v2019_12_01.models.ImageDataDisk] - :ivar zone_resilient: Specifies whether an image is zone resilient or not. Default is false. - Zone resilient images can be created only in regions that provide Zone Redundant Storage (ZRS). - :vartype zone_resilient: bool - """ - - _attribute_map = { - "os_disk": {"key": "osDisk", "type": "ImageOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[ImageDataDisk]"}, - "zone_resilient": {"key": "zoneResilient", "type": "bool"}, - } - - def __init__( - self, - *, - os_disk: Optional["_models.ImageOSDisk"] = None, - data_disks: Optional[List["_models.ImageDataDisk"]] = None, - zone_resilient: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2019_12_01.models.ImageOSDisk - :keyword data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype data_disks: list[~azure.mgmt.compute.v2019_12_01.models.ImageDataDisk] - :keyword zone_resilient: Specifies whether an image is zone resilient or not. Default is false. - Zone resilient images can be created only in regions that provide Zone Redundant Storage (ZRS). - :paramtype zone_resilient: bool - """ - super().__init__(**kwargs) - self.os_disk = os_disk - self.data_disks = data_disks - self.zone_resilient = zone_resilient - - -class ImageUpdate(UpdateResource): - """The source user image virtual hard disk. Only tags may be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar source_virtual_machine: The source virtual machine from which Image is created. - :vartype source_virtual_machine: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2019_12_01.models.ImageStorageProfile - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str - :ivar hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from the - image. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or - ~azure.mgmt.compute.v2019_12_01.models.HyperVGenerationTypes - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "source_virtual_machine": {"key": "properties.sourceVirtualMachine", "type": "SubResource"}, - "storage_profile": {"key": "properties.storageProfile", "type": "ImageStorageProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["_models.SubResource"] = None, - storage_profile: Optional["_models.ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword source_virtual_machine: The source virtual machine from which Image is created. - :paramtype source_virtual_machine: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2019_12_01.models.ImageStorageProfile - :keyword hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from - the image. Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2019_12_01.models.HyperVGenerationTypes - """ - super().__init__(tags=tags, **kwargs) - self.source_virtual_machine = source_virtual_machine - self.storage_profile = storage_profile - self.provisioning_state: Optional[str] = None - self.hyper_v_generation = hyper_v_generation - - -class InnerError(_serialization.Model): - """Inner error details. - - :ivar exceptiontype: The exception type. - :vartype exceptiontype: str - :ivar errordetail: The internal error message or exception dump. - :vartype errordetail: str - """ - - _attribute_map = { - "exceptiontype": {"key": "exceptiontype", "type": "str"}, - "errordetail": {"key": "errordetail", "type": "str"}, - } - - def __init__( - self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword exceptiontype: The exception type. - :paramtype exceptiontype: str - :keyword errordetail: The internal error message or exception dump. - :paramtype errordetail: str - """ - super().__init__(**kwargs) - self.exceptiontype = exceptiontype - self.errordetail = errordetail - - -class InstanceViewStatus(_serialization.Model): - """Instance view status. - - :ivar code: The status code. - :vartype code: str - :ivar level: The level code. Known values are: "Info", "Warning", and "Error". - :vartype level: str or ~azure.mgmt.compute.v2019_12_01.models.StatusLevelTypes - :ivar display_status: The short localizable label for the status. - :vartype display_status: str - :ivar message: The detailed status message, including for alerts and error messages. - :vartype message: str - :ivar time: The time of the status. - :vartype time: ~datetime.datetime - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "level": {"key": "level", "type": "str"}, - "display_status": {"key": "displayStatus", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "time": {"key": "time", "type": "iso-8601"}, - } - - def __init__( - self, - *, - code: Optional[str] = None, - level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, - display_status: Optional[str] = None, - message: Optional[str] = None, - time: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword code: The status code. - :paramtype code: str - :keyword level: The level code. Known values are: "Info", "Warning", and "Error". - :paramtype level: str or ~azure.mgmt.compute.v2019_12_01.models.StatusLevelTypes - :keyword display_status: The short localizable label for the status. - :paramtype display_status: str - :keyword message: The detailed status message, including for alerts and error messages. - :paramtype message: str - :keyword time: The time of the status. - :paramtype time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.code = code - self.level = level - self.display_status = display_status - self.message = message - self.time = time - - -class KeyVaultKeyReference(_serialization.Model): - """Describes a reference to Key Vault Key. - - All required parameters must be populated in order to send to server. - - :ivar key_url: The URL referencing a key encryption key in Key Vault. Required. - :vartype key_url: str - :ivar source_vault: The relative URL of the Key Vault containing the key. Required. - :vartype source_vault: ~azure.mgmt.compute.v2019_12_01.models.SubResource - """ - - _validation = { - "key_url": {"required": True}, - "source_vault": {"required": True}, - } - - _attribute_map = { - "key_url": {"key": "keyUrl", "type": "str"}, - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - } - - def __init__(self, *, key_url: str, source_vault: "_models.SubResource", **kwargs: Any) -> None: - """ - :keyword key_url: The URL referencing a key encryption key in Key Vault. Required. - :paramtype key_url: str - :keyword source_vault: The relative URL of the Key Vault containing the key. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2019_12_01.models.SubResource - """ - super().__init__(**kwargs) - self.key_url = key_url - self.source_vault = source_vault - - -class KeyVaultSecretReference(_serialization.Model): - """Describes a reference to Key Vault Secret. - - All required parameters must be populated in order to send to server. - - :ivar secret_url: The URL referencing a secret in a Key Vault. Required. - :vartype secret_url: str - :ivar source_vault: The relative URL of the Key Vault containing the secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2019_12_01.models.SubResource - """ - - _validation = { - "secret_url": {"required": True}, - "source_vault": {"required": True}, - } - - _attribute_map = { - "secret_url": {"key": "secretUrl", "type": "str"}, - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - } - - def __init__(self, *, secret_url: str, source_vault: "_models.SubResource", **kwargs: Any) -> None: - """ - :keyword secret_url: The URL referencing a secret in a Key Vault. Required. - :paramtype secret_url: str - :keyword source_vault: The relative URL of the Key Vault containing the secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2019_12_01.models.SubResource - """ - super().__init__(**kwargs) - self.secret_url = secret_url - self.source_vault = source_vault - - -class LinuxConfiguration(_serialization.Model): - """Specifies the Linux operating system settings on the virtual machine. :code:`
    `\\ - :code:`
    `For a list of supported Linux distributions, see `Linux on Azure-Endorsed - Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - - :ivar disable_password_authentication: Specifies whether password authentication should be - disabled. - :vartype disable_password_authentication: bool - :ivar ssh: Specifies the ssh key configuration for a Linux OS. - :vartype ssh: ~azure.mgmt.compute.v2019_12_01.models.SshConfiguration - :ivar provision_vm_agent: Indicates whether virtual machine agent should be provisioned on the - virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the request - body, default behavior is to set it to true. This will ensure that VM Agent is installed on - the VM so that extensions can be added to the VM later. - :vartype provision_vm_agent: bool - """ - - _attribute_map = { - "disable_password_authentication": {"key": "disablePasswordAuthentication", "type": "bool"}, - "ssh": {"key": "ssh", "type": "SshConfiguration"}, - "provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"}, - } - - def __init__( - self, - *, - disable_password_authentication: Optional[bool] = None, - ssh: Optional["_models.SshConfiguration"] = None, - provision_vm_agent: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword disable_password_authentication: Specifies whether password authentication should be - disabled. - :paramtype disable_password_authentication: bool - :keyword ssh: Specifies the ssh key configuration for a Linux OS. - :paramtype ssh: ~azure.mgmt.compute.v2019_12_01.models.SshConfiguration - :keyword provision_vm_agent: Indicates whether virtual machine agent should be provisioned on - the virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the - request body, default behavior is to set it to true. This will ensure that VM Agent is - installed on the VM so that extensions can be added to the VM later. - :paramtype provision_vm_agent: bool - """ - super().__init__(**kwargs) - self.disable_password_authentication = disable_password_authentication - self.ssh = ssh - self.provision_vm_agent = provision_vm_agent - - -class ListUsagesResult(_serialization.Model): - """The List Usages operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of compute resource usages. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.Usage] - :ivar next_link: The URI to fetch the next page of compute resource usage information. Call - ListNext() with this to fetch the next page of compute resource usage information. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Usage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of compute resource usages. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.Usage] - :keyword next_link: The URI to fetch the next page of compute resource usage information. Call - ListNext() with this to fetch the next page of compute resource usage information. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class LogAnalyticsInputBase(_serialization.Model): - """Api input base class for LogAnalytics Api. - - All required parameters must be populated in order to send to server. - - :ivar blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api - writes output logs to. Required. - :vartype blob_container_sas_uri: str - :ivar from_time: From time of the query. Required. - :vartype from_time: ~datetime.datetime - :ivar to_time: To time of the query. Required. - :vartype to_time: ~datetime.datetime - :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. - :vartype group_by_throttle_policy: bool - :ivar group_by_operation_name: Group query result by Operation Name. - :vartype group_by_operation_name: bool - :ivar group_by_resource_name: Group query result by Resource Name. - :vartype group_by_resource_name: bool - """ - - _validation = { - "blob_container_sas_uri": {"required": True}, - "from_time": {"required": True}, - "to_time": {"required": True}, - } - - _attribute_map = { - "blob_container_sas_uri": {"key": "blobContainerSasUri", "type": "str"}, - "from_time": {"key": "fromTime", "type": "iso-8601"}, - "to_time": {"key": "toTime", "type": "iso-8601"}, - "group_by_throttle_policy": {"key": "groupByThrottlePolicy", "type": "bool"}, - "group_by_operation_name": {"key": "groupByOperationName", "type": "bool"}, - "group_by_resource_name": {"key": "groupByResourceName", "type": "bool"}, - } - - def __init__( - self, - *, - blob_container_sas_uri: str, - from_time: datetime.datetime, - to_time: datetime.datetime, - group_by_throttle_policy: Optional[bool] = None, - group_by_operation_name: Optional[bool] = None, - group_by_resource_name: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics - Api writes output logs to. Required. - :paramtype blob_container_sas_uri: str - :keyword from_time: From time of the query. Required. - :paramtype from_time: ~datetime.datetime - :keyword to_time: To time of the query. Required. - :paramtype to_time: ~datetime.datetime - :keyword group_by_throttle_policy: Group query result by Throttle Policy applied. - :paramtype group_by_throttle_policy: bool - :keyword group_by_operation_name: Group query result by Operation Name. - :paramtype group_by_operation_name: bool - :keyword group_by_resource_name: Group query result by Resource Name. - :paramtype group_by_resource_name: bool - """ - super().__init__(**kwargs) - self.blob_container_sas_uri = blob_container_sas_uri - self.from_time = from_time - self.to_time = to_time - self.group_by_throttle_policy = group_by_throttle_policy - self.group_by_operation_name = group_by_operation_name - self.group_by_resource_name = group_by_resource_name - - -class LogAnalyticsOperationResult(_serialization.Model): - """LogAnalytics operation status response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar properties: LogAnalyticsOutput. - :vartype properties: ~azure.mgmt.compute.v2019_12_01.models.LogAnalyticsOutput - """ - - _validation = { - "properties": {"readonly": True}, - } - - _attribute_map = { - "properties": {"key": "properties", "type": "LogAnalyticsOutput"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.properties: Optional["_models.LogAnalyticsOutput"] = None - - -class LogAnalyticsOutput(_serialization.Model): - """LogAnalytics output properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar output: Output file Uri path to blob container. - :vartype output: str - """ - - _validation = { - "output": {"readonly": True}, - } - - _attribute_map = { - "output": {"key": "output", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.output: Optional[str] = None - - -class MaintenanceRedeployStatus(_serialization.Model): - """Maintenance Operation Status. - - :ivar is_customer_initiated_maintenance_allowed: True, if customer is allowed to perform - Maintenance. - :vartype is_customer_initiated_maintenance_allowed: bool - :ivar pre_maintenance_window_start_time: Start Time for the Pre Maintenance Window. - :vartype pre_maintenance_window_start_time: ~datetime.datetime - :ivar pre_maintenance_window_end_time: End Time for the Pre Maintenance Window. - :vartype pre_maintenance_window_end_time: ~datetime.datetime - :ivar maintenance_window_start_time: Start Time for the Maintenance Window. - :vartype maintenance_window_start_time: ~datetime.datetime - :ivar maintenance_window_end_time: End Time for the Maintenance Window. - :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: - "None", "RetryLater", "MaintenanceAborted", and "MaintenanceCompleted". - :vartype last_operation_result_code: str or - ~azure.mgmt.compute.v2019_12_01.models.MaintenanceOperationResultCodeTypes - :ivar last_operation_message: Message returned for the last Maintenance Operation. - :vartype last_operation_message: str - """ - - _attribute_map = { - "is_customer_initiated_maintenance_allowed": {"key": "isCustomerInitiatedMaintenanceAllowed", "type": "bool"}, - "pre_maintenance_window_start_time": {"key": "preMaintenanceWindowStartTime", "type": "iso-8601"}, - "pre_maintenance_window_end_time": {"key": "preMaintenanceWindowEndTime", "type": "iso-8601"}, - "maintenance_window_start_time": {"key": "maintenanceWindowStartTime", "type": "iso-8601"}, - "maintenance_window_end_time": {"key": "maintenanceWindowEndTime", "type": "iso-8601"}, - "last_operation_result_code": {"key": "lastOperationResultCode", "type": "str"}, - "last_operation_message": {"key": "lastOperationMessage", "type": "str"}, - } - - def __init__( - self, - *, - is_customer_initiated_maintenance_allowed: Optional[bool] = None, - pre_maintenance_window_start_time: Optional[datetime.datetime] = None, - pre_maintenance_window_end_time: Optional[datetime.datetime] = None, - maintenance_window_start_time: Optional[datetime.datetime] = None, - maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, - last_operation_message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_customer_initiated_maintenance_allowed: True, if customer is allowed to perform - Maintenance. - :paramtype is_customer_initiated_maintenance_allowed: bool - :keyword pre_maintenance_window_start_time: Start Time for the Pre Maintenance Window. - :paramtype pre_maintenance_window_start_time: ~datetime.datetime - :keyword pre_maintenance_window_end_time: End Time for the Pre Maintenance Window. - :paramtype pre_maintenance_window_end_time: ~datetime.datetime - :keyword maintenance_window_start_time: Start Time for the Maintenance Window. - :paramtype maintenance_window_start_time: ~datetime.datetime - :keyword maintenance_window_end_time: End Time for the Maintenance Window. - :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values - are: "None", "RetryLater", "MaintenanceAborted", and "MaintenanceCompleted". - :paramtype last_operation_result_code: str or - ~azure.mgmt.compute.v2019_12_01.models.MaintenanceOperationResultCodeTypes - :keyword last_operation_message: Message returned for the last Maintenance Operation. - :paramtype last_operation_message: str - """ - super().__init__(**kwargs) - self.is_customer_initiated_maintenance_allowed = is_customer_initiated_maintenance_allowed - self.pre_maintenance_window_start_time = pre_maintenance_window_start_time - self.pre_maintenance_window_end_time = pre_maintenance_window_end_time - self.maintenance_window_start_time = maintenance_window_start_time - self.maintenance_window_end_time = maintenance_window_end_time - self.last_operation_result_code = last_operation_result_code - self.last_operation_message = last_operation_message - - -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 ManagedDiskParameters(SubResource): - """The parameters of a managed disk. - - :ivar id: Resource Id. - :vartype id: str - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2019_12_01.models.DiskEncryptionSetParameters - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2019_12_01.models.DiskEncryptionSetParameters - """ - super().__init__(id=id, **kwargs) - self.storage_account_type = storage_account_type - self.disk_encryption_set = disk_encryption_set - - -class NetworkInterfaceReference(SubResource): - """Describes a network interface reference. - - :ivar id: Resource Id. - :vartype id: str - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - primary: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - """ - super().__init__(id=id, **kwargs) - self.primary = primary - - -class NetworkProfile(_serialization.Model): - """Specifies the network interfaces of the virtual machine. - - :ivar network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the virtual machine. - :vartype network_interfaces: - list[~azure.mgmt.compute.v2019_12_01.models.NetworkInterfaceReference] - """ - - _attribute_map = { - "network_interfaces": {"key": "networkInterfaces", "type": "[NetworkInterfaceReference]"}, - } - - def __init__( - self, *, network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs: Any - ) -> None: - """ - :keyword network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the virtual machine. - :paramtype network_interfaces: - list[~azure.mgmt.compute.v2019_12_01.models.NetworkInterfaceReference] - """ - super().__init__(**kwargs) - self.network_interfaces = network_interfaces - - -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. "AutomaticRepairs" - :vartype service_name: str or ~azure.mgmt.compute.v2019_12_01.models.OrchestrationServiceNames - :ivar action: The action to be performed. Required. Known values are: "Resume" and "Suspend". - :vartype action: str or ~azure.mgmt.compute.v2019_12_01.models.OrchestrationServiceStateAction - """ - - _validation = { - "service_name": {"required": True}, - "action": {"required": True}, - } - - _attribute_map = { - "service_name": {"key": "serviceName", "type": "str"}, - "action": {"key": "action", "type": "str"}, - } - - def __init__( - self, - *, - service_name: Union[str, "_models.OrchestrationServiceNames"], - action: Union[str, "_models.OrchestrationServiceStateAction"], - **kwargs: Any - ) -> None: - """ - :keyword service_name: The name of the service. Required. "AutomaticRepairs" - :paramtype service_name: str or - ~azure.mgmt.compute.v2019_12_01.models.OrchestrationServiceNames - :keyword action: The action to be performed. Required. Known values are: "Resume" and - "Suspend". - :paramtype action: str or - ~azure.mgmt.compute.v2019_12_01.models.OrchestrationServiceStateAction - """ - super().__init__(**kwargs) - self.service_name = service_name - self.action = action - - -class OrchestrationServiceSummary(_serialization.Model): - """Summary for an orchestration service of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar service_name: The name of the service. "AutomaticRepairs" - :vartype service_name: str or ~azure.mgmt.compute.v2019_12_01.models.OrchestrationServiceNames - :ivar service_state: The current state of the service. Known values are: "NotRunning", - "Running", and "Suspended". - :vartype service_state: str or ~azure.mgmt.compute.v2019_12_01.models.OrchestrationServiceState - """ - - _validation = { - "service_name": {"readonly": True}, - "service_state": {"readonly": True}, - } - - _attribute_map = { - "service_name": {"key": "serviceName", "type": "str"}, - "service_state": {"key": "serviceState", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.service_name: Optional[Union[str, "_models.OrchestrationServiceNames"]] = None - self.service_state: Optional[Union[str, "_models.OrchestrationServiceState"]] = None - - -class OSDisk(_serialization.Model): - """Specifies information about the operating system disk used by the virtual machine. - :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and VHDs for - Azure virtual machines - `_. - - All required parameters must be populated in order to send to server. - - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :vartype encryption_settings: ~azure.mgmt.compute.v2019_12_01.models.DiskEncryptionSettings - :ivar name: The disk name. - :vartype name: str - :ivar vhd: The virtual hard disk. - :vartype vhd: ~azure.mgmt.compute.v2019_12_01.models.VirtualHardDisk - :ivar image: 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. - :vartype image: ~azure.mgmt.compute.v2019_12_01.models.VirtualHardDisk - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None** for - Standard storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar diff_disk_settings: Specifies the ephemeral Disk Settings for the operating system disk - used by the virtual machine. - :vartype diff_disk_settings: ~azure.mgmt.compute.v2019_12_01.models.DiffDiskSettings - :ivar create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2019_12_01.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: ~azure.mgmt.compute.v2019_12_01.models.ManagedDiskParameters - """ - - _validation = { - "create_option": {"required": True}, - } - - _attribute_map = { - "os_type": {"key": "osType", "type": "str"}, - "encryption_settings": {"key": "encryptionSettings", "type": "DiskEncryptionSettings"}, - "name": {"key": "name", "type": "str"}, - "vhd": {"key": "vhd", "type": "VirtualHardDisk"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "diff_disk_settings": {"key": "diffDiskSettings", "type": "DiffDiskSettings"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, - name: Optional[str] = None, - vhd: Optional["_models.VirtualHardDisk"] = None, - image: Optional["_models.VirtualHardDisk"] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.ManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype encryption_settings: ~azure.mgmt.compute.v2019_12_01.models.DiskEncryptionSettings - :keyword name: The disk name. - :paramtype name: str - :keyword vhd: The virtual hard disk. - :paramtype vhd: ~azure.mgmt.compute.v2019_12_01.models.VirtualHardDisk - :keyword image: 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. - :paramtype image: ~azure.mgmt.compute.v2019_12_01.models.VirtualHardDisk - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None** for - Standard storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword diff_disk_settings: Specifies the ephemeral Disk Settings for the operating system - disk used by the virtual machine. - :paramtype diff_disk_settings: ~azure.mgmt.compute.v2019_12_01.models.DiffDiskSettings - :keyword create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2019_12_01.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: ~azure.mgmt.compute.v2019_12_01.models.ManagedDiskParameters - """ - super().__init__(**kwargs) - self.os_type = os_type - self.encryption_settings = encryption_settings - self.name = name - self.vhd = vhd - self.image = image - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.diff_disk_settings = diff_disk_settings - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - - -class OSDiskImage(_serialization.Model): - """Contains the os disk image information. - - All required parameters must be populated in order to send to server. - - :ivar operating_system: The operating system of the osDiskImage. Required. Known values are: - "Windows" and "Linux". - :vartype operating_system: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - """ - - _validation = { - "operating_system": {"required": True}, - } - - _attribute_map = { - "operating_system": {"key": "operatingSystem", "type": "str"}, - } - - def __init__(self, *, operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs: Any) -> None: - """ - :keyword operating_system: The operating system of the osDiskImage. Required. Known values are: - "Windows" and "Linux". - :paramtype operating_system: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - """ - super().__init__(**kwargs) - self.operating_system = operating_system - - -class OSDiskImageEncryption(DiskImageEncryption): - """Contains encryption settings for an OS disk image. - - :ivar disk_encryption_set_id: A relative URI containing the resource ID of the disk encryption - set. - :vartype disk_encryption_set_id: str - """ - - -class OSProfile(_serialization.Model): - """Specifies the operating system settings for the virtual machine. Some of the settings cannot be - changed once VM is provisioned. - - :ivar computer_name: Specifies the host OS name of the virtual machine. :code:`
    `\\ - :code:`
    ` This name cannot be updated after the VM is created. :code:`
    `\\ :code:`
    ` - **Max-length (Windows):** 15 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 - characters. :code:`
    `\\ :code:`
    ` For naming conventions and restrictions see `Azure - infrastructure services implementation guidelines - `_. - :vartype computer_name: str - :ivar admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` This property cannot be updated after the VM is created. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :vartype admin_username: str - :ivar admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :vartype admin_password: str - :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` **Note: Do not pass any - secrets or passwords in customData property** :code:`
    `\\ :code:`
    ` This property cannot - be updated after the VM is created. :code:`
    `\\ :code:`
    ` customData is passed to the VM - to be saved as a file, for more information see `Custom Data on Azure VMs - `_ - :code:`
    `\\ :code:`
    ` For using cloud-init for your Linux VM, see `Using cloud-init to - customize a Linux VM during creation - `_. - :vartype custom_data: str - :ivar windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :vartype windows_configuration: ~azure.mgmt.compute.v2019_12_01.models.WindowsConfiguration - :ivar linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :vartype linux_configuration: ~azure.mgmt.compute.v2019_12_01.models.LinuxConfiguration - :ivar secrets: Specifies set of certificates that should be installed onto the virtual machine. - :vartype secrets: list[~azure.mgmt.compute.v2019_12_01.models.VaultSecretGroup] - :ivar allow_extension_operations: Specifies whether extension operations should be allowed on - the virtual machine. :code:`
    `\\ :code:`
    `This may only be set to False when no - extensions are present on the virtual machine. - :vartype allow_extension_operations: bool - :ivar require_guest_provision_signal: Specifies whether the guest provision signal is required - to infer provision success of the virtual machine. - :vartype require_guest_provision_signal: bool - """ - - _attribute_map = { - "computer_name": {"key": "computerName", "type": "str"}, - "admin_username": {"key": "adminUsername", "type": "str"}, - "admin_password": {"key": "adminPassword", "type": "str"}, - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - "allow_extension_operations": {"key": "allowExtensionOperations", "type": "bool"}, - "require_guest_provision_signal": {"key": "requireGuestProvisionSignal", "type": "bool"}, - } - - def __init__( - self, - *, - computer_name: Optional[str] = None, - admin_username: Optional[str] = None, - admin_password: Optional[str] = None, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - allow_extension_operations: Optional[bool] = None, - require_guest_provision_signal: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword computer_name: Specifies the host OS name of the virtual machine. :code:`
    `\\ - :code:`
    ` This name cannot be updated after the VM is created. :code:`
    `\\ :code:`
    ` - **Max-length (Windows):** 15 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 - characters. :code:`
    `\\ :code:`
    ` For naming conventions and restrictions see `Azure - infrastructure services implementation guidelines - `_. - :paramtype computer_name: str - :keyword admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` This property cannot be updated after the VM is created. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :paramtype admin_username: str - :keyword admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :paramtype admin_password: str - :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` **Note: Do not pass any - secrets or passwords in customData property** :code:`
    `\\ :code:`
    ` This property cannot - be updated after the VM is created. :code:`
    `\\ :code:`
    ` customData is passed to the VM - to be saved as a file, for more information see `Custom Data on Azure VMs - `_ - :code:`
    `\\ :code:`
    ` For using cloud-init for your Linux VM, see `Using cloud-init to - customize a Linux VM during creation - `_. - :paramtype custom_data: str - :keyword windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :paramtype windows_configuration: ~azure.mgmt.compute.v2019_12_01.models.WindowsConfiguration - :keyword linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :paramtype linux_configuration: ~azure.mgmt.compute.v2019_12_01.models.LinuxConfiguration - :keyword secrets: Specifies set of certificates that should be installed onto the virtual - machine. - :paramtype secrets: list[~azure.mgmt.compute.v2019_12_01.models.VaultSecretGroup] - :keyword allow_extension_operations: Specifies whether extension operations should be allowed - on the virtual machine. :code:`
    `\\ :code:`
    `This may only be set to False when no - extensions are present on the virtual machine. - :paramtype allow_extension_operations: bool - :keyword require_guest_provision_signal: Specifies whether the guest provision signal is - required to infer provision success of the virtual machine. - :paramtype require_guest_provision_signal: bool - """ - super().__init__(**kwargs) - self.computer_name = computer_name - self.admin_username = admin_username - self.admin_password = admin_password - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - self.allow_extension_operations = allow_extension_operations - self.require_guest_provision_signal = require_guest_provision_signal - - -class Plan(_serialization.Model): - """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 the marketplace - image that you want to use and then click **Want to deploy programmatically, Get Started ->**. - Enter any required information and then click **Save**. - - :ivar name: The plan ID. - :vartype name: str - :ivar publisher: The publisher ID. - :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. - :vartype product: str - :ivar promotion_code: The promotion code. - :vartype promotion_code: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - "promotion_code": {"key": "promotionCode", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - publisher: Optional[str] = None, - product: Optional[str] = None, - promotion_code: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The plan ID. - :paramtype name: str - :keyword publisher: The publisher ID. - :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. - :paramtype product: str - :keyword promotion_code: The promotion code. - :paramtype promotion_code: str - """ - super().__init__(**kwargs) - self.name = name - self.publisher = publisher - self.product = product - self.promotion_code = promotion_code - - -class ProximityPlacementGroup(Resource): - """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. - :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] - :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Standard** : - Co-locate resources within an Azure region or Availability Zone. :code:`
    `\\ :code:`
    ` - **Ultra** : For future use. Known values are: "Standard" and "Ultra". - :vartype proximity_placement_group_type: str or - ~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroupType - :ivar virtual_machines: A list of references to all virtual machines in the proximity placement - group. - :vartype virtual_machines: - list[~azure.mgmt.compute.v2019_12_01.models.SubResourceWithColocationStatus] - :ivar virtual_machine_scale_sets: A list of references to all virtual machine scale sets in the - proximity placement group. - :vartype virtual_machine_scale_sets: - list[~azure.mgmt.compute.v2019_12_01.models.SubResourceWithColocationStatus] - :ivar availability_sets: A list of references to all availability sets in the proximity - placement group. - :vartype availability_sets: - list[~azure.mgmt.compute.v2019_12_01.models.SubResourceWithColocationStatus] - :ivar colocation_status: Describes colocation status of the Proximity Placement Group. - :vartype colocation_status: ~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "virtual_machines": {"readonly": True}, - "virtual_machine_scale_sets": {"readonly": True}, - "availability_sets": {"readonly": 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}"}, - "proximity_placement_group_type": {"key": "properties.proximityPlacementGroupType", "type": "str"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResourceWithColocationStatus]"}, - "virtual_machine_scale_sets": { - "key": "properties.virtualMachineScaleSets", - "type": "[SubResourceWithColocationStatus]", - }, - "availability_sets": {"key": "properties.availabilitySets", "type": "[SubResourceWithColocationStatus]"}, - "colocation_status": {"key": "properties.colocationStatus", "type": "InstanceViewStatus"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, - colocation_status: Optional["_models.InstanceViewStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Standard** : - Co-locate resources within an Azure region or Availability Zone. :code:`
    `\\ :code:`
    ` - **Ultra** : For future use. Known values are: "Standard" and "Ultra". - :paramtype proximity_placement_group_type: str or - ~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroupType - :keyword colocation_status: Describes colocation status of the Proximity Placement Group. - :paramtype colocation_status: ~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus - """ - super().__init__(location=location, tags=tags, **kwargs) - self.proximity_placement_group_type = proximity_placement_group_type - self.virtual_machines: Optional[List["_models.SubResourceWithColocationStatus"]] = None - self.virtual_machine_scale_sets: Optional[List["_models.SubResourceWithColocationStatus"]] = None - self.availability_sets: Optional[List["_models.SubResourceWithColocationStatus"]] = None - self.colocation_status = colocation_status - - -class ProximityPlacementGroupListResult(_serialization.Model): - """The List Proximity Placement Group operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of proximity placement groups. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroup] - :ivar next_link: The URI to fetch the next page of proximity placement groups. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ProximityPlacementGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of proximity placement groups. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroup] - :keyword next_link: The URI to fetch the next page of proximity placement groups. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ProximityPlacementGroupUpdate(UpdateResource): - """Specifies information about the proximity placement group. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - -class PurchasePlan(_serialization.Model): - """Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. - - All required parameters must be populated in order to send to server. - - :ivar publisher: The publisher ID. Required. - :vartype publisher: str - :ivar name: The plan ID. Required. - :vartype name: 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 - """ - - _validation = { - "publisher": {"required": True}, - "name": {"required": True}, - "product": {"required": True}, - } - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "product": {"key": "product", "type": "str"}, - } - - def __init__(self, *, publisher: str, name: str, product: str, **kwargs: Any) -> None: - """ - :keyword publisher: The publisher ID. Required. - :paramtype publisher: str - :keyword name: The plan ID. Required. - :paramtype name: 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 - """ - super().__init__(**kwargs) - self.publisher = publisher - self.name = name - self.product = product - - -class RecommendedMachineConfiguration(_serialization.Model): - """The properties describe the recommended machine configuration for this Image Definition. These - properties are updatable. - - :ivar v_cp_us: Describes the resource range. - :vartype v_cp_us: ~azure.mgmt.compute.v2019_12_01.models.ResourceRange - :ivar memory: Describes the resource range. - :vartype memory: ~azure.mgmt.compute.v2019_12_01.models.ResourceRange - """ - - _attribute_map = { - "v_cp_us": {"key": "vCPUs", "type": "ResourceRange"}, - "memory": {"key": "memory", "type": "ResourceRange"}, - } - - def __init__( - self, - *, - v_cp_us: Optional["_models.ResourceRange"] = None, - memory: Optional["_models.ResourceRange"] = None, - **kwargs: Any - ) -> None: - """ - :keyword v_cp_us: Describes the resource range. - :paramtype v_cp_us: ~azure.mgmt.compute.v2019_12_01.models.ResourceRange - :keyword memory: Describes the resource range. - :paramtype memory: ~azure.mgmt.compute.v2019_12_01.models.ResourceRange - """ - super().__init__(**kwargs) - self.v_cp_us = v_cp_us - self.memory = memory - - -class RecoveryWalkResponse(_serialization.Model): - """Response after calling a manual recovery walk. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar walk_performed: Whether the recovery walk was performed. - :vartype walk_performed: bool - :ivar next_platform_update_domain: The next update domain that needs to be walked. Null means - walk spanning all update domains has been completed. - :vartype next_platform_update_domain: int - """ - - _validation = { - "walk_performed": {"readonly": True}, - "next_platform_update_domain": {"readonly": True}, - } - - _attribute_map = { - "walk_performed": {"key": "walkPerformed", "type": "bool"}, - "next_platform_update_domain": {"key": "nextPlatformUpdateDomain", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.walk_performed: Optional[bool] = None - self.next_platform_update_domain: Optional[int] = None - - -class RegionalReplicationStatus(_serialization.Model): - """This is the regional replication status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar region: The region to which the gallery Image Version is being replicated to. - :vartype region: str - :ivar state: This is the regional replication state. Known values are: "Unknown", - "Replicating", "Completed", and "Failed". - :vartype state: str or ~azure.mgmt.compute.v2019_12_01.models.ReplicationState - :ivar details: The details of the replication status. - :vartype details: str - :ivar progress: It indicates progress of the replication job. - :vartype progress: int - """ - - _validation = { - "region": {"readonly": True}, - "state": {"readonly": True}, - "details": {"readonly": True}, - "progress": {"readonly": True}, - } - - _attribute_map = { - "region": {"key": "region", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "details": {"key": "details", "type": "str"}, - "progress": {"key": "progress", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.region: Optional[str] = None - self.state: Optional[Union[str, "_models.ReplicationState"]] = None - self.details: Optional[str] = None - self.progress: Optional[int] = None - - -class ReplicationStatus(_serialization.Model): - """This is the replication status of the gallery Image Version. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar aggregated_state: This is the aggregated replication status based on all the regional - replication status flags. Known values are: "Unknown", "InProgress", "Completed", and "Failed". - :vartype aggregated_state: str or - ~azure.mgmt.compute.v2019_12_01.models.AggregatedReplicationState - :ivar summary: This is a summary of replication status for each region. - :vartype summary: list[~azure.mgmt.compute.v2019_12_01.models.RegionalReplicationStatus] - """ - - _validation = { - "aggregated_state": {"readonly": True}, - "summary": {"readonly": True}, - } - - _attribute_map = { - "aggregated_state": {"key": "aggregatedState", "type": "str"}, - "summary": {"key": "summary", "type": "[RegionalReplicationStatus]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.aggregated_state: Optional[Union[str, "_models.AggregatedReplicationState"]] = None - self.summary: Optional[List["_models.RegionalReplicationStatus"]] = None - - -class RequestRateByIntervalInput(LogAnalyticsInputBase): - """Api request input for LogAnalytics getRequestRateByInterval Api. - - All required parameters must be populated in order to send to server. - - :ivar blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api - writes output logs to. Required. - :vartype blob_container_sas_uri: str - :ivar from_time: From time of the query. Required. - :vartype from_time: ~datetime.datetime - :ivar to_time: To time of the query. Required. - :vartype to_time: ~datetime.datetime - :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. - :vartype group_by_throttle_policy: bool - :ivar group_by_operation_name: Group query result by Operation Name. - :vartype group_by_operation_name: bool - :ivar group_by_resource_name: Group query result by Resource Name. - :vartype group_by_resource_name: bool - :ivar interval_length: Interval value in minutes used to create LogAnalytics call rate logs. - Required. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", and "SixtyMins". - :vartype interval_length: str or ~azure.mgmt.compute.v2019_12_01.models.IntervalInMins - """ - - _validation = { - "blob_container_sas_uri": {"required": True}, - "from_time": {"required": True}, - "to_time": {"required": True}, - "interval_length": {"required": True}, - } - - _attribute_map = { - "blob_container_sas_uri": {"key": "blobContainerSasUri", "type": "str"}, - "from_time": {"key": "fromTime", "type": "iso-8601"}, - "to_time": {"key": "toTime", "type": "iso-8601"}, - "group_by_throttle_policy": {"key": "groupByThrottlePolicy", "type": "bool"}, - "group_by_operation_name": {"key": "groupByOperationName", "type": "bool"}, - "group_by_resource_name": {"key": "groupByResourceName", "type": "bool"}, - "interval_length": {"key": "intervalLength", "type": "str"}, - } - - def __init__( - self, - *, - blob_container_sas_uri: str, - from_time: datetime.datetime, - to_time: datetime.datetime, - interval_length: Union[str, "_models.IntervalInMins"], - group_by_throttle_policy: Optional[bool] = None, - group_by_operation_name: Optional[bool] = None, - group_by_resource_name: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics - Api writes output logs to. Required. - :paramtype blob_container_sas_uri: str - :keyword from_time: From time of the query. Required. - :paramtype from_time: ~datetime.datetime - :keyword to_time: To time of the query. Required. - :paramtype to_time: ~datetime.datetime - :keyword group_by_throttle_policy: Group query result by Throttle Policy applied. - :paramtype group_by_throttle_policy: bool - :keyword group_by_operation_name: Group query result by Operation Name. - :paramtype group_by_operation_name: bool - :keyword group_by_resource_name: Group query result by Resource Name. - :paramtype group_by_resource_name: bool - :keyword interval_length: Interval value in minutes used to create LogAnalytics call rate logs. - Required. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", and "SixtyMins". - :paramtype interval_length: str or ~azure.mgmt.compute.v2019_12_01.models.IntervalInMins - """ - super().__init__( - blob_container_sas_uri=blob_container_sas_uri, - from_time=from_time, - to_time=to_time, - group_by_throttle_policy=group_by_throttle_policy, - group_by_operation_name=group_by_operation_name, - group_by_resource_name=group_by_resource_name, - **kwargs - ) - self.interval_length = interval_length - - -class ResourceRange(_serialization.Model): - """Describes the resource range. - - :ivar min: The minimum number of the resource. - :vartype min: int - :ivar max: The maximum number of the resource. - :vartype max: int - """ - - _attribute_map = { - "min": {"key": "min", "type": "int"}, - "max": {"key": "max", "type": "int"}, - } - - def __init__( - self, - *, - min: Optional[int] = None, # pylint: disable=redefined-builtin - max: Optional[int] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword min: The minimum number of the resource. - :paramtype min: int - :keyword max: The maximum number of the resource. - :paramtype max: int - """ - super().__init__(**kwargs) - self.min = min - self.max = max - - -class RollbackStatusInfo(_serialization.Model): - """Information about rollback on failed VM instances after a OS Upgrade operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar successfully_rolledback_instance_count: The number of instances which have been - successfully rolled back. - :vartype successfully_rolledback_instance_count: int - :ivar failed_rolledback_instance_count: The number of instances which failed to rollback. - :vartype failed_rolledback_instance_count: int - :ivar rollback_error: Error details if OS rollback failed. - :vartype rollback_error: ~azure.mgmt.compute.v2019_12_01.models.ApiError - """ - - _validation = { - "successfully_rolledback_instance_count": {"readonly": True}, - "failed_rolledback_instance_count": {"readonly": True}, - "rollback_error": {"readonly": True}, - } - - _attribute_map = { - "successfully_rolledback_instance_count": {"key": "successfullyRolledbackInstanceCount", "type": "int"}, - "failed_rolledback_instance_count": {"key": "failedRolledbackInstanceCount", "type": "int"}, - "rollback_error": {"key": "rollbackError", "type": "ApiError"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.successfully_rolledback_instance_count: Optional[int] = None - self.failed_rolledback_instance_count: Optional[int] = None - self.rollback_error: Optional["_models.ApiError"] = None - - -class RollingUpgradePolicy(_serialization.Model): - """The configuration parameters used while performing a rolling upgrade. - - :ivar max_batch_instance_percent: The maximum percent of total virtual machine instances that - will be upgraded simultaneously by the rolling upgrade in one batch. As this is a maximum, - unhealthy instances in previous or future batches can cause the percentage of instances in a - batch to decrease to ensure higher reliability. The default value for this parameter is 20%. - :vartype max_batch_instance_percent: int - :ivar max_unhealthy_instance_percent: The maximum percentage of the total virtual machine - instances in the scale set that can be simultaneously unhealthy, either as a result of being - upgraded, or by being found in an unhealthy state by the virtual machine health checks before - the rolling upgrade aborts. This constraint will be checked prior to starting any batch. The - default value for this parameter is 20%. - :vartype max_unhealthy_instance_percent: int - :ivar max_unhealthy_upgraded_instance_percent: The maximum percentage of upgraded virtual - machine instances that can be found to be in an unhealthy state. This check will happen after - each batch is upgraded. If this percentage is ever exceeded, the rolling update aborts. The - default value for this parameter is 20%. - :vartype max_unhealthy_upgraded_instance_percent: int - :ivar pause_time_between_batches: The wait time between completing the update for all virtual - machines in one batch and starting the next batch. The time duration should be specified in ISO - 8601 format. The default value is 0 seconds (PT0S). - :vartype pause_time_between_batches: str - """ - - _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}, - } - - _attribute_map = { - "max_batch_instance_percent": {"key": "maxBatchInstancePercent", "type": "int"}, - "max_unhealthy_instance_percent": {"key": "maxUnhealthyInstancePercent", "type": "int"}, - "max_unhealthy_upgraded_instance_percent": {"key": "maxUnhealthyUpgradedInstancePercent", "type": "int"}, - "pause_time_between_batches": {"key": "pauseTimeBetweenBatches", "type": "str"}, - } - - def __init__( - self, - *, - max_batch_instance_percent: Optional[int] = None, - max_unhealthy_instance_percent: Optional[int] = None, - max_unhealthy_upgraded_instance_percent: Optional[int] = None, - pause_time_between_batches: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword max_batch_instance_percent: The maximum percent of total virtual machine instances - that will be upgraded simultaneously by the rolling upgrade in one batch. As this is a maximum, - unhealthy instances in previous or future batches can cause the percentage of instances in a - batch to decrease to ensure higher reliability. The default value for this parameter is 20%. - :paramtype max_batch_instance_percent: int - :keyword max_unhealthy_instance_percent: The maximum percentage of the total virtual machine - instances in the scale set that can be simultaneously unhealthy, either as a result of being - upgraded, or by being found in an unhealthy state by the virtual machine health checks before - the rolling upgrade aborts. This constraint will be checked prior to starting any batch. The - default value for this parameter is 20%. - :paramtype max_unhealthy_instance_percent: int - :keyword max_unhealthy_upgraded_instance_percent: The maximum percentage of upgraded virtual - machine instances that can be found to be in an unhealthy state. This check will happen after - each batch is upgraded. If this percentage is ever exceeded, the rolling update aborts. The - default value for this parameter is 20%. - :paramtype max_unhealthy_upgraded_instance_percent: int - :keyword pause_time_between_batches: The wait time between completing the update for all - virtual machines in one batch and starting the next batch. The time duration should be - specified in ISO 8601 format. The default value is 0 seconds (PT0S). - :paramtype pause_time_between_batches: str - """ - super().__init__(**kwargs) - self.max_batch_instance_percent = max_batch_instance_percent - self.max_unhealthy_instance_percent = max_unhealthy_instance_percent - self.max_unhealthy_upgraded_instance_percent = max_unhealthy_upgraded_instance_percent - self.pause_time_between_batches = pause_time_between_batches - - -class RollingUpgradeProgressInfo(_serialization.Model): - """Information about the number of virtual machine instances in each upgrade state. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar successful_instance_count: The number of instances that have been successfully upgraded. - :vartype successful_instance_count: int - :ivar failed_instance_count: The number of instances that have failed to be upgraded - successfully. - :vartype failed_instance_count: int - :ivar in_progress_instance_count: The number of instances that are currently being upgraded. - :vartype in_progress_instance_count: int - :ivar pending_instance_count: The number of instances that have not yet begun to be upgraded. - :vartype pending_instance_count: int - """ - - _validation = { - "successful_instance_count": {"readonly": True}, - "failed_instance_count": {"readonly": True}, - "in_progress_instance_count": {"readonly": True}, - "pending_instance_count": {"readonly": True}, - } - - _attribute_map = { - "successful_instance_count": {"key": "successfulInstanceCount", "type": "int"}, - "failed_instance_count": {"key": "failedInstanceCount", "type": "int"}, - "in_progress_instance_count": {"key": "inProgressInstanceCount", "type": "int"}, - "pending_instance_count": {"key": "pendingInstanceCount", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.successful_instance_count: Optional[int] = None - self.failed_instance_count: Optional[int] = None - self.in_progress_instance_count: Optional[int] = None - self.pending_instance_count: Optional[int] = None - - -class RollingUpgradeRunningStatus(_serialization.Model): - """Information about the current running state of the overall upgrade. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Code indicating the current status of the upgrade. Known values are: - "RollingForward", "Cancelled", "Completed", and "Faulted". - :vartype code: str or ~azure.mgmt.compute.v2019_12_01.models.RollingUpgradeStatusCode - :ivar start_time: Start time of the upgrade. - :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start" - and "Cancel". - :vartype last_action: str or ~azure.mgmt.compute.v2019_12_01.models.RollingUpgradeActionType - :ivar last_action_time: Last action time of the upgrade. - :vartype last_action_time: ~datetime.datetime - """ - - _validation = { - "code": {"readonly": True}, - "start_time": {"readonly": True}, - "last_action": {"readonly": True}, - "last_action_time": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "last_action": {"key": "lastAction", "type": "str"}, - "last_action_time": {"key": "lastActionTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[Union[str, "_models.RollingUpgradeStatusCode"]] = None - self.start_time: Optional[datetime.datetime] = None - self.last_action: Optional[Union[str, "_models.RollingUpgradeActionType"]] = None - self.last_action_time: Optional[datetime.datetime] = None - - -class RollingUpgradeStatusInfo(Resource): - """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. - :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] - :ivar policy: The rolling upgrade policies applied for this upgrade. - :vartype policy: ~azure.mgmt.compute.v2019_12_01.models.RollingUpgradePolicy - :ivar running_status: Information about the current running state of the overall upgrade. - :vartype running_status: ~azure.mgmt.compute.v2019_12_01.models.RollingUpgradeRunningStatus - :ivar progress: Information about the number of virtual machine instances in each upgrade - state. - :vartype progress: ~azure.mgmt.compute.v2019_12_01.models.RollingUpgradeProgressInfo - :ivar error: Error details for this upgrade, if there are any. - :vartype error: ~azure.mgmt.compute.v2019_12_01.models.ApiError - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "policy": {"readonly": True}, - "running_status": {"readonly": True}, - "progress": {"readonly": True}, - "error": {"readonly": 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}"}, - "policy": {"key": "properties.policy", "type": "RollingUpgradePolicy"}, - "running_status": {"key": "properties.runningStatus", "type": "RollingUpgradeRunningStatus"}, - "progress": {"key": "properties.progress", "type": "RollingUpgradeProgressInfo"}, - "error": {"key": "properties.error", "type": "ApiError"}, - } - - 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__(location=location, tags=tags, **kwargs) - self.policy: Optional["_models.RollingUpgradePolicy"] = None - self.running_status: Optional["_models.RollingUpgradeRunningStatus"] = None - self.progress: Optional["_models.RollingUpgradeProgressInfo"] = None - self.error: Optional["_models.ApiError"] = None - - -class RunCommandDocumentBase(_serialization.Model): - """Describes the properties of a Run Command metadata. - - All required parameters must be populated in order to send to server. - - :ivar schema: The VM run command schema. Required. - :vartype schema: str - :ivar id: The VM run command id. Required. - :vartype id: str - :ivar os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - :ivar label: The VM run command label. Required. - :vartype label: str - :ivar description: The VM run command description. Required. - :vartype description: str - """ - - _validation = { - "schema": {"required": True}, - "id": {"required": True}, - "os_type": {"required": True}, - "label": {"required": True}, - "description": {"required": True}, - } - - _attribute_map = { - "schema": {"key": "$schema", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "os_type": {"key": "osType", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - schema: str, - id: str, # pylint: disable=redefined-builtin - os_type: Union[str, "_models.OperatingSystemTypes"], - label: str, - description: str, - **kwargs: Any - ) -> None: - """ - :keyword schema: The VM run command schema. Required. - :paramtype schema: str - :keyword id: The VM run command id. Required. - :paramtype id: str - :keyword os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - :keyword label: The VM run command label. Required. - :paramtype label: str - :keyword description: The VM run command description. Required. - :paramtype description: str - """ - super().__init__(**kwargs) - self.schema = schema - self.id = id - self.os_type = os_type - self.label = label - self.description = description - - -class RunCommandDocument(RunCommandDocumentBase): - """Describes the properties of a Run Command. - - All required parameters must be populated in order to send to server. - - :ivar schema: The VM run command schema. Required. - :vartype schema: str - :ivar id: The VM run command id. Required. - :vartype id: str - :ivar os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - :ivar label: The VM run command label. Required. - :vartype label: str - :ivar description: The VM run command description. Required. - :vartype description: str - :ivar script: The script to be executed. Required. - :vartype script: list[str] - :ivar parameters: The parameters used by the script. - :vartype parameters: list[~azure.mgmt.compute.v2019_12_01.models.RunCommandParameterDefinition] - """ - - _validation = { - "schema": {"required": True}, - "id": {"required": True}, - "os_type": {"required": True}, - "label": {"required": True}, - "description": {"required": True}, - "script": {"required": True}, - } - - _attribute_map = { - "schema": {"key": "$schema", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "os_type": {"key": "osType", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "script": {"key": "script", "type": "[str]"}, - "parameters": {"key": "parameters", "type": "[RunCommandParameterDefinition]"}, - } - - def __init__( - self, - *, - schema: str, - id: str, # pylint: disable=redefined-builtin - os_type: Union[str, "_models.OperatingSystemTypes"], - label: str, - description: str, - script: List[str], - parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword schema: The VM run command schema. Required. - :paramtype schema: str - :keyword id: The VM run command id. Required. - :paramtype id: str - :keyword os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - :keyword label: The VM run command label. Required. - :paramtype label: str - :keyword description: The VM run command description. Required. - :paramtype description: str - :keyword script: The script to be executed. Required. - :paramtype script: list[str] - :keyword parameters: The parameters used by the script. - :paramtype parameters: - list[~azure.mgmt.compute.v2019_12_01.models.RunCommandParameterDefinition] - """ - super().__init__(schema=schema, id=id, os_type=os_type, label=label, description=description, **kwargs) - self.script = script - self.parameters = parameters - - -class RunCommandInput(_serialization.Model): - """Capture Virtual Machine parameters. - - All required parameters must be populated in order to send to server. - - :ivar command_id: The run command id. Required. - :vartype command_id: str - :ivar script: Optional. The script to be executed. When this value is given, the given script - will override the default script of the command. - :vartype script: list[str] - :ivar parameters: The run command parameters. - :vartype parameters: list[~azure.mgmt.compute.v2019_12_01.models.RunCommandInputParameter] - """ - - _validation = { - "command_id": {"required": True}, - } - - _attribute_map = { - "command_id": {"key": "commandId", "type": "str"}, - "script": {"key": "script", "type": "[str]"}, - "parameters": {"key": "parameters", "type": "[RunCommandInputParameter]"}, - } - - def __init__( - self, - *, - command_id: str, - script: Optional[List[str]] = None, - parameters: Optional[List["_models.RunCommandInputParameter"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword command_id: The run command id. Required. - :paramtype command_id: str - :keyword script: Optional. The script to be executed. When this value is given, the given - script will override the default script of the command. - :paramtype script: list[str] - :keyword parameters: The run command parameters. - :paramtype parameters: list[~azure.mgmt.compute.v2019_12_01.models.RunCommandInputParameter] - """ - super().__init__(**kwargs) - self.command_id = command_id - self.script = script - self.parameters = parameters - - -class RunCommandInputParameter(_serialization.Model): - """Describes the properties of a run command parameter. - - All required parameters must be populated in order to send to server. - - :ivar name: The run command parameter name. Required. - :vartype name: str - :ivar value: The run command parameter value. Required. - :vartype value: str - """ - - _validation = { - "name": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: - """ - :keyword name: The run command parameter name. Required. - :paramtype name: str - :keyword value: The run command parameter value. Required. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class RunCommandListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine run commands. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.RunCommandDocumentBase] - :ivar next_link: The uri to fetch the next page of run commands. Call ListNext() with this to - fetch the next page of run commands. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RunCommandDocumentBase]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine run commands. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.RunCommandDocumentBase] - :keyword next_link: The uri to fetch the next page of run commands. Call ListNext() with this - to fetch the next page of run commands. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RunCommandParameterDefinition(_serialization.Model): - """Describes the properties of a run command parameter. - - All required parameters must be populated in order to send to server. - - :ivar name: The run command parameter name. Required. - :vartype name: str - :ivar type: The run command parameter type. Required. - :vartype type: str - :ivar default_value: The run command parameter default value. - :vartype default_value: str - :ivar required: The run command parameter required. - :vartype required: bool - """ - - _validation = { - "name": {"required": True}, - "type": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "default_value": {"key": "defaultValue", "type": "str"}, - "required": {"key": "required", "type": "bool"}, - } - - def __init__( - self, *, name: str, type: str, default_value: Optional[str] = None, required: bool = False, **kwargs: Any - ) -> None: - """ - :keyword name: The run command parameter name. Required. - :paramtype name: str - :keyword type: The run command parameter type. Required. - :paramtype type: str - :keyword default_value: The run command parameter default value. - :paramtype default_value: str - :keyword required: The run command parameter required. - :paramtype required: bool - """ - super().__init__(**kwargs) - self.name = name - self.type = type - self.default_value = default_value - self.required = required - - -class RunCommandResult(_serialization.Model): - """RunCommandResult. - - :ivar value: Run command operation response. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[InstanceViewStatus]"}, - } - - def __init__(self, *, value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Run command operation response. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.value = value - - -class ScaleInPolicy(_serialization.Model): - """Describes a scale-in policy for a virtual machine scale set. - - :ivar rules: The rules to be followed when scaling-in a virtual machine scale set. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Default** When a - virtual machine scale set is scaled in, the scale set will first be balanced across zones if it - is a zonal scale set. Then, it will be balanced across Fault Domains as far as possible. Within - each Fault Domain, the virtual machines chosen for removal will be the newest ones that are not - protected from scale-in. :code:`
    `\\ :code:`
    ` **OldestVM** When a virtual machine scale - set is being scaled-in, the oldest virtual machines that are not protected from scale-in will - be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the oldest virtual machines that are not protected - will be chosen for removal. :code:`
    `\\ :code:`
    ` **NewestVM** When a virtual machine - scale set is being scaled-in, the newest virtual machines that are not protected from scale-in - will be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the newest virtual machines that are not protected - will be chosen for removal. :code:`
    `\\ :code:`
    `. - :vartype rules: list[str or - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetScaleInRules] - """ - - _attribute_map = { - "rules": {"key": "rules", "type": "[str]"}, - } - - def __init__( - self, *, rules: Optional[List[Union[str, "_models.VirtualMachineScaleSetScaleInRules"]]] = None, **kwargs: Any - ) -> None: - """ - :keyword rules: The rules to be followed when scaling-in a virtual machine scale set. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Default** When a - virtual machine scale set is scaled in, the scale set will first be balanced across zones if it - is a zonal scale set. Then, it will be balanced across Fault Domains as far as possible. Within - each Fault Domain, the virtual machines chosen for removal will be the newest ones that are not - protected from scale-in. :code:`
    `\\ :code:`
    ` **OldestVM** When a virtual machine scale - set is being scaled-in, the oldest virtual machines that are not protected from scale-in will - be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the oldest virtual machines that are not protected - will be chosen for removal. :code:`
    `\\ :code:`
    ` **NewestVM** When a virtual machine - scale set is being scaled-in, the newest virtual machines that are not protected from scale-in - will be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the newest virtual machines that are not protected - will be chosen for removal. :code:`
    `\\ :code:`
    `. - :paramtype rules: list[str or - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetScaleInRules] - """ - super().__init__(**kwargs) - self.rules = rules - - -class ScheduledEventsProfile(_serialization.Model): - """ScheduledEventsProfile. - - :ivar terminate_notification_profile: Specifies Terminate Scheduled Event related - configurations. - :vartype terminate_notification_profile: - ~azure.mgmt.compute.v2019_12_01.models.TerminateNotificationProfile - """ - - _attribute_map = { - "terminate_notification_profile": { - "key": "terminateNotificationProfile", - "type": "TerminateNotificationProfile", - }, - } - - def __init__( - self, *, terminate_notification_profile: Optional["_models.TerminateNotificationProfile"] = None, **kwargs: Any - ) -> None: - """ - :keyword terminate_notification_profile: Specifies Terminate Scheduled Event related - configurations. - :paramtype terminate_notification_profile: - ~azure.mgmt.compute.v2019_12_01.models.TerminateNotificationProfile - """ - super().__init__(**kwargs) - self.terminate_notification_profile = terminate_notification_profile - - -class Sku(_serialization.Model): - """Describes a virtual machine scale set sku. NOTE: If the new VM SKU is not supported on the - hardware the scale set is currently on, you need to deallocate the VMs in the scale set before - you modify the SKU name. - - :ivar name: The sku name. - :vartype name: str - :ivar tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
    `\\ - :code:`
    ` Possible Values:\\ :code:`
    `\\ :code:`
    ` **Standard**\\ :code:`
    `\\ :code:`
    ` **Basic**. - :vartype tier: str - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: int - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "capacity": {"key": "capacity", "type": "int"}, - } - - def __init__( - self, *, name: Optional[str] = None, tier: Optional[str] = None, capacity: Optional[int] = None, **kwargs: Any - ) -> None: - """ - :keyword name: The sku name. - :paramtype name: str - :keyword tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
    `\\ - :code:`
    ` Possible Values:\\ :code:`
    `\\ :code:`
    ` **Standard**\\ :code:`
    `\\ :code:`
    ` **Basic**. - :paramtype tier: str - :keyword capacity: Specifies the number of virtual machines in the scale set. - :paramtype capacity: int - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - self.capacity = capacity - - -class SshConfiguration(_serialization.Model): - """SSH configuration for Linux based VMs running on Azure. - - :ivar public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :vartype public_keys: list[~azure.mgmt.compute.v2019_12_01.models.SshPublicKey] - """ - - _attribute_map = { - "public_keys": {"key": "publicKeys", "type": "[SshPublicKey]"}, - } - - def __init__(self, *, public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs: Any) -> None: - """ - :keyword public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :paramtype public_keys: list[~azure.mgmt.compute.v2019_12_01.models.SshPublicKey] - """ - super().__init__(**kwargs) - self.public_keys = public_keys - - -class SshPublicKey(_serialization.Model): - """Contains information about SSH certificate public key and the path on the Linux VM where the - public key is placed. - - :ivar path: Specifies the full path on the created VM where ssh public key is stored. If the - file already exists, the specified key is appended to the file. Example: - /home/user/.ssh/authorized_keys. - :vartype path: str - :ivar key_data: SSH public key certificate used to authenticate with the VM through ssh. The - key needs to be at least 2048-bit and in ssh-rsa format. :code:`
    `\\ :code:`
    ` For - creating ssh keys, see `Create SSH keys on Linux and Mac for Linux VMs in Azure - `_. - :vartype key_data: str - """ - - _attribute_map = { - "path": {"key": "path", "type": "str"}, - "key_data": {"key": "keyData", "type": "str"}, - } - - def __init__(self, *, path: Optional[str] = None, key_data: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword path: Specifies the full path on the created VM where ssh public key is stored. If the - file already exists, the specified key is appended to the file. Example: - /home/user/.ssh/authorized_keys. - :paramtype path: str - :keyword key_data: SSH public key certificate used to authenticate with the VM through ssh. The - key needs to be at least 2048-bit and in ssh-rsa format. :code:`
    `\\ :code:`
    ` For - creating ssh keys, see `Create SSH keys on Linux and Mac for Linux VMs in Azure - `_. - :paramtype key_data: str - """ - super().__init__(**kwargs) - self.path = path - self.key_data = key_data - - -class SshPublicKeyGenerateKeyPairResult(_serialization.Model): - """Response from generation of an SSH key pair. - - All required parameters must be populated in order to send to server. - - :ivar private_key: Private key portion of the key pair used to authenticate to a virtual - machine through ssh. The private key is returned in RFC3447 format and should be treated as a - secret. Required. - :vartype private_key: str - :ivar public_key: Public key portion of the key pair used to authenticate to a virtual machine - through ssh. The public key is in ssh-rsa format. Required. - :vartype public_key: str - :ivar id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{SshPublicKeyName}. - Required. - :vartype id: str - """ - - _validation = { - "private_key": {"required": True}, - "public_key": {"required": True}, - "id": {"required": True}, - } - - _attribute_map = { - "private_key": {"key": "privateKey", "type": "str"}, - "public_key": {"key": "publicKey", "type": "str"}, - "id": {"key": "id", "type": "str"}, - } - - def __init__( - self, *, private_key: str, public_key: str, id: str, **kwargs: Any # pylint: disable=redefined-builtin - ) -> None: - """ - :keyword private_key: Private key portion of the key pair used to authenticate to a virtual - machine through ssh. The private key is returned in RFC3447 format and should be treated as a - secret. Required. - :paramtype private_key: str - :keyword public_key: Public key portion of the key pair used to authenticate to a virtual - machine through ssh. The public key is in ssh-rsa format. Required. - :paramtype public_key: str - :keyword id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{SshPublicKeyName}. - Required. - :paramtype id: str - """ - super().__init__(**kwargs) - self.private_key = private_key - self.public_key = public_key - self.id = id - - -class SshPublicKeyResource(Resource): - """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. - :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] - :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, - the provided public key needs to be at least 2048-bit and in ssh-rsa format. - :vartype public_key: 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}"}, - "public_key": {"key": "properties.publicKey", "type": "str"}, - } - - 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 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) - self.public_key = public_key - - -class SshPublicKeysGroupListResult(_serialization.Model): - """The list SSH public keys operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of SSH public keys. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.SshPublicKeyResource] - :ivar next_link: The URI to fetch the next page of SSH public keys. Call ListNext() with this - URI to fetch the next page of SSH public keys. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SshPublicKeyResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.SshPublicKeyResource"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of SSH public keys. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.SshPublicKeyResource] - :keyword next_link: The URI to fetch the next page of SSH public keys. Call ListNext() with - this URI to fetch the next page of SSH public keys. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SshPublicKeyUpdateResource(UpdateResource): - """Specifies information about the SSH public key. - - :ivar tags: Resource tags. - :vartype tags: dict[str, 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, - the provided public key needs to be at least 2048-bit and in ssh-rsa format. - :vartype public_key: str - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "public_key": {"key": "properties.publicKey", "type": "str"}, - } - - def __init__( - self, *, tags: Optional[Dict[str, str]] = None, public_key: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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__(tags=tags, **kwargs) - self.public_key = public_key - - -class StorageProfile(_serialization.Model): - """Specifies the storage settings for the virtual machine disks. - - :ivar image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :vartype image_reference: ~azure.mgmt.compute.v2019_12_01.models.ImageReference - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2019_12_01.models.OSDisk - :ivar data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype data_disks: list[~azure.mgmt.compute.v2019_12_01.models.DataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "OSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[DataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.OSDisk"] = None, - data_disks: Optional[List["_models.DataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :paramtype image_reference: ~azure.mgmt.compute.v2019_12_01.models.ImageReference - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2019_12_01.models.OSDisk - :keyword data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype data_disks: list[~azure.mgmt.compute.v2019_12_01.models.DataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class SubResourceReadOnly(_serialization.Model): - """SubResourceReadOnly. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class SubResourceWithColocationStatus(SubResource): - """SubResourceWithColocationStatus. - - :ivar id: Resource Id. - :vartype id: str - :ivar colocation_status: Describes colocation status of a resource in the Proximity Placement - Group. - :vartype colocation_status: ~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "colocation_status": {"key": "colocationStatus", "type": "InstanceViewStatus"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - colocation_status: Optional["_models.InstanceViewStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword colocation_status: Describes colocation status of a resource in the Proximity - Placement Group. - :paramtype colocation_status: ~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus - """ - super().__init__(id=id, **kwargs) - self.colocation_status = colocation_status - - -class TargetRegion(_serialization.Model): - """Describes the target region information. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the region. Required. - :vartype name: str - :ivar regional_replica_count: The number of replicas of the Image Version to be created per - region. This property is updatable. - :vartype regional_replica_count: int - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountType - :ivar encryption: Optional. Allows users to provide customer managed keys for encrypting the OS - and data disks in the gallery artifact. - :vartype encryption: ~azure.mgmt.compute.v2019_12_01.models.EncryptionImages - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "regional_replica_count": {"key": "regionalReplicaCount", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "encryption": {"key": "encryption", "type": "EncryptionImages"}, - } - - def __init__( - self, - *, - name: str, - regional_replica_count: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - encryption: Optional["_models.EncryptionImages"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the region. Required. - :paramtype name: str - :keyword regional_replica_count: The number of replicas of the Image Version to be created per - region. This property is updatable. - :paramtype regional_replica_count: int - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2019_12_01.models.StorageAccountType - :keyword encryption: Optional. Allows users to provide customer managed keys for encrypting the - OS and data disks in the gallery artifact. - :paramtype encryption: ~azure.mgmt.compute.v2019_12_01.models.EncryptionImages - """ - super().__init__(**kwargs) - self.name = name - self.regional_replica_count = regional_replica_count - self.storage_account_type = storage_account_type - self.encryption = encryption - - -class TerminateNotificationProfile(_serialization.Model): - """TerminateNotificationProfile. - - :ivar not_before_timeout: Configurable length of time a Virtual Machine being deleted will have - to potentially approve the Terminate Scheduled Event before the event is auto approved (timed - out). The configuration must be specified in ISO 8601 format, the default value is 5 minutes - (PT5M). - :vartype not_before_timeout: str - :ivar enable: Specifies whether the Terminate Scheduled event is enabled or disabled. - :vartype enable: bool - """ - - _attribute_map = { - "not_before_timeout": {"key": "notBeforeTimeout", "type": "str"}, - "enable": {"key": "enable", "type": "bool"}, - } - - def __init__( - self, *, not_before_timeout: Optional[str] = None, enable: Optional[bool] = None, **kwargs: Any - ) -> None: - """ - :keyword not_before_timeout: Configurable length of time a Virtual Machine being deleted will - have to potentially approve the Terminate Scheduled Event before the event is auto approved - (timed out). The configuration must be specified in ISO 8601 format, the default value is 5 - minutes (PT5M). - :paramtype not_before_timeout: str - :keyword enable: Specifies whether the Terminate Scheduled event is enabled or disabled. - :paramtype enable: bool - """ - super().__init__(**kwargs) - self.not_before_timeout = not_before_timeout - self.enable = enable - - -class ThrottledRequestsInput(LogAnalyticsInputBase): - """Api request input for LogAnalytics getThrottledRequests Api. - - All required parameters must be populated in order to send to server. - - :ivar blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api - writes output logs to. Required. - :vartype blob_container_sas_uri: str - :ivar from_time: From time of the query. Required. - :vartype from_time: ~datetime.datetime - :ivar to_time: To time of the query. Required. - :vartype to_time: ~datetime.datetime - :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. - :vartype group_by_throttle_policy: bool - :ivar group_by_operation_name: Group query result by Operation Name. - :vartype group_by_operation_name: bool - :ivar group_by_resource_name: Group query result by Resource Name. - :vartype group_by_resource_name: bool - """ - - -class UpgradeOperationHistoricalStatusInfo(_serialization.Model): - """Virtual Machine Scale Set OS Upgrade History operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar properties: Information about the properties of the upgrade operation. - :vartype properties: - ~azure.mgmt.compute.v2019_12_01.models.UpgradeOperationHistoricalStatusInfoProperties - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - """ - - _validation = { - "properties": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "properties": {"key": "properties", "type": "UpgradeOperationHistoricalStatusInfoProperties"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.properties: Optional["_models.UpgradeOperationHistoricalStatusInfoProperties"] = None - self.type: Optional[str] = None - self.location: Optional[str] = None - - -class UpgradeOperationHistoricalStatusInfoProperties(_serialization.Model): # pylint: disable=name-too-long - """Describes each OS upgrade on the Virtual Machine Scale Set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar running_status: Information about the overall status of the upgrade operation. - :vartype running_status: ~azure.mgmt.compute.v2019_12_01.models.UpgradeOperationHistoryStatus - :ivar progress: Counts of the VMs in each state. - :vartype progress: ~azure.mgmt.compute.v2019_12_01.models.RollingUpgradeProgressInfo - :ivar error: Error Details for this upgrade if there are any. - :vartype error: ~azure.mgmt.compute.v2019_12_01.models.ApiError - :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", and - "Platform". - :vartype started_by: str or ~azure.mgmt.compute.v2019_12_01.models.UpgradeOperationInvoker - :ivar target_image_reference: Image Reference details. - :vartype target_image_reference: ~azure.mgmt.compute.v2019_12_01.models.ImageReference - :ivar rollback_info: Information about OS rollback if performed. - :vartype rollback_info: ~azure.mgmt.compute.v2019_12_01.models.RollbackStatusInfo - """ - - _validation = { - "running_status": {"readonly": True}, - "progress": {"readonly": True}, - "error": {"readonly": True}, - "started_by": {"readonly": True}, - "target_image_reference": {"readonly": True}, - "rollback_info": {"readonly": True}, - } - - _attribute_map = { - "running_status": {"key": "runningStatus", "type": "UpgradeOperationHistoryStatus"}, - "progress": {"key": "progress", "type": "RollingUpgradeProgressInfo"}, - "error": {"key": "error", "type": "ApiError"}, - "started_by": {"key": "startedBy", "type": "str"}, - "target_image_reference": {"key": "targetImageReference", "type": "ImageReference"}, - "rollback_info": {"key": "rollbackInfo", "type": "RollbackStatusInfo"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.running_status: Optional["_models.UpgradeOperationHistoryStatus"] = None - self.progress: Optional["_models.RollingUpgradeProgressInfo"] = None - self.error: Optional["_models.ApiError"] = None - self.started_by: Optional[Union[str, "_models.UpgradeOperationInvoker"]] = None - self.target_image_reference: Optional["_models.ImageReference"] = None - self.rollback_info: Optional["_models.RollbackStatusInfo"] = None - - -class UpgradeOperationHistoryStatus(_serialization.Model): - """Information about the current running state of the overall upgrade. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Code indicating the current status of the upgrade. Known values are: - "RollingForward", "Cancelled", "Completed", and "Faulted". - :vartype code: str or ~azure.mgmt.compute.v2019_12_01.models.UpgradeState - :ivar start_time: Start time of the upgrade. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the upgrade. - :vartype end_time: ~datetime.datetime - """ - - _validation = { - "code": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[Union[str, "_models.UpgradeState"]] = None - self.start_time: Optional[datetime.datetime] = None - self.end_time: Optional[datetime.datetime] = None - - -class UpgradePolicy(_serialization.Model): - """Describes an upgrade policy - automatic, manual, or rolling. - - :ivar mode: Specifies the mode of an upgrade to virtual machines in the scale set.\\ :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Manual** - You - control the application of updates to virtual machines in the scale set. You do this by using - the manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - All virtual - machines in the scale set are automatically updated at the same time. Known values are: - "Automatic", "Manual", and "Rolling". - :vartype mode: str or ~azure.mgmt.compute.v2019_12_01.models.UpgradeMode - :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling - upgrade. - :vartype rolling_upgrade_policy: ~azure.mgmt.compute.v2019_12_01.models.RollingUpgradePolicy - :ivar automatic_os_upgrade_policy: Configuration parameters used for performing automatic OS - Upgrade. - :vartype automatic_os_upgrade_policy: - ~azure.mgmt.compute.v2019_12_01.models.AutomaticOSUpgradePolicy - """ - - _attribute_map = { - "mode": {"key": "mode", "type": "str"}, - "rolling_upgrade_policy": {"key": "rollingUpgradePolicy", "type": "RollingUpgradePolicy"}, - "automatic_os_upgrade_policy": {"key": "automaticOSUpgradePolicy", "type": "AutomaticOSUpgradePolicy"}, - } - - def __init__( - self, - *, - mode: Optional[Union[str, "_models.UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, - automatic_os_upgrade_policy: Optional["_models.AutomaticOSUpgradePolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword mode: Specifies the mode of an upgrade to virtual machines in the scale set.\\ - :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` - **Manual** - You control the application of updates to virtual machines in the scale set. You - do this by using the manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - - All virtual machines in the scale set are automatically updated at the same time. Known values - are: "Automatic", "Manual", and "Rolling". - :paramtype mode: str or ~azure.mgmt.compute.v2019_12_01.models.UpgradeMode - :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling - upgrade. - :paramtype rolling_upgrade_policy: ~azure.mgmt.compute.v2019_12_01.models.RollingUpgradePolicy - :keyword automatic_os_upgrade_policy: Configuration parameters used for performing automatic OS - Upgrade. - :paramtype automatic_os_upgrade_policy: - ~azure.mgmt.compute.v2019_12_01.models.AutomaticOSUpgradePolicy - """ - super().__init__(**kwargs) - self.mode = mode - self.rolling_upgrade_policy = rolling_upgrade_policy - self.automatic_os_upgrade_policy = automatic_os_upgrade_policy - - -class Usage(_serialization.Model): - """Describes Compute Resource Usage. - - 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 unit: An enum describing the unit of usage measurement. Required. Default value is - "Count". - :vartype unit: str - :ivar current_value: The current usage of the resource. Required. - :vartype current_value: int - :ivar limit: The maximum permitted usage of the resource. Required. - :vartype limit: int - :ivar name: The name of the type of usage. Required. - :vartype name: ~azure.mgmt.compute.v2019_12_01.models.UsageName - """ - - _validation = { - "unit": {"required": True, "constant": True}, - "current_value": {"required": True}, - "limit": {"required": True}, - "name": {"required": True}, - } - - _attribute_map = { - "unit": {"key": "unit", "type": "str"}, - "current_value": {"key": "currentValue", "type": "int"}, - "limit": {"key": "limit", "type": "int"}, - "name": {"key": "name", "type": "UsageName"}, - } - - unit = "Count" - - def __init__(self, *, current_value: int, limit: int, name: "_models.UsageName", **kwargs: Any) -> None: - """ - :keyword current_value: The current usage of the resource. Required. - :paramtype current_value: int - :keyword limit: The maximum permitted usage of the resource. Required. - :paramtype limit: int - :keyword name: The name of the type of usage. Required. - :paramtype name: ~azure.mgmt.compute.v2019_12_01.models.UsageName - """ - super().__init__(**kwargs) - self.current_value = current_value - self.limit = limit - self.name = name - - -class UsageName(_serialization.Model): - """The Usage Names. - - :ivar value: The name of the resource. - :vartype value: str - :ivar localized_value: The localized name of the resource. - :vartype localized_value: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, - } - - def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The name of the resource. - :paramtype value: str - :keyword localized_value: The localized name of the resource. - :paramtype localized_value: str - """ - super().__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - -class UserArtifactManage(_serialization.Model): - """UserArtifactManage. - - All required parameters must be populated in order to send to server. - - :ivar install: Required. The path and arguments to install the gallery application. This is - limited to 4096 characters. Required. - :vartype install: str - :ivar remove: Required. The path and arguments to remove the gallery application. This is - limited to 4096 characters. Required. - :vartype remove: str - :ivar update: Optional. The path and arguments to update the gallery application. If not - present, then update operation will invoke remove command on the previous version and install - command on the current version of the gallery application. This is limited to 4096 characters. - :vartype update: str - """ - - _validation = { - "install": {"required": True}, - "remove": {"required": True}, - } - - _attribute_map = { - "install": {"key": "install", "type": "str"}, - "remove": {"key": "remove", "type": "str"}, - "update": {"key": "update", "type": "str"}, - } - - def __init__(self, *, install: str, remove: str, update: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword install: Required. The path and arguments to install the gallery application. This is - limited to 4096 characters. Required. - :paramtype install: str - :keyword remove: Required. The path and arguments to remove the gallery application. This is - limited to 4096 characters. Required. - :paramtype remove: str - :keyword update: Optional. The path and arguments to update the gallery application. If not - present, then update operation will invoke remove command on the previous version and install - command on the current version of the gallery application. This is limited to 4096 characters. - :paramtype update: str - """ - super().__init__(**kwargs) - self.install = install - self.remove = remove - self.update = update - - -class UserArtifactSource(_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 media_link: Required. The mediaLink of the artifact, must be a readable storage page - blob. Required. - :vartype media_link: str - :ivar default_configuration_link: Optional. The defaultConfigurationLink of the artifact, must - be a readable storage page blob. - :vartype default_configuration_link: str - """ - - _validation = { - "media_link": {"required": True}, - } - - _attribute_map = { - "media_link": {"key": "mediaLink", "type": "str"}, - "default_configuration_link": {"key": "defaultConfigurationLink", "type": "str"}, - } - - def __init__(self, *, media_link: str, default_configuration_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword media_link: Required. The mediaLink of the artifact, must be a readable storage page - blob. Required. - :paramtype media_link: str - :keyword default_configuration_link: Optional. The defaultConfigurationLink of the artifact, - must be a readable storage page blob. - :paramtype default_configuration_link: str - """ - super().__init__(**kwargs) - self.media_link = media_link - self.default_configuration_link = default_configuration_link - - -class UserAssignedIdentitiesValue(_serialization.Model): - """UserAssignedIdentitiesValue. - - 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: Optional[str] = None - self.client_id: Optional[str] = None - - -class VaultCertificate(_serialization.Model): - """Describes a single certificate reference in a Key Vault, and where the certificate should - reside on the VM. - - :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as - a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :vartype certificate_url: str - :ivar certificate_store: For Windows VMs, specifies the certificate store on the Virtual - Machine to which the certificate should be added. The specified certificate store is implicitly - in the LocalMachine account. :code:`
    `\\ :code:`
    `For Linux VMs, the certificate file is - placed under the /var/lib/waagent directory, with the file name <UppercaseThumbprint>.crt - for the X509 certificate file and <UppercaseThumbprint>.prv for private key. Both of - these files are .pem formatted. - :vartype certificate_store: str - """ - - _attribute_map = { - "certificate_url": {"key": "certificateUrl", "type": "str"}, - "certificate_store": {"key": "certificateStore", "type": "str"}, - } - - def __init__( - self, *, certificate_url: Optional[str] = None, certificate_store: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault - as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :paramtype certificate_url: str - :keyword certificate_store: For Windows VMs, specifies the certificate store on the Virtual - Machine to which the certificate should be added. The specified certificate store is implicitly - in the LocalMachine account. :code:`
    `\\ :code:`
    `For Linux VMs, the certificate file is - placed under the /var/lib/waagent directory, with the file name <UppercaseThumbprint>.crt - for the X509 certificate file and <UppercaseThumbprint>.prv for private key. Both of - these files are .pem formatted. - :paramtype certificate_store: str - """ - super().__init__(**kwargs) - self.certificate_url = certificate_url - self.certificate_store = certificate_store - - -class VaultSecretGroup(_serialization.Model): - """Describes a set of certificates which are all in the same Key Vault. - - :ivar source_vault: The relative URL of the Key Vault containing all of the certificates in - VaultCertificates. - :vartype source_vault: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar vault_certificates: The list of key vault references in SourceVault which contain - certificates. - :vartype vault_certificates: list[~azure.mgmt.compute.v2019_12_01.models.VaultCertificate] - """ - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - "vault_certificates": {"key": "vaultCertificates", "type": "[VaultCertificate]"}, - } - - def __init__( - self, - *, - source_vault: Optional["_models.SubResource"] = None, - vault_certificates: Optional[List["_models.VaultCertificate"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source_vault: The relative URL of the Key Vault containing all of the certificates in - VaultCertificates. - :paramtype source_vault: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword vault_certificates: The list of key vault references in SourceVault which contain - certificates. - :paramtype vault_certificates: list[~azure.mgmt.compute.v2019_12_01.models.VaultCertificate] - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.vault_certificates = vault_certificates - - -class VirtualHardDisk(_serialization.Model): - """Describes the uri of a disk. - - :ivar uri: Specifies the virtual hard disk's uri. - :vartype uri: str - """ - - _attribute_map = { - "uri": {"key": "uri", "type": "str"}, - } - - def __init__(self, *, uri: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword uri: Specifies the virtual hard disk's uri. - :paramtype uri: str - """ - super().__init__(**kwargs) - self.uri = uri - - -class VirtualMachine(Resource): - """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. - :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] - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2019_12_01.models.Plan - :ivar resources: The virtual machine child extension resources. - :vartype resources: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] - :ivar identity: The identity of the virtual machine, if configured. - :vartype identity: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineIdentity - :ivar zones: The virtual machine zones. - :vartype zones: list[str] - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2019_12_01.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2019_12_01.models.StorageProfile - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine. - :vartype additional_capabilities: ~azure.mgmt.compute.v2019_12_01.models.AdditionalCapabilities - :ivar os_profile: Specifies the operating system settings used while creating the virtual - machine. Some of the settings cannot be changed once VM is provisioned. - :vartype os_profile: ~azure.mgmt.compute.v2019_12_01.models.OSProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2019_12_01.models.NetworkProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2019_12_01.models.DiagnosticsProfile - :ivar availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. The availability set to which the VM is being added should be under the same resource - group as the availability set resource. An existing VM cannot be added to an availability set. - :code:`
    `\\ :code:`
    `This property cannot exist along with a non-null - properties.virtualMachineScaleSet reference. - :vartype availability_set: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar virtual_machine_scale_set: Specifies information about the virtual machine scale set that - the virtual machine should be assigned to. Virtual machines specified in the same virtual - machine scale set are allocated to different nodes to maximize availability. Currently, a VM - can only be added to virtual machine scale set at creation time. An existing VM cannot be added - to a virtual machine scale set. :code:`
    `\\ :code:`
    `This property cannot exist along - with a non-null properties.availabilitySet reference. :code:`
    `\\ :code:`
    `Minimum - api‐version: 2019‐03‐01. - :vartype virtual_machine_scale_set: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the virtual machine should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar priority: Specifies the priority for the virtual machine. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :vartype priority: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachinePriorityTypes - :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, both - 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. - :code:`
    `\\ :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are - supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and - "Delete". - :vartype eviction_policy: str or - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineEvictionPolicyTypes - :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2019_12_01.models.BillingProfile - :ivar host: Specifies information about the dedicated host that the virtual machine resides in. - :code:`
    `\\ :code:`
    `Minimum api-version: 2018-10-01. - :vartype host: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineInstanceView - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar vm_id: Specifies the VM unique ID which is a 128-bits identifier that is encoded and - stored in all Azure IaaS VMs SMBIOS and can be read using platform BIOS commands. - :vartype vm_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "resources": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - "vm_id": {"readonly": 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}"}, - "plan": {"key": "plan", "type": "Plan"}, - "resources": {"key": "resources", "type": "[VirtualMachineExtension]"}, - "identity": {"key": "identity", "type": "VirtualMachineIdentity"}, - "zones": {"key": "zones", "type": "[str]"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "virtual_machine_scale_set": {"key": "properties.virtualMachineScaleSet", "type": "SubResource"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "priority": {"key": "properties.priority", "type": "str"}, - "eviction_policy": {"key": "properties.evictionPolicy", "type": "str"}, - "billing_profile": {"key": "properties.billingProfile", "type": "BillingProfile"}, - "host": {"key": "properties.host", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineInstanceView"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineIdentity"] = None, - zones: Optional[List[str]] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - os_profile: Optional["_models.OSProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - virtual_machine_scale_set: Optional["_models.SubResource"] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["_models.BillingProfile"] = None, - host: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2019_12_01.models.Plan - :keyword identity: The identity of the virtual machine, if configured. - :paramtype identity: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineIdentity - :keyword zones: The virtual machine zones. - :paramtype zones: list[str] - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2019_12_01.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2019_12_01.models.StorageProfile - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2019_12_01.models.AdditionalCapabilities - :keyword os_profile: Specifies the operating system settings used while creating the virtual - machine. Some of the settings cannot be changed once VM is provisioned. - :paramtype os_profile: ~azure.mgmt.compute.v2019_12_01.models.OSProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2019_12_01.models.NetworkProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2019_12_01.models.DiagnosticsProfile - :keyword availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. The availability set to which the VM is being added should be under the same resource - group as the availability set resource. An existing VM cannot be added to an availability set. - :code:`
    `\\ :code:`
    `This property cannot exist along with a non-null - properties.virtualMachineScaleSet reference. - :paramtype availability_set: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword virtual_machine_scale_set: Specifies information about the virtual machine scale set - that the virtual machine should be assigned to. Virtual machines specified in the same virtual - machine scale set are allocated to different nodes to maximize availability. Currently, a VM - can only be added to virtual machine scale set at creation time. An existing VM cannot be added - to a virtual machine scale set. :code:`
    `\\ :code:`
    `This property cannot exist along - with a non-null properties.availabilitySet reference. :code:`
    `\\ :code:`
    `Minimum - api‐version: 2019‐03‐01. - :paramtype virtual_machine_scale_set: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the virtual machine should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword priority: Specifies the priority for the virtual machine. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :paramtype priority: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachinePriorityTypes - :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, both - 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. - :code:`
    `\\ :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are - supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and - "Delete". - :paramtype eviction_policy: str or - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineEvictionPolicyTypes - :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual - machine. :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2019_12_01.models.BillingProfile - :keyword host: Specifies information about the dedicated host that the virtual machine resides - in. :code:`
    `\\ :code:`
    `Minimum api-version: 2018-10-01. - :paramtype host: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.plan = plan - self.resources: Optional[List["_models.VirtualMachineExtension"]] = None - self.identity = identity - self.zones = zones - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.additional_capabilities = additional_capabilities - self.os_profile = os_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.virtual_machine_scale_set = virtual_machine_scale_set - self.proximity_placement_group = proximity_placement_group - self.priority = priority - self.eviction_policy = eviction_policy - self.billing_profile = billing_profile - self.host = host - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineInstanceView"] = None - self.license_type = license_type - self.vm_id: Optional[str] = None - - -class VirtualMachineAgentInstanceView(_serialization.Model): - """The instance view of the VM Agent running on the virtual machine. - - :ivar vm_agent_version: The VM Agent full version. - :vartype vm_agent_version: str - :ivar extension_handlers: The virtual machine extension handler instance view. - :vartype extension_handlers: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionHandlerInstanceView] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "vm_agent_version": {"key": "vmAgentVersion", "type": "str"}, - "extension_handlers": {"key": "extensionHandlers", "type": "[VirtualMachineExtensionHandlerInstanceView]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword vm_agent_version: The VM Agent full version. - :paramtype vm_agent_version: str - :keyword extension_handlers: The virtual machine extension handler instance view. - :paramtype extension_handlers: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionHandlerInstanceView] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.vm_agent_version = vm_agent_version - self.extension_handlers = extension_handlers - self.statuses = statuses - - -class VirtualMachineCaptureParameters(_serialization.Model): - """Capture Virtual Machine parameters. - - All required parameters must be populated in order to send to server. - - :ivar vhd_prefix: The captured virtual hard disk's name prefix. Required. - :vartype vhd_prefix: str - :ivar destination_container_name: The destination container name. Required. - :vartype destination_container_name: str - :ivar overwrite_vhds: Specifies whether to overwrite the destination virtual hard disk, in case - of conflict. Required. - :vartype overwrite_vhds: bool - """ - - _validation = { - "vhd_prefix": {"required": True}, - "destination_container_name": {"required": True}, - "overwrite_vhds": {"required": True}, - } - - _attribute_map = { - "vhd_prefix": {"key": "vhdPrefix", "type": "str"}, - "destination_container_name": {"key": "destinationContainerName", "type": "str"}, - "overwrite_vhds": {"key": "overwriteVhds", "type": "bool"}, - } - - def __init__( - self, *, vhd_prefix: str, destination_container_name: str, overwrite_vhds: bool, **kwargs: Any - ) -> None: - """ - :keyword vhd_prefix: The captured virtual hard disk's name prefix. Required. - :paramtype vhd_prefix: str - :keyword destination_container_name: The destination container name. Required. - :paramtype destination_container_name: str - :keyword overwrite_vhds: Specifies whether to overwrite the destination virtual hard disk, in - case of conflict. Required. - :paramtype overwrite_vhds: bool - """ - super().__init__(**kwargs) - self.vhd_prefix = vhd_prefix - self.destination_container_name = destination_container_name - self.overwrite_vhds = overwrite_vhds - - -class VirtualMachineCaptureResult(SubResource): - """Output of virtual machine capture operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar schema: the schema of the captured virtual machine. - :vartype schema: str - :ivar content_version: the version of the content. - :vartype content_version: str - :ivar parameters: parameters of the captured virtual machine. - :vartype parameters: JSON - :ivar resources: a list of resource items of the captured virtual machine. - :vartype resources: list[JSON] - """ - - _validation = { - "schema": {"readonly": True}, - "content_version": {"readonly": True}, - "parameters": {"readonly": True}, - "resources": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "schema": {"key": "$schema", "type": "str"}, - "content_version": {"key": "contentVersion", "type": "str"}, - "parameters": {"key": "parameters", "type": "object"}, - "resources": {"key": "resources", "type": "[object]"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(id=id, **kwargs) - self.schema: Optional[str] = None - self.content_version: Optional[str] = None - self.parameters: Optional[JSON] = None - self.resources: Optional[List[JSON]] = None - - -class VirtualMachineExtension(Resource): - """Describes a Virtual Machine Extension. - - 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] - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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. - :vartype instance_view: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionInstanceView - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineExtensionInstanceView"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, 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, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :keyword instance_view: The virtual machine extension instance view. - :paramtype instance_view: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionInstanceView - """ - super().__init__(location=location, tags=tags, **kwargs) - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - self.instance_view = instance_view - - -class VirtualMachineExtensionHandlerInstanceView(_serialization.Model): # pylint: disable=name-too-long - """The instance view of a virtual machine extension handler. - - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar status: The extension handler status. - :vartype status: ~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "status": {"key": "status", "type": "InstanceViewStatus"}, - } - - def __init__( - self, - *, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - status: Optional["_models.InstanceViewStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword status: The extension handler status. - :paramtype status: ~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus - """ - super().__init__(**kwargs) - self.type = type - self.type_handler_version = type_handler_version - self.status = status - - -class VirtualMachineExtensionImage(Resource): - """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. - :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] - :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. - :vartype compute_role: str - :ivar handler_schema: The schema defined by publisher, where extension consumers should provide - settings in a matching schema. - :vartype handler_schema: str - :ivar vm_scale_set_enabled: Whether the extension can be used on xRP VMScaleSets. By default - existing extensions are usable on scalesets, but there might be cases where a publisher wants - to explicitly indicate the extension is only enabled for CRP VMs but not VMSS. - :vartype vm_scale_set_enabled: bool - :ivar supports_multiple_extensions: Whether the handler can support multiple extensions. - :vartype supports_multiple_extensions: bool - """ - - _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}"}, - "operating_system": {"key": "properties.operatingSystem", "type": "str"}, - "compute_role": {"key": "properties.computeRole", "type": "str"}, - "handler_schema": {"key": "properties.handlerSchema", "type": "str"}, - "vm_scale_set_enabled": {"key": "properties.vmScaleSetEnabled", "type": "bool"}, - "supports_multiple_extensions": {"key": "properties.supportsMultipleExtensions", "type": "bool"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - operating_system: Optional[str] = None, - compute_role: Optional[str] = None, - handler_schema: Optional[str] = None, - vm_scale_set_enabled: Optional[bool] = None, - supports_multiple_extensions: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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. - :paramtype compute_role: str - :keyword handler_schema: The schema defined by publisher, where extension consumers should - provide settings in a matching schema. - :paramtype handler_schema: str - :keyword vm_scale_set_enabled: Whether the extension can be used on xRP VMScaleSets. By default - existing extensions are usable on scalesets, but there might be cases where a publisher wants - to explicitly indicate the extension is only enabled for CRP VMs but not VMSS. - :paramtype vm_scale_set_enabled: bool - :keyword supports_multiple_extensions: Whether the handler can support multiple extensions. - :paramtype supports_multiple_extensions: bool - """ - super().__init__(location=location, tags=tags, **kwargs) - self.operating_system = operating_system - self.compute_role = compute_role - self.handler_schema = handler_schema - self.vm_scale_set_enabled = vm_scale_set_enabled - self.supports_multiple_extensions = supports_multiple_extensions - - -class VirtualMachineExtensionInstanceView(_serialization.Model): - """The instance view of a virtual machine extension. - - :ivar name: The virtual machine extension name. - :vartype name: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar substatuses: The resource status information. - :vartype substatuses: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "substatuses": {"key": "substatuses", "type": "[InstanceViewStatus]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - substatuses: Optional[List["_models.InstanceViewStatus"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The virtual machine extension name. - :paramtype name: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword substatuses: The resource status information. - :paramtype substatuses: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.name = name - self.type = type - self.type_handler_version = type_handler_version - self.substatuses = substatuses - self.statuses = statuses - - -class VirtualMachineExtensionsListResult(_serialization.Model): - """The List Extension operation response. - - :ivar value: The list of extensions. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineExtension]"}, - } - - def __init__(self, *, value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of extensions. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] - """ - super().__init__(**kwargs) - self.value = value - - -class VirtualMachineExtensionUpdate(UpdateResource): - """Describes a Virtual Machine Extension. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - force_update_tag: Optional[str] = None, - publisher: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - auto_upgrade_minor_version: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - """ - super().__init__(tags=tags, **kwargs) - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type = type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - - -class VirtualMachineHealthStatus(_serialization.Model): - """The health status of the VM. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The health status information for the VM. - :vartype status: ~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus - """ - - _validation = { - "status": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "InstanceViewStatus"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional["_models.InstanceViewStatus"] = None - - -class VirtualMachineIdentity(_serialization.Model): - """Identity for the virtual machine. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of virtual machine identity. This property will only be - provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the virtual machine. This property will only be - provided for a system assigned identity. - :vartype tenant_id: str - :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, - UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Known values - are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :vartype type: str or ~azure.mgmt.compute.v2019_12_01.models.ResourceIdentityType - :ivar user_assigned_identities: The list of user identities associated with the Virtual - Machine. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2019_12_01.models.UserAssignedIdentitiesValue] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentitiesValue}"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, - UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Known values - are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :paramtype type: str or ~azure.mgmt.compute.v2019_12_01.models.ResourceIdentityType - :keyword user_assigned_identities: The list of user identities associated with the Virtual - Machine. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2019_12_01.models.UserAssignedIdentitiesValue] - """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.type = type - self.user_assigned_identities = user_assigned_identities - - -class VirtualMachineImageResource(SubResource): - """Virtual machine image resource information. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar location: The supported Azure location of the resource. Required. - :vartype location: str - :ivar tags: Specifies the tags that are assigned to the virtual machine. For more information - about using tags, see `Using tags to organize your Azure resources - `_. - :vartype tags: dict[str, str] - """ - - _validation = { - "name": {"required": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__( - self, - *, - name: str, - location: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The name of the resource. Required. - :paramtype name: str - :keyword location: The supported Azure location of the resource. Required. - :paramtype location: str - :keyword tags: Specifies the tags that are assigned to the virtual machine. For more - information about using tags, see `Using tags to organize your Azure resources - `_. - :paramtype tags: dict[str, str] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.location = location - self.tags = tags - - -class VirtualMachineImage(VirtualMachineImageResource): - """Describes a Virtual Machine Image. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar location: The supported Azure location of the resource. Required. - :vartype location: str - :ivar tags: Specifies the tags that are assigned to the virtual machine. For more information - about using tags, see `Using tags to organize your Azure resources - `_. - :vartype tags: dict[str, str] - :ivar plan: Used for establishing the purchase context of any 3rd Party artifact through - MarketPlace. - :vartype plan: ~azure.mgmt.compute.v2019_12_01.models.PurchasePlan - :ivar os_disk_image: Contains the os disk image information. - :vartype os_disk_image: ~azure.mgmt.compute.v2019_12_01.models.OSDiskImage - :ivar data_disk_images: - :vartype data_disk_images: list[~azure.mgmt.compute.v2019_12_01.models.DataDiskImage] - :ivar automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. - :vartype automatic_os_upgrade_properties: - ~azure.mgmt.compute.v2019_12_01.models.AutomaticOSUpgradeProperties - :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or - ~azure.mgmt.compute.v2019_12_01.models.HyperVGenerationTypes - """ - - _validation = { - "name": {"required": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "plan": {"key": "properties.plan", "type": "PurchasePlan"}, - "os_disk_image": {"key": "properties.osDiskImage", "type": "OSDiskImage"}, - "data_disk_images": {"key": "properties.dataDiskImages", "type": "[DataDiskImage]"}, - "automatic_os_upgrade_properties": { - "key": "properties.automaticOSUpgradeProperties", - "type": "AutomaticOSUpgradeProperties", - }, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - location: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.PurchasePlan"] = None, - os_disk_image: Optional["_models.OSDiskImage"] = None, - data_disk_images: Optional[List["_models.DataDiskImage"]] = None, - automatic_os_upgrade_properties: Optional["_models.AutomaticOSUpgradeProperties"] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The name of the resource. Required. - :paramtype name: str - :keyword location: The supported Azure location of the resource. Required. - :paramtype location: str - :keyword tags: Specifies the tags that are assigned to the virtual machine. For more - information about using tags, see `Using tags to organize your Azure resources - `_. - :paramtype tags: dict[str, str] - :keyword plan: Used for establishing the purchase context of any 3rd Party artifact through - MarketPlace. - :paramtype plan: ~azure.mgmt.compute.v2019_12_01.models.PurchasePlan - :keyword os_disk_image: Contains the os disk image information. - :paramtype os_disk_image: ~azure.mgmt.compute.v2019_12_01.models.OSDiskImage - :keyword data_disk_images: - :paramtype data_disk_images: list[~azure.mgmt.compute.v2019_12_01.models.DataDiskImage] - :keyword automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the - image. - :paramtype automatic_os_upgrade_properties: - ~azure.mgmt.compute.v2019_12_01.models.AutomaticOSUpgradeProperties - :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1" and - "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2019_12_01.models.HyperVGenerationTypes - """ - super().__init__(id=id, name=name, location=location, tags=tags, **kwargs) - self.plan = plan - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - self.automatic_os_upgrade_properties = automatic_os_upgrade_properties - self.hyper_v_generation = hyper_v_generation - - -class VirtualMachineInstanceView(_serialization.Model): - """The instance view of a virtual machine. - - :ivar platform_update_domain: Specifies the update domain of the virtual machine. - :vartype platform_update_domain: int - :ivar platform_fault_domain: Specifies the fault domain of the virtual machine. - :vartype platform_fault_domain: int - :ivar computer_name: The computer name assigned to the virtual machine. - :vartype computer_name: str - :ivar os_name: The Operating System running on the virtual machine. - :vartype os_name: str - :ivar os_version: The version of Operating System running on the virtual machine. - :vartype os_version: str - :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. Known - values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_12_01.models.HyperVGenerationType - :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. - :vartype rdp_thumb_print: str - :ivar vm_agent: The VM Agent running on the virtual machine. - :vartype vm_agent: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineAgentInstanceView - :ivar maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :vartype maintenance_redeploy_status: - ~azure.mgmt.compute.v2019_12_01.models.MaintenanceRedeployStatus - :ivar disks: The virtual machine disk information. - :vartype disks: list[~azure.mgmt.compute.v2019_12_01.models.DiskInstanceView] - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionInstanceView] - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2019_12_01.models.BootDiagnosticsInstanceView - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "platform_update_domain": {"key": "platformUpdateDomain", "type": "int"}, - "platform_fault_domain": {"key": "platformFaultDomain", "type": "int"}, - "computer_name": {"key": "computerName", "type": "str"}, - "os_name": {"key": "osName", "type": "str"}, - "os_version": {"key": "osVersion", "type": "str"}, - "hyper_v_generation": {"key": "hyperVGeneration", "type": "str"}, - "rdp_thumb_print": {"key": "rdpThumbPrint", "type": "str"}, - "vm_agent": {"key": "vmAgent", "type": "VirtualMachineAgentInstanceView"}, - "maintenance_redeploy_status": {"key": "maintenanceRedeployStatus", "type": "MaintenanceRedeployStatus"}, - "disks": {"key": "disks", "type": "[DiskInstanceView]"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineExtensionInstanceView]"}, - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnosticsInstanceView"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - platform_update_domain: Optional[int] = None, - platform_fault_domain: Optional[int] = None, - computer_name: Optional[str] = None, - os_name: Optional[str] = None, - os_version: Optional[str] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationType"]] = None, - rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, - disks: Optional[List["_models.DiskInstanceView"]] = None, - extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword platform_update_domain: Specifies the update domain of the virtual machine. - :paramtype platform_update_domain: int - :keyword platform_fault_domain: Specifies the fault domain of the virtual machine. - :paramtype platform_fault_domain: int - :keyword computer_name: The computer name assigned to the virtual machine. - :paramtype computer_name: str - :keyword os_name: The Operating System running on the virtual machine. - :paramtype os_name: str - :keyword os_version: The version of Operating System running on the virtual machine. - :paramtype os_version: str - :keyword hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2019_12_01.models.HyperVGenerationType - :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. - :paramtype rdp_thumb_print: str - :keyword vm_agent: The VM Agent running on the virtual machine. - :paramtype vm_agent: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineAgentInstanceView - :keyword maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :paramtype maintenance_redeploy_status: - ~azure.mgmt.compute.v2019_12_01.models.MaintenanceRedeployStatus - :keyword disks: The virtual machine disk information. - :paramtype disks: list[~azure.mgmt.compute.v2019_12_01.models.DiskInstanceView] - :keyword extensions: The extensions information. - :paramtype extensions: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionInstanceView] - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2019_12_01.models.BootDiagnosticsInstanceView - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.platform_update_domain = platform_update_domain - self.platform_fault_domain = platform_fault_domain - self.computer_name = computer_name - self.os_name = os_name - self.os_version = os_version - self.hyper_v_generation = hyper_v_generation - self.rdp_thumb_print = rdp_thumb_print - self.vm_agent = vm_agent - self.maintenance_redeploy_status = maintenance_redeploy_status - self.disks = disks - self.extensions = extensions - self.boot_diagnostics = boot_diagnostics - self.statuses = statuses - - -class VirtualMachineListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machines. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachine] - :ivar next_link: The URI to fetch the next page of VMs. Call ListNext() with this URI to fetch - the next page of Virtual Machines. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachine]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machines. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachine] - :keyword next_link: The URI to fetch the next page of VMs. Call ListNext() with this URI to - fetch the next page of Virtual Machines. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineReimageParameters(_serialization.Model): - """Parameters for Reimaging Virtual Machine. NOTE: Virtual Machine OS disk will always be - reimaged. - - :ivar temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This temp - disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :vartype temp_disk: bool - """ - - _attribute_map = { - "temp_disk": {"key": "tempDisk", "type": "bool"}, - } - - def __init__(self, *, temp_disk: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This - temp disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :paramtype temp_disk: bool - """ - super().__init__(**kwargs) - self.temp_disk = temp_disk - - -class VirtualMachineScaleSet(Resource): - """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. - :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] - :ivar sku: The virtual machine scale set sku. - :vartype sku: ~azure.mgmt.compute.v2019_12_01.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2019_12_01.models.Plan - :ivar identity: The identity of the virtual machine scale set, if configured. - :vartype identity: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetIdentity - :ivar zones: The virtual machine scale set zones. NOTE: Availability zones can only be set when - you create the scale set. - :vartype zones: list[str] - :ivar upgrade_policy: The upgrade policy. - :vartype upgrade_policy: ~azure.mgmt.compute.v2019_12_01.models.UpgradePolicy - :ivar automatic_repairs_policy: Policy for automatic repairs. - :vartype automatic_repairs_policy: - ~azure.mgmt.compute.v2019_12_01.models.AutomaticRepairsPolicy - :ivar virtual_machine_profile: The virtual machine profile. - :vartype virtual_machine_profile: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar overprovision: Specifies whether the Virtual Machine Scale Set should be overprovisioned. - :vartype overprovision: bool - :ivar do_not_run_extensions_on_overprovisioned_v_ms: When Overprovision is enabled, extensions - are launched only on the requested number of VMs which are finally kept. This property will - hence ensure that the extensions do not run on the extra overprovisioned VMs. - :vartype do_not_run_extensions_on_overprovisioned_v_ms: bool - :ivar unique_id: Specifies the ID which uniquely identifies a Virtual Machine Scale Set. - :vartype unique_id: str - :ivar single_placement_group: When true this limits the scale set to a single placement group, - of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be modified to - false. However, if singlePlacementGroup is false, it may not be modified to true. - :vartype single_placement_group: bool - :ivar zone_balance: Whether to force strictly even Virtual Machine distribution cross x-zones - in case there is zone outage. - :vartype zone_balance: bool - :ivar platform_fault_domain_count: Fault Domain count for each placement group. - :vartype platform_fault_domain_count: int - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the virtual machine scale set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines - have the capability to support attaching managed data disks with UltraSSD_LRS storage account - type. - :vartype additional_capabilities: ~azure.mgmt.compute.v2019_12_01.models.AdditionalCapabilities - :ivar scale_in_policy: Specifies the scale-in policy that decides which virtual machines are - chosen for removal when a Virtual Machine Scale Set is scaled-in. - :vartype scale_in_policy: ~azure.mgmt.compute.v2019_12_01.models.ScaleInPolicy - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "unique_id": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "identity": {"key": "identity", "type": "VirtualMachineScaleSetIdentity"}, - "zones": {"key": "zones", "type": "[str]"}, - "upgrade_policy": {"key": "properties.upgradePolicy", "type": "UpgradePolicy"}, - "automatic_repairs_policy": {"key": "properties.automaticRepairsPolicy", "type": "AutomaticRepairsPolicy"}, - "virtual_machine_profile": { - "key": "properties.virtualMachineProfile", - "type": "VirtualMachineScaleSetVMProfile", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "overprovision": {"key": "properties.overprovision", "type": "bool"}, - "do_not_run_extensions_on_overprovisioned_v_ms": { - "key": "properties.doNotRunExtensionsOnOverprovisionedVMs", - "type": "bool", - }, - "unique_id": {"key": "properties.uniqueId", "type": "str"}, - "single_placement_group": {"key": "properties.singlePlacementGroup", "type": "bool"}, - "zone_balance": {"key": "properties.zoneBalance", "type": "bool"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "scale_in_policy": {"key": "properties.scaleInPolicy", "type": "ScaleInPolicy"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, - zones: Optional[List[str]] = None, - upgrade_policy: Optional["_models.UpgradePolicy"] = None, - automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, - overprovision: Optional[bool] = None, - do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, - single_placement_group: Optional[bool] = None, - zone_balance: Optional[bool] = None, - platform_fault_domain_count: Optional[int] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - scale_in_policy: Optional["_models.ScaleInPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The virtual machine scale set sku. - :paramtype sku: ~azure.mgmt.compute.v2019_12_01.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2019_12_01.models.Plan - :keyword identity: The identity of the virtual machine scale set, if configured. - :paramtype identity: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetIdentity - :keyword zones: The virtual machine scale set zones. NOTE: Availability zones can only be set - when you create the scale set. - :paramtype zones: list[str] - :keyword upgrade_policy: The upgrade policy. - :paramtype upgrade_policy: ~azure.mgmt.compute.v2019_12_01.models.UpgradePolicy - :keyword automatic_repairs_policy: Policy for automatic repairs. - :paramtype automatic_repairs_policy: - ~azure.mgmt.compute.v2019_12_01.models.AutomaticRepairsPolicy - :keyword virtual_machine_profile: The virtual machine profile. - :paramtype virtual_machine_profile: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMProfile - :keyword overprovision: Specifies whether the Virtual Machine Scale Set should be - overprovisioned. - :paramtype overprovision: bool - :keyword do_not_run_extensions_on_overprovisioned_v_ms: When Overprovision is enabled, - extensions are launched only on the requested number of VMs which are finally kept. This - property will hence ensure that the extensions do not run on the extra overprovisioned VMs. - :paramtype do_not_run_extensions_on_overprovisioned_v_ms: bool - :keyword single_placement_group: When true this limits the scale set to a single placement - group, of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be - modified to false. However, if singlePlacementGroup is false, it may not be modified to true. - :paramtype single_placement_group: bool - :keyword zone_balance: Whether to force strictly even Virtual Machine distribution cross - x-zones in case there is zone outage. - :paramtype zone_balance: bool - :keyword platform_fault_domain_count: Fault Domain count for each placement group. - :paramtype platform_fault_domain_count: int - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the virtual machine scale set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines - have the capability to support attaching managed data disks with UltraSSD_LRS storage account - type. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2019_12_01.models.AdditionalCapabilities - :keyword scale_in_policy: Specifies the scale-in policy that decides which virtual machines are - chosen for removal when a Virtual Machine Scale Set is scaled-in. - :paramtype scale_in_policy: ~azure.mgmt.compute.v2019_12_01.models.ScaleInPolicy - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.plan = plan - self.identity = identity - self.zones = zones - self.upgrade_policy = upgrade_policy - self.automatic_repairs_policy = automatic_repairs_policy - self.virtual_machine_profile = virtual_machine_profile - self.provisioning_state: Optional[str] = None - self.overprovision = overprovision - self.do_not_run_extensions_on_overprovisioned_v_ms = do_not_run_extensions_on_overprovisioned_v_ms - self.unique_id: Optional[str] = None - self.single_placement_group = single_placement_group - self.zone_balance = zone_balance - self.platform_fault_domain_count = platform_fault_domain_count - self.proximity_placement_group = proximity_placement_group - self.additional_capabilities = additional_capabilities - self.scale_in_policy = scale_in_policy - - -class VirtualMachineScaleSetDataDisk(_serialization.Model): - """Describes a virtual machine scale set data disk. - - All required parameters must be populated in order to send to server. - - :ivar name: The disk name. - :vartype name: str - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar create_option: The create option. Required. Known values are: "FromImage", "Empty", and - "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2019_12_01.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetManagedDiskParameters - :ivar disk_iops_read_write: Specifies the Read-Write IOPS for the managed disk. Should be used - only when StorageAccountType is UltraSSD_LRS. If not specified, a default value would be - assigned based on diskSizeGB. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: Specifies the bandwidth in MB per second for the managed disk. - Should be used only when StorageAccountType is UltraSSD_LRS. If not specified, a default value - would be assigned based on diskSizeGB. - :vartype disk_m_bps_read_write: int - """ - - _validation = { - "lun": {"required": True}, - "create_option": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "VirtualMachineScaleSetManagedDiskParameters"}, - "disk_iops_read_write": {"key": "diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "diskMBpsReadWrite", "type": "int"}, - } - - def __init__( - self, - *, - lun: int, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, - disk_iops_read_write: Optional[int] = None, - disk_m_bps_read_write: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword create_option: The create option. Required. Known values are: "FromImage", "Empty", - and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2019_12_01.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetManagedDiskParameters - :keyword disk_iops_read_write: Specifies the Read-Write IOPS for the managed disk. Should be - used only when StorageAccountType is UltraSSD_LRS. If not specified, a default value would be - assigned based on diskSizeGB. - :paramtype disk_iops_read_write: int - :keyword disk_m_bps_read_write: Specifies the bandwidth in MB per second for the managed disk. - Should be used only when StorageAccountType is UltraSSD_LRS. If not specified, a default value - would be assigned based on diskSizeGB. - :paramtype disk_m_bps_read_write: int - """ - super().__init__(**kwargs) - self.name = name - self.lun = lun - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - self.disk_iops_read_write = disk_iops_read_write - self.disk_m_bps_read_write = disk_m_bps_read_write - - -class VirtualMachineScaleSetExtension(SubResourceReadOnly): - """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. - :vartype id: str - :ivar name: The name of the extension. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar force_update_tag: If a value is provided and is different from the previous value, the - extension handler will be forced to update even if the extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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 - needs to be provisioned. - :vartype provision_after_extensions: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "provision_after_extensions": {"key": "properties.provisionAfterExtensions", "type": "[str]"}, - } - - 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, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - provision_after_extensions: Optional[List[str]] = 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :keyword provision_after_extensions: Collection of extension names after which this extension - needs to be provisioned. - :paramtype provision_after_extensions: list[str] - """ - super().__init__(**kwargs) - self.name = name - self.type: Optional[str] = None - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - self.provision_after_extensions = provision_after_extensions - - -class VirtualMachineScaleSetExtensionListResult(_serialization.Model): # pylint: disable=name-too-long - """The List VM scale set extension operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of VM scale set extensions. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtension] - :ivar next_link: The uri to fetch the next page of VM scale set extensions. Call ListNext() - with this to fetch the next page of VM scale set extensions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetExtension]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of VM scale set extensions. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtension] - :keyword next_link: The uri to fetch the next page of VM scale set extensions. Call ListNext() - with this to fetch the next page of VM scale set extensions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetExtensionProfile(_serialization.Model): - """Describes a virtual machine scale set extension profile. - - :ivar extensions: The virtual machine scale set child extension resources. - :vartype extensions: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtension] - """ - - _attribute_map = { - "extensions": {"key": "extensions", "type": "[VirtualMachineScaleSetExtension]"}, - } - - def __init__( - self, *, extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, **kwargs: Any - ) -> None: - """ - :keyword extensions: The virtual machine scale set child extension resources. - :paramtype extensions: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtension] - """ - super().__init__(**kwargs) - self.extensions = extensions - - -class VirtualMachineScaleSetExtensionUpdate(SubResourceReadOnly): - """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. - :vartype id: str - :ivar name: The name of the extension. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar force_update_tag: If a value is provided and is different from the previous value, the - extension handler will be forced to update even if the extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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 - needs to be provisioned. - :vartype provision_after_extensions: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "provision_after_extensions": {"key": "properties.provisionAfterExtensions", "type": "[str]"}, - } - - def __init__( - self, - *, - 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, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - provision_after_extensions: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword force_update_tag: If a value is provided and is different from the previous value, the - extension handler will be forced to update even if the extension configuration has not changed. - :paramtype force_update_tag: str - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :keyword provision_after_extensions: Collection of extension names after which this extension - needs to be provisioned. - :paramtype provision_after_extensions: list[str] - """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.type: Optional[str] = None - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - self.provision_after_extensions = provision_after_extensions - - -class VirtualMachineScaleSetIdentity(_serialization.Model): - """Identity for the virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of virtual machine scale set identity. This property will - only be provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the virtual machine scale set. This property - will only be provided for a system assigned identity. - :vartype tenant_id: str - :ivar type: The type of identity used for the virtual machine scale set. The type - 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user - assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and - "None". - :vartype type: str or ~azure.mgmt.compute.v2019_12_01.models.ResourceIdentityType - :ivar user_assigned_identities: The list of user identities associated with the virtual machine - scale set. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": { - "key": "userAssignedIdentities", - "type": "{VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue}", - }, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, - user_assigned_identities: Optional[ - Dict[str, "_models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of identity used for the virtual machine scale set. The type - 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user - assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and - "None". - :paramtype type: str or ~azure.mgmt.compute.v2019_12_01.models.ResourceIdentityType - :keyword user_assigned_identities: The list of user identities associated with the virtual - machine scale set. The user identity dictionary key references will be ARM resource ids in the - form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue] - """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.type = type - self.user_assigned_identities = user_assigned_identities - - -class VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue(_serialization.Model): # pylint: disable=name-too-long - """VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue. - - 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: Optional[str] = None - self.client_id: Optional[str] = None - - -class VirtualMachineScaleSetInstanceView(_serialization.Model): - """The instance view of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar virtual_machine: The instance view status summary for the virtual machine scale set. - :vartype virtual_machine: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetInstanceViewStatusesSummary - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMExtensionsSummary] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - :ivar orchestration_services: The orchestration services information. - :vartype orchestration_services: - list[~azure.mgmt.compute.v2019_12_01.models.OrchestrationServiceSummary] - """ - - _validation = { - "virtual_machine": {"readonly": True}, - "extensions": {"readonly": True}, - "orchestration_services": {"readonly": True}, - } - - _attribute_map = { - "virtual_machine": {"key": "virtualMachine", "type": "VirtualMachineScaleSetInstanceViewStatusesSummary"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineScaleSetVMExtensionsSummary]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - "orchestration_services": {"key": "orchestrationServices", "type": "[OrchestrationServiceSummary]"}, - } - - def __init__(self, *, statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs: Any) -> None: - """ - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.virtual_machine: Optional["_models.VirtualMachineScaleSetInstanceViewStatusesSummary"] = None - self.extensions: Optional[List["_models.VirtualMachineScaleSetVMExtensionsSummary"]] = None - self.statuses = statuses - self.orchestration_services: Optional[List["_models.OrchestrationServiceSummary"]] = None - - -class VirtualMachineScaleSetInstanceViewStatusesSummary(_serialization.Model): # pylint: disable=name-too-long - """Instance view statuses summary for virtual machines of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar statuses_summary: The extensions information. - :vartype statuses_summary: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineStatusCodeCount] - """ - - _validation = { - "statuses_summary": {"readonly": True}, - } - - _attribute_map = { - "statuses_summary": {"key": "statusesSummary", "type": "[VirtualMachineStatusCodeCount]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.statuses_summary: Optional[List["_models.VirtualMachineStatusCodeCount"]] = None - - -class VirtualMachineScaleSetIPConfiguration(SubResource): - """Describes a virtual machine scale set network profile's IP configuration. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The IP configuration name. Required. - :vartype name: str - :ivar subnet: Specifies the identifier of the subnet. - :vartype subnet: ~azure.mgmt.compute.v2019_12_01.models.ApiEntityReference - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - :ivar public_ip_address_configuration: The publicIPAddressConfiguration. - :vartype public_ip_address_configuration: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration - :ivar private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2019_12_01.models.IPVersion - :ivar application_gateway_backend_address_pools: Specifies an array of references to backend - address pools of application gateways. A scale set can reference backend address pools of - multiple application gateways. Multiple scale sets cannot use the same application gateway. - :vartype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - :ivar application_security_groups: Specifies an array of references to application security - group. - :vartype application_security_groups: list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - :ivar load_balancer_backend_address_pools: Specifies an array of references to backend address - pools of load balancers. A scale set can reference backend address pools of one public and one - internal load balancer. Multiple scale sets cannot use the same basic sku load balancer. - :vartype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - :ivar load_balancer_inbound_nat_pools: Specifies an array of references to inbound Nat pools of - the load balancers. A scale set can reference inbound nat pools of one public and one internal - load balancer. Multiple scale sets cannot use the same basic sku load balancer. - :vartype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subnet": {"key": "properties.subnet", "type": "ApiEntityReference"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "public_ip_address_configuration": { - "key": "properties.publicIPAddressConfiguration", - "type": "VirtualMachineScaleSetPublicIPAddressConfiguration", - }, - "private_ip_address_version": {"key": "properties.privateIPAddressVersion", "type": "str"}, - "application_gateway_backend_address_pools": { - "key": "properties.applicationGatewayBackendAddressPools", - "type": "[SubResource]", - }, - "application_security_groups": {"key": "properties.applicationSecurityGroups", "type": "[SubResource]"}, - "load_balancer_backend_address_pools": { - "key": "properties.loadBalancerBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_inbound_nat_pools": {"key": "properties.loadBalancerInboundNatPools", "type": "[SubResource]"}, - } - - def __init__( - self, - *, - name: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - subnet: Optional["_models.ApiEntityReference"] = None, - primary: Optional[bool] = None, - public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, - application_security_groups: Optional[List["_models.SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The IP configuration name. Required. - :paramtype name: str - :keyword subnet: Specifies the identifier of the subnet. - :paramtype subnet: ~azure.mgmt.compute.v2019_12_01.models.ApiEntityReference - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - :keyword public_ip_address_configuration: The publicIPAddressConfiguration. - :paramtype public_ip_address_configuration: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration - :keyword private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2019_12_01.models.IPVersion - :keyword application_gateway_backend_address_pools: Specifies an array of references to backend - address pools of application gateways. A scale set can reference backend address pools of - multiple application gateways. Multiple scale sets cannot use the same application gateway. - :paramtype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - :keyword application_security_groups: Specifies an array of references to application security - group. - :paramtype application_security_groups: - list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - :keyword load_balancer_backend_address_pools: Specifies an array of references to backend - address pools of load balancers. A scale set can reference backend address pools of one public - and one internal load balancer. Multiple scale sets cannot use the same basic sku load - balancer. - :paramtype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - :keyword load_balancer_inbound_nat_pools: Specifies an array of references to inbound Nat pools - of the load balancers. A scale set can reference inbound nat pools of one public and one - internal load balancer. Multiple scale sets cannot use the same basic sku load balancer. - :paramtype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.subnet = subnet - self.primary = primary - self.public_ip_address_configuration = public_ip_address_configuration - self.private_ip_address_version = private_ip_address_version - self.application_gateway_backend_address_pools = application_gateway_backend_address_pools - self.application_security_groups = application_security_groups - self.load_balancer_backend_address_pools = load_balancer_backend_address_pools - self.load_balancer_inbound_nat_pools = load_balancer_inbound_nat_pools - - -class VirtualMachineScaleSetIpTag(_serialization.Model): - """Contains the IP tag associated with the public IP address. - - :ivar ip_tag_type: IP tag type. Example: FirstPartyUsage. - :vartype ip_tag_type: str - :ivar tag: IP tag associated with the public IP. Example: SQL, Storage etc. - :vartype tag: str - """ - - _attribute_map = { - "ip_tag_type": {"key": "ipTagType", "type": "str"}, - "tag": {"key": "tag", "type": "str"}, - } - - def __init__(self, *, ip_tag_type: Optional[str] = None, tag: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword ip_tag_type: IP tag type. Example: FirstPartyUsage. - :paramtype ip_tag_type: str - :keyword tag: IP tag associated with the public IP. Example: SQL, Storage etc. - :paramtype tag: str - """ - super().__init__(**kwargs) - self.ip_tag_type = ip_tag_type - self.tag = tag - - -class VirtualMachineScaleSetListOSUpgradeHistory(_serialization.Model): # pylint: disable=name-too-long - """List of Virtual Machine Scale Set OS Upgrade History operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of OS upgrades performed on the virtual machine scale set. Required. - :vartype value: - list[~azure.mgmt.compute.v2019_12_01.models.UpgradeOperationHistoricalStatusInfo] - :ivar next_link: The uri to fetch the next page of OS Upgrade History. Call ListNext() with - this to fetch the next page of history of upgrades. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[UpgradeOperationHistoricalStatusInfo]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: List["_models.UpgradeOperationHistoricalStatusInfo"], - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of OS upgrades performed on the virtual machine scale set. Required. - :paramtype value: - list[~azure.mgmt.compute.v2019_12_01.models.UpgradeOperationHistoricalStatusInfo] - :keyword next_link: The uri to fetch the next page of OS Upgrade History. Call ListNext() with - this to fetch the next page of history of upgrades. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSet] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call ListNext() - with this to fetch the next page of VMSS. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSet] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call - ListNext() with this to fetch the next page of VMSS. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListSkusResult(_serialization.Model): - """The Virtual Machine Scale Set List Skus operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of skus available for the virtual machine scale set. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetSku] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Set Skus. Call - ListNext() with this to fetch the next page of VMSS Skus. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetSku]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of skus available for the virtual machine scale set. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetSku] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Set Skus. Call - ListNext() with this to fetch the next page of VMSS Skus. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListWithLinkResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSet] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call ListNext() - with this to fetch the next page of Virtual Machine Scale Sets. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSet] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call - ListNext() with this to fetch the next page of Virtual Machine Scale Sets. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetManagedDiskParameters(_serialization.Model): # pylint: disable=name-too-long - """Describes the parameters of a ScaleSet managed disk. - - :ivar storage_account_type: Specifies the storage account type for the managed disk. Managed OS - disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS can - only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", - "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2019_12_01.models.DiskEncryptionSetParameters - """ - - _attribute_map = { - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - } - - def __init__( - self, - *, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword storage_account_type: Specifies the storage account type for the managed disk. Managed - OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS - can only be used with data disks, it cannot be used with OS Disk. Known values are: - "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2019_12_01.models.DiskEncryptionSetParameters - """ - super().__init__(**kwargs) - self.storage_account_type = storage_account_type - self.disk_encryption_set = disk_encryption_set - - -class VirtualMachineScaleSetNetworkConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's network configurations. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The network configuration name. Required. - :vartype name: str - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :vartype enable_accelerated_networking: bool - :ivar network_security_group: The network security group. - :vartype network_security_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar dns_settings: The dns settings to be applied on the network interfaces. - :vartype dns_settings: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :ivar ip_configurations: Specifies the IP configurations of the network interface. - :vartype ip_configurations: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetIPConfiguration] - :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :vartype enable_ip_forwarding: bool - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "enable_accelerated_networking": {"key": "properties.enableAcceleratedNetworking", "type": "bool"}, - "network_security_group": {"key": "properties.networkSecurityGroup", "type": "SubResource"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetNetworkConfigurationDnsSettings", - }, - "ip_configurations": {"key": "properties.ipConfigurations", "type": "[VirtualMachineScaleSetIPConfiguration]"}, - "enable_ip_forwarding": {"key": "properties.enableIPForwarding", "type": "bool"}, - } - - def __init__( - self, - *, - name: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - primary: Optional[bool] = None, - enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["_models.SubResource"] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, - enable_ip_forwarding: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The network configuration name. Required. - :paramtype name: str - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :paramtype enable_accelerated_networking: bool - :keyword network_security_group: The network security group. - :paramtype network_security_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword dns_settings: The dns settings to be applied on the network interfaces. - :paramtype dns_settings: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :keyword ip_configurations: Specifies the IP configurations of the network interface. - :paramtype ip_configurations: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetIPConfiguration] - :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :paramtype enable_ip_forwarding: bool - """ - super().__init__(id=id, **kwargs) - self.name = name - self.primary = primary - self.enable_accelerated_networking = enable_accelerated_networking - self.network_security_group = network_security_group - self.dns_settings = dns_settings - self.ip_configurations = ip_configurations - self.enable_ip_forwarding = enable_ip_forwarding - - -class VirtualMachineScaleSetNetworkConfigurationDnsSettings(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines scale sets network configuration's DNS settings. - - :ivar dns_servers: List of DNS servers IP addresses. - :vartype dns_servers: list[str] - """ - - _attribute_map = { - "dns_servers": {"key": "dnsServers", "type": "[str]"}, - } - - def __init__(self, *, dns_servers: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword dns_servers: List of DNS servers IP addresses. - :paramtype dns_servers: list[str] - """ - super().__init__(**kwargs) - self.dns_servers = dns_servers - - -class VirtualMachineScaleSetNetworkProfile(_serialization.Model): - """Describes a virtual machine scale set network profile. - - :ivar health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :vartype health_probe: ~azure.mgmt.compute.v2019_12_01.models.ApiEntityReference - :ivar network_interface_configurations: The list of network configurations. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetNetworkConfiguration] - """ - - _attribute_map = { - "health_probe": {"key": "healthProbe", "type": "ApiEntityReference"}, - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineScaleSetNetworkConfiguration]", - }, - } - - def __init__( - self, - *, - health_probe: Optional["_models.ApiEntityReference"] = None, - network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :paramtype health_probe: ~azure.mgmt.compute.v2019_12_01.models.ApiEntityReference - :keyword network_interface_configurations: The list of network configurations. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetNetworkConfiguration] - """ - super().__init__(**kwargs) - self.health_probe = health_probe - self.network_interface_configurations = network_interface_configurations - - -class VirtualMachineScaleSetOSDisk(_serialization.Model): - """Describes a virtual machine scale set operating system disk. - - All required parameters must be populated in order to send to server. - - :ivar name: The disk name. - :vartype name: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar create_option: Specifies how the virtual machines in the scale set should be created.\\ - :code:`
    `\\ :code:`
    ` The only allowed value is: **FromImage** \\u2013 This value is used - when you are using an image to create the virtual machine. If you are using a platform image, - you also use the imageReference element described above. If you are using a marketplace image, - you also use the plan element previously described. Required. Known values are: "FromImage", - "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2019_12_01.models.DiskCreateOptionTypes - :ivar diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk - used by the virtual machine scale set. - :vartype diff_disk_settings: ~azure.mgmt.compute.v2019_12_01.models.DiffDiskSettings - :ivar disk_size_gb: Specifies the size of the operating system disk in gigabytes. This element - can be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - :ivar image: Specifies information about the unmanaged user image to base the scale set on. - :vartype image: ~azure.mgmt.compute.v2019_12_01.models.VirtualHardDisk - :ivar vhd_containers: Specifies the container urls that are used to store operating system - disks for the scale set. - :vartype vhd_containers: list[str] - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - - _validation = { - "create_option": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "create_option": {"key": "createOption", "type": "str"}, - "diff_disk_settings": {"key": "diffDiskSettings", "type": "DiffDiskSettings"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "os_type": {"key": "osType", "type": "str"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "vhd_containers": {"key": "vhdContainers", "type": "[str]"}, - "managed_disk": {"key": "managedDisk", "type": "VirtualMachineScaleSetManagedDiskParameters"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, - disk_size_gb: Optional[int] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - image: Optional["_models.VirtualHardDisk"] = None, - vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword create_option: Specifies how the virtual machines in the scale set should be - created.\\ :code:`
    `\\ :code:`
    ` The only allowed value is: **FromImage** \\u2013 This - value is used when you are using an image to create the virtual machine. If you are using a - platform image, you also use the imageReference element described above. If you are using a - marketplace image, you also use the plan element previously described. Required. Known values - are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2019_12_01.models.DiskCreateOptionTypes - :keyword diff_disk_settings: Specifies the ephemeral disk Settings for the operating system - disk used by the virtual machine scale set. - :paramtype diff_disk_settings: ~azure.mgmt.compute.v2019_12_01.models.DiffDiskSettings - :keyword disk_size_gb: Specifies the size of the operating system disk in gigabytes. This - element can be used to overwrite the size of the disk in a virtual machine image. - :code:`
    `\\ :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - :keyword image: Specifies information about the unmanaged user image to base the scale set on. - :paramtype image: ~azure.mgmt.compute.v2019_12_01.models.VirtualHardDisk - :keyword vhd_containers: Specifies the container urls that are used to store operating system - disks for the scale set. - :paramtype vhd_containers: list[str] - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - super().__init__(**kwargs) - self.name = name - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.create_option = create_option - self.diff_disk_settings = diff_disk_settings - self.disk_size_gb = disk_size_gb - self.os_type = os_type - self.image = image - self.vhd_containers = vhd_containers - self.managed_disk = managed_disk - - -class VirtualMachineScaleSetOSProfile(_serialization.Model): - """Describes a virtual machine scale set OS profile. - - :ivar computer_name_prefix: Specifies the computer name prefix for all of the virtual machines - in the scale set. Computer name prefixes must be 1 to 15 characters long. - :vartype computer_name_prefix: str - :ivar admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :vartype admin_username: str - :ivar admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :vartype admin_password: str - :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` For using cloud-init for - your VM, see `Using cloud-init to customize a Linux VM during creation - `_. - :vartype custom_data: str - :ivar windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :vartype windows_configuration: ~azure.mgmt.compute.v2019_12_01.models.WindowsConfiguration - :ivar linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :vartype linux_configuration: ~azure.mgmt.compute.v2019_12_01.models.LinuxConfiguration - :ivar secrets: Specifies set of certificates that should be installed onto the virtual machines - in the scale set. - :vartype secrets: list[~azure.mgmt.compute.v2019_12_01.models.VaultSecretGroup] - """ - - _attribute_map = { - "computer_name_prefix": {"key": "computerNamePrefix", "type": "str"}, - "admin_username": {"key": "adminUsername", "type": "str"}, - "admin_password": {"key": "adminPassword", "type": "str"}, - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - } - - def __init__( - self, - *, - computer_name_prefix: Optional[str] = None, - admin_username: Optional[str] = None, - admin_password: Optional[str] = None, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword computer_name_prefix: Specifies the computer name prefix for all of the virtual - machines in the scale set. Computer name prefixes must be 1 to 15 characters long. - :paramtype computer_name_prefix: str - :keyword admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :paramtype admin_username: str - :keyword admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :paramtype admin_password: str - :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` For using cloud-init for - your VM, see `Using cloud-init to customize a Linux VM during creation - `_. - :paramtype custom_data: str - :keyword windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :paramtype windows_configuration: ~azure.mgmt.compute.v2019_12_01.models.WindowsConfiguration - :keyword linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :paramtype linux_configuration: ~azure.mgmt.compute.v2019_12_01.models.LinuxConfiguration - :keyword secrets: Specifies set of certificates that should be installed onto the virtual - machines in the scale set. - :paramtype secrets: list[~azure.mgmt.compute.v2019_12_01.models.VaultSecretGroup] - """ - super().__init__(**kwargs) - self.computer_name_prefix = computer_name_prefix - self.admin_username = admin_username - self.admin_password = admin_password - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - - -class VirtualMachineScaleSetPublicIPAddressConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines scale set IP Configuration's PublicIPAddress configuration. - - All required parameters must be populated in order to send to server. - - :ivar name: The publicIP address configuration name. Required. - :vartype name: str - :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. - :vartype idle_timeout_in_minutes: int - :ivar dns_settings: The dns settings to be applied on the publicIP addresses . - :vartype dns_settings: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - :ivar ip_tags: The list of IP tags associated with the public IP address. - :vartype ip_tags: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetIpTag] - :ivar public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. - :vartype public_ip_prefix: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar public_ip_address_version: 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 'IPv6'. Known values are: "IPv4" and "IPv6". - :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2019_12_01.models.IPVersion - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "idle_timeout_in_minutes": {"key": "properties.idleTimeoutInMinutes", "type": "int"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings", - }, - "ip_tags": {"key": "properties.ipTags", "type": "[VirtualMachineScaleSetIpTag]"}, - "public_ip_prefix": {"key": "properties.publicIPPrefix", "type": "SubResource"}, - "public_ip_address_version": {"key": "properties.publicIPAddressVersion", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - ip_tags: Optional[List["_models.VirtualMachineScaleSetIpTag"]] = None, - public_ip_prefix: Optional["_models.SubResource"] = None, - public_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The publicIP address configuration name. Required. - :paramtype name: str - :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. - :paramtype idle_timeout_in_minutes: int - :keyword dns_settings: The dns settings to be applied on the publicIP addresses . - :paramtype dns_settings: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - :keyword ip_tags: The list of IP tags associated with the public IP address. - :paramtype ip_tags: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetIpTag] - :keyword public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. - :paramtype public_ip_prefix: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword public_ip_address_version: 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 'IPv6'. Known values are: "IPv4" and "IPv6". - :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2019_12_01.models.IPVersion - """ - super().__init__(**kwargs) - self.name = name - self.idle_timeout_in_minutes = idle_timeout_in_minutes - self.dns_settings = dns_settings - self.ip_tags = ip_tags - self.public_ip_prefix = public_ip_prefix - self.public_ip_address_version = public_ip_address_version - - -class VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings( - _serialization.Model -): # pylint: disable=name-too-long - """Describes a virtual machines scale sets network configuration's DNS settings. - - All required parameters must be populated in order to send to server. - - :ivar domain_name_label: The Domain name label.The concatenation of the domain name label and - vm index will be the domain name labels of the PublicIPAddress resources that will be created. - Required. - :vartype domain_name_label: str - """ - - _validation = { - "domain_name_label": {"required": True}, - } - - _attribute_map = { - "domain_name_label": {"key": "domainNameLabel", "type": "str"}, - } - - def __init__(self, *, domain_name_label: str, **kwargs: Any) -> None: - """ - :keyword domain_name_label: The Domain name label.The concatenation of the domain name label - and vm index will be the domain name labels of the PublicIPAddress resources that will be - created. Required. - :paramtype domain_name_label: str - """ - super().__init__(**kwargs) - self.domain_name_label = domain_name_label - - -class VirtualMachineScaleSetVMReimageParameters(VirtualMachineReimageParameters): # pylint: disable=name-too-long - """Describes a Virtual Machine Scale Set VM Reimage Parameters. - - :ivar temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This temp - disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :vartype temp_disk: bool - """ - - -class VirtualMachineScaleSetReimageParameters(VirtualMachineScaleSetVMReimageParameters): - """Describes a Virtual Machine Scale Set VM Reimage Parameters. - - :ivar temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This temp - disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :vartype temp_disk: bool - :ivar instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :vartype instance_ids: list[str] - """ - - _attribute_map = { - "temp_disk": {"key": "tempDisk", "type": "bool"}, - "instance_ids": {"key": "instanceIds", "type": "[str]"}, - } - - def __init__( - self, *, temp_disk: Optional[bool] = None, instance_ids: Optional[List[str]] = None, **kwargs: Any - ) -> None: - """ - :keyword temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This - temp disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :paramtype temp_disk: bool - :keyword instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :paramtype instance_ids: list[str] - """ - super().__init__(temp_disk=temp_disk, **kwargs) - self.instance_ids = instance_ids - - -class VirtualMachineScaleSetSku(_serialization.Model): - """Describes an available virtual machine scale set sku. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of resource the sku applies to. - :vartype resource_type: str - :ivar sku: The Sku. - :vartype sku: ~azure.mgmt.compute.v2019_12_01.models.Sku - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetSkuCapacity - """ - - _validation = { - "resource_type": {"readonly": True}, - "sku": {"readonly": True}, - "capacity": {"readonly": True}, - } - - _attribute_map = { - "resource_type": {"key": "resourceType", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "capacity": {"key": "capacity", "type": "VirtualMachineScaleSetSkuCapacity"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_type: Optional[str] = None - self.sku: Optional["_models.Sku"] = None - self.capacity: Optional["_models.VirtualMachineScaleSetSkuCapacity"] = None - - -class VirtualMachineScaleSetSkuCapacity(_serialization.Model): - """Describes scaling information of a sku. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar minimum: The minimum capacity. - :vartype minimum: int - :ivar maximum: The maximum capacity that can be set. - :vartype maximum: int - :ivar default_capacity: The default capacity. - :vartype default_capacity: int - :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic" and - "None". - :vartype scale_type: str or - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetSkuScaleType - """ - - _validation = { - "minimum": {"readonly": True}, - "maximum": {"readonly": True}, - "default_capacity": {"readonly": True}, - "scale_type": {"readonly": True}, - } - - _attribute_map = { - "minimum": {"key": "minimum", "type": "int"}, - "maximum": {"key": "maximum", "type": "int"}, - "default_capacity": {"key": "defaultCapacity", "type": "int"}, - "scale_type": {"key": "scaleType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.minimum: Optional[int] = None - self.maximum: Optional[int] = None - self.default_capacity: Optional[int] = None - self.scale_type: Optional[Union[str, "_models.VirtualMachineScaleSetSkuScaleType"]] = None - - -class VirtualMachineScaleSetStorageProfile(_serialization.Model): - """Describes a virtual machine scale set storage profile. - - :ivar image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :vartype image_reference: ~azure.mgmt.compute.v2019_12_01.models.ImageReference - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetOSDisk - :ivar data_disks: Specifies the parameters that are used to add data disks to the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :vartype data_disks: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetDataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "VirtualMachineScaleSetOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[VirtualMachineScaleSetDataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :paramtype image_reference: ~azure.mgmt.compute.v2019_12_01.models.ImageReference - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetOSDisk - :keyword data_disks: Specifies the parameters that are used to add data disks to the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :paramtype data_disks: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetDataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class VirtualMachineScaleSetUpdate(UpdateResource): - """Describes a Virtual Machine Scale Set. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The virtual machine scale set sku. - :vartype sku: ~azure.mgmt.compute.v2019_12_01.models.Sku - :ivar plan: The purchase plan when deploying a virtual machine scale set from VM Marketplace - images. - :vartype plan: ~azure.mgmt.compute.v2019_12_01.models.Plan - :ivar identity: The identity of the virtual machine scale set, if configured. - :vartype identity: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetIdentity - :ivar upgrade_policy: The upgrade policy. - :vartype upgrade_policy: ~azure.mgmt.compute.v2019_12_01.models.UpgradePolicy - :ivar automatic_repairs_policy: Policy for automatic repairs. - :vartype automatic_repairs_policy: - ~azure.mgmt.compute.v2019_12_01.models.AutomaticRepairsPolicy - :ivar virtual_machine_profile: The virtual machine profile. - :vartype virtual_machine_profile: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetUpdateVMProfile - :ivar overprovision: Specifies whether the Virtual Machine Scale Set should be overprovisioned. - :vartype overprovision: bool - :ivar do_not_run_extensions_on_overprovisioned_v_ms: When Overprovision is enabled, extensions - are launched only on the requested number of VMs which are finally kept. This property will - hence ensure that the extensions do not run on the extra overprovisioned VMs. - :vartype do_not_run_extensions_on_overprovisioned_v_ms: bool - :ivar single_placement_group: When true this limits the scale set to a single placement group, - of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be modified to - false. However, if singlePlacementGroup is false, it may not be modified to true. - :vartype single_placement_group: bool - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines - have the capability to support attaching managed data disks with UltraSSD_LRS storage account - type. - :vartype additional_capabilities: ~azure.mgmt.compute.v2019_12_01.models.AdditionalCapabilities - :ivar scale_in_policy: Specifies the scale-in policy that decides which virtual machines are - chosen for removal when a Virtual Machine Scale Set is scaled-in. - :vartype scale_in_policy: ~azure.mgmt.compute.v2019_12_01.models.ScaleInPolicy - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the virtual machine scale set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "identity": {"key": "identity", "type": "VirtualMachineScaleSetIdentity"}, - "upgrade_policy": {"key": "properties.upgradePolicy", "type": "UpgradePolicy"}, - "automatic_repairs_policy": {"key": "properties.automaticRepairsPolicy", "type": "AutomaticRepairsPolicy"}, - "virtual_machine_profile": { - "key": "properties.virtualMachineProfile", - "type": "VirtualMachineScaleSetUpdateVMProfile", - }, - "overprovision": {"key": "properties.overprovision", "type": "bool"}, - "do_not_run_extensions_on_overprovisioned_v_ms": { - "key": "properties.doNotRunExtensionsOnOverprovisionedVMs", - "type": "bool", - }, - "single_placement_group": {"key": "properties.singlePlacementGroup", "type": "bool"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "scale_in_policy": {"key": "properties.scaleInPolicy", "type": "ScaleInPolicy"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["_models.UpgradePolicy"] = None, - automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, - overprovision: Optional[bool] = None, - do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, - single_placement_group: Optional[bool] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - scale_in_policy: Optional["_models.ScaleInPolicy"] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The virtual machine scale set sku. - :paramtype sku: ~azure.mgmt.compute.v2019_12_01.models.Sku - :keyword plan: The purchase plan when deploying a virtual machine scale set from VM Marketplace - images. - :paramtype plan: ~azure.mgmt.compute.v2019_12_01.models.Plan - :keyword identity: The identity of the virtual machine scale set, if configured. - :paramtype identity: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetIdentity - :keyword upgrade_policy: The upgrade policy. - :paramtype upgrade_policy: ~azure.mgmt.compute.v2019_12_01.models.UpgradePolicy - :keyword automatic_repairs_policy: Policy for automatic repairs. - :paramtype automatic_repairs_policy: - ~azure.mgmt.compute.v2019_12_01.models.AutomaticRepairsPolicy - :keyword virtual_machine_profile: The virtual machine profile. - :paramtype virtual_machine_profile: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetUpdateVMProfile - :keyword overprovision: Specifies whether the Virtual Machine Scale Set should be - overprovisioned. - :paramtype overprovision: bool - :keyword do_not_run_extensions_on_overprovisioned_v_ms: When Overprovision is enabled, - extensions are launched only on the requested number of VMs which are finally kept. This - property will hence ensure that the extensions do not run on the extra overprovisioned VMs. - :paramtype do_not_run_extensions_on_overprovisioned_v_ms: bool - :keyword single_placement_group: When true this limits the scale set to a single placement - group, of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be - modified to false. However, if singlePlacementGroup is false, it may not be modified to true. - :paramtype single_placement_group: bool - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines - have the capability to support attaching managed data disks with UltraSSD_LRS storage account - type. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2019_12_01.models.AdditionalCapabilities - :keyword scale_in_policy: Specifies the scale-in policy that decides which virtual machines are - chosen for removal when a Virtual Machine Scale Set is scaled-in. - :paramtype scale_in_policy: ~azure.mgmt.compute.v2019_12_01.models.ScaleInPolicy - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the virtual machine scale set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource - """ - super().__init__(tags=tags, **kwargs) - self.sku = sku - self.plan = plan - self.identity = identity - self.upgrade_policy = upgrade_policy - self.automatic_repairs_policy = automatic_repairs_policy - self.virtual_machine_profile = virtual_machine_profile - self.overprovision = overprovision - self.do_not_run_extensions_on_overprovisioned_v_ms = do_not_run_extensions_on_overprovisioned_v_ms - self.single_placement_group = single_placement_group - self.additional_capabilities = additional_capabilities - self.scale_in_policy = scale_in_policy - self.proximity_placement_group = proximity_placement_group - - -class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's IP configuration. NOTE: The subnet of a - scale set may be modified as long as the original subnet and the new subnet are in the same - virtual network. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The IP configuration name. - :vartype name: str - :ivar subnet: The subnet. - :vartype subnet: ~azure.mgmt.compute.v2019_12_01.models.ApiEntityReference - :ivar primary: Specifies the primary IP Configuration in case the network interface has more - than one IP Configuration. - :vartype primary: bool - :ivar public_ip_address_configuration: The publicIPAddressConfiguration. - :vartype public_ip_address_configuration: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration - :ivar private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2019_12_01.models.IPVersion - :ivar application_gateway_backend_address_pools: The application gateway backend address pools. - :vartype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - :ivar application_security_groups: Specifies an array of references to application security - group. - :vartype application_security_groups: list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - :ivar load_balancer_backend_address_pools: The load balancer backend address pools. - :vartype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - :ivar load_balancer_inbound_nat_pools: The load balancer inbound nat pools. - :vartype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subnet": {"key": "properties.subnet", "type": "ApiEntityReference"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "public_ip_address_configuration": { - "key": "properties.publicIPAddressConfiguration", - "type": "VirtualMachineScaleSetUpdatePublicIPAddressConfiguration", - }, - "private_ip_address_version": {"key": "properties.privateIPAddressVersion", "type": "str"}, - "application_gateway_backend_address_pools": { - "key": "properties.applicationGatewayBackendAddressPools", - "type": "[SubResource]", - }, - "application_security_groups": {"key": "properties.applicationSecurityGroups", "type": "[SubResource]"}, - "load_balancer_backend_address_pools": { - "key": "properties.loadBalancerBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_inbound_nat_pools": {"key": "properties.loadBalancerInboundNatPools", "type": "[SubResource]"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - subnet: Optional["_models.ApiEntityReference"] = None, - primary: Optional[bool] = None, - public_ip_address_configuration: Optional[ - "_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration" - ] = None, - private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, - application_security_groups: Optional[List["_models.SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The IP configuration name. - :paramtype name: str - :keyword subnet: The subnet. - :paramtype subnet: ~azure.mgmt.compute.v2019_12_01.models.ApiEntityReference - :keyword primary: Specifies the primary IP Configuration in case the network interface has more - than one IP Configuration. - :paramtype primary: bool - :keyword public_ip_address_configuration: The publicIPAddressConfiguration. - :paramtype public_ip_address_configuration: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration - :keyword private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2019_12_01.models.IPVersion - :keyword application_gateway_backend_address_pools: The application gateway backend address - pools. - :paramtype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - :keyword application_security_groups: Specifies an array of references to application security - group. - :paramtype application_security_groups: - list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - :keyword load_balancer_backend_address_pools: The load balancer backend address pools. - :paramtype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - :keyword load_balancer_inbound_nat_pools: The load balancer inbound nat pools. - :paramtype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2019_12_01.models.SubResource] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.subnet = subnet - self.primary = primary - self.public_ip_address_configuration = public_ip_address_configuration - self.private_ip_address_version = private_ip_address_version - self.application_gateway_backend_address_pools = application_gateway_backend_address_pools - self.application_security_groups = application_security_groups - self.load_balancer_backend_address_pools = load_balancer_backend_address_pools - self.load_balancer_inbound_nat_pools = load_balancer_inbound_nat_pools - - -class VirtualMachineScaleSetUpdateNetworkConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's network configurations. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The network configuration name. - :vartype name: str - :ivar primary: Whether this is a primary NIC on a virtual machine. - :vartype primary: bool - :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :vartype enable_accelerated_networking: bool - :ivar network_security_group: The network security group. - :vartype network_security_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar dns_settings: The dns settings to be applied on the network interfaces. - :vartype dns_settings: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :ivar ip_configurations: The virtual machine scale set IP Configuration. - :vartype ip_configurations: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetUpdateIPConfiguration] - :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :vartype enable_ip_forwarding: bool - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "enable_accelerated_networking": {"key": "properties.enableAcceleratedNetworking", "type": "bool"}, - "network_security_group": {"key": "properties.networkSecurityGroup", "type": "SubResource"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetNetworkConfigurationDnsSettings", - }, - "ip_configurations": { - "key": "properties.ipConfigurations", - "type": "[VirtualMachineScaleSetUpdateIPConfiguration]", - }, - "enable_ip_forwarding": {"key": "properties.enableIPForwarding", "type": "bool"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - primary: Optional[bool] = None, - enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["_models.SubResource"] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, - enable_ip_forwarding: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The network configuration name. - :paramtype name: str - :keyword primary: Whether this is a primary NIC on a virtual machine. - :paramtype primary: bool - :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :paramtype enable_accelerated_networking: bool - :keyword network_security_group: The network security group. - :paramtype network_security_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword dns_settings: The dns settings to be applied on the network interfaces. - :paramtype dns_settings: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :keyword ip_configurations: The virtual machine scale set IP Configuration. - :paramtype ip_configurations: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetUpdateIPConfiguration] - :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :paramtype enable_ip_forwarding: bool - """ - super().__init__(id=id, **kwargs) - self.name = name - self.primary = primary - self.enable_accelerated_networking = enable_accelerated_networking - self.network_security_group = network_security_group - self.dns_settings = dns_settings - self.ip_configurations = ip_configurations - self.enable_ip_forwarding = enable_ip_forwarding - - -class VirtualMachineScaleSetUpdateNetworkProfile(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile. - - :ivar health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :vartype health_probe: ~azure.mgmt.compute.v2019_12_01.models.ApiEntityReference - :ivar network_interface_configurations: The list of network configurations. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] - """ - - _attribute_map = { - "health_probe": {"key": "healthProbe", "type": "ApiEntityReference"}, - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineScaleSetUpdateNetworkConfiguration]", - }, - } - - def __init__( - self, - *, - health_probe: Optional["_models.ApiEntityReference"] = None, - network_interface_configurations: Optional[ - List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :paramtype health_probe: ~azure.mgmt.compute.v2019_12_01.models.ApiEntityReference - :keyword network_interface_configurations: The list of network configurations. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] - """ - super().__init__(**kwargs) - self.health_probe = health_probe - self.network_interface_configurations = network_interface_configurations - - -class VirtualMachineScaleSetUpdateOSDisk(_serialization.Model): - """Describes virtual machine scale set operating system disk Update Object. This should be used - for Updating VMSS OS Disk. - - :ivar caching: The caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar disk_size_gb: Specifies the size of the operating system disk in gigabytes. This element - can be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before - using it to attach to the Virtual Machine. If SourceImage is provided, the destination - VirtualHardDisk should not exist. - :vartype image: ~azure.mgmt.compute.v2019_12_01.models.VirtualHardDisk - :ivar vhd_containers: The list of virtual hard disk container uris. - :vartype vhd_containers: list[str] - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - - _attribute_map = { - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "vhd_containers": {"key": "vhdContainers", "type": "[str]"}, - "managed_disk": {"key": "managedDisk", "type": "VirtualMachineScaleSetManagedDiskParameters"}, - } - - def __init__( - self, - *, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - disk_size_gb: Optional[int] = None, - image: Optional["_models.VirtualHardDisk"] = None, - vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword caching: The caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword disk_size_gb: Specifies the size of the operating system disk in gigabytes. This - element can be used to overwrite the size of the disk in a virtual machine image. - :code:`
    `\\ :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied - before using it to attach to the Virtual Machine. If SourceImage is provided, the destination - VirtualHardDisk should not exist. - :paramtype image: ~azure.mgmt.compute.v2019_12_01.models.VirtualHardDisk - :keyword vhd_containers: The list of virtual hard disk container uris. - :paramtype vhd_containers: list[str] - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - super().__init__(**kwargs) - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.disk_size_gb = disk_size_gb - self.image = image - self.vhd_containers = vhd_containers - self.managed_disk = managed_disk - - -class VirtualMachineScaleSetUpdateOSProfile(_serialization.Model): - """Describes a virtual machine scale set OS profile. - - :ivar custom_data: A base-64 encoded string of custom data. - :vartype custom_data: str - :ivar windows_configuration: The Windows Configuration of the OS profile. - :vartype windows_configuration: ~azure.mgmt.compute.v2019_12_01.models.WindowsConfiguration - :ivar linux_configuration: The Linux Configuration of the OS profile. - :vartype linux_configuration: ~azure.mgmt.compute.v2019_12_01.models.LinuxConfiguration - :ivar secrets: The List of certificates for addition to the VM. - :vartype secrets: list[~azure.mgmt.compute.v2019_12_01.models.VaultSecretGroup] - """ - - _attribute_map = { - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - } - - def __init__( - self, - *, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword custom_data: A base-64 encoded string of custom data. - :paramtype custom_data: str - :keyword windows_configuration: The Windows Configuration of the OS profile. - :paramtype windows_configuration: ~azure.mgmt.compute.v2019_12_01.models.WindowsConfiguration - :keyword linux_configuration: The Linux Configuration of the OS profile. - :paramtype linux_configuration: ~azure.mgmt.compute.v2019_12_01.models.LinuxConfiguration - :keyword secrets: The List of certificates for addition to the VM. - :paramtype secrets: list[~azure.mgmt.compute.v2019_12_01.models.VaultSecretGroup] - """ - super().__init__(**kwargs) - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - - -class VirtualMachineScaleSetUpdatePublicIPAddressConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines scale set IP Configuration's PublicIPAddress configuration. - - :ivar name: The publicIP address configuration name. - :vartype name: str - :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. - :vartype idle_timeout_in_minutes: int - :ivar dns_settings: The dns settings to be applied on the publicIP addresses . - :vartype dns_settings: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "idle_timeout_in_minutes": {"key": "properties.idleTimeoutInMinutes", "type": "int"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings", - }, - } - - def __init__( - self, - *, - name: Optional[str] = None, - idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The publicIP address configuration name. - :paramtype name: str - :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. - :paramtype idle_timeout_in_minutes: int - :keyword dns_settings: The dns settings to be applied on the publicIP addresses . - :paramtype dns_settings: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - """ - super().__init__(**kwargs) - self.name = name - self.idle_timeout_in_minutes = idle_timeout_in_minutes - self.dns_settings = dns_settings - - -class VirtualMachineScaleSetUpdateStorageProfile(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machine scale set storage profile. - - :ivar image_reference: The image reference. - :vartype image_reference: ~azure.mgmt.compute.v2019_12_01.models.ImageReference - :ivar os_disk: The OS disk. - :vartype os_disk: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetUpdateOSDisk - :ivar data_disks: The data disks. - :vartype data_disks: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetDataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "VirtualMachineScaleSetUpdateOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[VirtualMachineScaleSetDataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: The image reference. - :paramtype image_reference: ~azure.mgmt.compute.v2019_12_01.models.ImageReference - :keyword os_disk: The OS disk. - :paramtype os_disk: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetUpdateOSDisk - :keyword data_disks: The data disks. - :paramtype data_disks: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetDataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class VirtualMachineScaleSetUpdateVMProfile(_serialization.Model): - """Describes a virtual machine scale set virtual machine profile. - - :ivar os_profile: The virtual machine scale set OS profile. - :vartype os_profile: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetUpdateOSProfile - :ivar storage_profile: The virtual machine scale set storage profile. - :vartype storage_profile: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetUpdateStorageProfile - :ivar network_profile: The virtual machine scale set network profile. - :vartype network_profile: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetUpdateNetworkProfile - :ivar diagnostics_profile: The virtual machine scale set diagnostics profile. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2019_12_01.models.DiagnosticsProfile - :ivar extension_profile: The virtual machine scale set extension profile. - :vartype extension_profile: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtensionProfile - :ivar license_type: The license type, which is for bring your own license scenario. - :vartype license_type: str - :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2019_12_01.models.BillingProfile - :ivar scheduled_events_profile: Specifies Scheduled Event related configurations. - :vartype scheduled_events_profile: - ~azure.mgmt.compute.v2019_12_01.models.ScheduledEventsProfile - """ - - _attribute_map = { - "os_profile": {"key": "osProfile", "type": "VirtualMachineScaleSetUpdateOSProfile"}, - "storage_profile": {"key": "storageProfile", "type": "VirtualMachineScaleSetUpdateStorageProfile"}, - "network_profile": {"key": "networkProfile", "type": "VirtualMachineScaleSetUpdateNetworkProfile"}, - "diagnostics_profile": {"key": "diagnosticsProfile", "type": "DiagnosticsProfile"}, - "extension_profile": {"key": "extensionProfile", "type": "VirtualMachineScaleSetExtensionProfile"}, - "license_type": {"key": "licenseType", "type": "str"}, - "billing_profile": {"key": "billingProfile", "type": "BillingProfile"}, - "scheduled_events_profile": {"key": "scheduledEventsProfile", "type": "ScheduledEventsProfile"}, - } - - def __init__( - self, - *, - os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, - license_type: Optional[str] = None, - billing_profile: Optional["_models.BillingProfile"] = None, - scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_profile: The virtual machine scale set OS profile. - :paramtype os_profile: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetUpdateOSProfile - :keyword storage_profile: The virtual machine scale set storage profile. - :paramtype storage_profile: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetUpdateStorageProfile - :keyword network_profile: The virtual machine scale set network profile. - :paramtype network_profile: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetUpdateNetworkProfile - :keyword diagnostics_profile: The virtual machine scale set diagnostics profile. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2019_12_01.models.DiagnosticsProfile - :keyword extension_profile: The virtual machine scale set extension profile. - :paramtype extension_profile: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtensionProfile - :keyword license_type: The license type, which is for bring your own license scenario. - :paramtype license_type: str - :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2019_12_01.models.BillingProfile - :keyword scheduled_events_profile: Specifies Scheduled Event related configurations. - :paramtype scheduled_events_profile: - ~azure.mgmt.compute.v2019_12_01.models.ScheduledEventsProfile - """ - super().__init__(**kwargs) - self.os_profile = os_profile - self.storage_profile = storage_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.extension_profile = extension_profile - self.license_type = license_type - self.billing_profile = billing_profile - self.scheduled_events_profile = scheduled_events_profile - - -class VirtualMachineScaleSetVM(Resource): - """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. - :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] - :ivar instance_id: The virtual machine instance ID. - :vartype instance_id: str - :ivar sku: The virtual machine SKU. - :vartype sku: ~azure.mgmt.compute.v2019_12_01.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2019_12_01.models.Plan - :ivar resources: The virtual machine child extension resources. - :vartype resources: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] - :ivar zones: The virtual machine zones. - :vartype zones: list[str] - :ivar latest_model_applied: Specifies whether the latest model has been applied to the virtual - machine. - :vartype latest_model_applied: bool - :ivar vm_id: Azure VM unique ID. - :vartype vm_id: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMInstanceView - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2019_12_01.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2019_12_01.models.StorageProfile - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine in the scale set. For instance: whether the virtual machine has the capability - to support attaching managed data disks with UltraSSD_LRS storage account type. - :vartype additional_capabilities: ~azure.mgmt.compute.v2019_12_01.models.AdditionalCapabilities - :ivar os_profile: Specifies the operating system settings for the virtual machine. - :vartype os_profile: ~azure.mgmt.compute.v2019_12_01.models.OSProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2019_12_01.models.NetworkProfile - :ivar network_profile_configuration: Specifies the network profile configuration of the virtual - machine. - :vartype network_profile_configuration: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMNetworkProfileConfiguration - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2019_12_01.models.DiagnosticsProfile - :ivar availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :vartype availability_set: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar model_definition_applied: Specifies whether the model applied to the virtual machine is - the model of the virtual machine scale set or the customized model for the virtual machine. - :vartype model_definition_applied: str - :ivar protection_policy: Specifies the protection policy of the virtual machine. - :vartype protection_policy: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMProtectionPolicy - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "instance_id": {"readonly": True}, - "sku": {"readonly": True}, - "resources": {"readonly": True}, - "zones": {"readonly": True}, - "latest_model_applied": {"readonly": True}, - "vm_id": {"readonly": True}, - "instance_view": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "model_definition_applied": {"readonly": 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}"}, - "instance_id": {"key": "instanceId", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "resources": {"key": "resources", "type": "[VirtualMachineExtension]"}, - "zones": {"key": "zones", "type": "[str]"}, - "latest_model_applied": {"key": "properties.latestModelApplied", "type": "bool"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineScaleSetVMInstanceView"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "network_profile_configuration": { - "key": "properties.networkProfileConfiguration", - "type": "VirtualMachineScaleSetVMNetworkProfileConfiguration", - }, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "model_definition_applied": {"key": "properties.modelDefinitionApplied", "type": "str"}, - "protection_policy": {"key": "properties.protectionPolicy", "type": "VirtualMachineScaleSetVMProtectionPolicy"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - os_profile: Optional["_models.OSProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - network_profile_configuration: Optional["_models.VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - protection_policy: Optional["_models.VirtualMachineScaleSetVMProtectionPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2019_12_01.models.Plan - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2019_12_01.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2019_12_01.models.StorageProfile - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine in the scale set. For instance: whether the virtual machine has the capability - to support attaching managed data disks with UltraSSD_LRS storage account type. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2019_12_01.models.AdditionalCapabilities - :keyword os_profile: Specifies the operating system settings for the virtual machine. - :paramtype os_profile: ~azure.mgmt.compute.v2019_12_01.models.OSProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2019_12_01.models.NetworkProfile - :keyword network_profile_configuration: Specifies the network profile configuration of the - virtual machine. - :paramtype network_profile_configuration: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMNetworkProfileConfiguration - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2019_12_01.models.DiagnosticsProfile - :keyword availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :paramtype availability_set: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - :keyword protection_policy: Specifies the protection policy of the virtual machine. - :paramtype protection_policy: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMProtectionPolicy - """ - super().__init__(location=location, tags=tags, **kwargs) - self.instance_id: Optional[str] = None - self.sku: Optional["_models.Sku"] = None - self.plan = plan - self.resources: Optional[List["_models.VirtualMachineExtension"]] = None - self.zones: Optional[List[str]] = None - self.latest_model_applied: Optional[bool] = None - self.vm_id: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineScaleSetVMInstanceView"] = None - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.additional_capabilities = additional_capabilities - self.os_profile = os_profile - self.network_profile = network_profile - self.network_profile_configuration = network_profile_configuration - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.provisioning_state: Optional[str] = None - self.license_type = license_type - self.model_definition_applied: Optional[str] = None - self.protection_policy = protection_policy - - -class VirtualMachineScaleSetVMExtensionsSummary(_serialization.Model): # pylint: disable=name-too-long - """Extensions summary for virtual machines of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The extension name. - :vartype name: str - :ivar statuses_summary: The extensions information. - :vartype statuses_summary: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineStatusCodeCount] - """ - - _validation = { - "name": {"readonly": True}, - "statuses_summary": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "statuses_summary": {"key": "statusesSummary", "type": "[VirtualMachineStatusCodeCount]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.statuses_summary: Optional[List["_models.VirtualMachineStatusCodeCount"]] = None - - -class VirtualMachineScaleSetVMInstanceIDs(_serialization.Model): - """Specifies a list of virtual machine instance IDs from the VM scale set. - - :ivar instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :vartype instance_ids: list[str] - """ - - _attribute_map = { - "instance_ids": {"key": "instanceIds", "type": "[str]"}, - } - - def __init__(self, *, instance_ids: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :paramtype instance_ids: list[str] - """ - super().__init__(**kwargs) - self.instance_ids = instance_ids - - -class VirtualMachineScaleSetVMInstanceRequiredIDs(_serialization.Model): # pylint: disable=name-too-long - """Specifies a list of virtual machine instance IDs from the VM scale set. - - All required parameters must be populated in order to send to server. - - :ivar instance_ids: The virtual machine scale set instance ids. Required. - :vartype instance_ids: list[str] - """ - - _validation = { - "instance_ids": {"required": True}, - } - - _attribute_map = { - "instance_ids": {"key": "instanceIds", "type": "[str]"}, - } - - def __init__(self, *, instance_ids: List[str], **kwargs: Any) -> None: - """ - :keyword instance_ids: The virtual machine scale set instance ids. Required. - :paramtype instance_ids: list[str] - """ - super().__init__(**kwargs) - self.instance_ids = instance_ids - - -class VirtualMachineScaleSetVMInstanceView(_serialization.Model): - """The instance view of a virtual machine scale set VM. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar platform_update_domain: The Update Domain count. - :vartype platform_update_domain: int - :ivar platform_fault_domain: The Fault Domain count. - :vartype platform_fault_domain: int - :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. - :vartype rdp_thumb_print: str - :ivar vm_agent: The VM Agent running on the virtual machine. - :vartype vm_agent: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineAgentInstanceView - :ivar maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :vartype maintenance_redeploy_status: - ~azure.mgmt.compute.v2019_12_01.models.MaintenanceRedeployStatus - :ivar disks: The disks information. - :vartype disks: list[~azure.mgmt.compute.v2019_12_01.models.DiskInstanceView] - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionInstanceView] - :ivar vm_health: The health status for the VM. - :vartype vm_health: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineHealthStatus - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2019_12_01.models.BootDiagnosticsInstanceView - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - :ivar placement_group_id: The placement group in which the VM is running. If the VM is - deallocated it will not have a placementGroupId. - :vartype placement_group_id: str - """ - - _validation = { - "vm_health": {"readonly": True}, - } - - _attribute_map = { - "platform_update_domain": {"key": "platformUpdateDomain", "type": "int"}, - "platform_fault_domain": {"key": "platformFaultDomain", "type": "int"}, - "rdp_thumb_print": {"key": "rdpThumbPrint", "type": "str"}, - "vm_agent": {"key": "vmAgent", "type": "VirtualMachineAgentInstanceView"}, - "maintenance_redeploy_status": {"key": "maintenanceRedeployStatus", "type": "MaintenanceRedeployStatus"}, - "disks": {"key": "disks", "type": "[DiskInstanceView]"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineExtensionInstanceView]"}, - "vm_health": {"key": "vmHealth", "type": "VirtualMachineHealthStatus"}, - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnosticsInstanceView"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - "placement_group_id": {"key": "placementGroupId", "type": "str"}, - } - - def __init__( - self, - *, - platform_update_domain: Optional[int] = None, - platform_fault_domain: Optional[int] = None, - rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, - disks: Optional[List["_models.DiskInstanceView"]] = None, - extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - placement_group_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword platform_update_domain: The Update Domain count. - :paramtype platform_update_domain: int - :keyword platform_fault_domain: The Fault Domain count. - :paramtype platform_fault_domain: int - :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. - :paramtype rdp_thumb_print: str - :keyword vm_agent: The VM Agent running on the virtual machine. - :paramtype vm_agent: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineAgentInstanceView - :keyword maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :paramtype maintenance_redeploy_status: - ~azure.mgmt.compute.v2019_12_01.models.MaintenanceRedeployStatus - :keyword disks: The disks information. - :paramtype disks: list[~azure.mgmt.compute.v2019_12_01.models.DiskInstanceView] - :keyword extensions: The extensions information. - :paramtype extensions: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionInstanceView] - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2019_12_01.models.BootDiagnosticsInstanceView - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2019_12_01.models.InstanceViewStatus] - :keyword placement_group_id: The placement group in which the VM is running. If the VM is - deallocated it will not have a placementGroupId. - :paramtype placement_group_id: str - """ - super().__init__(**kwargs) - self.platform_update_domain = platform_update_domain - self.platform_fault_domain = platform_fault_domain - self.rdp_thumb_print = rdp_thumb_print - self.vm_agent = vm_agent - self.maintenance_redeploy_status = maintenance_redeploy_status - self.disks = disks - self.extensions = extensions - self.vm_health: Optional["_models.VirtualMachineHealthStatus"] = None - self.boot_diagnostics = boot_diagnostics - self.statuses = statuses - self.placement_group_id = placement_group_id - - -class VirtualMachineScaleSetVMListResult(_serialization.Model): - """The List Virtual Machine Scale Set VMs operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets VMs. Required. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Set VMs. Call - ListNext() with this to fetch the next page of VMSS VMs. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetVM]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets VMs. Required. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Set VMs. Call - ListNext() with this to fetch the next page of VMSS VMs. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetVMNetworkProfileConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machine scale set VM network profile. - - :ivar network_interface_configurations: The list of network configurations. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetNetworkConfiguration] - """ - - _attribute_map = { - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineScaleSetNetworkConfiguration]", - }, - } - - def __init__( - self, - *, - network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword network_interface_configurations: The list of network configurations. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetNetworkConfiguration] - """ - super().__init__(**kwargs) - self.network_interface_configurations = network_interface_configurations - - -class VirtualMachineScaleSetVMProfile(_serialization.Model): - """Describes a virtual machine scale set virtual machine profile. - - :ivar os_profile: Specifies the operating system settings for the virtual machines in the scale - set. - :vartype os_profile: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetOSProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetStorageProfile - :ivar network_profile: Specifies properties of the network interfaces of the virtual machines - in the scale set. - :vartype network_profile: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetNetworkProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2019_12_01.models.DiagnosticsProfile - :ivar extension_profile: Specifies a collection of settings for extensions installed on virtual - machines in the scale set. - :vartype extension_profile: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtensionProfile - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
    `\\ :code:`
    `Minimum api-version: 2017-10-30-preview. Known values are: - "Regular", "Low", and "Spot". - :vartype priority: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachinePriorityTypes - :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, both - 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. - :code:`
    `\\ :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are - supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and - "Delete". - :vartype eviction_policy: str or - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineEvictionPolicyTypes - :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2019_12_01.models.BillingProfile - :ivar scheduled_events_profile: Specifies Scheduled Event related configurations. - :vartype scheduled_events_profile: - ~azure.mgmt.compute.v2019_12_01.models.ScheduledEventsProfile - """ - - _attribute_map = { - "os_profile": {"key": "osProfile", "type": "VirtualMachineScaleSetOSProfile"}, - "storage_profile": {"key": "storageProfile", "type": "VirtualMachineScaleSetStorageProfile"}, - "network_profile": {"key": "networkProfile", "type": "VirtualMachineScaleSetNetworkProfile"}, - "diagnostics_profile": {"key": "diagnosticsProfile", "type": "DiagnosticsProfile"}, - "extension_profile": {"key": "extensionProfile", "type": "VirtualMachineScaleSetExtensionProfile"}, - "license_type": {"key": "licenseType", "type": "str"}, - "priority": {"key": "priority", "type": "str"}, - "eviction_policy": {"key": "evictionPolicy", "type": "str"}, - "billing_profile": {"key": "billingProfile", "type": "BillingProfile"}, - "scheduled_events_profile": {"key": "scheduledEventsProfile", "type": "ScheduledEventsProfile"}, - } - - def __init__( - self, - *, - os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, - license_type: Optional[str] = None, - priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["_models.BillingProfile"] = None, - scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_profile: Specifies the operating system settings for the virtual machines in the - scale set. - :paramtype os_profile: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetOSProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetStorageProfile - :keyword network_profile: Specifies properties of the network interfaces of the virtual - machines in the scale set. - :paramtype network_profile: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetNetworkProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2019_12_01.models.DiagnosticsProfile - :keyword extension_profile: Specifies a collection of settings for extensions installed on - virtual machines in the scale set. - :paramtype extension_profile: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtensionProfile - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
    `\\ :code:`
    `Minimum api-version: 2017-10-30-preview. Known values are: - "Regular", "Low", and "Spot". - :paramtype priority: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachinePriorityTypes - :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, both - 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. - :code:`
    `\\ :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are - supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and - "Delete". - :paramtype eviction_policy: str or - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineEvictionPolicyTypes - :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2019_12_01.models.BillingProfile - :keyword scheduled_events_profile: Specifies Scheduled Event related configurations. - :paramtype scheduled_events_profile: - ~azure.mgmt.compute.v2019_12_01.models.ScheduledEventsProfile - """ - super().__init__(**kwargs) - self.os_profile = os_profile - self.storage_profile = storage_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.extension_profile = extension_profile - self.license_type = license_type - self.priority = priority - self.eviction_policy = eviction_policy - self.billing_profile = billing_profile - self.scheduled_events_profile = scheduled_events_profile - - -class VirtualMachineScaleSetVMProtectionPolicy(_serialization.Model): - """The protection policy of a virtual machine scale set VM. - - :ivar protect_from_scale_in: Indicates that the virtual machine scale set VM shouldn't be - considered for deletion during a scale-in operation. - :vartype protect_from_scale_in: bool - :ivar protect_from_scale_set_actions: Indicates that model updates or actions (including - scale-in) initiated on the virtual machine scale set should not be applied to the virtual - machine scale set VM. - :vartype protect_from_scale_set_actions: bool - """ - - _attribute_map = { - "protect_from_scale_in": {"key": "protectFromScaleIn", "type": "bool"}, - "protect_from_scale_set_actions": {"key": "protectFromScaleSetActions", "type": "bool"}, - } - - def __init__( - self, - *, - protect_from_scale_in: Optional[bool] = None, - protect_from_scale_set_actions: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword protect_from_scale_in: Indicates that the virtual machine scale set VM shouldn't be - considered for deletion during a scale-in operation. - :paramtype protect_from_scale_in: bool - :keyword protect_from_scale_set_actions: Indicates that model updates or actions (including - scale-in) initiated on the virtual machine scale set should not be applied to the virtual - machine scale set VM. - :paramtype protect_from_scale_set_actions: bool - """ - super().__init__(**kwargs) - self.protect_from_scale_in = protect_from_scale_in - self.protect_from_scale_set_actions = protect_from_scale_set_actions - - -class VirtualMachineSize(_serialization.Model): - """Describes the properties of a VM size. - - :ivar name: The name of the virtual machine size. - :vartype name: str - :ivar number_of_cores: The number of cores supported by the virtual machine size. - :vartype number_of_cores: int - :ivar os_disk_size_in_mb: The OS disk size, in MB, allowed by the virtual machine size. - :vartype os_disk_size_in_mb: int - :ivar resource_disk_size_in_mb: The resource disk size, in MB, allowed by the virtual machine - size. - :vartype resource_disk_size_in_mb: int - :ivar memory_in_mb: The amount of memory, in MB, supported by the virtual machine size. - :vartype memory_in_mb: int - :ivar max_data_disk_count: The maximum number of data disks that can be attached to the virtual - machine size. - :vartype max_data_disk_count: int - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "number_of_cores": {"key": "numberOfCores", "type": "int"}, - "os_disk_size_in_mb": {"key": "osDiskSizeInMB", "type": "int"}, - "resource_disk_size_in_mb": {"key": "resourceDiskSizeInMB", "type": "int"}, - "memory_in_mb": {"key": "memoryInMB", "type": "int"}, - "max_data_disk_count": {"key": "maxDataDiskCount", "type": "int"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - number_of_cores: Optional[int] = None, - os_disk_size_in_mb: Optional[int] = None, - resource_disk_size_in_mb: Optional[int] = None, - memory_in_mb: Optional[int] = None, - max_data_disk_count: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the virtual machine size. - :paramtype name: str - :keyword number_of_cores: The number of cores supported by the virtual machine size. - :paramtype number_of_cores: int - :keyword os_disk_size_in_mb: The OS disk size, in MB, allowed by the virtual machine size. - :paramtype os_disk_size_in_mb: int - :keyword resource_disk_size_in_mb: The resource disk size, in MB, allowed by the virtual - machine size. - :paramtype resource_disk_size_in_mb: int - :keyword memory_in_mb: The amount of memory, in MB, supported by the virtual machine size. - :paramtype memory_in_mb: int - :keyword max_data_disk_count: The maximum number of data disks that can be attached to the - virtual machine size. - :paramtype max_data_disk_count: int - """ - super().__init__(**kwargs) - self.name = name - self.number_of_cores = number_of_cores - self.os_disk_size_in_mb = os_disk_size_in_mb - self.resource_disk_size_in_mb = resource_disk_size_in_mb - self.memory_in_mb = memory_in_mb - self.max_data_disk_count = max_data_disk_count - - -class VirtualMachineSizeListResult(_serialization.Model): - """The List Virtual Machine operation response. - - :ivar value: The list of virtual machine sizes. - :vartype value: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineSize] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineSize]"}, - } - - def __init__(self, *, value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of virtual machine sizes. - :paramtype value: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineSize] - """ - super().__init__(**kwargs) - self.value = value - - -class VirtualMachineStatusCodeCount(_serialization.Model): - """The status code and count of the virtual machine scale set instance view status summary. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The instance view status code. - :vartype code: str - :ivar count: The number of instances having a particular status code. - :vartype count: int - """ - - _validation = { - "code": {"readonly": True}, - "count": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "count": {"key": "count", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.count: Optional[int] = None - - -class VirtualMachineUpdate(UpdateResource): - """Describes a Virtual Machine Update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2019_12_01.models.Plan - :ivar identity: The identity of the virtual machine, if configured. - :vartype identity: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineIdentity - :ivar zones: The virtual machine zones. - :vartype zones: list[str] - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2019_12_01.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2019_12_01.models.StorageProfile - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine. - :vartype additional_capabilities: ~azure.mgmt.compute.v2019_12_01.models.AdditionalCapabilities - :ivar os_profile: Specifies the operating system settings used while creating the virtual - machine. Some of the settings cannot be changed once VM is provisioned. - :vartype os_profile: ~azure.mgmt.compute.v2019_12_01.models.OSProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2019_12_01.models.NetworkProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2019_12_01.models.DiagnosticsProfile - :ivar availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. The availability set to which the VM is being added should be under the same resource - group as the availability set resource. An existing VM cannot be added to an availability set. - :code:`
    `\\ :code:`
    `This property cannot exist along with a non-null - properties.virtualMachineScaleSet reference. - :vartype availability_set: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar virtual_machine_scale_set: Specifies information about the virtual machine scale set that - the virtual machine should be assigned to. Virtual machines specified in the same virtual - machine scale set are allocated to different nodes to maximize availability. Currently, a VM - can only be added to virtual machine scale set at creation time. An existing VM cannot be added - to a virtual machine scale set. :code:`
    `\\ :code:`
    `This property cannot exist along - with a non-null properties.availabilitySet reference. :code:`
    `\\ :code:`
    `Minimum - api‐version: 2019‐03‐01. - :vartype virtual_machine_scale_set: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the virtual machine should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar priority: Specifies the priority for the virtual machine. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :vartype priority: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachinePriorityTypes - :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, both - 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. - :code:`
    `\\ :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are - supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and - "Delete". - :vartype eviction_policy: str or - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineEvictionPolicyTypes - :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2019_12_01.models.BillingProfile - :ivar host: Specifies information about the dedicated host that the virtual machine resides in. - :code:`
    `\\ :code:`
    `Minimum api-version: 2018-10-01. - :vartype host: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineInstanceView - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar vm_id: Specifies the VM unique ID which is a 128-bits identifier that is encoded and - stored in all Azure IaaS VMs SMBIOS and can be read using platform BIOS commands. - :vartype vm_id: str - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - "vm_id": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "plan": {"key": "plan", "type": "Plan"}, - "identity": {"key": "identity", "type": "VirtualMachineIdentity"}, - "zones": {"key": "zones", "type": "[str]"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "virtual_machine_scale_set": {"key": "properties.virtualMachineScaleSet", "type": "SubResource"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "priority": {"key": "properties.priority", "type": "str"}, - "eviction_policy": {"key": "properties.evictionPolicy", "type": "str"}, - "billing_profile": {"key": "properties.billingProfile", "type": "BillingProfile"}, - "host": {"key": "properties.host", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineInstanceView"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineIdentity"] = None, - zones: Optional[List[str]] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - os_profile: Optional["_models.OSProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - virtual_machine_scale_set: Optional["_models.SubResource"] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["_models.BillingProfile"] = None, - host: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2019_12_01.models.Plan - :keyword identity: The identity of the virtual machine, if configured. - :paramtype identity: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineIdentity - :keyword zones: The virtual machine zones. - :paramtype zones: list[str] - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2019_12_01.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2019_12_01.models.StorageProfile - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2019_12_01.models.AdditionalCapabilities - :keyword os_profile: Specifies the operating system settings used while creating the virtual - machine. Some of the settings cannot be changed once VM is provisioned. - :paramtype os_profile: ~azure.mgmt.compute.v2019_12_01.models.OSProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2019_12_01.models.NetworkProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2019_12_01.models.DiagnosticsProfile - :keyword availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. The availability set to which the VM is being added should be under the same resource - group as the availability set resource. An existing VM cannot be added to an availability set. - :code:`
    `\\ :code:`
    `This property cannot exist along with a non-null - properties.virtualMachineScaleSet reference. - :paramtype availability_set: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword virtual_machine_scale_set: Specifies information about the virtual machine scale set - that the virtual machine should be assigned to. Virtual machines specified in the same virtual - machine scale set are allocated to different nodes to maximize availability. Currently, a VM - can only be added to virtual machine scale set at creation time. An existing VM cannot be added - to a virtual machine scale set. :code:`
    `\\ :code:`
    `This property cannot exist along - with a non-null properties.availabilitySet reference. :code:`
    `\\ :code:`
    `Minimum - api‐version: 2019‐03‐01. - :paramtype virtual_machine_scale_set: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the virtual machine should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword priority: Specifies the priority for the virtual machine. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :paramtype priority: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachinePriorityTypes - :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, both - 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. - :code:`
    `\\ :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are - supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and - "Delete". - :paramtype eviction_policy: str or - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineEvictionPolicyTypes - :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual - machine. :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2019_12_01.models.BillingProfile - :keyword host: Specifies information about the dedicated host that the virtual machine resides - in. :code:`
    `\\ :code:`
    `Minimum api-version: 2018-10-01. - :paramtype host: ~azure.mgmt.compute.v2019_12_01.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. This element is only used for images that contain the Windows Server operating - system. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server :code:`
    `\\ :code:`
    ` If this - element is included in a request for an update, the value must match the initial value. This - value cannot be updated. :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid - Use Benefit for Windows Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - """ - super().__init__(tags=tags, **kwargs) - self.plan = plan - self.identity = identity - self.zones = zones - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.additional_capabilities = additional_capabilities - self.os_profile = os_profile - self.network_profile = network_profile - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.virtual_machine_scale_set = virtual_machine_scale_set - self.proximity_placement_group = proximity_placement_group - self.priority = priority - self.eviction_policy = eviction_policy - self.billing_profile = billing_profile - self.host = host - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineInstanceView"] = None - self.license_type = license_type - self.vm_id: Optional[str] = None - - -class VMScaleSetConvertToSinglePlacementGroupInput(_serialization.Model): # pylint: disable=name-too-long - """VMScaleSetConvertToSinglePlacementGroupInput. - - :ivar active_placement_group_id: Id of the placement group in which you want future virtual - machine instances to be placed. To query placement group Id, please use Virtual Machine Scale - Set VMs - Get API. If not provided, the platform will choose one with maximum number of virtual - machine instances. - :vartype active_placement_group_id: str - """ - - _attribute_map = { - "active_placement_group_id": {"key": "activePlacementGroupId", "type": "str"}, - } - - def __init__(self, *, active_placement_group_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword active_placement_group_id: Id of the placement group in which you want future virtual - machine instances to be placed. To query placement group Id, please use Virtual Machine Scale - Set VMs - Get API. If not provided, the platform will choose one with maximum number of virtual - machine instances. - :paramtype active_placement_group_id: str - """ - super().__init__(**kwargs) - self.active_placement_group_id = active_placement_group_id - - -class WindowsConfiguration(_serialization.Model): - """Specifies Windows operating system settings on the virtual machine. - - :ivar provision_vm_agent: Indicates whether virtual machine agent should be provisioned on the - virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the request - body, default behavior is to set it to true. This will ensure that VM Agent is installed on - the VM so that extensions can be added to the VM later. - :vartype provision_vm_agent: bool - :ivar enable_automatic_updates: Indicates whether Automatic Updates is enabled for the Windows - virtual machine. Default value is true. :code:`
    `\\ :code:`
    ` For virtual machine scale - sets, this property can be updated and updates will take effect on OS reprovisioning. - :vartype enable_automatic_updates: bool - :ivar time_zone: Specifies the time zone of the virtual machine. e.g. "Pacific Standard Time". - :code:`
    `\\ :code:`
    ` Possible values can be `TimeZoneInfo.Id - `_ - value from time zones returned by `TimeZoneInfo.GetSystemTimeZones - `_. - :vartype time_zone: str - :ivar additional_unattend_content: Specifies additional base-64 encoded XML formatted - information that can be included in the Unattend.xml file, which is used by Windows Setup. - :vartype additional_unattend_content: - list[~azure.mgmt.compute.v2019_12_01.models.AdditionalUnattendContent] - :ivar win_rm: Specifies the Windows Remote Management listeners. This enables remote Windows - PowerShell. - :vartype win_rm: ~azure.mgmt.compute.v2019_12_01.models.WinRMConfiguration - """ - - _attribute_map = { - "provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"}, - "enable_automatic_updates": {"key": "enableAutomaticUpdates", "type": "bool"}, - "time_zone": {"key": "timeZone", "type": "str"}, - "additional_unattend_content": {"key": "additionalUnattendContent", "type": "[AdditionalUnattendContent]"}, - "win_rm": {"key": "winRM", "type": "WinRMConfiguration"}, - } - - def __init__( - self, - *, - provision_vm_agent: Optional[bool] = None, - enable_automatic_updates: Optional[bool] = None, - time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, - win_rm: Optional["_models.WinRMConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword provision_vm_agent: Indicates whether virtual machine agent should be provisioned on - the virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the - request body, default behavior is to set it to true. This will ensure that VM Agent is - installed on the VM so that extensions can be added to the VM later. - :paramtype provision_vm_agent: bool - :keyword enable_automatic_updates: Indicates whether Automatic Updates is enabled for the - Windows virtual machine. Default value is true. :code:`
    `\\ :code:`
    ` For virtual machine - scale sets, this property can be updated and updates will take effect on OS reprovisioning. - :paramtype enable_automatic_updates: bool - :keyword time_zone: Specifies the time zone of the virtual machine. e.g. "Pacific Standard - Time". :code:`
    `\\ :code:`
    ` Possible values can be `TimeZoneInfo.Id - `_ - value from time zones returned by `TimeZoneInfo.GetSystemTimeZones - `_. - :paramtype time_zone: str - :keyword additional_unattend_content: Specifies additional base-64 encoded XML formatted - information that can be included in the Unattend.xml file, which is used by Windows Setup. - :paramtype additional_unattend_content: - list[~azure.mgmt.compute.v2019_12_01.models.AdditionalUnattendContent] - :keyword win_rm: Specifies the Windows Remote Management listeners. This enables remote Windows - PowerShell. - :paramtype win_rm: ~azure.mgmt.compute.v2019_12_01.models.WinRMConfiguration - """ - super().__init__(**kwargs) - self.provision_vm_agent = provision_vm_agent - self.enable_automatic_updates = enable_automatic_updates - self.time_zone = time_zone - self.additional_unattend_content = additional_unattend_content - self.win_rm = win_rm - - -class WinRMConfiguration(_serialization.Model): - """Describes Windows Remote Management configuration of the VM. - - :ivar listeners: The list of Windows Remote Management listeners. - :vartype listeners: list[~azure.mgmt.compute.v2019_12_01.models.WinRMListener] - """ - - _attribute_map = { - "listeners": {"key": "listeners", "type": "[WinRMListener]"}, - } - - def __init__(self, *, listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs: Any) -> None: - """ - :keyword listeners: The list of Windows Remote Management listeners. - :paramtype listeners: list[~azure.mgmt.compute.v2019_12_01.models.WinRMListener] - """ - super().__init__(**kwargs) - self.listeners = listeners - - -class WinRMListener(_serialization.Model): - """Describes Protocol and thumbprint of Windows Remote Management listener. - - :ivar protocol: Specifies the protocol of WinRM listener. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. Known values are: - "Http" and "Https". - :vartype protocol: str or ~azure.mgmt.compute.v2019_12_01.models.ProtocolTypes - :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as - a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :vartype certificate_url: str - """ - - _attribute_map = { - "protocol": {"key": "protocol", "type": "str"}, - "certificate_url": {"key": "certificateUrl", "type": "str"}, - } - - def __init__( - self, - *, - protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, - certificate_url: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword protocol: Specifies the protocol of WinRM listener. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. Known - values are: "Http" and "Https". - :paramtype protocol: str or ~azure.mgmt.compute.v2019_12_01.models.ProtocolTypes - :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault - as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :paramtype certificate_url: str - """ - super().__init__(**kwargs) - self.protocol = protocol - self.certificate_url = certificate_url diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/__init__.py deleted file mode 100644 index b79bc7bf3104..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/__init__.py +++ /dev/null @@ -1,73 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import Operations # type: ignore -from ._operations import AvailabilitySetsOperations # 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 VirtualMachineExtensionImagesOperations # type: ignore -from ._operations import VirtualMachineExtensionsOperations # type: ignore -from ._operations import VirtualMachineImagesOperations # type: ignore -from ._operations import UsageOperations # type: ignore -from ._operations import VirtualMachinesOperations # type: ignore -from ._operations import VirtualMachineSizesOperations # type: ignore -from ._operations import ImagesOperations # 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 LogAnalyticsOperations # type: ignore -from ._operations import VirtualMachineRunCommandsOperations # type: ignore -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 ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AvailabilitySetsOperations", - "ProximityPlacementGroupsOperations", - "DedicatedHostGroupsOperations", - "DedicatedHostsOperations", - "SshPublicKeysOperations", - "VirtualMachineExtensionImagesOperations", - "VirtualMachineExtensionsOperations", - "VirtualMachineImagesOperations", - "UsageOperations", - "VirtualMachinesOperations", - "VirtualMachineSizesOperations", - "ImagesOperations", - "VirtualMachineScaleSetsOperations", - "VirtualMachineScaleSetExtensionsOperations", - "VirtualMachineScaleSetRollingUpgradesOperations", - "VirtualMachineScaleSetVMExtensionsOperations", - "VirtualMachineScaleSetVMsOperations", - "LogAnalyticsOperations", - "VirtualMachineRunCommandsOperations", - "GalleriesOperations", - "GalleryImagesOperations", - "GalleryImageVersionsOperations", - "GalleryApplicationsOperations", - "GalleryApplicationVersionsOperations", -] -__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/v2019_12_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_operations.py deleted file mode 100644 index 9134c8d83c7d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_operations.py +++ /dev/null @@ -1,23743 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterator, List, Literal, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import ComputeManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_operations_list_request(**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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/operations") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-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}", - ) - 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"), - } - - _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_availability_sets_delete_request( - resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_availability_sets_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes", - ) - 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"), - } - - _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_proximity_placement_groups_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-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}", - ) - 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"), - } - - _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_proximity_placement_groups_update_request( # pylint: disable=name-too-long - resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-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}", - ) - 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"), - } - - _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_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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 -) -> 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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", - ) - 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"), - } - - _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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dedicated_host_groups_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2019-12-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}", - ) - 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"), - } - - _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_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", "2019-12-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}", - ) - 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"), - } - - _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_dedicated_host_groups_delete_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_dedicated_host_groups_get_request( - 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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dedicated_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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dedicated_hosts_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2019-12-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}", - ) - 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"), - } - - _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_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", "2019-12-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}", - ) - 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"), - } - - _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_dedicated_hosts_delete_request( - resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_dedicated_hosts_get_request( - resource_group_name: str, - host_group_name: str, - host_name: str, - subscription_id: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", - ) - 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"), - } - - _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) - - -def build_dedicated_hosts_list_by_host_group_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/sshPublicKeys") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2019-12-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}", - ) - 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"), - } - - _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_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", "2019-12-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}", - ) - 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"), - } - - _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_ssh_public_keys_delete_request( - resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", - ) - 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"), - } - - _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_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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}/generateKeyPair", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_extension_images_get_request( # pylint: disable=name-too-long - location: str, publisher_name: str, type: str, version: str, subscription_id: str, **kwargs: Any -) -> 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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types", - ) - 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"), - } - - _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_extension_images_list_versions_request( # pylint: disable=name-too-long - location: str, - publisher_name: str, - type: str, - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - if orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2019-12-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-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}", - ) - 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"), - } - - _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_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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 -) -> 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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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) - - -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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", - ) - 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"), - } - - _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) - - -def build_virtual_machine_images_list_offers_request( # pylint: disable=name-too-long - location: str, publisher_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers" - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_images_list_skus_request( # pylint: disable=name-too-long - location: str, publisher_name: str, offer: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages" - ) - 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines", - ) - 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_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", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture", - ) - 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"), - } - - _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_machines_create_or_update_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", "2019-12-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_update_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", "2019-12-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}", - ) - 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"), - } - - _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_virtual_machines_delete_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_get_request( - resource_group_name: str, - vm_name: str, - subscription_id: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", - ) - 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"), - } - - _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) - - -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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView", - ) - 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"), - } - - _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_machines_convert_to_managed_disks_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_deallocate_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_generalize_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_list_all_request( - subscription_id: str, *, status_only: 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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if status_only is not None: - _params["statusOnly"] = _SERIALIZER.query("status_only", status_only, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes", - ) - 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"), - } - - _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_machines_power_off_request( - resource_group_name: str, vm_name: str, subscription_id: str, *, skip_shutdown: bool = False, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reapply", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_restart_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_start_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_redeploy_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -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", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_perform_maintenance_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/simulateEviction", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_run_command_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand", - ) - 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"), - } - - _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_sizes_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes" - ) - 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-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}", - ) - 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"), - } - - _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_images_delete_request( - resource_group_name: str, image_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", - ) - 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"), - } - - _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) - - -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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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, **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", "2019-12-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_update_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", "2019-12-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}", - ) - 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"), - } - - _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_virtual_machine_scale_sets_delete_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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, **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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", - ) - 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"), - } - - _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_scale_sets_deallocate_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", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_delete_instances_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **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", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_get_instance_view_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_list_all_request( # pylint: disable=name-too-long - subscription_id: str, **kwargs: Any -) -> 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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_list_skus_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory", - ) - 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"), - } - - _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_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 -) -> 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", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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, - **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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk", - ) - 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"), - } - - _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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", 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 -) -> 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", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/setOrchestrationServiceState", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2019-12-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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", "2019-12-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}", - ) - 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"), - } - - _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_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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 -) -> 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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions", - ) - 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"), - } - - _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_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> 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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest", - ) - 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"), - } - - _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_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", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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_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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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) - - -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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions", - ) - 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"), - } - - _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) - - -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", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_set_vms_reimage_all_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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, **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", "2019-12-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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: Literal["instanceView"] = "instanceView", - **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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView", - ) - 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"), - } - - _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_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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines", - ) - 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"), - } - - _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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machine_scale_set_vms_redeploy_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/simulateEviction", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> 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", "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand", - ) - 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"), - } - - _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_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", "2019-12-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", - ) - 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 -) -> 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", "2019-12-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", - ) - 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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands" - ) - 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", "2019-12-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}", - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"), - "commandId": _SERIALIZER.url("command_id", command_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_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", "2019-12-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/galleries/{galleryName}", - ) - 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"), - } - - _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_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", "2019-12-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/galleries/{galleryName}", - ) - 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"), - } - - _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_galleries_get_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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", - ) - 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"), - } - - _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) - - -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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2019-12-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/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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_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", "2019-12-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/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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_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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images", - ) - 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"), - } - - _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_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, - **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", "2019-12-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/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", - ) - 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"), - } - - _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_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", "2019-12-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/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", - ) - 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"), - } - - _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_image_versions_get_request( - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image_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", "2019-12-01")) - 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}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - 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}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - 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", - ) - 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"), - } - - _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_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", "2019-12-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/galleries/{galleryName}/applications/{galleryApplicationName}", - ) - 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"), - } - - _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", "2019-12-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/galleries/{galleryName}/applications/{galleryApplicationName}", - ) - 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"), - } - - _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_get_request( - 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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", - ) - 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"), - } - - _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_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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", - ) - 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"), - } - - _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) - - -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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications", - ) - 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"), - } - - _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_gallery_application_versions_create_or_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, - **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", "2019-12-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/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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_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, - **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", "2019-12-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/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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_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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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) - - -def build_gallery_application_versions_delete_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, - **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", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-12-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions", - ) - 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"), - } - - _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) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.ComputeManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.ComputeOperationValue"]: - """Gets a list of compute operations. - - :return: An iterator like instance of either ComputeOperationValue or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.ComputeOperationValue] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[_models.ComputeOperationListResult] = 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_operations_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def 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) - - 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 AvailabilitySetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.ComputeManagementClient`'s - :attr:`availability_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: _models.AvailabilitySet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySet, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Is either a - AvailabilitySet type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySet") - - _request = build_availability_sets_create_or_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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, - availability_set_name: str, - parameters: _models.AvailabilitySetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySetUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Is either a - AvailabilitySetUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySetUpdate or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySetUpdate") - - _request = build_availability_sets_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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 "2019-12-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.v2019_12_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", 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) - - _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("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription( - self, *, expand: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. - - :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.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets 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 AvailabilitySet or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - 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_available_sizes( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes that can be used to create a new virtual machine in - an existing availability set. - - :param resource_group_name: The name of the resource group. Required. - :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.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_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 - - if response.status_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 ProximityPlacementGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.ComputeManagementClient`'s - :attr:`proximity_placement_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - resource_group_name: str, - proximity_placement_group_name: str, - parameters: _models.ProximityPlacementGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Create or update a proximity placement group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Create Proximity Placement Group operation. - Required. - :type parameters: ~azure.mgmt.compute.v2019_12_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.v2019_12_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - proximity_placement_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Create or update a proximity placement group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Create Proximity Placement Group operation. - Required. - :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.v2019_12_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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 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. Is - either a ProximityPlacementGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroup or IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("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. 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.v2019_12_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.v2019_12_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. 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.v2019_12_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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 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. Is - either a ProximityPlacementGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroupUpdate or - IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ProximityPlacementGroupUpdate") - - _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, - ) - _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("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any - ) -> None: - """Delete a proximity placement group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - 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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _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, - 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 - - @distributed_trace - 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. 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.v2019_12_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - _request = build_proximity_placement_groups_get_request( - resource_group_name=resource_group_name, - proximity_placement_group_name=proximity_placement_group_name, - subscription_id=self._config.subscription_id, - include_colocation_status=include_colocation_status, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a subscription. - - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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 - ) -> ItemPaged["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a resource group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProximityPlacementGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class DedicatedHostGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.ComputeManagementClient`'s - :attr:`dedicated_host_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: _models.DedicatedHostGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroup, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Is either a - DedicatedHostGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroup or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DedicatedHostGroup") - - _request = build_dedicated_host_groups_create_or_update_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: _models.DedicatedHostGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroupUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :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: IO[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.v2019_12_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroupUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Is either - a DedicatedHostGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroupUpdate or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-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") - - _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) - - _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("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: - """ - 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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_dedicated_host_groups_delete_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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, host_group_name: str, **kwargs: Any) -> _models.DedicatedHostGroup: - """Retrieves information about a dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", 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, - 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("DedicatedHostGroup", 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 - ) -> ItemPaged["_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. - :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.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 - - if response.status_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, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_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 - - if response.status_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 DedicatedHostsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.ComputeManagementClient`'s - :attr:`dedicated_hosts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, 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 "2019-12-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, "DedicatedHost") - - _request = build_dedicated_hosts_create_or_update_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHost, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHost - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. 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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. Is either a DedicatedHost - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHost or IO[bytes] - :return: An instance of LROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.DedicatedHost] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, 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 "2019-12-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, "DedicatedHostUpdate") - - _request = build_dedicated_hosts_update_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, - 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]: - 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, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHostUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostUpdate - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host 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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Is either a - DedicatedHostUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostUpdate or IO[bytes] - :return: An instance of LROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.DedicatedHost] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_delete_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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, host_group_name: str, host_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete 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 - :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 "2019-12-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, - host_group_name=host_group_name, - host_name=host_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: DedicatedHost or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-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 - ) -> ItemPaged["_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. - :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.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.DedicatedHostListResult] = 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_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, - 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("DedicatedHostListResult", 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 SshPublicKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.ComputeManagementClient`'s - :attr:`ssh_public_keys` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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.v2019_12_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 "2019-12-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_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) - - 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 - ) -> ItemPaged["_models.SshPublicKeyResource"]: - """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in - the response to get the next page of SSH public keys. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either SshPublicKeyResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-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 - - def extract_data(pipeline_response): - deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @overload - def create( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: _models.SshPublicKeyResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to create the SSH public key. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_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.v2019_12_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. - - :param resource_group_name: The name of the resource group. 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.v2019_12_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: Union[_models.SshPublicKeyResource, IO[bytes]], - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. - - :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.v2019_12_01.models.SshPublicKeyResource or IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.SshPublicKeyResource - :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 "2019-12-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") - - _request = build_ssh_public_keys_create_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SshPublicKeyResource", 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, - ssh_public_key_name: str, - parameters: _models.SshPublicKeyUpdateResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _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 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.v2019_12_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.v2019_12_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2019_12_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2019_12_01.models.SshPublicKeyUpdateResource or - IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.SshPublicKeyResource - :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 "2019-12-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( - resource_group_name=resource_group_name, - ssh_public_key_name=ssh_public_key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("SshPublicKeyResource", 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, ssh_public_key_name: str, **kwargs: Any - ) -> None: - """Delete an SSH public key. - - :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: - """ - 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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_ssh_public_keys_delete_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) - - _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, 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. - :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.v2019_12_01.models.SshPublicKeyResource - :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 "2019-12-01")) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - - _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) - - _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("SshPublicKeyResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def generate_key_pair( - self, resource_group_name: str, ssh_public_key_name: str, **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. 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: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.SshPublicKeyGenerateKeyPairResult - :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 "2019-12-01")) - cls: ClsType[_models.SshPublicKeyGenerateKeyPairResult] = kwargs.pop("cls", None) - - _request = build_ssh_public_keys_generate_key_pair_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) - - _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("SshPublicKeyGenerateKeyPairResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class VirtualMachineExtensionImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_extension_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, type: str, version: str, **kwargs: Any - ) -> _models.VirtualMachineExtensionImage: - """Gets a virtual machine extension image. - - :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.v2019_12_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 "2019-12-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 - - @distributed_trace - def list_types( - self, location: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineExtensionImage]: - """Gets a list of virtual machine extension image types. - - :param location: The name of 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.v2019_12_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 "2019-12-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - - _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) - - _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 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 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.v2019_12_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 "2019-12-01")) - 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 - - -class VirtualMachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, 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 "2019-12-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, "VirtualMachineExtension") - - _request = build_virtual_machine_extensions_create_or_update_request( - resource_group_name=resource_group_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2019_12_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 VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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] - :keyword content_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.v2019_12_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2019_12_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.v2019_12_01.models.VirtualMachineExtension] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - 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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineExtensionUpdate") - - _request = build_virtual_machine_extensions_update_request( - resource_group_name=resource_group_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, - 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]: - 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, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to update the extension. - - :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: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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 - ) -> 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_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 LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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.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.v2019_12_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.v2019_12_01.models.VirtualMachineExtension] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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) - - _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, vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The operation to delete the extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the extension should be deleted. - 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-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, - 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) - - 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_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.v2019_12_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 "2019-12-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) - - deserialized = self._deserialize("VirtualMachineExtension", 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_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.v2019_12_01.models.VirtualMachineExtensionsListResult - :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 "2019-12-01")) - cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_list_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineExtensionsListResult", pipeline_response.http_response) - - 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.v2019_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.v2019_12_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 "2019-12-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.v2019_12_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 "2019-12-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. - - :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.v2019_12_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 "2019-12-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_list_offers_request( - location=location, - publisher_name=publisher_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_12_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 "2019-12-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 = 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_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 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.v2019_12_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 "2019-12-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _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) - - _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 - - -class UsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.ComputeManagementClient`'s - :attr:`usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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 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.v2019_12_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 "2019-12-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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -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.v2019_12_01.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.VirtualMachine"]: - """Gets all the virtual machines under the specified subscription for the specified location. - - :param location: The location for which virtual machines under the subscription are queried. - Required. - :type location: str - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-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 - - 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) - - def _capture_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-12-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 - - 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_capture( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachineCaptureParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. - - :param resource_group_name: The name of the resource group. Required. - :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.v2019_12_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.v2019_12_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. - - :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.v2019_12_01.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_capture( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. - - :param resource_group_name: The name of the resource group. 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.v2019_12_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.v2019_12_01.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineCaptureResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._capture_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineCaptureResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, 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.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 - ) - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, 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 "2019-12-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, "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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachine, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :param resource_group_name: The name of the resource group. 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.v2019_12_01.models.VirtualMachine - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :param resource_group_name: The name of the resource group. 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 content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :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 Create Virtual Machine operation. Is either a - VirtualMachine type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachine or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_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 "2019-12-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._create_or_update_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("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 _update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineUpdate, 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 "2019-12-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, "VirtualMachineUpdate") - - _request = build_virtual_machines_update_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 - - 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 = 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, - vm_name: str, - parameters: _models.VirtualMachineUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. - - :param resource_group_name: The name of the resource group. 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.v2019_12_01.models.VirtualMachineUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. - - :param resource_group_name: The name of the resource group. 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 content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_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]], - **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.v2019_12_01.models.VirtualMachineUpdate or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_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 "2019-12-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, - 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, **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 "2019-12-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, - 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, vm_name: str, **kwargs: Any) -> LROPoller[None]: - """The operation to delete 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 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 "2019-12-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, - 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_name: str, *, expand: Literal["instanceView"] = "instanceView", **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-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.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) - - _request = build_virtual_machines_instance_view_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineInstanceView", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _convert_to_managed_disks_initial( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> 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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_convert_to_managed_disks_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. :code:`
    `For Windows, please refer to - `Convert a virtual machine from unmanaged disks to managed disks. - `_.\\ - :code:`
    `For Linux, please refer to `Convert a virtual machine from unmanaged disks to - managed disks. - `_. - - :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 "2019-12-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._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 - ) - 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 _deallocate_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[Iterator[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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_deallocate(self, resource_group_name: str, vm_name: str, **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. - :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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._deallocate_initial( - resource_group_name=resource_group_name, - vm_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 - - @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. :code:`
    `For Windows, please refer to - `Create a managed image of a generalized VM in Azure - `_.\\ - :code:`
    `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 "2019-12-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 - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-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, - 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, **kwargs: Any) -> ItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-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, - 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_available_sizes( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes to which the specified virtual machine can be - resized. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_available_sizes_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _power_off_initial( - self, resource_group_name: str, vm_name: str, *, skip_shutdown: bool = False, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_power_off_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_power_off( - self, resource_group_name: str, vm_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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool - :return: An instance of 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 "2019-12-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, **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, - 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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_reapply_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. - :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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reapply_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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_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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_restart_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. - :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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._restart_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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_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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_start(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[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 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 "2019-12-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, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_redeploy_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_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 "2019-12-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]: - 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 "2019-12-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( - 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 - - 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_reimage( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[_models.VirtualMachineReimageParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: ~azure.mgmt.compute.v2019_12_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 the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. 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 the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. 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.v2019_12_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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-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_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # 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_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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_perform_maintenance(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: - """Shuts down the virtual machine, moves it to an already updated node, and powers it back on - during the self-service phase of planned maintenance. - - :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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_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 - - @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. The eviction will occur within - 30 minutes of calling the API. - - :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 "2019-12-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 _run_command_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, 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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RunCommandInput") - - _request = build_virtual_machines_run_command_request( - 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 - - 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_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.RunCommandInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_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.v2019_12_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._run_command_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineSizesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.VirtualMachineSize"]: - """This API is deprecated. Use `Resources Skus - `_. - - :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.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_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 - - 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 - - if response.status_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 ImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.ComputeManagementClient`'s - :attr:`images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any - ) -> 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 "2019-12-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, "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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: _models.Image, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Create or update 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 - :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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.Image] - :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. - - :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 - :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.v2019_12_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.v2019_12_01.models.Image] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._create_or_update_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: 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.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Image]( - 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]], - **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 "2019-12-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, "ImageUpdate") - - _request = build_images_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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, - image_name: str, - parameters: _models.ImageUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Update 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 - :param parameters: Parameters supplied to the Update Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Update 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 - :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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Update 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 - :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.v2019_12_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.v2019_12_01.models.Image] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: 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.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Image]( - 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]: - 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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_images_delete_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, image_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes an Image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - image_name=image_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, resource_group_name: str, image_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.Image: - """Gets an image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: Image or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.Image] = kwargs.pop("cls", None) - - _request = build_images_get_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Image", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Image"]: - """Gets the list of images 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 Image or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_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.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class 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.v2019_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, 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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualMachineScaleSet") - - _request = build_virtual_machine_scale_sets_create_or_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSet - :keyword content_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.v2019_12_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. 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 VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 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.v2019_12_01.models.VirtualMachineScaleSet or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_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 "2019-12-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, - 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]], - **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 "2019-12-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, "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, - 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]: - 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, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. - - :param resource_group_name: The name of the resource group. 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.v2019_12_01.models.VirtualMachineScaleSetUpdate - :keyword content_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.v2019_12_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. - - :param resource_group_name: The name of the resource group. 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: IO[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 VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_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]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update 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 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.v2019_12_01.models.VirtualMachineScaleSetUpdate or - IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_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 "2019-12-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, - 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, **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 "2019-12-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, - 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, vm_scale_set_name: str, **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 - :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 "2019-12-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, - 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, **kwargs: Any) -> _models.VirtualMachineScaleSet: - """Display information about a 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 - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _deallocate_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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_deallocate( - 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]: - """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. - :type 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.v2019_12_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_deallocate( - 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]: - """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. - :type 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_deallocate( - 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]: - """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. - :type 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.v2019_12_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 "2019-12-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, - 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 _delete_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-12-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") - - _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, - 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_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """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. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2019_12_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: - """ - - @overload - def begin_delete_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]: - """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. - 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_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, 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.v2019_12_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 "2019-12-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, - 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. - - :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.v2019_12_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 "2019-12-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 - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_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 - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-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_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: - 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) -> ItemPaged["_models.VirtualMachineScaleSet"]: - """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource - group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this - till nextLink is null to fetch all the VM Scale Sets. - - :return: An iterator like instance of either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = 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_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("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) - - 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_skus( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineScaleSetSku"]: - """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM - instances allowed for each SKU. - - :param resource_group_name: The name of the resource group. Required. - :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.v2019_12_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 "2019-12-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) - - @distributed_trace - def get_os_upgrade_history( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.UpgradeOperationHistoricalStatusInfo"]: - """Gets list of OS upgrades 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 - :return: An iterator like instance of either UpgradeOperationHistoricalStatusInfo or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_sets_get_os_upgrade_history_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListOSUpgradeHistory", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _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 - ) -> 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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_power_off_request( - resource_group_name=resource_group_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, - 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_power_off( - self, - resource_group_name: str, - vm_scale_set_name: 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) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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.v2019_12_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 - :keyword content_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: 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. - - :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 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 - :keyword content_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_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: bool = False, - **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. Required. - :type 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.v2019_12_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] - :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 "2019-12-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, - 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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_restart_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :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.v2019_12_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 "2019-12-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, - 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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_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 - 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_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.v2019_12_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. - - :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.v2019_12_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 "2019-12-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 _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]: - 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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_redeploy_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_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.v2019_12_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.v2019_12_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 "2019-12-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 - ) -> 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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_perform_maintenance( - 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]: - """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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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.v2019_12_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_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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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_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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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.v2019_12_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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-12-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") - - _request = build_virtual_machine_scale_sets_update_instances_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :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.v2019_12_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: - """ - - @overload - def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _reimage_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-12-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( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_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.v2019_12_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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Is either a - VirtualMachineScaleSetReimageParameters type or a IO[bytes] type. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetReimageParameters or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reimage_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_scale_set_reimage_input=vm_scale_set_reimage_input, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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_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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_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.v2019_12_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. - - :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.v2019_12_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 "2019-12-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 - - @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, **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 - :return: RecoveryWalkResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-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, - 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("RecoveryWalkResponse", 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 true 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.v2019_12_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 true 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 - 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 true 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. Is either a - VMScaleSetConvertToSinglePlacementGroupInput type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VMScaleSetConvertToSinglePlacementGroupInput") - - _request = build_virtual_machine_scale_sets_convert_to_single_placement_group_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - def _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]: - 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 "2019-12-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") - - _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, - 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_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. - - :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.v2019_12_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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_set_orchestration_service_state( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Changes ServiceState property for a given service. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the virtual machine scale set to create or update. - Required. - :type vm_scale_set_name: str - :param parameters: The input object for SetOrchestrationServiceState API. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_set_orchestration_service_state( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Changes ServiceState property for a given service. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the virtual machine scale set to create or update. - Required. - :type vm_scale_set_name: str - :param parameters: The input object for SetOrchestrationServiceState API. Is either a - OrchestrationServiceStateInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-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) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - -class 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.v2019_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtension, 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 "2019-12-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") - - _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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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. - - :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.v2019_12_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.v2019_12_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.v2019_12_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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.v2019_12_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.v2019_12_01.models.VirtualMachineScaleSetExtension] - :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 "2019-12-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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - 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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtensionUpdate") - - _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, - 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]: - 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, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtensionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :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.v2019_12_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.v2019_12_01.models.VirtualMachineScaleSetExtension] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2019-12-01")) - 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, - 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, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The operation to delete the extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be deleted. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSetExtension: - """The operation to get the extension. - - :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.v2019_12_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 "2019-12-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 - - @distributed_trace - def list( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_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.v2019_12_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 "2019-12-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) - - -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.v2019_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_rolling_upgrades_cancel_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - 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 - - 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. - - :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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._cancel_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **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, - 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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request( - resource_group_name=resource_group_name, - 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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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 "2019-12-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 - ) -> 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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = 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, - 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 - - return deserialized # type: ignore - - @distributed_trace - def begin_start_extension_upgrade( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Starts a rolling upgrade to move all extensions for all virtual machine scale set instances to - the latest available extension version. Instances which are already running the latest - extension versions are not affected. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-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 - - 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_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.v2019_12_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 "2019-12-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 - ) - - response = pipeline_response.http_response - - if response.status_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.v2019_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vm_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, 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 "2019-12-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, "VirtualMachineExtension") - - _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) - - _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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """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.v2019_12_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 VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] - :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.VirtualMachineExtension]: - """The operation to create or update the VMSS VM extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] - :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.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """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 VirtualMachineExtension type or a IO[bytes] type. Required. - :type extension_parameters: ~azure.mgmt.compute.v2019_12_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.v2019_12_01.models.VirtualMachineExtension] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.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, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, 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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineExtensionUpdate") - - _request = build_virtual_machine_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, - 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]: - 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, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to 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 Update Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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.VirtualMachineExtension]: - """The operation to 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 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 VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_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, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to 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 Update Virtual Machine Extension - operation. Is either a VirtualMachineExtensionUpdate type or a IO[bytes] type. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2019_12_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.v2019_12_01.models.VirtualMachineExtension] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.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, vm_extension_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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_extensions_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - 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, 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 resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :return: An instance of 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 "2019-12-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) - - 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, - instance_id: str, - vm_extension_name: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineExtension: - """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: VirtualMachineExtension or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.VirtualMachineExtension] = 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("VirtualMachineExtension", 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 - ) -> _models.VirtualMachineExtensionsListResult: - """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: VirtualMachineExtensionsListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionsListResult - :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 "2019-12-01")) - cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_extensions_list_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_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 VirtualMachineScaleSetVMsOperations: # 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.v2019_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _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 - ) -> 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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_scale_set_vm_reimage_input, (IOBase, bytes)): - _content = vm_scale_set_vm_reimage_input - else: - if vm_scale_set_vm_reimage_input is not None: - _json = self._serialize.body(vm_scale_set_vm_reimage_input, "VirtualMachineScaleSetVMReimageParameters") - else: - _json = None - - _request = build_virtual_machine_scale_set_vms_reimage_request( - 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 - 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_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Default value is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMReimageParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Default value is None. - :type vm_scale_set_vm_reimage_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[ - Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] - ] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Is either a VirtualMachineScaleSetVMReimageParameters type or a IO[bytes] type. Default value - is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2019_12_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 "2019-12-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, **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, - 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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_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. - :type 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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reimage_all_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - 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 "2019-12-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) - - 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_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. - :type 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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._deallocate_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, 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 "2019-12-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, "VirtualMachineScaleSetVM") - - _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, - 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, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.VirtualMachineScaleSetVM, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM - :keyword content_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.v2019_12_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - 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 VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. - Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM] - :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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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, - 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("VirtualMachineScaleSetVM", 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.VirtualMachineScaleSetVM].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetVM]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, 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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - 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, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes 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: 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 "2019-12-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, - 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, - instance_id: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_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 "2019-12-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.v2019_12_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 "2019-12-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 - ) -> ItemPaged["_models.VirtualMachineScaleSetVM"]: - """Gets a list of all virtual machines in a VM scale sets. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param virtual_machine_scale_set_name: The name of the VM scale set. Required. - :type virtual_machine_scale_set_name: str - :keyword filter: The filter to apply to the operation. Allowed values are - 'startswith(instanceView/statuses/code, 'PowerState') eq true', 'properties/latestModelApplied - eq true', 'properties/latestModelApplied eq false'. Default value is None. - :paramtype filter: str - :keyword select: The list parameters. Allowed values are 'instanceView', - 'instanceView/statuses'. Default value is None. - :paramtype select: str - :keyword expand: The expand expression to apply to the operation. Allowed values are - 'instanceView'. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_set_vms_list_request( - resource_group_name=resource_group_name, - virtual_machine_scale_set_name=virtual_machine_scale_set_name, - subscription_id=self._config.subscription_id, - filter=filter, - select=select, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVMListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _power_off_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - skip_shutdown: bool = False, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_power_off_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - skip_shutdown: bool = False, - **kwargs: Any - ) -> LROPoller[None]: - """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached - and you are getting charged for the resources. Instead, use deallocate to release resources and - avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-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 "2019-12-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 - - return deserialized # type: ignore - - @distributed_trace - def begin_restart( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Restarts a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type 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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._restart_initial( - resource_group_name=resource_group_name, - vm_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 - - 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, - 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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_start_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 - - return deserialized # type: ignore - - @distributed_trace - def begin_start( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Starts a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM 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 "2019-12-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_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 - - 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, - 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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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 vm_scale_set_name: The name of the VM 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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._redeploy_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **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, 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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_perform_maintenance( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Shuts down the virtual machine in a VMScaleSet, moves it to an already updated node, and powers - it back on during the self-service phase of planned maintenance. - - :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 "2019-12-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def simulate_eviction( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> None: - """The operation to simulate the eviction of spot virtual machine in a VM scale set. The eviction - will occur within 30 minutes of calling the API. - - :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 "2019-12-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 _run_command_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, 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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RunCommandInput") - - _request = build_virtual_machine_scale_set_vms_run_command_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 - 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_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - :type 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.v2019_12_01.models.RunCommandInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> 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. - :type 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.v2019_12_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.v2019_12_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._run_command_initial( - resource_group_name=resource_group_name, - vm_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("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, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class LogAnalyticsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.ComputeManagementClient`'s - :attr:`log_analytics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - 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 "2019-12-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, "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, - ) - _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_export_request_rate_by_interval( - self, - location: str, - parameters: _models.RequestRateByIntervalInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. - - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. - Required. - :type parameters: ~azure.mgmt.compute.v2019_12_01.models.RequestRateByIntervalInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.LogAnalyticsOperationResult] - :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. - - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_export_request_rate_by_interval( - self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. - - :param location: The 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.v2019_12_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.v2019_12_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 "2019-12-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, 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, - 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("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, 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.LogAnalyticsOperationResult].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 - ) - - def _export_throttled_requests_initial( - self, location: str, parameters: Union[_models.ThrottledRequestsInput, 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 "2019-12-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, - 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_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.v2019_12_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.v2019_12_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.v2019_12_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. - - :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.v2019_12_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.v2019_12_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 "2019-12-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, 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, - 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("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, 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.LogAnalyticsOperationResult].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 - ) - - -class VirtualMachineRunCommandsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.ComputeManagementClient`'s - :attr:`virtual_machine_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.RunCommandDocumentBase"]: - """Lists all available run commands for a subscription in a location. - - :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 - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_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 "2019-12-01")) - cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_run_commands_list_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RunCommandListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - 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, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: - """Gets specific run command for a subscription in a location. - - :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.v2019_12_01.models.RunCommandDocument - :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 "2019-12-01")) - cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) - - _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, - 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("RunCommandDocument", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class GalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.ComputeManagementClient`'s - :attr:`galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2019-12-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(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 - - 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) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: _models.Gallery, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_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. - Required. - :type gallery_name: str - :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. - Required. - :type gallery: ~azure.mgmt.compute.v2019_12_01.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.v2019_12_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2019_12_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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. Is - either a Gallery type or a IO[bytes] type. Required. - :type gallery: ~azure.mgmt.compute.v2019_12_01.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.v2019_12_01.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 "2019-12-01")) - 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) - - 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, **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 _update_initial( - self, - resource_group_name: str, - gallery_name: str, - gallery: Union[_models.GalleryUpdate, 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 "2019-12-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(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) - - _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]: - 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, - 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. 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 update Shared Image Gallery operation. Required. - :type gallery: ~azure.mgmt.compute.v2019_12_01.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.v2019_12_01.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. 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 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.v2019_12_01.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. 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 update Shared Image Gallery operation. Is either a - GalleryUpdate type or a IO[bytes] type. Required. - :type gallery: ~azure.mgmt.compute.v2019_12_01.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.v2019_12_01.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 "2019-12-01")) - 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, **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 - ) - - @distributed_trace - def get(self, resource_group_name: str, gallery_name: str, **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 - :return: Gallery or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.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 "2019-12-01")) - 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, - 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("Gallery", 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, **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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_galleries_delete_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) - - _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, gallery_name: str, **kwargs: Any) -> LROPoller[None]: - """Delete 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 to be deleted. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-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, - gallery_name=gallery_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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.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 "2019-12-01")) - 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 - - 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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_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.v2019_12_01.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 "2019-12-01")) - 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 - - 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) - - 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 GalleryImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.ComputeManagementClient`'s - :attr:`gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_image_name: str, - gallery_image: Union[_models.GalleryImage, 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 "2019-12-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(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 = 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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.v2019_12_01.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.v2019_12_01.models.GalleryImage] - :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: IO[bytes], - *, - 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: IO[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.v2019_12_01.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2019_12_01.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.v2019_12_01.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 "2019-12-01")) - 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) - - 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: 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, - ) - return LROPoller[_models.GalleryImage]( - 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: Union[_models.GalleryImageUpdate, 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 "2019-12-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(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 = 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: - 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, - 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.v2019_12_01.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.v2019_12_01.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2019_12_01.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image: Union[_models.GalleryImageUpdate, IO[bytes]], - **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. Is either a - GalleryImageUpdate type or a IO[bytes] type. Required. - :type gallery_image: ~azure.mgmt.compute.v2019_12_01.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.v2019_12_01.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 "2019-12-01")) - 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) - - 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: 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, - ) - 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_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.v2019_12_01.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 "2019-12-01")) - cls: ClsType[_models.GalleryImage] = kwargs.pop("cls", None) - - _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) - raise HttpResponseError(response=response, 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 _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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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) - - _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, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> LROPoller[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 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 "2019-12-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, - 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 - ) -> ItemPaged["_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.v2019_12_01.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 "2019-12-01")) - cls: ClsType[_models.GalleryImageList] = 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_images_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("GalleryImageList", 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 GalleryImageVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.ComputeManagementClient`'s - :attr:`gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_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 "2019-12-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(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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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.v2019_12_01.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.v2019_12_01.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. 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.v2019_12_01.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2019_12_01.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.v2019_12_01.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 "2019-12-01")) - 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, **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, - 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 "2019-12-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(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) - - _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]: - 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, - 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. - - :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.v2019_12_01.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.v2019_12_01.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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 LROPoller that returns either GalleryImageVersion or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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 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.v2019_12_01.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.v2019_12_01.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 "2019-12-01")) - 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) - - 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, **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 - ) - - @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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2019_12_01.models.ReplicationStatusTypes - :return: GalleryImageVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.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 "2019-12-01")) - 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( - 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, - 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 "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - **kwargs: Any - ) -> LROPoller[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 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 "2019-12-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, - 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 - - 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_image( - self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> ItemPaged["_models.GalleryImageVersion"]: - """List gallery Image Versions in 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 - resides. 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) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.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 "2019-12-01")) - cls: ClsType[_models.GalleryImageVersionList] = 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_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, - 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("GalleryImageVersionList", 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 GalleryApplicationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.ComputeManagementClient`'s - :attr:`gallery_applications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application: Union[_models.GalleryApplication, 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 "2019-12-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(gallery_application, (IOBase, bytes)): - _content = gallery_application - else: - _json = self._serialize.body(gallery_application, "GalleryApplication") - - _request = build_gallery_applications_create_or_update_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, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: _models.GalleryApplication, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2019_12_01.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 GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_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]: - """Create or update 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 is to be created. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the create or 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.v2019_12_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplication, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2019_12_01.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.v2019_12_01.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 "2019-12-01")) - 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._create_or_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, **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 _update_initial( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, 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 "2019-12-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(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_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, - ) - _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]: - 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, - gallery_application_name: str, - gallery_application: _models.GalleryApplicationUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the update gallery Application operation. - Required. - :type gallery_application: ~azure.mgmt.compute.v2019_12_01.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.v2019_12_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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 is to be updated. 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. - :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.v2019_12_01.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. 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. - :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. - :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.v2019_12_01.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.v2019_12_01.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 "2019-12-01")) - 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, **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 - ) - - @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.v2019_12_01.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 "2019-12-01")) - 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 - ) -> 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 "2019-12-01")) - 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) - 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, 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. 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. - :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be deleted. - 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 "2019-12-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, - 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, **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 - ) -> ItemPaged["_models.GalleryApplication"]: - """List gallery Application 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 Application Gallery from which Application - Definitions are to be listed. 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.v2019_12_01.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 "2019-12-01")) - cls: ClsType[_models.GalleryApplicationList] = 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_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: - 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 GalleryApplicationVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2019_12_01.ComputeManagementClient`'s - :attr:`gallery_application_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: Union[_models.GalleryApplicationVersion, 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 "2019-12-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(gallery_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersion") - - _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, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersion, - *, - 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. - :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 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.v2019_12_01.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 GalleryApplicationVersion or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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], - *, - 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. - :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 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] - :keyword content_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.v2019_12_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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]], - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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.v2019_12_01.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.v2019_12_01.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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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) - if cont_token is None: - 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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.GalleryApplicationVersion]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - 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]], - **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 "2019-12-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(gallery_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersionUpdate") - - _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, - 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]: - 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, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2019_12_01.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 GalleryApplicationVersion or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update 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 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] - :keyword content_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.v2019_12_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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]], - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2019_12_01.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.v2019_12_01.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 "2019-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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) - 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_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 - ) - 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: 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.GalleryApplicationVersion].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - 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, - 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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2019_12_01.models.ReplicationStatusTypes - :return: GalleryApplicationVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2019_12_01.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 "2019-12-01")) - 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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Delete 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 - deleted. 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-12-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, - 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, - 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_application( - self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> ItemPaged["_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.v2019_12_01.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 "2019-12-01")) - 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) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2020_05_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_compute_management_client.py deleted file mode 100644 index f06c113d57f2..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_compute_management_client.py +++ /dev/null @@ -1,132 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import DiskAccessesOperations, DiskEncryptionSetsOperations, DisksOperations, SnapshotsOperations - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar disks: DisksOperations operations - :vartype disks: azure.mgmt.compute.v2020_05_01.operations.DisksOperations - :ivar snapshots: SnapshotsOperations operations - :vartype snapshots: azure.mgmt.compute.v2020_05_01.operations.SnapshotsOperations - :ivar disk_encryption_sets: DiskEncryptionSetsOperations operations - :vartype disk_encryption_sets: - azure.mgmt.compute.v2020_05_01.operations.DiskEncryptionSetsOperations - :ivar disk_accesses: DiskAccessesOperations operations - :vartype disk_accesses: azure.mgmt.compute.v2020_05_01.operations.DiskAccessesOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-05-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - 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, "2020-05-01") - self.snapshots = SnapshotsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-05-01" - ) - self.disk_encryption_sets = DiskEncryptionSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-05-01" - ) - self.disk_accesses = DiskAccessesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-05-01" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_configuration.py deleted file mode 100644 index c593b74856c1..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-05-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2020-05-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_metadata.json deleted file mode 100644 index 148fd0b9b794..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_metadata.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "chosen_version": "2020-05-01", - "total_api_version_list": ["2020-05-01"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "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.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "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.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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", - "snapshots": "SnapshotsOperations", - "disk_encryption_sets": "DiskEncryptionSetsOperations", - "disk_accesses": "DiskAccessesOperations" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node
    is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj 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 deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2020_05_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/_compute_management_client.py deleted file mode 100644 index dd4167fc08ee..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/_compute_management_client.py +++ /dev/null @@ -1,136 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import DiskAccessesOperations, DiskEncryptionSetsOperations, DisksOperations, SnapshotsOperations - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar disks: DisksOperations operations - :vartype disks: azure.mgmt.compute.v2020_05_01.aio.operations.DisksOperations - :ivar snapshots: SnapshotsOperations operations - :vartype snapshots: azure.mgmt.compute.v2020_05_01.aio.operations.SnapshotsOperations - :ivar disk_encryption_sets: DiskEncryptionSetsOperations operations - :vartype disk_encryption_sets: - azure.mgmt.compute.v2020_05_01.aio.operations.DiskEncryptionSetsOperations - :ivar disk_accesses: DiskAccessesOperations operations - :vartype disk_accesses: azure.mgmt.compute.v2020_05_01.aio.operations.DiskAccessesOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-05-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - 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, "2020-05-01") - self.snapshots = SnapshotsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-05-01" - ) - self.disk_encryption_sets = DiskEncryptionSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-05-01" - ) - self.disk_accesses = DiskAccessesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-05-01" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/_configuration.py deleted file mode 100644 index 95afb544c581..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-05-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2020-05-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/__init__.py deleted file mode 100644 index daa94a7f93b2..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/__init__.py +++ /dev/null @@ -1,31 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import DisksOperations # type: ignore -from ._operations import SnapshotsOperations # type: ignore -from ._operations import DiskEncryptionSetsOperations # type: ignore -from ._operations import DiskAccessesOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DisksOperations", - "SnapshotsOperations", - "DiskEncryptionSetsOperations", - "DiskAccessesOperations", -] -__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/v2020_05_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/__init__.py deleted file mode 100644 index 73e346dc390c..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/__init__.py +++ /dev/null @@ -1,122 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - AccessUri, - ApiError, - ApiErrorBase, - CreationData, - Disk, - DiskAccess, - DiskAccessList, - DiskAccessUpdate, - DiskEncryptionSet, - DiskEncryptionSetList, - DiskEncryptionSetUpdate, - DiskList, - DiskSku, - DiskUpdate, - Encryption, - EncryptionSetIdentity, - EncryptionSettingsCollection, - EncryptionSettingsElement, - GrantAccessData, - ImageDiskReference, - InnerError, - KeyVaultAndKeyReference, - KeyVaultAndSecretReference, - PrivateEndpoint, - PrivateEndpointConnection, - PrivateLinkResource, - PrivateLinkResourceListResult, - PrivateLinkServiceConnectionState, - Resource, - ShareInfoElement, - Snapshot, - SnapshotList, - SnapshotSku, - SnapshotUpdate, - SourceVault, -) - -from ._compute_management_client_enums import ( # type: ignore - AccessLevel, - DiskCreateOption, - DiskEncryptionSetIdentityType, - DiskState, - DiskStorageAccountTypes, - EncryptionType, - HyperVGeneration, - NetworkAccessPolicy, - OperatingSystemTypes, - PrivateEndpointConnectionProvisioningState, - PrivateEndpointServiceConnectionStatus, - SnapshotStorageAccountTypes, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AccessUri", - "ApiError", - "ApiErrorBase", - "CreationData", - "Disk", - "DiskAccess", - "DiskAccessList", - "DiskAccessUpdate", - "DiskEncryptionSet", - "DiskEncryptionSetList", - "DiskEncryptionSetUpdate", - "DiskList", - "DiskSku", - "DiskUpdate", - "Encryption", - "EncryptionSetIdentity", - "EncryptionSettingsCollection", - "EncryptionSettingsElement", - "GrantAccessData", - "ImageDiskReference", - "InnerError", - "KeyVaultAndKeyReference", - "KeyVaultAndSecretReference", - "PrivateEndpoint", - "PrivateEndpointConnection", - "PrivateLinkResource", - "PrivateLinkResourceListResult", - "PrivateLinkServiceConnectionState", - "Resource", - "ShareInfoElement", - "Snapshot", - "SnapshotList", - "SnapshotSku", - "SnapshotUpdate", - "SourceVault", - "AccessLevel", - "DiskCreateOption", - "DiskEncryptionSetIdentityType", - "DiskState", - "DiskStorageAccountTypes", - "EncryptionType", - "HyperVGeneration", - "NetworkAccessPolicy", - "OperatingSystemTypes", - "PrivateEndpointConnectionProvisioningState", - "PrivateEndpointServiceConnectionStatus", - "SnapshotStorageAccountTypes", -] -__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/v2020_05_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/_compute_management_client_enums.py deleted file mode 100644 index 23017fa32d69..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/_compute_management_client_enums.py +++ /dev/null @@ -1,149 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AccessLevel.""" - - NONE = "None" - READ = "Read" - WRITE = "Write" - - -class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This enumerates the possible sources of a disk's creation.""" - - EMPTY = "Empty" - """Create an empty data disk of a size given by diskSizeGB.""" - ATTACH = "Attach" - """Disk will be attached to a VM.""" - FROM_IMAGE = "FromImage" - """Create a new disk from a platform image specified by the given imageReference or - galleryImageReference.""" - IMPORT = "Import" - """Create a disk by importing from a blob specified by a sourceUri in a storage account specified - by storageAccountId.""" - COPY = "Copy" - """Create a new disk or snapshot by copying from a disk or snapshot specified by the given - sourceResourceId.""" - RESTORE = "Restore" - """Create a new disk by copying from a backup recovery point.""" - UPLOAD = "Upload" - """Create a new disk by obtaining a write token and using it to directly upload the contents of - the disk.""" - IMPORT_ENUM = "Import" - """Create a disk by importing from a blob specified by a sourceUri in a storage account specified - by storageAccountId.""" - - -class DiskEncryptionSetIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported.""" - - SYSTEM_ASSIGNED = "SystemAssigned" - - -class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The state of the disk.""" - - UNATTACHED = "Unattached" - """The disk is not being used and can be attached to a VM.""" - ATTACHED = "Attached" - """The disk is currently mounted to a running VM.""" - RESERVED = "Reserved" - """The disk is mounted to a stopped-deallocated VM""" - ACTIVE_SAS = "ActiveSAS" - """The disk currently has an Active SAS Uri associated with it.""" - READY_TO_UPLOAD = "ReadyToUpload" - """A disk is ready to be created by upload by requesting a write token.""" - ACTIVE_UPLOAD = "ActiveUpload" - """A disk is created for upload and a write token has been issued for uploading to it.""" - - -class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The sku name.""" - - STANDARD_LRS = "Standard_LRS" - """Standard HDD locally redundant storage. Best for backup, non-critical, and infrequent access.""" - PREMIUM_LRS = "Premium_LRS" - """Premium SSD locally redundant storage. Best for production and performance sensitive workloads.""" - STANDARD_SSD_LRS = "StandardSSD_LRS" - """Standard SSD locally redundant storage. Best for web servers, lightly used enterprise - applications and dev/test.""" - ULTRA_SSD_LRS = "UltraSSD_LRS" - """Ultra SSD locally redundant storage. Best for IO-intensive workloads such as SAP HANA, top tier - databases (for example, SQL, Oracle), and other transaction-heavy workloads.""" - - -class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of key used to encrypt the data of the disk.""" - - ENCRYPTION_AT_REST_WITH_PLATFORM_KEY = "EncryptionAtRestWithPlatformKey" - """Disk is encrypted at rest with Platform managed key. It is the default encryption type. This is - not a valid encryption type for disk encryption sets.""" - ENCRYPTION_AT_REST_WITH_CUSTOMER_KEY = "EncryptionAtRestWithCustomerKey" - """Disk is encrypted at rest with Customer managed key that can be changed and revoked by a - customer.""" - ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" - """Disk is encrypted at rest with 2 layers of encryption. One of the keys is Customer managed and - the other key is Platform managed.""" - - -class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The hypervisor generation of the Virtual Machine. Applicable to OS disks only.""" - - V1 = "V1" - V2 = "V2" - - -class NetworkAccessPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Policy for accessing the disk via network.""" - - ALLOW_ALL = "AllowAll" - """The disk can be exported or uploaded to from any network.""" - ALLOW_PRIVATE = "AllowPrivate" - """The disk can be exported or uploaded to using a DiskAccess resource's private endpoints.""" - DENY_ALL = "DenyAll" - """The disk cannot be exported.""" - - -class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The Operating System type.""" - - WINDOWS = "Windows" - LINUX = "Linux" - - -class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current provisioning state.""" - - SUCCEEDED = "Succeeded" - CREATING = "Creating" - DELETING = "Deleting" - FAILED = "Failed" - - -class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The private endpoint connection status.""" - - PENDING = "Pending" - APPROVED = "Approved" - REJECTED = "Rejected" - - -class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The sku name.""" - - STANDARD_LRS = "Standard_LRS" - """Standard HDD locally redundant storage""" - PREMIUM_LRS = "Premium_LRS" - """Premium SSD locally redundant storage""" - STANDARD_ZRS = "Standard_ZRS" - """Standard zone redundant storage""" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/_models_py3.py deleted file mode 100644 index eaf234c495de..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/_models_py3.py +++ /dev/null @@ -1,1932 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -class AccessUri(_serialization.Model): - """A disk access SAS uri. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar access_sas: A SAS uri for accessing a disk. - :vartype access_sas: str - """ - - _validation = { - "access_sas": {"readonly": True}, - } - - _attribute_map = { - "access_sas": {"key": "accessSAS", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.access_sas: Optional[str] = None - - -class ApiError(_serialization.Model): - """Api error. - - :ivar details: The Api error details. - :vartype details: list[~azure.mgmt.compute.v2020_05_01.models.ApiErrorBase] - :ivar innererror: The Api inner error. - :vartype innererror: ~azure.mgmt.compute.v2020_05_01.models.InnerError - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "details": {"key": "details", "type": "[ApiErrorBase]"}, - "innererror": {"key": "innererror", "type": "InnerError"}, - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - details: Optional[List["_models.ApiErrorBase"]] = None, - innererror: Optional["_models.InnerError"] = None, - code: Optional[str] = None, - target: Optional[str] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword details: The Api error details. - :paramtype details: list[~azure.mgmt.compute.v2020_05_01.models.ApiErrorBase] - :keyword innererror: The Api inner error. - :paramtype innererror: ~azure.mgmt.compute.v2020_05_01.models.InnerError - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.details = details - self.innererror = innererror - self.code = code - self.target = target - self.message = message - - -class ApiErrorBase(_serialization.Model): - """Api error base. - - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.target = target - self.message = message - - -class CreationData(_serialization.Model): - """Data used when creating a disk. - - 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 create_option: This enumerates the possible sources of a disk's creation. Required. Known - values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", and - "Import". - :vartype create_option: str or ~azure.mgmt.compute.v2020_05_01.models.DiskCreateOption - :ivar storage_account_id: Required if createOption is Import. The Azure Resource Manager - identifier of the storage account containing the blob to import as a disk. - :vartype storage_account_id: str - :ivar image_reference: Disk source information. - :vartype image_reference: ~azure.mgmt.compute.v2020_05_01.models.ImageDiskReference - :ivar gallery_image_reference: Required if creating from a Gallery Image. The id of the - ImageDiskReference will be the ARM id of the shared galley image version from which to create a - disk. - :vartype gallery_image_reference: ~azure.mgmt.compute.v2020_05_01.models.ImageDiskReference - :ivar source_uri: If createOption is Import, this is the URI of a blob to be imported into a - managed disk. - :vartype source_uri: str - :ivar source_resource_id: If createOption is Copy, this is the ARM id of the source snapshot or - disk. - :vartype source_resource_id: str - :ivar source_unique_id: If this field is set, this is the unique id identifying the source of - this resource. - :vartype source_unique_id: str - :ivar upload_size_bytes: If createOption is Upload, this is the size of the contents of the - upload including the VHD footer. This value should be between 20972032 (20 MiB + 512 bytes for - the VHD footer) and 35183298347520 bytes (32 TiB + 512 bytes for the VHD footer). - :vartype upload_size_bytes: int - """ - - _validation = { - "create_option": {"required": True}, - "source_unique_id": {"readonly": True}, - } - - _attribute_map = { - "create_option": {"key": "createOption", "type": "str"}, - "storage_account_id": {"key": "storageAccountId", "type": "str"}, - "image_reference": {"key": "imageReference", "type": "ImageDiskReference"}, - "gallery_image_reference": {"key": "galleryImageReference", "type": "ImageDiskReference"}, - "source_uri": {"key": "sourceUri", "type": "str"}, - "source_resource_id": {"key": "sourceResourceId", "type": "str"}, - "source_unique_id": {"key": "sourceUniqueId", "type": "str"}, - "upload_size_bytes": {"key": "uploadSizeBytes", "type": "int"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOption"], - storage_account_id: Optional[str] = None, - image_reference: Optional["_models.ImageDiskReference"] = None, - gallery_image_reference: Optional["_models.ImageDiskReference"] = None, - source_uri: Optional[str] = None, - source_resource_id: Optional[str] = None, - upload_size_bytes: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword create_option: This enumerates the possible sources of a disk's creation. Required. - Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", and - "Import". - :paramtype create_option: str or ~azure.mgmt.compute.v2020_05_01.models.DiskCreateOption - :keyword storage_account_id: Required if createOption is Import. The Azure Resource Manager - identifier of the storage account containing the blob to import as a disk. - :paramtype storage_account_id: str - :keyword image_reference: Disk source information. - :paramtype image_reference: ~azure.mgmt.compute.v2020_05_01.models.ImageDiskReference - :keyword gallery_image_reference: Required if creating from a Gallery Image. The id of the - ImageDiskReference will be the ARM id of the shared galley image version from which to create a - disk. - :paramtype gallery_image_reference: ~azure.mgmt.compute.v2020_05_01.models.ImageDiskReference - :keyword source_uri: If createOption is Import, this is the URI of a blob to be imported into a - managed disk. - :paramtype source_uri: str - :keyword source_resource_id: If createOption is Copy, this is the ARM id of the source snapshot - or disk. - :paramtype source_resource_id: str - :keyword upload_size_bytes: If createOption is Upload, this is the size of the contents of the - upload including the VHD footer. This value should be between 20972032 (20 MiB + 512 bytes for - the VHD footer) and 35183298347520 bytes (32 TiB + 512 bytes for the VHD footer). - :paramtype upload_size_bytes: int - """ - super().__init__(**kwargs) - self.create_option = create_option - self.storage_account_id = storage_account_id - self.image_reference = image_reference - self.gallery_image_reference = gallery_image_reference - self.source_uri = source_uri - self.source_resource_id = source_resource_id - self.source_unique_id: Optional[str] = None - self.upload_size_bytes = upload_size_bytes - - -class Resource(_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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - - -class Disk(Resource): - """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. - :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] - :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 - disk attached. maxShares should be set to a value greater than one for disks to allow attaching - them to multiple VMs. - :vartype managed_by_extended: list[str] - :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or - UltraSSD_LRS. - :vartype sku: ~azure.mgmt.compute.v2020_05_01.models.DiskSku - :ivar zones: The Logical zone list for Disk. - :vartype zones: list[str] - :ivar time_created: The time when the disk was created. - :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2020_05_01.models.OperatingSystemTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_05_01.models.HyperVGeneration - :ivar creation_data: Disk source information. CreationData information cannot be changed after - the disk has been created. - :vartype creation_data: ~azure.mgmt.compute.v2020_05_01.models.CreationData - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. - :vartype disk_size_bytes: int - :ivar unique_id: Unique Guid identifying the resource. - :vartype unique_id: str - :ivar encryption_settings_collection: Encryption settings collection used for Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2020_05_01.models.EncryptionSettingsCollection - :ivar provisioning_state: The disk provisioning state. - :vartype provisioning_state: str - :ivar disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :vartype disk_m_bps_read_write: int - :ivar disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_only: int - :ivar disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :vartype disk_m_bps_read_only: int - :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", - "Reserved", "ActiveSAS", "ReadyToUpload", and "ActiveUpload". - :vartype disk_state: str or ~azure.mgmt.compute.v2020_05_01.models.DiskState - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2020_05_01.models.Encryption - :ivar max_shares: The maximum number of VMs that can attach to the disk at the same time. Value - greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :vartype max_shares: int - :ivar share_info: Details of the list of all VMs that have the disk attached. maxShares should - be set to a value greater than one for disks to allow attaching them to multiple VMs. - :vartype share_info: list[~azure.mgmt.compute.v2020_05_01.models.ShareInfoElement] - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2020_05_01.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "managed_by": {"readonly": True}, - "managed_by_extended": {"readonly": True}, - "time_created": {"readonly": True}, - "disk_size_bytes": {"readonly": True}, - "unique_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "disk_state": {"readonly": True}, - "share_info": {"readonly": 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}"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "managed_by_extended": {"key": "managedByExtended", "type": "[str]"}, - "sku": {"key": "sku", "type": "DiskSku"}, - "zones": {"key": "zones", "type": "[str]"}, - "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "creation_data": {"key": "properties.creationData", "type": "CreationData"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "disk_size_bytes": {"key": "properties.diskSizeBytes", "type": "int"}, - "unique_id": {"key": "properties.uniqueId", "type": "str"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "disk_iops_read_write": {"key": "properties.diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "properties.diskMBpsReadWrite", "type": "int"}, - "disk_iops_read_only": {"key": "properties.diskIOPSReadOnly", "type": "int"}, - "disk_m_bps_read_only": {"key": "properties.diskMBpsReadOnly", "type": "int"}, - "disk_state": {"key": "properties.diskState", "type": "str"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "max_shares": {"key": "properties.maxShares", "type": "int"}, - "share_info": {"key": "properties.shareInfo", "type": "[ShareInfoElement]"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.DiskSku"] = None, - zones: Optional[List[str]] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - creation_data: Optional["_models.CreationData"] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - disk_iops_read_write: Optional[int] = None, - disk_m_bps_read_write: Optional[int] = None, - disk_iops_read_only: Optional[int] = None, - disk_m_bps_read_only: Optional[int] = None, - encryption: Optional["_models.Encryption"] = None, - max_shares: Optional[int] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or - UltraSSD_LRS. - :paramtype sku: ~azure.mgmt.compute.v2020_05_01.models.DiskSku - :keyword zones: The Logical zone list for Disk. - :paramtype zones: list[str] - :keyword os_type: The Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2020_05_01.models.OperatingSystemTypes - :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.v2020_05_01.models.HyperVGeneration - :keyword creation_data: Disk source information. CreationData information cannot be changed - after the disk has been created. - :paramtype creation_data: ~azure.mgmt.compute.v2020_05_01.models.CreationData - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used for Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2020_05_01.models.EncryptionSettingsCollection - :keyword disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_write: int - :keyword disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :paramtype disk_m_bps_read_write: int - :keyword disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_only: int - :keyword disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :paramtype disk_m_bps_read_only: int - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2020_05_01.models.Encryption - :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. - Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :paramtype max_shares: int - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2020_05_01.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.managed_by: Optional[str] = None - self.managed_by_extended: Optional[List[str]] = None - self.sku = sku - self.zones = zones - self.time_created: Optional[datetime.datetime] = None - self.os_type = os_type - self.hyper_v_generation = hyper_v_generation - self.creation_data = creation_data - self.disk_size_gb = disk_size_gb - self.disk_size_bytes: Optional[int] = None - self.unique_id: Optional[str] = None - self.encryption_settings_collection = encryption_settings_collection - self.provisioning_state: Optional[str] = None - self.disk_iops_read_write = disk_iops_read_write - self.disk_m_bps_read_write = disk_m_bps_read_write - self.disk_iops_read_only = disk_iops_read_only - self.disk_m_bps_read_only = disk_m_bps_read_only - self.disk_state: Optional[Union[str, "_models.DiskState"]] = None - self.encryption = encryption - self.max_shares = max_shares - self.share_info: Optional[List["_models.ShareInfoElement"]] = None - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - - -class DiskAccess(Resource): - """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. - :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] - :ivar private_endpoint_connections: A readonly collection of private endpoint connections - created on the disk. Currently only one endpoint connection is supported. - :vartype private_endpoint_connections: - list[~azure.mgmt.compute.v2020_05_01.models.PrivateEndpointConnection] - :ivar provisioning_state: The disk access resource provisioning state. - :vartype provisioning_state: str - :ivar time_created: The time when the disk access was created. - :vartype time_created: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "private_endpoint_connections": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "time_created": {"readonly": 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}"}, - "private_endpoint_connections": { - "key": "properties.privateEndpointConnections", - "type": "[PrivateEndpointConnection]", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, - } - - 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__(location=location, tags=tags, **kwargs) - self.private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None - self.provisioning_state: Optional[str] = None - self.time_created: Optional[datetime.datetime] = None - - -class DiskAccessList(_serialization.Model): - """The List disk access operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of disk access resources. Required. - :vartype value: list[~azure.mgmt.compute.v2020_05_01.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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DiskAccess]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.DiskAccess"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of disk access resources. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_05_01.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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DiskAccessUpdate(_serialization.Model): - """Used for updating a disk access resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class DiskEncryptionSet(Resource): - """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. - :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] - :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.v2020_05_01.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and - "EncryptionAtRestWithPlatformAndCustomerKeys". - :vartype encryption_type: str or ~azure.mgmt.compute.v2020_05_01.models.EncryptionType - :ivar active_key: The key vault key which is currently used by this disk encryption set. - :vartype active_key: ~azure.mgmt.compute.v2020_05_01.models.KeyVaultAndKeyReference - :ivar previous_keys: A readonly collection of key vault keys previously used by this disk - encryption set while a key rotation is in progress. It will be empty if there is no ongoing key - rotation. - :vartype previous_keys: list[~azure.mgmt.compute.v2020_05_01.models.KeyVaultAndKeyReference] - :ivar provisioning_state: The disk encryption set provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "previous_keys": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "identity": {"key": "identity", "type": "EncryptionSetIdentity"}, - "encryption_type": {"key": "properties.encryptionType", "type": "str"}, - "active_key": {"key": "properties.activeKey", "type": "KeyVaultAndKeyReference"}, - "previous_keys": {"key": "properties.previousKeys", "type": "[KeyVaultAndKeyReference]"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "_models.EncryptionType"]] = None, - active_key: Optional["_models.KeyVaultAndKeyReference"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2020_05_01.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values - are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and - "EncryptionAtRestWithPlatformAndCustomerKeys". - :paramtype encryption_type: str or ~azure.mgmt.compute.v2020_05_01.models.EncryptionType - :keyword active_key: The key vault key which is currently used by this disk encryption set. - :paramtype active_key: ~azure.mgmt.compute.v2020_05_01.models.KeyVaultAndKeyReference - """ - super().__init__(location=location, tags=tags, **kwargs) - self.identity = identity - self.encryption_type = encryption_type - self.active_key = active_key - self.previous_keys: Optional[List["_models.KeyVaultAndKeyReference"]] = None - self.provisioning_state: Optional[str] = None - - -class DiskEncryptionSetList(_serialization.Model): - """The List disk encryption set operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of disk encryption sets. Required. - :vartype value: list[~azure.mgmt.compute.v2020_05_01.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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DiskEncryptionSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DiskEncryptionSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of disk encryption sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_05_01.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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DiskEncryptionSetUpdate(_serialization.Model): - """disk encryption set update resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and - "EncryptionAtRestWithPlatformAndCustomerKeys". - :vartype encryption_type: str or ~azure.mgmt.compute.v2020_05_01.models.EncryptionType - :ivar active_key: Key Vault Key Url and vault id of KeK, KeK is optional and when provided is - used to unwrap the encryptionKey. - :vartype active_key: ~azure.mgmt.compute.v2020_05_01.models.KeyVaultAndKeyReference - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "encryption_type": {"key": "properties.encryptionType", "type": "str"}, - "active_key": {"key": "properties.activeKey", "type": "KeyVaultAndKeyReference"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - encryption_type: Optional[Union[str, "_models.EncryptionType"]] = None, - active_key: Optional["_models.KeyVaultAndKeyReference"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values - are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and - "EncryptionAtRestWithPlatformAndCustomerKeys". - :paramtype encryption_type: str or ~azure.mgmt.compute.v2020_05_01.models.EncryptionType - :keyword active_key: Key Vault Key Url and vault id of KeK, KeK is optional and when provided - is used to unwrap the encryptionKey. - :paramtype active_key: ~azure.mgmt.compute.v2020_05_01.models.KeyVaultAndKeyReference - """ - super().__init__(**kwargs) - self.tags = tags - self.encryption_type = encryption_type - self.active_key = active_key - - -class DiskList(_serialization.Model): - """The List Disks operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of disks. Required. - :vartype value: list[~azure.mgmt.compute.v2020_05_01.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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Disk]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of disks. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_05_01.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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DiskSku(_serialization.Model): - """The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", - and "UltraSSD_LRS". - :vartype name: str or ~azure.mgmt.compute.v2020_05_01.models.DiskStorageAccountTypes - :ivar tier: The sku tier. - :vartype tier: str - """ - - _validation = { - "tier": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__(self, *, name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs: Any) -> None: - """ - :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", and "UltraSSD_LRS". - :paramtype name: str or ~azure.mgmt.compute.v2020_05_01.models.DiskStorageAccountTypes - """ - super().__init__(**kwargs) - self.name = name - self.tier: Optional[str] = None - - -class DiskUpdate(_serialization.Model): - """Disk update resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or - UltraSSD_LRS. - :vartype sku: ~azure.mgmt.compute.v2020_05_01.models.DiskSku - :ivar os_type: the Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2020_05_01.models.OperatingSystemTypes - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2020_05_01.models.EncryptionSettingsCollection - :ivar disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :vartype disk_m_bps_read_write: int - :ivar disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_only: int - :ivar disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :vartype disk_m_bps_read_only: int - :ivar max_shares: The maximum number of VMs that can attach to the disk at the same time. Value - greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :vartype max_shares: int - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2020_05_01.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2020_05_01.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "DiskSku"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "disk_iops_read_write": {"key": "properties.diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "properties.diskMBpsReadWrite", "type": "int"}, - "disk_iops_read_only": {"key": "properties.diskIOPSReadOnly", "type": "int"}, - "disk_m_bps_read_only": {"key": "properties.diskMBpsReadOnly", "type": "int"}, - "max_shares": {"key": "properties.maxShares", "type": "int"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.DiskSku"] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - disk_iops_read_write: Optional[int] = None, - disk_m_bps_read_write: Optional[int] = None, - disk_iops_read_only: Optional[int] = None, - disk_m_bps_read_only: Optional[int] = None, - max_shares: Optional[int] = None, - encryption: Optional["_models.Encryption"] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or - UltraSSD_LRS. - :paramtype sku: ~azure.mgmt.compute.v2020_05_01.models.DiskSku - :keyword os_type: the Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2020_05_01.models.OperatingSystemTypes - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2020_05_01.models.EncryptionSettingsCollection - :keyword disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_write: int - :keyword disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :paramtype disk_m_bps_read_write: int - :keyword disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_only: int - :keyword disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :paramtype disk_m_bps_read_only: int - :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. - Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :paramtype max_shares: int - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2020_05_01.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2020_05_01.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - """ - super().__init__(**kwargs) - self.tags = tags - self.sku = sku - self.os_type = os_type - self.disk_size_gb = disk_size_gb - self.encryption_settings_collection = encryption_settings_collection - self.disk_iops_read_write = disk_iops_read_write - self.disk_m_bps_read_write = disk_m_bps_read_write - self.disk_iops_read_only = disk_iops_read_only - self.disk_m_bps_read_only = disk_m_bps_read_only - self.max_shares = max_shares - self.encryption = encryption - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - - -class Encryption(_serialization.Model): - """Encryption at rest settings for disk or snapshot. - - :ivar disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling - encryption at rest. - :vartype disk_encryption_set_id: str - :ivar type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and - "EncryptionAtRestWithPlatformAndCustomerKeys". - :vartype type: str or ~azure.mgmt.compute.v2020_05_01.models.EncryptionType - """ - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - disk_encryption_set_id: Optional[str] = None, - type: Optional[Union[str, "_models.EncryptionType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling - encryption at rest. - :paramtype disk_encryption_set_id: str - :keyword type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and - "EncryptionAtRestWithPlatformAndCustomerKeys". - :paramtype type: str or ~azure.mgmt.compute.v2020_05_01.models.EncryptionType - """ - super().__init__(**kwargs) - self.disk_encryption_set_id = disk_encryption_set_id - self.type = type - - -class EncryptionSetIdentity(_serialization.Model): - """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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is - supported. "SystemAssigned" - :vartype type: str or ~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSetIdentityType - :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-client-tenant-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype tenant_id: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__( - self, *, type: Optional[Union[str, "_models.DiskEncryptionSetIdentityType"]] = None, **kwargs: Any - ) -> None: - """ - :keyword type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned - is supported. "SystemAssigned" - :paramtype type: str or ~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSetIdentityType - """ - super().__init__(**kwargs) - self.type = type - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - - -class EncryptionSettingsCollection(_serialization.Model): - """Encryption settings for disk or snapshot. - - All required parameters must be populated in order to send to server. - - :ivar enabled: Set this flag to true and provide DiskEncryptionKey and optional - KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and - KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, - the existing settings remain unchanged. Required. - :vartype enabled: bool - :ivar encryption_settings: A collection of encryption settings, one for each disk volume. - :vartype encryption_settings: - list[~azure.mgmt.compute.v2020_05_01.models.EncryptionSettingsElement] - :ivar encryption_settings_version: Describes what type of encryption is used for the disks. - Once this field is set, it cannot be overwritten. '1.0' corresponds to Azure Disk Encryption - with AAD app.'1.1' corresponds to Azure Disk Encryption. - :vartype encryption_settings_version: str - """ - - _validation = { - "enabled": {"required": True}, - } - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "encryption_settings": {"key": "encryptionSettings", "type": "[EncryptionSettingsElement]"}, - "encryption_settings_version": {"key": "encryptionSettingsVersion", "type": "str"}, - } - - def __init__( - self, - *, - enabled: bool, - encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, - encryption_settings_version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Set this flag to true and provide DiskEncryptionKey and optional - KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and - KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, - the existing settings remain unchanged. Required. - :paramtype enabled: bool - :keyword encryption_settings: A collection of encryption settings, one for each disk volume. - :paramtype encryption_settings: - list[~azure.mgmt.compute.v2020_05_01.models.EncryptionSettingsElement] - :keyword encryption_settings_version: Describes what type of encryption is used for the disks. - Once this field is set, it cannot be overwritten. '1.0' corresponds to Azure Disk Encryption - with AAD app.'1.1' corresponds to Azure Disk Encryption. - :paramtype encryption_settings_version: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.encryption_settings = encryption_settings - self.encryption_settings_version = encryption_settings_version - - -class EncryptionSettingsElement(_serialization.Model): - """Encryption settings for one disk volume. - - :ivar disk_encryption_key: Key Vault Secret Url and vault id of the disk encryption key. - :vartype disk_encryption_key: ~azure.mgmt.compute.v2020_05_01.models.KeyVaultAndSecretReference - :ivar key_encryption_key: Key Vault Key Url and vault id of the key encryption key. - KeyEncryptionKey is optional and when provided is used to unwrap the disk encryption key. - :vartype key_encryption_key: ~azure.mgmt.compute.v2020_05_01.models.KeyVaultAndKeyReference - """ - - _attribute_map = { - "disk_encryption_key": {"key": "diskEncryptionKey", "type": "KeyVaultAndSecretReference"}, - "key_encryption_key": {"key": "keyEncryptionKey", "type": "KeyVaultAndKeyReference"}, - } - - def __init__( - self, - *, - disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_key: Key Vault Secret Url and vault id of the disk encryption key. - :paramtype disk_encryption_key: - ~azure.mgmt.compute.v2020_05_01.models.KeyVaultAndSecretReference - :keyword key_encryption_key: Key Vault Key Url and vault id of the key encryption key. - KeyEncryptionKey is optional and when provided is used to unwrap the disk encryption key. - :paramtype key_encryption_key: ~azure.mgmt.compute.v2020_05_01.models.KeyVaultAndKeyReference - """ - super().__init__(**kwargs) - self.disk_encryption_key = disk_encryption_key - self.key_encryption_key = key_encryption_key - - -class GrantAccessData(_serialization.Model): - """Data used for requesting a SAS. - - All required parameters must be populated in order to send to server. - - :ivar access: Required. Known values are: "None", "Read", and "Write". - :vartype access: str or ~azure.mgmt.compute.v2020_05_01.models.AccessLevel - :ivar duration_in_seconds: Time duration in seconds until the SAS access expires. Required. - :vartype duration_in_seconds: int - """ - - _validation = { - "access": {"required": True}, - "duration_in_seconds": {"required": True}, - } - - _attribute_map = { - "access": {"key": "access", "type": "str"}, - "duration_in_seconds": {"key": "durationInSeconds", "type": "int"}, - } - - def __init__(self, *, access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, **kwargs: Any) -> None: - """ - :keyword access: Required. Known values are: "None", "Read", and "Write". - :paramtype access: str or ~azure.mgmt.compute.v2020_05_01.models.AccessLevel - :keyword duration_in_seconds: Time duration in seconds until the SAS access expires. Required. - :paramtype duration_in_seconds: int - """ - super().__init__(**kwargs) - self.access = access - self.duration_in_seconds = duration_in_seconds - - -class ImageDiskReference(_serialization.Model): - """The source image used for creating the disk. - - All required parameters must be populated in order to send to server. - - :ivar id: A relative uri containing either a Platform Image Repository or user image reference. - Required. - :vartype id: str - :ivar lun: If the disk is created from an image's data disk, this is an index that indicates - which of the data disks in the image to use. For OS disks, this field is null. - :vartype lun: int - """ - - _validation = { - "id": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__( - self, *, id: str, lun: Optional[int] = None, **kwargs: Any # pylint: disable=redefined-builtin - ) -> None: - """ - :keyword id: A relative uri containing either a Platform Image Repository or user image - reference. Required. - :paramtype id: str - :keyword lun: If the disk is created from an image's data disk, this is an index that indicates - which of the data disks in the image to use. For OS disks, this field is null. - :paramtype lun: int - """ - super().__init__(**kwargs) - self.id = id - self.lun = lun - - -class InnerError(_serialization.Model): - """Inner error details. - - :ivar exceptiontype: The exception type. - :vartype exceptiontype: str - :ivar errordetail: The internal error message or exception dump. - :vartype errordetail: str - """ - - _attribute_map = { - "exceptiontype": {"key": "exceptiontype", "type": "str"}, - "errordetail": {"key": "errordetail", "type": "str"}, - } - - def __init__( - self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword exceptiontype: The exception type. - :paramtype exceptiontype: str - :keyword errordetail: The internal error message or exception dump. - :paramtype errordetail: str - """ - super().__init__(**kwargs) - self.exceptiontype = exceptiontype - self.errordetail = errordetail - - -class KeyVaultAndKeyReference(_serialization.Model): - """Key Vault Key Url and vault id of KeK, KeK is optional and when provided is used to unwrap the - encryptionKey. - - All required parameters must be populated in order to send to server. - - :ivar source_vault: Resource id of the KeyVault containing the key or secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2020_05_01.models.SourceVault - :ivar key_url: Url pointing to a key or secret in KeyVault. Required. - :vartype key_url: str - """ - - _validation = { - "source_vault": {"required": True}, - "key_url": {"required": True}, - } - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SourceVault"}, - "key_url": {"key": "keyUrl", "type": "str"}, - } - - def __init__(self, *, source_vault: "_models.SourceVault", key_url: str, **kwargs: Any) -> None: - """ - :keyword source_vault: Resource id of the KeyVault containing the key or secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2020_05_01.models.SourceVault - :keyword key_url: Url pointing to a key or secret in KeyVault. Required. - :paramtype key_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.key_url = key_url - - -class KeyVaultAndSecretReference(_serialization.Model): - """Key Vault Secret Url and vault id of the encryption key. - - All required parameters must be populated in order to send to server. - - :ivar source_vault: Resource id of the KeyVault containing the key or secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2020_05_01.models.SourceVault - :ivar secret_url: Url pointing to a key or secret in KeyVault. Required. - :vartype secret_url: str - """ - - _validation = { - "source_vault": {"required": True}, - "secret_url": {"required": True}, - } - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SourceVault"}, - "secret_url": {"key": "secretUrl", "type": "str"}, - } - - def __init__(self, *, source_vault: "_models.SourceVault", secret_url: str, **kwargs: Any) -> None: - """ - :keyword source_vault: Resource id of the KeyVault containing the key or secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2020_05_01.models.SourceVault - :keyword secret_url: Url pointing to a key or secret in KeyVault. Required. - :paramtype secret_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.secret_url = secret_url - - -class PrivateEndpoint(_serialization.Model): - """The Private Endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ARM identifier for Private Endpoint. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class PrivateEndpointConnection(_serialization.Model): - """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. - :vartype id: str - :ivar name: private endpoint connection name. - :vartype name: str - :ivar type: private endpoint connection type. - :vartype type: str - :ivar private_endpoint: The resource of private end point. - :vartype private_endpoint: ~azure.mgmt.compute.v2020_05_01.models.PrivateEndpoint - :ivar private_link_service_connection_state: A collection of information about the state of the - connection between DiskAccess and Virtual Network. - :vartype private_link_service_connection_state: - ~azure.mgmt.compute.v2020_05_01.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2020_05_01.models.PrivateEndpointConnectionProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionState", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - private_endpoint: Optional["_models.PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_endpoint: The resource of private end point. - :paramtype private_endpoint: ~azure.mgmt.compute.v2020_05_01.models.PrivateEndpoint - :keyword private_link_service_connection_state: A collection of information about the state of - the connection between DiskAccess and Virtual Network. - :paramtype private_link_service_connection_state: - ~azure.mgmt.compute.v2020_05_01.models.PrivateLinkServiceConnectionState - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.private_endpoint = private_endpoint - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = None - - -class PrivateLinkResource(_serialization.Model): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: private link resource Id. - :vartype id: str - :ivar name: private link resource name. - :vartype name: str - :ivar type: private link resource type. - :vartype type: str - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - :ivar required_zone_names: The private link resource DNS zone name. - :vartype required_zone_names: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "group_id": {"readonly": True}, - "required_members": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "group_id": {"key": "properties.groupId", "type": "str"}, - "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, - } - - def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword required_zone_names: The private link resource DNS zone name. - :paramtype required_zone_names: list[str] - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.group_id: Optional[str] = None - self.required_members: Optional[List[str]] = None - self.required_zone_names = required_zone_names - - -class PrivateLinkResourceListResult(_serialization.Model): - """A list of private link resources. - - :ivar value: Array of private link resources. - :vartype value: list[~azure.mgmt.compute.v2020_05_01.models.PrivateLinkResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateLinkResource]"}, - } - - def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Array of private link resources. - :paramtype value: list[~azure.mgmt.compute.v2020_05_01.models.PrivateLinkResource] - """ - super().__init__(**kwargs) - self.value = value - - -class PrivateLinkServiceConnectionState(_serialization.Model): - """A collection of information about the state of the connection between service consumer and - provider. - - :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", and "Rejected". - :vartype status: str or - ~azure.mgmt.compute.v2020_05_01.models.PrivateEndpointServiceConnectionStatus - :ivar description: The reason for approval/rejection of the connection. - :vartype description: str - :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :vartype actions_required: str - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", and "Rejected". - :paramtype status: str or - ~azure.mgmt.compute.v2020_05_01.models.PrivateEndpointServiceConnectionStatus - :keyword description: The reason for approval/rejection of the connection. - :paramtype description: str - :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :paramtype actions_required: str - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required = actions_required - - -class ShareInfoElement(_serialization.Model): - """ShareInfoElement. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar vm_uri: A relative URI containing the ID of the VM that has the disk attached. - :vartype vm_uri: str - """ - - _validation = { - "vm_uri": {"readonly": True}, - } - - _attribute_map = { - "vm_uri": {"key": "vmUri", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.vm_uri: Optional[str] = None - - -class Snapshot(Resource): - """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. - :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] - :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. - :vartype sku: ~azure.mgmt.compute.v2020_05_01.models.SnapshotSku - :ivar time_created: The time when the snapshot was created. - :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2020_05_01.models.OperatingSystemTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_05_01.models.HyperVGeneration - :ivar creation_data: Disk source information. CreationData information cannot be changed after - the disk has been created. - :vartype creation_data: ~azure.mgmt.compute.v2020_05_01.models.CreationData - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. - :vartype disk_size_bytes: int - :ivar unique_id: Unique Guid identifying the resource. - :vartype unique_id: str - :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2020_05_01.models.EncryptionSettingsCollection - :ivar provisioning_state: The disk provisioning state. - :vartype provisioning_state: str - :ivar incremental: Whether a snapshot is incremental. Incremental snapshots on the same disk - occupy less space than full snapshots and can be diffed. - :vartype incremental: bool - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2020_05_01.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2020_05_01.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "managed_by": {"readonly": True}, - "time_created": {"readonly": True}, - "disk_size_bytes": {"readonly": True}, - "unique_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "sku": {"key": "sku", "type": "SnapshotSku"}, - "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "creation_data": {"key": "properties.creationData", "type": "CreationData"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "disk_size_bytes": {"key": "properties.diskSizeBytes", "type": "int"}, - "unique_id": {"key": "properties.uniqueId", "type": "str"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "incremental": {"key": "properties.incremental", "type": "bool"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.SnapshotSku"] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - creation_data: Optional["_models.CreationData"] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - incremental: Optional[bool] = None, - encryption: Optional["_models.Encryption"] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. - :paramtype sku: ~azure.mgmt.compute.v2020_05_01.models.SnapshotSku - :keyword os_type: The Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2020_05_01.models.OperatingSystemTypes - :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.v2020_05_01.models.HyperVGeneration - :keyword creation_data: Disk source information. CreationData information cannot be changed - after the disk has been created. - :paramtype creation_data: ~azure.mgmt.compute.v2020_05_01.models.CreationData - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2020_05_01.models.EncryptionSettingsCollection - :keyword incremental: Whether a snapshot is incremental. Incremental snapshots on the same disk - occupy less space than full snapshots and can be diffed. - :paramtype incremental: bool - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2020_05_01.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2020_05_01.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.managed_by: Optional[str] = None - self.sku = sku - self.time_created: Optional[datetime.datetime] = None - self.os_type = os_type - self.hyper_v_generation = hyper_v_generation - self.creation_data = creation_data - self.disk_size_gb = disk_size_gb - self.disk_size_bytes: Optional[int] = None - self.unique_id: Optional[str] = None - self.encryption_settings_collection = encryption_settings_collection - self.provisioning_state: Optional[str] = None - self.incremental = incremental - self.encryption = encryption - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - - -class SnapshotList(_serialization.Model): - """The List Snapshots operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of snapshots. Required. - :vartype value: list[~azure.mgmt.compute.v2020_05_01.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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Snapshot]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of snapshots. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_05_01.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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SnapshotSku(_serialization.Model): - """The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", and "Standard_ZRS". - :vartype name: str or ~azure.mgmt.compute.v2020_05_01.models.SnapshotStorageAccountTypes - :ivar tier: The sku tier. - :vartype tier: str - """ - - _validation = { - "tier": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__( - self, *, name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs: Any - ) -> None: - """ - :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", and - "Standard_ZRS". - :paramtype name: str or ~azure.mgmt.compute.v2020_05_01.models.SnapshotStorageAccountTypes - """ - super().__init__(**kwargs) - self.name = name - self.tier: Optional[str] = None - - -class SnapshotUpdate(_serialization.Model): - """Snapshot update resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. - :vartype sku: ~azure.mgmt.compute.v2020_05_01.models.SnapshotSku - :ivar os_type: the Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2020_05_01.models.OperatingSystemTypes - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2020_05_01.models.EncryptionSettingsCollection - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2020_05_01.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2020_05_01.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "SnapshotSku"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.SnapshotSku"] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - encryption: Optional["_models.Encryption"] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. - :paramtype sku: ~azure.mgmt.compute.v2020_05_01.models.SnapshotSku - :keyword os_type: the Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2020_05_01.models.OperatingSystemTypes - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2020_05_01.models.EncryptionSettingsCollection - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2020_05_01.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2020_05_01.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - """ - super().__init__(**kwargs) - self.tags = tags - self.sku = sku - self.os_type = os_type - self.disk_size_gb = disk_size_gb - self.encryption_settings_collection = encryption_settings_collection - self.encryption = encryption - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - - -class SourceVault(_serialization.Model): - """The vault id is an Azure Resource Manager Resource id in the form - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/__init__.py deleted file mode 100644 index daa94a7f93b2..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/__init__.py +++ /dev/null @@ -1,31 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import DisksOperations # type: ignore -from ._operations import SnapshotsOperations # type: ignore -from ._operations import DiskEncryptionSetsOperations # type: ignore -from ._operations import DiskAccessesOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DisksOperations", - "SnapshotsOperations", - "DiskEncryptionSetsOperations", - "DiskAccessesOperations", -] -__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/v2020_05_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2020_06_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_compute_management_client.py deleted file mode 100644 index 3a9d15667567..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_compute_management_client.py +++ /dev/null @@ -1,252 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ( - AvailabilitySetsOperations, - DedicatedHostGroupsOperations, - DedicatedHostsOperations, - ImagesOperations, - LogAnalyticsOperations, - Operations, - ProximityPlacementGroupsOperations, - SshPublicKeysOperations, - UsageOperations, - VirtualMachineExtensionImagesOperations, - VirtualMachineExtensionsOperations, - VirtualMachineImagesOperations, - VirtualMachineRunCommandsOperations, - VirtualMachineScaleSetExtensionsOperations, - VirtualMachineScaleSetRollingUpgradesOperations, - VirtualMachineScaleSetVMExtensionsOperations, - VirtualMachineScaleSetVMRunCommandsOperations, - VirtualMachineScaleSetVMsOperations, - VirtualMachineScaleSetsOperations, - VirtualMachineSizesOperations, - VirtualMachinesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.compute.v2020_06_01.operations.Operations - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2020_06_01.operations.AvailabilitySetsOperations - :ivar proximity_placement_groups: ProximityPlacementGroupsOperations operations - :vartype proximity_placement_groups: - azure.mgmt.compute.v2020_06_01.operations.ProximityPlacementGroupsOperations - :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations - :vartype dedicated_host_groups: - azure.mgmt.compute.v2020_06_01.operations.DedicatedHostGroupsOperations - :ivar dedicated_hosts: DedicatedHostsOperations operations - :vartype dedicated_hosts: azure.mgmt.compute.v2020_06_01.operations.DedicatedHostsOperations - :ivar ssh_public_keys: SshPublicKeysOperations operations - :vartype ssh_public_keys: azure.mgmt.compute.v2020_06_01.operations.SshPublicKeysOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2020_06_01.operations.VirtualMachineExtensionImagesOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2020_06_01.operations.VirtualMachineExtensionsOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2020_06_01.operations.VirtualMachineImagesOperations - :ivar usage: UsageOperations operations - :vartype usage: azure.mgmt.compute.v2020_06_01.operations.UsageOperations - :ivar virtual_machines: VirtualMachinesOperations operations - :vartype virtual_machines: azure.mgmt.compute.v2020_06_01.operations.VirtualMachinesOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2020_06_01.operations.VirtualMachineSizesOperations - :ivar images: ImagesOperations operations - :vartype images: azure.mgmt.compute.v2020_06_01.operations.ImagesOperations - :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations - :vartype virtual_machine_scale_sets: - azure.mgmt.compute.v2020_06_01.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations - operations - :vartype virtual_machine_scale_set_extensions: - azure.mgmt.compute.v2020_06_01.operations.VirtualMachineScaleSetExtensionsOperations - :ivar virtual_machine_scale_set_rolling_upgrades: - VirtualMachineScaleSetRollingUpgradesOperations operations - :vartype virtual_machine_scale_set_rolling_upgrades: - azure.mgmt.compute.v2020_06_01.operations.VirtualMachineScaleSetRollingUpgradesOperations - :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations - operations - :vartype virtual_machine_scale_set_vm_extensions: - azure.mgmt.compute.v2020_06_01.operations.VirtualMachineScaleSetVMExtensionsOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2020_06_01.operations.VirtualMachineScaleSetVMsOperations - :ivar log_analytics: LogAnalyticsOperations operations - :vartype log_analytics: azure.mgmt.compute.v2020_06_01.operations.LogAnalyticsOperations - :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations - :vartype virtual_machine_run_commands: - azure.mgmt.compute.v2020_06_01.operations.VirtualMachineRunCommandsOperations - :ivar virtual_machine_scale_set_vm_run_commands: VirtualMachineScaleSetVMRunCommandsOperations - operations - :vartype virtual_machine_scale_set_vm_run_commands: - azure.mgmt.compute.v2020_06_01.operations.VirtualMachineScaleSetVMRunCommandsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2020-06-01") - self.availability_sets = AvailabilitySetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.proximity_placement_groups = ProximityPlacementGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.dedicated_host_groups = DedicatedHostGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.dedicated_hosts = DedicatedHostsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.ssh_public_keys = SshPublicKeysOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_images = VirtualMachineImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2020-06-01") - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2020-06-01") - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.log_analytics = LogAnalyticsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_configuration.py deleted file mode 100644 index d570b6052fdc..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2020-06-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_metadata.json deleted file mode 100644 index 6f559a4a9259..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_metadata.json +++ /dev/null @@ -1,130 +0,0 @@ -{ - "chosen_version": "2020-06-01", - "total_api_version_list": ["2020-06-01"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "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.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "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.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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": { - "operations": "Operations", - "availability_sets": "AvailabilitySetsOperations", - "proximity_placement_groups": "ProximityPlacementGroupsOperations", - "dedicated_host_groups": "DedicatedHostGroupsOperations", - "dedicated_hosts": "DedicatedHostsOperations", - "ssh_public_keys": "SshPublicKeysOperations", - "virtual_machine_extension_images": "VirtualMachineExtensionImagesOperations", - "virtual_machine_extensions": "VirtualMachineExtensionsOperations", - "virtual_machine_images": "VirtualMachineImagesOperations", - "usage": "UsageOperations", - "virtual_machines": "VirtualMachinesOperations", - "virtual_machine_sizes": "VirtualMachineSizesOperations", - "images": "ImagesOperations", - "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", - "log_analytics": "LogAnalyticsOperations", - "virtual_machine_run_commands": "VirtualMachineRunCommandsOperations", - "virtual_machine_scale_set_vm_run_commands": "VirtualMachineScaleSetVMRunCommandsOperations" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj 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 deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2020_06_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/_compute_management_client.py deleted file mode 100644 index 3681d3706304..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/_compute_management_client.py +++ /dev/null @@ -1,258 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ( - AvailabilitySetsOperations, - DedicatedHostGroupsOperations, - DedicatedHostsOperations, - ImagesOperations, - LogAnalyticsOperations, - Operations, - ProximityPlacementGroupsOperations, - SshPublicKeysOperations, - UsageOperations, - VirtualMachineExtensionImagesOperations, - VirtualMachineExtensionsOperations, - VirtualMachineImagesOperations, - VirtualMachineRunCommandsOperations, - VirtualMachineScaleSetExtensionsOperations, - VirtualMachineScaleSetRollingUpgradesOperations, - VirtualMachineScaleSetVMExtensionsOperations, - VirtualMachineScaleSetVMRunCommandsOperations, - VirtualMachineScaleSetVMsOperations, - VirtualMachineScaleSetsOperations, - VirtualMachineSizesOperations, - VirtualMachinesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.compute.v2020_06_01.aio.operations.Operations - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2020_06_01.aio.operations.AvailabilitySetsOperations - :ivar proximity_placement_groups: ProximityPlacementGroupsOperations operations - :vartype proximity_placement_groups: - azure.mgmt.compute.v2020_06_01.aio.operations.ProximityPlacementGroupsOperations - :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations - :vartype dedicated_host_groups: - azure.mgmt.compute.v2020_06_01.aio.operations.DedicatedHostGroupsOperations - :ivar dedicated_hosts: DedicatedHostsOperations operations - :vartype dedicated_hosts: - azure.mgmt.compute.v2020_06_01.aio.operations.DedicatedHostsOperations - :ivar ssh_public_keys: SshPublicKeysOperations operations - :vartype ssh_public_keys: azure.mgmt.compute.v2020_06_01.aio.operations.SshPublicKeysOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2020_06_01.aio.operations.VirtualMachineExtensionImagesOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2020_06_01.aio.operations.VirtualMachineExtensionsOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2020_06_01.aio.operations.VirtualMachineImagesOperations - :ivar usage: UsageOperations operations - :vartype usage: azure.mgmt.compute.v2020_06_01.aio.operations.UsageOperations - :ivar virtual_machines: VirtualMachinesOperations operations - :vartype virtual_machines: - azure.mgmt.compute.v2020_06_01.aio.operations.VirtualMachinesOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2020_06_01.aio.operations.VirtualMachineSizesOperations - :ivar images: ImagesOperations operations - :vartype images: azure.mgmt.compute.v2020_06_01.aio.operations.ImagesOperations - :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations - :vartype virtual_machine_scale_sets: - azure.mgmt.compute.v2020_06_01.aio.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations - operations - :vartype virtual_machine_scale_set_extensions: - azure.mgmt.compute.v2020_06_01.aio.operations.VirtualMachineScaleSetExtensionsOperations - :ivar virtual_machine_scale_set_rolling_upgrades: - VirtualMachineScaleSetRollingUpgradesOperations operations - :vartype virtual_machine_scale_set_rolling_upgrades: - azure.mgmt.compute.v2020_06_01.aio.operations.VirtualMachineScaleSetRollingUpgradesOperations - :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations - operations - :vartype virtual_machine_scale_set_vm_extensions: - azure.mgmt.compute.v2020_06_01.aio.operations.VirtualMachineScaleSetVMExtensionsOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2020_06_01.aio.operations.VirtualMachineScaleSetVMsOperations - :ivar log_analytics: LogAnalyticsOperations operations - :vartype log_analytics: azure.mgmt.compute.v2020_06_01.aio.operations.LogAnalyticsOperations - :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations - :vartype virtual_machine_run_commands: - azure.mgmt.compute.v2020_06_01.aio.operations.VirtualMachineRunCommandsOperations - :ivar virtual_machine_scale_set_vm_run_commands: VirtualMachineScaleSetVMRunCommandsOperations - operations - :vartype virtual_machine_scale_set_vm_run_commands: - azure.mgmt.compute.v2020_06_01.aio.operations.VirtualMachineScaleSetVMRunCommandsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2020-06-01") - self.availability_sets = AvailabilitySetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.proximity_placement_groups = ProximityPlacementGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.dedicated_host_groups = DedicatedHostGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.dedicated_hosts = DedicatedHostsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.ssh_public_keys = SshPublicKeysOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_images = VirtualMachineImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2020-06-01") - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2020-06-01") - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.log_analytics = LogAnalyticsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-06-01" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/_configuration.py deleted file mode 100644 index 22e7e4691e7f..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2020-06-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/__init__.py deleted file mode 100644 index dfc04c351e85..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/__init__.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import Operations # type: ignore -from ._operations import AvailabilitySetsOperations # 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 VirtualMachineExtensionImagesOperations # type: ignore -from ._operations import VirtualMachineExtensionsOperations # type: ignore -from ._operations import VirtualMachineImagesOperations # type: ignore -from ._operations import UsageOperations # type: ignore -from ._operations import VirtualMachinesOperations # type: ignore -from ._operations import VirtualMachineSizesOperations # type: ignore -from ._operations import ImagesOperations # 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 LogAnalyticsOperations # type: ignore -from ._operations import VirtualMachineRunCommandsOperations # type: ignore -from ._operations import VirtualMachineScaleSetVMRunCommandsOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AvailabilitySetsOperations", - "ProximityPlacementGroupsOperations", - "DedicatedHostGroupsOperations", - "DedicatedHostsOperations", - "SshPublicKeysOperations", - "VirtualMachineExtensionImagesOperations", - "VirtualMachineExtensionsOperations", - "VirtualMachineImagesOperations", - "UsageOperations", - "VirtualMachinesOperations", - "VirtualMachineSizesOperations", - "ImagesOperations", - "VirtualMachineScaleSetsOperations", - "VirtualMachineScaleSetExtensionsOperations", - "VirtualMachineScaleSetRollingUpgradesOperations", - "VirtualMachineScaleSetVMExtensionsOperations", - "VirtualMachineScaleSetVMsOperations", - "LogAnalyticsOperations", - "VirtualMachineRunCommandsOperations", - "VirtualMachineScaleSetVMRunCommandsOperations", -] -__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/v2020_06_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_operations.py deleted file mode 100644 index 58d6b376dc1d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_operations.py +++ /dev/null @@ -1,16970 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, Dict, IO, List, Literal, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import ( - build_availability_sets_create_or_update_request, - build_availability_sets_delete_request, - build_availability_sets_get_request, - build_availability_sets_list_available_sizes_request, - build_availability_sets_list_by_subscription_request, - build_availability_sets_list_request, - build_availability_sets_update_request, - build_dedicated_host_groups_create_or_update_request, - build_dedicated_host_groups_delete_request, - build_dedicated_host_groups_get_request, - build_dedicated_host_groups_list_by_resource_group_request, - build_dedicated_host_groups_list_by_subscription_request, - build_dedicated_host_groups_update_request, - build_dedicated_hosts_create_or_update_request, - build_dedicated_hosts_delete_request, - build_dedicated_hosts_get_request, - build_dedicated_hosts_list_by_host_group_request, - build_dedicated_hosts_update_request, - build_images_create_or_update_request, - build_images_delete_request, - build_images_get_request, - build_images_list_by_resource_group_request, - build_images_list_request, - build_images_update_request, - build_log_analytics_export_request_rate_by_interval_request, - build_log_analytics_export_throttled_requests_request, - build_operations_list_request, - build_proximity_placement_groups_create_or_update_request, - build_proximity_placement_groups_delete_request, - build_proximity_placement_groups_get_request, - build_proximity_placement_groups_list_by_resource_group_request, - build_proximity_placement_groups_list_by_subscription_request, - build_proximity_placement_groups_update_request, - build_ssh_public_keys_create_request, - build_ssh_public_keys_delete_request, - build_ssh_public_keys_generate_key_pair_request, - build_ssh_public_keys_get_request, - build_ssh_public_keys_list_by_resource_group_request, - build_ssh_public_keys_list_by_subscription_request, - build_ssh_public_keys_update_request, - build_usage_list_request, - build_virtual_machine_extension_images_get_request, - build_virtual_machine_extension_images_list_types_request, - build_virtual_machine_extension_images_list_versions_request, - build_virtual_machine_extensions_create_or_update_request, - build_virtual_machine_extensions_delete_request, - build_virtual_machine_extensions_get_request, - build_virtual_machine_extensions_list_request, - build_virtual_machine_extensions_update_request, - build_virtual_machine_images_get_request, - build_virtual_machine_images_list_offers_request, - build_virtual_machine_images_list_publishers_request, - build_virtual_machine_images_list_request, - build_virtual_machine_images_list_skus_request, - build_virtual_machine_run_commands_create_or_update_request, - build_virtual_machine_run_commands_delete_request, - build_virtual_machine_run_commands_get_by_virtual_machine_request, - build_virtual_machine_run_commands_get_request, - build_virtual_machine_run_commands_list_by_virtual_machine_request, - build_virtual_machine_run_commands_list_request, - build_virtual_machine_run_commands_update_request, - build_virtual_machine_scale_set_extensions_create_or_update_request, - build_virtual_machine_scale_set_extensions_delete_request, - build_virtual_machine_scale_set_extensions_get_request, - build_virtual_machine_scale_set_extensions_list_request, - build_virtual_machine_scale_set_extensions_update_request, - build_virtual_machine_scale_set_rolling_upgrades_cancel_request, - build_virtual_machine_scale_set_rolling_upgrades_get_latest_request, - build_virtual_machine_scale_set_rolling_upgrades_start_extension_upgrade_request, - build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request, - build_virtual_machine_scale_set_vm_extensions_create_or_update_request, - build_virtual_machine_scale_set_vm_extensions_delete_request, - build_virtual_machine_scale_set_vm_extensions_get_request, - build_virtual_machine_scale_set_vm_extensions_list_request, - build_virtual_machine_scale_set_vm_extensions_update_request, - build_virtual_machine_scale_set_vm_run_commands_create_or_update_request, - build_virtual_machine_scale_set_vm_run_commands_delete_request, - build_virtual_machine_scale_set_vm_run_commands_get_request, - build_virtual_machine_scale_set_vm_run_commands_list_request, - build_virtual_machine_scale_set_vm_run_commands_update_request, - build_virtual_machine_scale_set_vms_deallocate_request, - build_virtual_machine_scale_set_vms_delete_request, - build_virtual_machine_scale_set_vms_get_instance_view_request, - build_virtual_machine_scale_set_vms_get_request, - build_virtual_machine_scale_set_vms_list_request, - build_virtual_machine_scale_set_vms_perform_maintenance_request, - build_virtual_machine_scale_set_vms_power_off_request, - build_virtual_machine_scale_set_vms_redeploy_request, - build_virtual_machine_scale_set_vms_reimage_all_request, - build_virtual_machine_scale_set_vms_reimage_request, - build_virtual_machine_scale_set_vms_restart_request, - build_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data_request, - build_virtual_machine_scale_set_vms_run_command_request, - build_virtual_machine_scale_set_vms_simulate_eviction_request, - build_virtual_machine_scale_set_vms_start_request, - build_virtual_machine_scale_set_vms_update_request, - build_virtual_machine_scale_sets_convert_to_single_placement_group_request, - build_virtual_machine_scale_sets_create_or_update_request, - build_virtual_machine_scale_sets_deallocate_request, - build_virtual_machine_scale_sets_delete_instances_request, - build_virtual_machine_scale_sets_delete_request, - build_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk_request, - build_virtual_machine_scale_sets_get_instance_view_request, - build_virtual_machine_scale_sets_get_os_upgrade_history_request, - build_virtual_machine_scale_sets_get_request, - build_virtual_machine_scale_sets_list_all_request, - build_virtual_machine_scale_sets_list_request, - build_virtual_machine_scale_sets_list_skus_request, - build_virtual_machine_scale_sets_perform_maintenance_request, - build_virtual_machine_scale_sets_power_off_request, - build_virtual_machine_scale_sets_redeploy_request, - build_virtual_machine_scale_sets_reimage_all_request, - build_virtual_machine_scale_sets_reimage_request, - build_virtual_machine_scale_sets_restart_request, - build_virtual_machine_scale_sets_set_orchestration_service_state_request, - build_virtual_machine_scale_sets_start_request, - build_virtual_machine_scale_sets_update_instances_request, - build_virtual_machine_scale_sets_update_request, - build_virtual_machine_sizes_list_request, - build_virtual_machines_assess_patches_request, - build_virtual_machines_capture_request, - build_virtual_machines_convert_to_managed_disks_request, - build_virtual_machines_create_or_update_request, - build_virtual_machines_deallocate_request, - build_virtual_machines_delete_request, - build_virtual_machines_generalize_request, - build_virtual_machines_get_request, - build_virtual_machines_instance_view_request, - build_virtual_machines_list_all_request, - build_virtual_machines_list_available_sizes_request, - build_virtual_machines_list_by_location_request, - build_virtual_machines_list_request, - build_virtual_machines_perform_maintenance_request, - build_virtual_machines_power_off_request, - build_virtual_machines_reapply_request, - build_virtual_machines_redeploy_request, - build_virtual_machines_reimage_request, - build_virtual_machines_restart_request, - build_virtual_machines_retrieve_boot_diagnostics_data_request, - build_virtual_machines_run_command_request, - build_virtual_machines_simulate_eviction_request, - build_virtual_machines_start_request, - build_virtual_machines_update_request, -) -from .._configuration import ComputeManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.ComputeOperationValue"]: - """Gets a list of compute operations. - - :return: An iterator like instance of either ComputeOperationValue or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.ComputeOperationValue] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[_models.ComputeOperationListResult] = 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_operations_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async 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, 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 AvailabilitySetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`availability_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySet, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Is either a - AvailabilitySet type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySet") - - _request = build_availability_sets_create_or_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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, - availability_set_name: str, - parameters: _models.AvailabilitySetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySetUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Is either a - AvailabilitySetUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySetUpdate or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySetUpdate") - - _request = build_availability_sets_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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: - """ - 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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_availability_sets_delete_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get(self, resource_group_name: str, availability_set_name: str, **kwargs: Any) -> _models.AvailabilitySet: - """Retrieves information about an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", 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) - - _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("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription( - self, *, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. - - :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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, 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(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets 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 AvailabilitySet or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, 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_available_sizes( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes that can be used to create a new virtual machine in - an existing availability set. - - :param resource_group_name: The name of the resource group. Required. - :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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_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 - - if response.status_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 ProximityPlacementGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`proximity_placement_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - 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. 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.v2020_06_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.v2020_06_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. 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.v2020_06_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - 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 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. Is - either a ProximityPlacementGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroup or IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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. 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.v2020_06_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.v2020_06_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. 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.v2020_06_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - 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 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. Is - either a ProximityPlacementGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroupUpdate or - IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ProximityPlacementGroupUpdate") - - _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, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete(self, resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any) -> None: - """Delete a proximity placement group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _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, - 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_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. 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.v2020_06_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - _request = build_proximity_placement_groups_get_request( - resource_group_name=resource_group_name, - proximity_placement_group_name=proximity_placement_group_name, - subscription_id=self._config.subscription_id, - include_colocation_status=include_colocation_status, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a subscription. - - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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 - ) -> AsyncItemPaged["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a resource group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) - - -class DedicatedHostGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`dedicated_host_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - host_group_name: str, - parameters: _models.DedicatedHostGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroup, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Is either a - DedicatedHostGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroup or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DedicatedHostGroup") - - _request = build_dedicated_host_groups_create_or_update_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DedicatedHostGroup", 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, - host_group_name: str, - parameters: _models.DedicatedHostGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroupUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :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: IO[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.v2020_06_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroupUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Is either - a DedicatedHostGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroupUpdate or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-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") - - _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) - - _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("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: - """ - 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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_dedicated_host_groups_delete_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - host_group_name: str, - *, - expand: Literal["instanceView"] = "instanceView", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Retrieves information about a dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :keyword expand: The expand expression to apply on the operation. The response shows the list - of instance view of the dedicated hosts under the dedicated host group. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", 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) - - _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("DedicatedHostGroup", 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 - ) -> AsyncItemPaged["_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. - :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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 - def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_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 - - if response.status_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 DedicatedHostsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`dedicated_hosts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, 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 "2020-06-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, "DedicatedHost") - - _request = build_dedicated_hosts_create_or_update_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, - 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) - - 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, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHost, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHost - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. 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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. Is either a DedicatedHost - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHost or IO[bytes] - :return: An instance of AsyncLROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.DedicatedHost] - :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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, 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 "2020-06-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, "DedicatedHostUpdate") - - _request = build_dedicated_hosts_update_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, - 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, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHostUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostUpdate - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host 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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Is either a - DedicatedHostUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.DedicatedHost] - :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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_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 "2020-06-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_delete_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 [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, host_group_name: str, host_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete 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 - :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 "2020-06-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, - 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_async - async def get( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: DedicatedHost or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.DedicatedHost] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_get_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DedicatedHost", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_host_group( - self, resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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. - :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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.DedicatedHostListResult] = 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_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, - 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("DedicatedHostListResult", 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 SshPublicKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`ssh_public_keys` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-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_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("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) - - 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 - ) -> AsyncItemPaged["_models.SshPublicKeyResource"]: - """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in - the response to get the next page of SSH public keys. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either SshPublicKeyResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-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 - - 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) - - 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) - - @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.v2020_06_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.v2020_06_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2020_06_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2020_06_01.models.SshPublicKeyResource or IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.SshPublicKeyResource - :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 "2020-06-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") - - _request = build_ssh_public_keys_create_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, - 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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # 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. - - :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: ~azure.mgmt.compute.v2020_06_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.v2020_06_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2020_06_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2020_06_01.models.SshPublicKeyUpdateResource or - IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.SshPublicKeyResource - :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 "2020-06-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( - resource_group_name=resource_group_name, - ssh_public_key_name=ssh_public_key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("SshPublicKeyResource", 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, ssh_public_key_name: str, **kwargs: Any) -> None: - """Delete an SSH public key. - - :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: - """ - 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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_ssh_public_keys_delete_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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, 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. - :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.v2020_06_01.models.SshPublicKeyResource - :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 "2020-06-01")) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - - _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) - - _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("SshPublicKeyResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def generate_key_pair( - self, resource_group_name: str, ssh_public_key_name: str, **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. 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: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.SshPublicKeyGenerateKeyPairResult - :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 "2020-06-01")) - cls: ClsType[_models.SshPublicKeyGenerateKeyPairResult] = kwargs.pop("cls", None) - - _request = build_ssh_public_keys_generate_key_pair_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) - - _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("SshPublicKeyGenerateKeyPairResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class VirtualMachineExtensionImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_extension_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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. - - :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.v2020_06_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 "2020-06-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 = 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 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 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.v2020_06_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 "2020-06-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - - _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) - - _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 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 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.v2020_06_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 "2020-06-01")) - 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 = 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 - - -class VirtualMachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, 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 "2020-06-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, "VirtualMachineExtension") - - _request = build_virtual_machine_extensions_create_or_update_request( - resource_group_name=resource_group_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, - 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) - - 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, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2020_06_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 VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_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 create or 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 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] - :keyword content_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.v2020_06_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2020_06_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.v2020_06_01.models.VirtualMachineExtension] - :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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2020-06-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( - resource_group_name=resource_group_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, - 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, - 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. - - :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: - ~azure.mgmt.compute.v2020_06_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.v2020_06_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.v2020_06_01.models.VirtualMachineExtension] - :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.v2020_06_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.v2020_06_01.models.VirtualMachineExtension] - :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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2020-06-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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) - - _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, vm_name: str, vm_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_name: The name of the virtual machine where the extension should be deleted. - 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-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, - vm_extension_name=vm_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - 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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_get_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list( - self, resource_group_name: str, vm_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.VirtualMachineExtensionsListResult: - """The operation to get all extensions of a Virtual Machine. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine containing the extension. Required. - :type vm_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineExtensionsListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionsListResult - :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 "2020-06-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 VirtualMachineImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.v2020_06_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 "2020-06-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.v2020_06_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 "2020-06-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.v2020_06_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 "2020-06-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. - - :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.v2020_06_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 "2020-06-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) - 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. - - :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.v2020_06_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 "2020-06-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _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) - - _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 - - -class UsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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 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.v2020_06_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 "2020-06-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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ListUsagesResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class 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.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.VirtualMachine"]: - """Gets all the virtual machines under the specified subscription for the specified location. - - :param location: The location for which virtual machines under the subscription are queried. - Required. - :type location: str - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-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 - - 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) - - 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 _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, - 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 "2020-06-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, "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 = 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_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. 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.v2020_06_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.v2020_06_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. 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.v2020_06_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. 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.v2020_06_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.v2020_06_01.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-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 - ) - 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) - 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.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 _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, 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 "2020-06-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, - 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) - - 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, - vm_name: str, - parameters: _models.VirtualMachine, - *, - 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. 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.v2020_06_01.models.VirtualMachine - :keyword content_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.v2020_06_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], - *, - 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. 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 content_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.v2020_06_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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :param resource_group_name: The name of the resource group. Required. - :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.v2020_06_01.models.VirtualMachine or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_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 "2020-06-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, - 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, **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]], - **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 "2020-06-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, - 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) - - 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, - vm_name: str, - parameters: _models.VirtualMachineUpdate, - *, - 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. 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.v2020_06_01.models.VirtualMachineUpdate - :keyword content_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.v2020_06_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - 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. 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 content_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.v2020_06_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]], - **kwargs: Any - ) -> AsyncLROPoller[_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.v2020_06_01.models.VirtualMachineUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_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 "2020-06-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, - 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, **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 "2020-06-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) - - 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, vm_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to delete a virtual machine. - - :param resource_group_name: The name of the resource group. Required. - :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 "2020-06-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, **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_name: str, *, expand: Literal["instanceView"] = "instanceView", **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) - - _request = build_virtual_machines_get_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def instance_view( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> _models.VirtualMachineInstanceView: - """Retrieves information about the run-time state of a virtual machine. - - :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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) - - _request = build_virtual_machines_instance_view_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineInstanceView", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _convert_to_managed_disks_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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_convert_to_managed_disks_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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. - - :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 "2020-06-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, **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 "2020-06-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, - 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, **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 - :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 "2020-06-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, - 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. :code:`
    `For Windows, please refer to - `Create a managed image of a generalized VM in Azure - `_.\\ - :code:`
    `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 "2020-06-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, **kwargs: Any) -> AsyncItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-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, - 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("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) - - 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, *, status_only: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-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, - 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("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) - - 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_available_sizes( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes to which the specified virtual machine can be - resized. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_available_sizes_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 - - if response.status_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_name: 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 "2020-06-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_power_off_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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_name: str, *, skip_shutdown: bool = False, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with - the same provisioned resources. You are still charged for this virtual machine. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._power_off_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - skip_shutdown=skip_shutdown, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reapply_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - 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 "2020-06-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_reapply_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - 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_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. - :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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reapply_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **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_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 "2020-06-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_restart_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - 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_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. - :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 "2020-06-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._restart_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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_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 "2020-06-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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_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 "2020-06-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]: - 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 "2020-06-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_redeploy_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_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. - :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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._redeploy_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reimage_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2020-06-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( - 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) - - 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 the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: ~azure.mgmt.compute.v2020_06_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 the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. 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.v2020_06_01.models.VirtualMachineReimageParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def retrieve_boot_diagnostics_data( - self, - resource_group_name: str, - vm_name: str, - *, - sas_uri_expiration_time_in_minutes: Optional[int] = None, - **kwargs: Any - ) -> _models.RetrieveBootDiagnosticsDataResult: - """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword sas_uri_expiration_time_in_minutes: Expiration duration in minutes for the SAS URIs - with a value between 1 to 1440 minutes. :code:`
    `\\ :code:`
    `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.v2020_06_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 "2020-06-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]: - 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 "2020-06-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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_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. - :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 "2020-06-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_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 - - @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 "2020-06-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]: - 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 "2020-06-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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) - - _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_assess_patches( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineAssessPatchesResult]: - """Assess patches on the VM. - - :param resource_group_name: The name of the resource group. Required. - :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.v2020_06_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 "2020-06-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 - ) - 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) - 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.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 _run_command_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, 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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RunCommandInput") - - _request = build_virtual_machines_run_command_request( - 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) - - 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_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.RunCommandInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_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.v2020_06_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._run_command_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineSizesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """This API is deprecated. Use `Resources Skus - `_. - - :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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_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 - - 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 - - if response.status_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 ImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> 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 "2020-06-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) - - 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, - image_name: str, - parameters: _models.Image, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Create or update an image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param 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.v2020_06_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Create or update an image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param 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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.Image] - :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. - - :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 - :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.v2020_06_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.v2020_06_01.models.Image] - :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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._create_or_update_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Image]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, 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 "2020-06-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, "ImageUpdate") - - _request = build_images_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) - - 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, - image_name: str, - parameters: _models.ImageUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Update 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 - :param parameters: Parameters supplied to the Update Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Update 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 - :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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Update 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 - :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.v2020_06_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.v2020_06_01.models.Image] - :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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Image]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial(self, resource_group_name: str, image_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_images_delete_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, image_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes 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 - :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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - image_name=image_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - 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.v2020_06_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 "2020-06-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 = 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("Image", 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) -> AsyncItemPaged["_models.Image"]: - """Gets the list of images 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 Image or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-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 - - 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) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - parameters: Union[_models.VirtualMachineScaleSet, 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 "2020-06-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, - 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) - - 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, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. 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.v2020_06_01.models.VirtualMachineScaleSet - :keyword content_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.v2020_06_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. 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: IO[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 VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 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.v2020_06_01.models.VirtualMachineScaleSet or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_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 "2020-06-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, - 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]], - **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 "2020-06-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, "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, - 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, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSetUpdate, - *, - 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. 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.v2020_06_01.models.VirtualMachineScaleSetUpdate - :keyword content_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.v2020_06_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], - *, - 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. 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: IO[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 VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Update 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 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.v2020_06_01.models.VirtualMachineScaleSetUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_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 "2020-06-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, - 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 _delete_initial( - self, resource_group_name: str, vm_scale_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 "2020-06-01")) - cls: ClsType[AsyncIterator[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, - 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, vm_scale_set_name: str, **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 - :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 "2020-06-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, - 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, **kwargs: Any - ) -> _models.VirtualMachineScaleSet: - """Display information about a 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 - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-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, - 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 _deallocate_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 "2020-06-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_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_deallocate( - 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]: - """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. - :type 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.v2020_06_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_deallocate( - 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]: - """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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_deallocate( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and - releases the compute resources. You are not billed for the compute resources that this virtual - machine scale set deallocates. - - :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.v2020_06_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 "2020-06-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, - 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 _delete_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2020-06-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: - _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, - 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_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """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. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :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], - *, - 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. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **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.v2020_06_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-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, - 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.v2020_06_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 "2020-06-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) -> AsyncItemPaged["_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 - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-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_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("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 - def list_all(self, **kwargs: Any) -> AsyncItemPaged["_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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = 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_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("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) - - 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_skus( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineScaleSetSku"]: - """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM - instances allowed for each SKU. - - :param resource_group_name: The name of the resource group. Required. - :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.v2020_06_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 "2020-06-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 - - 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) - - @distributed_trace - def get_os_upgrade_history( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.UpgradeOperationHistoricalStatusInfo"]: - """Gets list of OS upgrades 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 - :return: An iterator like instance of either UpgradeOperationHistoricalStatusInfo or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-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 _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]: - 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 "2020-06-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_power_off_request( - resource_group_name=resource_group_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, - 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_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - 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. - - :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.v2020_06_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 - :keyword content_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_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - 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. - - :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 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 - :keyword content_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_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: bool = False, - **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. - - :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.v2020_06_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] - :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 "2020-06-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 "2020-06-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_restart_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :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.v2020_06_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 "2020-06-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, - 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 "2020-06-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 - 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_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. Required. - :type 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.v2020_06_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. Required. - :type 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.v2020_06_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 "2020-06-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 _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, - 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 "2020-06-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_redeploy_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_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. - - :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.v2020_06_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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_redeploy( - self, - resource_group_name: str, - vm_scale_set_name: str, - 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. Required. - :type 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.v2020_06_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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._redeploy_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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 _perform_maintenance_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-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_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_perform_maintenance( - 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]: - """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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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.v2020_06_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_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 - ) -> 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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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_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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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.v2020_06_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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2020-06-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: - _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, - 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_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :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.v2020_06_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reimage_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_scale_set_reimage_input, (IOBase, bytes)): - _content = vm_scale_set_reimage_input - else: - if vm_scale_set_reimage_input is not None: - _json = self._serialize.body(vm_scale_set_reimage_input, "VirtualMachineScaleSetReimageParameters") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which - don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual - machine is reset to initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetReimageParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which - don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual - machine is reset to initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. - :type vm_scale_set_reimage_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which - don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual - machine is reset to initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Is either a - VirtualMachineScaleSetReimageParameters type or a IO[bytes] type. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetReimageParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_scale_set_reimage_input=vm_scale_set_reimage_input, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reimage_all_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_all_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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, **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 - :return: RecoveryWalkResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RecoveryWalkResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2020_06_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. - - :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.v2020_06_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 "2020-06-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 _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 "2020-06-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, - 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_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.v2020_06_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.v2020_06_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 "2020-06-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 - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2020-06-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") - - _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, - 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) - - 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, - 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. - - :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.v2020_06_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.v2020_06_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2020_06_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtension, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to create or update an extension. - - :param resource_group_name: The name of the resource group. Required. - :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.v2020_06_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.v2020_06_01.models.VirtualMachineScaleSetExtension] - :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 "2020-06-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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _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]: - 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 "2020-06-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") - - _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, - 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) - - 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, - 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.v2020_06_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.v2020_06_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :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.v2020_06_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.v2020_06_01.models.VirtualMachineScaleSetExtension] - :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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2020-06-01")) - cls: ClsType[AsyncIterator[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, - 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, 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 "2020-06-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.v2020_06_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 "2020-06-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 - ) -> AsyncItemPaged["_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.v2020_06_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 "2020-06-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. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> 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 "2020-06-01")) - 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, - 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 - - @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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._cancel_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _start_os_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2020-06-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, - 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) - - _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_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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._start_os_upgrade_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _start_extension_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2020-06-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - 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 - - @distributed_trace_async - async def begin_start_extension_upgrade( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Starts a rolling upgrade to move all extensions for all virtual machine scale set instances to - the latest available extension version. Instances which are already running the latest - extension versions are not affected. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._start_extension_upgrade_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get_latest( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> _models.RollingUpgradeStatusInfo: - """Gets the status of the latest virtual machine scale set rolling upgrade. - - :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.v2020_06_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 "2020-06-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 = 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("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.v2020_06_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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2020-06-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, "VirtualMachineScaleSetVMExtension") - - _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) - - _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) - - 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, - 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.v2020_06_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.v2020_06_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.v2020_06_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.v2020_06_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.v2020_06_01.models.VirtualMachineScaleSetVMExtension] - :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 "2020-06-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, - 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 "2020-06-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") - - _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, - 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, - 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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2020_06_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) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to update the VMSS VM extension. - - :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.v2020_06_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to update the VMSS VM extension. - - :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.v2020_06_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.v2020_06_01.models.VirtualMachineScaleSetVMExtension] - :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 "2020-06-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) - - 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 _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, - 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 "2020-06-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_extensions_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - 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, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to delete the VMSS VM extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - 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. - :type 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.v2020_06_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 "2020-06-01")) - 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 = 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("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list( - self, - resource_group_name: str, - vm_scale_set_name: str, - 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. Required. - :type 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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_extensions_list_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_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 - - -class VirtualMachineScaleSetVMsOperations: # 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.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _reimage_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[ - Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] - ] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - 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 "2020-06-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( - 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 - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - 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.v2020_06_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 - ) -> 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. - Is either a VirtualMachineScaleSetVMReimageParameters type or a IO[bytes] type. Default value - is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMReimageParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_scale_set_vm_reimage_input=vm_scale_set_vm_reimage_input, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reimage_all_initial( - self, resource_group_name: str, vm_scale_set_name: str, 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 "2020-06-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) - - 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_reimage_all( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. - This operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_all_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _deallocate_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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. - - :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 "2020-06-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 - - async def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, 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 "2020-06-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, "VirtualMachineScaleSetVM") - - _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, - 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( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.VirtualMachineScaleSetVM, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVM - :keyword content_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) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - 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 VirtualMachineScaleSetVM or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVM] - :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, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. - Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVM or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVM or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVM] - :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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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, - 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("VirtualMachineScaleSetVM", 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.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 - ) - - async def _delete_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 "2020-06-01")) - 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, - 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, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes 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: 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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - 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, - instance_id: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-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 = 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("VirtualMachineScaleSetVM", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_instance_view( - self, resource_group_name: str, vm_scale_set_name: str, 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.v2020_06_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 "2020-06-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 - ) -> AsyncItemPaged["_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.v2020_06_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 "2020-06-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 "2020-06-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. - - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._power_off_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **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, - 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 "2020-06-01")) - cls: ClsType[AsyncIterator[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 = 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_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. - :type 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 "2020-06-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._restart_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _start_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 "2020-06-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_start_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - 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 - :param vm_scale_set_name: The name of the VM 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 "2020-06-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_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _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, - 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 "2020-06-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_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, - 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_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. - :type 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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._redeploy_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def retrieve_boot_diagnostics_data( - self, - resource_group_name: str, - vm_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. Required. - :type 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. :code:`
    `\\ :code:`
    `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.v2020_06_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 "2020-06-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 = 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_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 "2020-06-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) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_perform_maintenance( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> 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 "2020-06-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. - - :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 "2020-06-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 _run_command_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, 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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RunCommandInput") - - _request = build_virtual_machine_scale_set_vms_run_command_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 - 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_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - :type 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.v2020_06_01.models.RunCommandInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> 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. - :type 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.v2020_06_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.v2020_06_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._run_command_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class LogAnalyticsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`log_analytics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _export_request_rate_by_interval_initial( - self, location: str, parameters: Union[_models.RequestRateByIntervalInput, 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 "2020-06-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, "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, - ) - _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_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 location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. - Required. - :type parameters: ~azure.mgmt.compute.v2020_06_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.v2020_06_01.models.LogAnalyticsOperationResult] - :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. - - :param location: The location upon which virtual-machine-sizes is queried. 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.v2020_06_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 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.v2020_06_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.v2020_06_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 "2020-06-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._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, - **kwargs - ) - 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) - 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LogAnalyticsOperationResult]( - 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 - ) -> 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 "2020-06-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, - 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_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.v2020_06_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.v2020_06_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.v2020_06_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. - - :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.v2020_06_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.v2020_06_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 "2020-06-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._export_throttled_requests_initial( - location=location, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - 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) - 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LogAnalyticsOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineRunCommandsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.RunCommandDocumentBase"]: - """Lists all available run commands for a subscription in a location. - - :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 - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_run_commands_list_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RunCommandListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, location: str, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: - """Gets specific run command for a subscription in a location. - - :param location: The 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.v2020_06_01.models.RunCommandDocument - :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 "2020-06-01")) - cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) - - _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, - 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("RunCommandDocument", 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, - 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 "2020-06-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(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_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, - ) - _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) - - 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, - 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. - :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. - :type run_command_name: str - :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. - Required. - :type run_command: ~azure.mgmt.compute.v2020_06_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.v2020_06_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. 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. - :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". - :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.v2020_06_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. 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. - :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.v2020_06_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.v2020_06_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 "2020-06-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._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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommand", 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.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 _update_initial( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommandUpdate, 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 "2020-06-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(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_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, - ) - _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, - vm_name: 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. - - :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. - Required. - :type vm_name: 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. - Required. - :type run_command: ~azure.mgmt.compute.v2020_06_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.v2020_06_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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. - Required. - :type vm_name: 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. - 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". - :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.v2020_06_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be updated. - Required. - :type vm_name: 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.v2020_06_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.v2020_06_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 "2020-06-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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommand", 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.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 _delete_initial( - self, resource_group_name: str, vm_name: str, run_command_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 "2020-06-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_run_commands_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - run_command_name=run_command_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, vm_name: str, run_command_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to delete the 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. - Required. - :type vm_name: str - :param run_command_name: The name of the virtual machine run command. 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 = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-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, - run_command_name=run_command_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_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. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine containing the run command. 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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - - _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) - - _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_by_virtual_machine( - self, resource_group_name: str, vm_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineRunCommand"]: - """The operation to get all run commands 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 run command. Required. - :type vm_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-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_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) - - -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.v2020_06_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vm_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommand, 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 "2020-06-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(run_command, (IOBase, bytes)): - _content = run_command - else: - _json = self._serialize.body(run_command, "VirtualMachineRunCommand") - - _request = build_virtual_machine_scale_set_vm_run_commands_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, - 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) - - 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, - 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 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 - :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. - Required. - :type run_command: ~azure.mgmt.compute.v2020_06_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.v2020_06_01.models.VirtualMachineRunCommand] - :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, - 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 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 - :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". - :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.v2020_06_01.models.VirtualMachineRunCommand] - :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, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update 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 - :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.v2020_06_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.v2020_06_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 "2020-06-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._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, - 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("VirtualMachineRunCommand", 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.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 _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]], - **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 "2020-06-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(run_command, (IOBase, bytes)): - _content = run_command - else: - _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") - - _request = build_virtual_machine_scale_set_vm_run_commands_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, - 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, - 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 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 - :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. - Required. - :type run_command: ~azure.mgmt.compute.v2020_06_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.v2020_06_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """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_scale_set_name: The name of the VM 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. - 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". - :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.v2020_06_01.models.VirtualMachineRunCommand] - :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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """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_scale_set_name: The name of the VM 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.v2020_06_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.v2020_06_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 "2020-06-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_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, - 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("VirtualMachineRunCommand", 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.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 _delete_initial( - 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, - 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 "2020-06-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_run_commands_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, - 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, vm_scale_set_name: str, instance_id: str, run_command_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """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_scale_set_name: The name of the VM 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 - :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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - run_command_name=run_command_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, - 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.v2020_06_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 "2020-06-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 - ) -> AsyncItemPaged["_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.v2020_06_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 "2020-06-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/v2020_06_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/__init__.py deleted file mode 100644 index 7186e0fa7c79..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/__init__.py +++ /dev/null @@ -1,498 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - AdditionalCapabilities, - AdditionalUnattendContent, - ApiEntityReference, - ApiError, - ApiErrorBase, - AutomaticOSUpgradePolicy, - AutomaticOSUpgradeProperties, - AutomaticRepairsPolicy, - AvailabilitySet, - AvailabilitySetListResult, - AvailabilitySetUpdate, - AvailablePatchSummary, - BillingProfile, - BootDiagnostics, - BootDiagnosticsInstanceView, - ComputeOperationListResult, - ComputeOperationValue, - DataDisk, - DataDiskImage, - DedicatedHost, - DedicatedHostAllocatableVM, - DedicatedHostAvailableCapacity, - DedicatedHostGroup, - DedicatedHostGroupInstanceView, - DedicatedHostGroupListResult, - DedicatedHostGroupUpdate, - DedicatedHostInstanceView, - DedicatedHostInstanceViewWithName, - DedicatedHostListResult, - DedicatedHostUpdate, - DiagnosticsProfile, - DiffDiskSettings, - DisallowedConfiguration, - DiskEncryptionSetParameters, - DiskEncryptionSettings, - DiskInstanceView, - HardwareProfile, - Image, - ImageDataDisk, - ImageDisk, - ImageListResult, - ImageOSDisk, - ImageReference, - ImageStorageProfile, - ImageUpdate, - InnerError, - InstanceViewStatus, - KeyVaultKeyReference, - KeyVaultSecretReference, - LastPatchInstallationSummary, - LinuxConfiguration, - ListUsagesResult, - LogAnalyticsInputBase, - LogAnalyticsOperationResult, - LogAnalyticsOutput, - MaintenanceRedeployStatus, - ManagedDiskParameters, - NetworkInterfaceReference, - NetworkProfile, - OSDisk, - OSDiskImage, - OSProfile, - OrchestrationServiceStateInput, - OrchestrationServiceSummary, - PatchSettings, - Plan, - ProximityPlacementGroup, - ProximityPlacementGroupListResult, - ProximityPlacementGroupUpdate, - PurchasePlan, - RecoveryWalkResponse, - RequestRateByIntervalInput, - Resource, - RetrieveBootDiagnosticsDataResult, - RollbackStatusInfo, - RollingUpgradePolicy, - RollingUpgradeProgressInfo, - RollingUpgradeRunningStatus, - RollingUpgradeStatusInfo, - RunCommandDocument, - RunCommandDocumentBase, - RunCommandInput, - RunCommandInputParameter, - RunCommandListResult, - RunCommandParameterDefinition, - RunCommandResult, - ScaleInPolicy, - ScheduledEventsProfile, - SecurityProfile, - Sku, - SshConfiguration, - SshPublicKey, - SshPublicKeyGenerateKeyPairResult, - SshPublicKeyResource, - SshPublicKeyUpdateResource, - SshPublicKeysGroupListResult, - StorageProfile, - SubResource, - SubResourceReadOnly, - SubResourceWithColocationStatus, - TerminateNotificationProfile, - ThrottledRequestsInput, - UpdateResource, - UpgradeOperationHistoricalStatusInfo, - UpgradeOperationHistoricalStatusInfoProperties, - UpgradeOperationHistoryStatus, - UpgradePolicy, - Usage, - UsageName, - UserAssignedIdentitiesValue, - VMScaleSetConvertToSinglePlacementGroupInput, - VaultCertificate, - VaultSecretGroup, - VirtualHardDisk, - VirtualMachine, - VirtualMachineAgentInstanceView, - VirtualMachineAssessPatchesResult, - VirtualMachineCaptureParameters, - VirtualMachineCaptureResult, - VirtualMachineExtension, - VirtualMachineExtensionHandlerInstanceView, - VirtualMachineExtensionImage, - VirtualMachineExtensionInstanceView, - VirtualMachineExtensionUpdate, - VirtualMachineExtensionsListResult, - VirtualMachineHealthStatus, - VirtualMachineIdentity, - VirtualMachineImage, - VirtualMachineImageResource, - VirtualMachineInstanceView, - VirtualMachineListResult, - VirtualMachinePatchStatus, - VirtualMachineReimageParameters, - VirtualMachineRunCommand, - VirtualMachineRunCommandInstanceView, - VirtualMachineRunCommandScriptSource, - VirtualMachineRunCommandUpdate, - VirtualMachineRunCommandsListResult, - VirtualMachineScaleSet, - VirtualMachineScaleSetDataDisk, - VirtualMachineScaleSetExtension, - VirtualMachineScaleSetExtensionListResult, - VirtualMachineScaleSetExtensionProfile, - VirtualMachineScaleSetExtensionUpdate, - VirtualMachineScaleSetIPConfiguration, - VirtualMachineScaleSetIdentity, - VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue, - VirtualMachineScaleSetInstanceView, - VirtualMachineScaleSetInstanceViewStatusesSummary, - VirtualMachineScaleSetIpTag, - VirtualMachineScaleSetListOSUpgradeHistory, - VirtualMachineScaleSetListResult, - VirtualMachineScaleSetListSkusResult, - VirtualMachineScaleSetListWithLinkResult, - VirtualMachineScaleSetManagedDiskParameters, - VirtualMachineScaleSetNetworkConfiguration, - VirtualMachineScaleSetNetworkConfigurationDnsSettings, - VirtualMachineScaleSetNetworkProfile, - VirtualMachineScaleSetOSDisk, - VirtualMachineScaleSetOSProfile, - VirtualMachineScaleSetPublicIPAddressConfiguration, - VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings, - VirtualMachineScaleSetReimageParameters, - VirtualMachineScaleSetSku, - VirtualMachineScaleSetSkuCapacity, - VirtualMachineScaleSetStorageProfile, - VirtualMachineScaleSetUpdate, - VirtualMachineScaleSetUpdateIPConfiguration, - VirtualMachineScaleSetUpdateNetworkConfiguration, - VirtualMachineScaleSetUpdateNetworkProfile, - VirtualMachineScaleSetUpdateOSDisk, - VirtualMachineScaleSetUpdateOSProfile, - VirtualMachineScaleSetUpdatePublicIPAddressConfiguration, - VirtualMachineScaleSetUpdateStorageProfile, - VirtualMachineScaleSetUpdateVMProfile, - VirtualMachineScaleSetVM, - VirtualMachineScaleSetVMExtension, - VirtualMachineScaleSetVMExtensionUpdate, - VirtualMachineScaleSetVMExtensionsListResult, - VirtualMachineScaleSetVMExtensionsSummary, - VirtualMachineScaleSetVMInstanceIDs, - VirtualMachineScaleSetVMInstanceRequiredIDs, - VirtualMachineScaleSetVMInstanceView, - VirtualMachineScaleSetVMListResult, - VirtualMachineScaleSetVMNetworkProfileConfiguration, - VirtualMachineScaleSetVMProfile, - VirtualMachineScaleSetVMProtectionPolicy, - VirtualMachineScaleSetVMReimageParameters, - VirtualMachineSize, - VirtualMachineSizeListResult, - VirtualMachineSoftwarePatchProperties, - VirtualMachineStatusCodeCount, - VirtualMachineUpdate, - WinRMConfiguration, - WinRMListener, - WindowsConfiguration, -) - -from ._compute_management_client_enums import ( # type: ignore - AvailabilitySetSkuTypes, - CachingTypes, - DedicatedHostLicenseTypes, - DiffDiskOptions, - DiffDiskPlacement, - DiskCreateOptionTypes, - ExecutionState, - HyperVGenerationType, - HyperVGenerationTypes, - IPVersion, - InGuestPatchMode, - IntervalInMins, - MaintenanceOperationResultCodeTypes, - OperatingSystemStateTypes, - OperatingSystemTypes, - OrchestrationServiceNames, - OrchestrationServiceState, - OrchestrationServiceStateAction, - PatchAssessmentState, - PatchOperationStatus, - ProtocolTypes, - ProximityPlacementGroupType, - RebootStatus, - ResourceIdentityType, - RollingUpgradeActionType, - RollingUpgradeStatusCode, - SettingNames, - SoftwareUpdateRebootBehavior, - StatusLevelTypes, - StorageAccountTypes, - UpgradeMode, - UpgradeOperationInvoker, - UpgradeState, - VirtualMachineEvictionPolicyTypes, - VirtualMachinePriorityTypes, - VirtualMachineScaleSetScaleInRules, - VirtualMachineScaleSetSkuScaleType, - VirtualMachineSizeTypes, - VmDiskTypes, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AdditionalCapabilities", - "AdditionalUnattendContent", - "ApiEntityReference", - "ApiError", - "ApiErrorBase", - "AutomaticOSUpgradePolicy", - "AutomaticOSUpgradeProperties", - "AutomaticRepairsPolicy", - "AvailabilitySet", - "AvailabilitySetListResult", - "AvailabilitySetUpdate", - "AvailablePatchSummary", - "BillingProfile", - "BootDiagnostics", - "BootDiagnosticsInstanceView", - "ComputeOperationListResult", - "ComputeOperationValue", - "DataDisk", - "DataDiskImage", - "DedicatedHost", - "DedicatedHostAllocatableVM", - "DedicatedHostAvailableCapacity", - "DedicatedHostGroup", - "DedicatedHostGroupInstanceView", - "DedicatedHostGroupListResult", - "DedicatedHostGroupUpdate", - "DedicatedHostInstanceView", - "DedicatedHostInstanceViewWithName", - "DedicatedHostListResult", - "DedicatedHostUpdate", - "DiagnosticsProfile", - "DiffDiskSettings", - "DisallowedConfiguration", - "DiskEncryptionSetParameters", - "DiskEncryptionSettings", - "DiskInstanceView", - "HardwareProfile", - "Image", - "ImageDataDisk", - "ImageDisk", - "ImageListResult", - "ImageOSDisk", - "ImageReference", - "ImageStorageProfile", - "ImageUpdate", - "InnerError", - "InstanceViewStatus", - "KeyVaultKeyReference", - "KeyVaultSecretReference", - "LastPatchInstallationSummary", - "LinuxConfiguration", - "ListUsagesResult", - "LogAnalyticsInputBase", - "LogAnalyticsOperationResult", - "LogAnalyticsOutput", - "MaintenanceRedeployStatus", - "ManagedDiskParameters", - "NetworkInterfaceReference", - "NetworkProfile", - "OSDisk", - "OSDiskImage", - "OSProfile", - "OrchestrationServiceStateInput", - "OrchestrationServiceSummary", - "PatchSettings", - "Plan", - "ProximityPlacementGroup", - "ProximityPlacementGroupListResult", - "ProximityPlacementGroupUpdate", - "PurchasePlan", - "RecoveryWalkResponse", - "RequestRateByIntervalInput", - "Resource", - "RetrieveBootDiagnosticsDataResult", - "RollbackStatusInfo", - "RollingUpgradePolicy", - "RollingUpgradeProgressInfo", - "RollingUpgradeRunningStatus", - "RollingUpgradeStatusInfo", - "RunCommandDocument", - "RunCommandDocumentBase", - "RunCommandInput", - "RunCommandInputParameter", - "RunCommandListResult", - "RunCommandParameterDefinition", - "RunCommandResult", - "ScaleInPolicy", - "ScheduledEventsProfile", - "SecurityProfile", - "Sku", - "SshConfiguration", - "SshPublicKey", - "SshPublicKeyGenerateKeyPairResult", - "SshPublicKeyResource", - "SshPublicKeyUpdateResource", - "SshPublicKeysGroupListResult", - "StorageProfile", - "SubResource", - "SubResourceReadOnly", - "SubResourceWithColocationStatus", - "TerminateNotificationProfile", - "ThrottledRequestsInput", - "UpdateResource", - "UpgradeOperationHistoricalStatusInfo", - "UpgradeOperationHistoricalStatusInfoProperties", - "UpgradeOperationHistoryStatus", - "UpgradePolicy", - "Usage", - "UsageName", - "UserAssignedIdentitiesValue", - "VMScaleSetConvertToSinglePlacementGroupInput", - "VaultCertificate", - "VaultSecretGroup", - "VirtualHardDisk", - "VirtualMachine", - "VirtualMachineAgentInstanceView", - "VirtualMachineAssessPatchesResult", - "VirtualMachineCaptureParameters", - "VirtualMachineCaptureResult", - "VirtualMachineExtension", - "VirtualMachineExtensionHandlerInstanceView", - "VirtualMachineExtensionImage", - "VirtualMachineExtensionInstanceView", - "VirtualMachineExtensionUpdate", - "VirtualMachineExtensionsListResult", - "VirtualMachineHealthStatus", - "VirtualMachineIdentity", - "VirtualMachineImage", - "VirtualMachineImageResource", - "VirtualMachineInstanceView", - "VirtualMachineListResult", - "VirtualMachinePatchStatus", - "VirtualMachineReimageParameters", - "VirtualMachineRunCommand", - "VirtualMachineRunCommandInstanceView", - "VirtualMachineRunCommandScriptSource", - "VirtualMachineRunCommandUpdate", - "VirtualMachineRunCommandsListResult", - "VirtualMachineScaleSet", - "VirtualMachineScaleSetDataDisk", - "VirtualMachineScaleSetExtension", - "VirtualMachineScaleSetExtensionListResult", - "VirtualMachineScaleSetExtensionProfile", - "VirtualMachineScaleSetExtensionUpdate", - "VirtualMachineScaleSetIPConfiguration", - "VirtualMachineScaleSetIdentity", - "VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue", - "VirtualMachineScaleSetInstanceView", - "VirtualMachineScaleSetInstanceViewStatusesSummary", - "VirtualMachineScaleSetIpTag", - "VirtualMachineScaleSetListOSUpgradeHistory", - "VirtualMachineScaleSetListResult", - "VirtualMachineScaleSetListSkusResult", - "VirtualMachineScaleSetListWithLinkResult", - "VirtualMachineScaleSetManagedDiskParameters", - "VirtualMachineScaleSetNetworkConfiguration", - "VirtualMachineScaleSetNetworkConfigurationDnsSettings", - "VirtualMachineScaleSetNetworkProfile", - "VirtualMachineScaleSetOSDisk", - "VirtualMachineScaleSetOSProfile", - "VirtualMachineScaleSetPublicIPAddressConfiguration", - "VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings", - "VirtualMachineScaleSetReimageParameters", - "VirtualMachineScaleSetSku", - "VirtualMachineScaleSetSkuCapacity", - "VirtualMachineScaleSetStorageProfile", - "VirtualMachineScaleSetUpdate", - "VirtualMachineScaleSetUpdateIPConfiguration", - "VirtualMachineScaleSetUpdateNetworkConfiguration", - "VirtualMachineScaleSetUpdateNetworkProfile", - "VirtualMachineScaleSetUpdateOSDisk", - "VirtualMachineScaleSetUpdateOSProfile", - "VirtualMachineScaleSetUpdatePublicIPAddressConfiguration", - "VirtualMachineScaleSetUpdateStorageProfile", - "VirtualMachineScaleSetUpdateVMProfile", - "VirtualMachineScaleSetVM", - "VirtualMachineScaleSetVMExtension", - "VirtualMachineScaleSetVMExtensionUpdate", - "VirtualMachineScaleSetVMExtensionsListResult", - "VirtualMachineScaleSetVMExtensionsSummary", - "VirtualMachineScaleSetVMInstanceIDs", - "VirtualMachineScaleSetVMInstanceRequiredIDs", - "VirtualMachineScaleSetVMInstanceView", - "VirtualMachineScaleSetVMListResult", - "VirtualMachineScaleSetVMNetworkProfileConfiguration", - "VirtualMachineScaleSetVMProfile", - "VirtualMachineScaleSetVMProtectionPolicy", - "VirtualMachineScaleSetVMReimageParameters", - "VirtualMachineSize", - "VirtualMachineSizeListResult", - "VirtualMachineSoftwarePatchProperties", - "VirtualMachineStatusCodeCount", - "VirtualMachineUpdate", - "WinRMConfiguration", - "WinRMListener", - "WindowsConfiguration", - "AvailabilitySetSkuTypes", - "CachingTypes", - "DedicatedHostLicenseTypes", - "DiffDiskOptions", - "DiffDiskPlacement", - "DiskCreateOptionTypes", - "ExecutionState", - "HyperVGenerationType", - "HyperVGenerationTypes", - "IPVersion", - "InGuestPatchMode", - "IntervalInMins", - "MaintenanceOperationResultCodeTypes", - "OperatingSystemStateTypes", - "OperatingSystemTypes", - "OrchestrationServiceNames", - "OrchestrationServiceState", - "OrchestrationServiceStateAction", - "PatchAssessmentState", - "PatchOperationStatus", - "ProtocolTypes", - "ProximityPlacementGroupType", - "RebootStatus", - "ResourceIdentityType", - "RollingUpgradeActionType", - "RollingUpgradeStatusCode", - "SettingNames", - "SoftwareUpdateRebootBehavior", - "StatusLevelTypes", - "StorageAccountTypes", - "UpgradeMode", - "UpgradeOperationInvoker", - "UpgradeState", - "VirtualMachineEvictionPolicyTypes", - "VirtualMachinePriorityTypes", - "VirtualMachineScaleSetScaleInRules", - "VirtualMachineScaleSetSkuScaleType", - "VirtualMachineSizeTypes", - "VmDiskTypes", -] -__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/v2020_06_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/_compute_management_client_enums.py deleted file mode 100644 index f5690b8513a5..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/_compute_management_client_enums.py +++ /dev/null @@ -1,569 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AvailabilitySetSkuTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the sku of an Availability Set. Use 'Aligned' for virtual machines with managed disks - and 'Classic' for virtual machines with unmanaged disks. Default value is 'Classic'. - """ - - CLASSIC = "Classic" - ALIGNED = "Aligned" - - -class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** :code:`
    `\\ - :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for Standard storage. - ReadOnly for Premium storage**. - """ - - NONE = "None" - READ_ONLY = "ReadOnly" - READ_WRITE = "ReadWrite" - - -class DedicatedHostLicenseTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the software license type that will be applied to the VMs deployed on the dedicated - host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **None** - :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ :code:`
    ` - **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. - """ - - NONE = "None" - WINDOWS_SERVER_HYBRID = "Windows_Server_Hybrid" - WINDOWS_SERVER_PERPETUAL = "Windows_Server_Perpetual" - - -class DiffDiskOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the ephemeral disk option for operating system disk.""" - - LOCAL = "Local" - - -class DiffDiskPlacement(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the ephemeral disk placement for operating system disk. This property can be used by - user in the request to choose the location i.e, cache disk or resource disk space for Ephemeral - OS disk provisioning. For more information on Ephemeral OS disk size requirements, please refer - Ephemeral OS disk size requirements for Windows VM at - https://docs.microsoft.com/en-us/azure/virtual-machines/windows/ephemeral-os-disks#size-requirements - and Linux VM at - https://docs.microsoft.com/en-us/azure/virtual-machines/linux/ephemeral-os-disks#size-requirements. - """ - - CACHE_DISK = "CacheDisk" - RESOURCE_DISK = "ResourceDisk" - - -class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies how the virtual machine should be created.\\ :code:`
    `\\ :code:`
    ` Possible - values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value is used when you are - using a specialized disk to create the virtual machine.\\ :code:`
    `\\ :code:`
    ` - **FromImage** \\u2013 This value is used when you are using an image to create the virtual - machine. If you are using a platform image, you also use the imageReference element described - above. If you are using a marketplace image, you also use the plan element previously - described. - """ - - FROM_IMAGE = "FromImage" - EMPTY = "Empty" - ATTACH = "Attach" - - -class ExecutionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Script execution status.""" - - UNKNOWN = "Unknown" - PENDING = "Pending" - RUNNING = "Running" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - TIMED_OUT = "TimedOut" - CANCELED = "Canceled" - - -class HyperVGenerationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the HyperVGeneration Type associated with a resource.""" - - V1 = "V1" - V2 = "V2" - - -class HyperVGenerationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the HyperVGeneration Type.""" - - V1 = "V1" - V2 = "V2" - - -class InGuestPatchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the mode of in-guest patching to IaaS virtual machine.\\ :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Manual** - You control the - application of patches to a virtual machine. You do this by applying patches manually inside - the VM. In this mode, automatic updates are disabled; the property - WindowsConfiguration.enableAutomaticUpdates must be false\\ :code:`
    `\\ :code:`
    ` - **AutomaticByOS** - The virtual machine will automatically be updated by the OS. The property - WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
    `\\ :code:`
    ` - **AutomaticByPlatform** - the virtual machine will automatically updated by the platform. The - properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. - """ - - MANUAL = "Manual" - AUTOMATIC_BY_OS = "AutomaticByOS" - AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" - - -class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Interval value in minutes used to create LogAnalytics call rate logs.""" - - THREE_MINS = "ThreeMins" - FIVE_MINS = "FiveMins" - THIRTY_MINS = "ThirtyMins" - SIXTY_MINS = "SixtyMins" - - -class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """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'. - """ - - I_PV4 = "IPv4" - I_PV6 = "IPv6" - - -class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The Last Maintenance Operation Result Code.""" - - NONE = "None" - RETRY_LATER = "RetryLater" - MAINTENANCE_ABORTED = "MaintenanceAborted" - MAINTENANCE_COMPLETED = "MaintenanceCompleted" - - -class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The OS State.""" - - GENERALIZED = "Generalized" - """Generalized image. Needs to be provisioned during deployment time.""" - SPECIALIZED = "Specialized" - """Specialized image. Contains already provisioned OS Disk.""" - - -class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The operating system of the osDiskImage.""" - - WINDOWS = "Windows" - LINUX = "Linux" - - -class OrchestrationServiceNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The name of the service.""" - - AUTOMATIC_REPAIRS = "AutomaticRepairs" - - -class OrchestrationServiceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current state of the service.""" - - NOT_RUNNING = "NotRunning" - RUNNING = "Running" - SUSPENDED = "Suspended" - - -class OrchestrationServiceStateAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The action to be performed.""" - - RESUME = "Resume" - SUSPEND = "Suspend" - - -class PatchAssessmentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Describes the outcome of an install operation for a given patch.""" - - INSTALLED = "Installed" - FAILED = "Failed" - EXCLUDED = "Excluded" - NOT_SELECTED = "NotSelected" - PENDING = "Pending" - AVAILABLE = "Available" - - -class PatchOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The overall success or failure status of the operation. It remains "InProgress" until the - operation completes. At that point it will become "Failed", "Succeeded", or - "CompletedWithWarnings.". - """ - - IN_PROGRESS = "InProgress" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - COMPLETED_WITH_WARNINGS = "CompletedWithWarnings" - - -class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the protocol of WinRM listener. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. - """ - - HTTP = "Http" - HTTPS = "Https" - - -class ProximityPlacementGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the type of the proximity placement group. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **Standard** : Co-locate resources within an Azure - region or Availability Zone. :code:`
    `\\ :code:`
    ` **Ultra** : For future use. - """ - - STANDARD = "Standard" - ULTRA = "Ultra" - - -class RebootStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The reboot status of the machine after the patch operation. It will be in "NotNeeded" status if - reboot is not needed after the patch operation. "Required" will be the status once the patch is - applied and machine is required to reboot. "Started" will be the reboot status when the machine - has started to reboot. "Failed" will be the status if the machine is failed to reboot. - "Completed" will be the status once the machine is rebooted successfully. - """ - - NOT_NEEDED = "NotNeeded" - REQUIRED = "Required" - STARTED = "Started" - FAILED = "Failed" - COMPLETED = "Completed" - - -class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' - includes both an implicitly created identity and a set of user assigned identities. The type - 'None' will remove any identities from the virtual machine. - """ - - SYSTEM_ASSIGNED = "SystemAssigned" - USER_ASSIGNED = "UserAssigned" - SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" - NONE = "None" - - -class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The last action performed on the rolling upgrade.""" - - START = "Start" - CANCEL = "Cancel" - - -class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Code indicating the current status of the upgrade.""" - - ROLLING_FORWARD = "RollingForward" - CANCELLED = "Cancelled" - COMPLETED = "Completed" - FAULTED = "Faulted" - - -class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the name of the setting to which the content applies. Possible values are: - FirstLogonCommands and AutoLogon. - """ - - AUTO_LOGON = "AutoLogon" - FIRST_LOGON_COMMANDS = "FirstLogonCommands" - - -class SoftwareUpdateRebootBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Describes the reboot requirements of the patch.""" - - NEVER_REBOOTS = "NeverReboots" - ALWAYS_REQUIRES_REBOOT = "AlwaysRequiresReboot" - CAN_REQUEST_REBOOT = "CanRequestReboot" - - -class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The level code.""" - - INFO = "Info" - WARNING = "Warning" - ERROR = "Error" - - -class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used - with data disks. It cannot be used with OS Disk. Standard_LRS uses Standard HDD. - StandardSSD_LRS uses Standard SSD. Premium_LRS uses Premium SSD. UltraSSD_LRS uses Ultra disk. - For more information regarding disks supported for Windows Virtual Machines, refer to - https://docs.microsoft.com/en-us/azure/virtual-machines/windows/disks-types and, for Linux - Virtual Machines, refer to - https://docs.microsoft.com/en-us/azure/virtual-machines/linux/disks-types. - """ - - STANDARD_LRS = "Standard_LRS" - PREMIUM_LRS = "Premium_LRS" - STANDARD_SSD_LRS = "StandardSSD_LRS" - ULTRA_SSD_LRS = "UltraSSD_LRS" - - -class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the mode of an upgrade to virtual machines in the scale set.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Manual** - You control - the application of updates to virtual machines in the scale set. You do this by using the - manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - All virtual machines in - the scale set are automatically updated at the same time. - """ - - AUTOMATIC = "Automatic" - MANUAL = "Manual" - ROLLING = "Rolling" - - -class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Invoker of the Upgrade Operation.""" - - UNKNOWN = "Unknown" - USER = "User" - PLATFORM = "Platform" - - -class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Code indicating the current status of the upgrade.""" - - ROLLING_FORWARD = "RollingForward" - CANCELLED = "Cancelled" - COMPLETED = "Completed" - FAULTED = "Faulted" - - -class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the eviction policy for the Azure Spot VM/VMSS.""" - - DEALLOCATE = "Deallocate" - DELETE = "Delete" - - -class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the priority for a standalone virtual machine or the virtual machines in the scale - set. :code:`
    `\\ :code:`
    ` 'Low' enum will be deprecated in the future, please use 'Spot' - as the enum to deploy Azure Spot VM/VMSS. - """ - - REGULAR = "Regular" - LOW = "Low" - SPOT = "Spot" - - -class VirtualMachineScaleSetScaleInRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """VirtualMachineScaleSetScaleInRules.""" - - DEFAULT = "Default" - OLDEST_VM = "OldestVM" - NEWEST_VM = "NewestVM" - - -class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scale type applicable to the sku.""" - - AUTOMATIC = "Automatic" - NONE = "None" - - -class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the size of the virtual machine. For more information about virtual machine sizes, - see `Sizes for virtual machines - `_. :code:`
    `\\ :code:`
    ` - The available VM sizes depend on region and availability set. For a list of available sizes use - these APIs: :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in an - availability set - `_ - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in a region - `_ :code:`
    `\\ - :code:`
    ` `List all available virtual machine sizes for resizing - `_. - :code:`
    `\\ :code:`
    ` This list of sizes is no longer updated and the - **VirtualMachineSizeTypes** string constants will be removed from the subsequent REST API - specification. Use `List all available virtual machine sizes in a region - `_ to get the latest - sizes. - """ - - BASIC_A0 = "Basic_A0" - BASIC_A1 = "Basic_A1" - BASIC_A2 = "Basic_A2" - BASIC_A3 = "Basic_A3" - BASIC_A4 = "Basic_A4" - STANDARD_A0 = "Standard_A0" - STANDARD_A1 = "Standard_A1" - STANDARD_A2 = "Standard_A2" - STANDARD_A3 = "Standard_A3" - STANDARD_A4 = "Standard_A4" - STANDARD_A5 = "Standard_A5" - STANDARD_A6 = "Standard_A6" - STANDARD_A7 = "Standard_A7" - STANDARD_A8 = "Standard_A8" - STANDARD_A9 = "Standard_A9" - STANDARD_A10 = "Standard_A10" - STANDARD_A11 = "Standard_A11" - STANDARD_A1_V2 = "Standard_A1_v2" - STANDARD_A2_V2 = "Standard_A2_v2" - STANDARD_A4_V2 = "Standard_A4_v2" - STANDARD_A8_V2 = "Standard_A8_v2" - STANDARD_A2_M_V2 = "Standard_A2m_v2" - STANDARD_A4_M_V2 = "Standard_A4m_v2" - STANDARD_A8_M_V2 = "Standard_A8m_v2" - STANDARD_B1_S = "Standard_B1s" - STANDARD_B1_MS = "Standard_B1ms" - STANDARD_B2_S = "Standard_B2s" - STANDARD_B2_MS = "Standard_B2ms" - STANDARD_B4_MS = "Standard_B4ms" - STANDARD_B8_MS = "Standard_B8ms" - STANDARD_D1 = "Standard_D1" - STANDARD_D2 = "Standard_D2" - STANDARD_D3 = "Standard_D3" - STANDARD_D4 = "Standard_D4" - STANDARD_D11 = "Standard_D11" - STANDARD_D12 = "Standard_D12" - STANDARD_D13 = "Standard_D13" - STANDARD_D14 = "Standard_D14" - STANDARD_D1_V2 = "Standard_D1_v2" - STANDARD_D2_V2 = "Standard_D2_v2" - STANDARD_D3_V2 = "Standard_D3_v2" - STANDARD_D4_V2 = "Standard_D4_v2" - STANDARD_D5_V2 = "Standard_D5_v2" - STANDARD_D2_V3 = "Standard_D2_v3" - STANDARD_D4_V3 = "Standard_D4_v3" - STANDARD_D8_V3 = "Standard_D8_v3" - STANDARD_D16_V3 = "Standard_D16_v3" - STANDARD_D32_V3 = "Standard_D32_v3" - STANDARD_D64_V3 = "Standard_D64_v3" - STANDARD_D2_S_V3 = "Standard_D2s_v3" - STANDARD_D4_S_V3 = "Standard_D4s_v3" - STANDARD_D8_S_V3 = "Standard_D8s_v3" - STANDARD_D16_S_V3 = "Standard_D16s_v3" - STANDARD_D32_S_V3 = "Standard_D32s_v3" - STANDARD_D64_S_V3 = "Standard_D64s_v3" - STANDARD_D11_V2 = "Standard_D11_v2" - STANDARD_D12_V2 = "Standard_D12_v2" - STANDARD_D13_V2 = "Standard_D13_v2" - STANDARD_D14_V2 = "Standard_D14_v2" - STANDARD_D15_V2 = "Standard_D15_v2" - STANDARD_DS1 = "Standard_DS1" - STANDARD_DS2 = "Standard_DS2" - STANDARD_DS3 = "Standard_DS3" - STANDARD_DS4 = "Standard_DS4" - STANDARD_DS11 = "Standard_DS11" - STANDARD_DS12 = "Standard_DS12" - STANDARD_DS13 = "Standard_DS13" - STANDARD_DS14 = "Standard_DS14" - STANDARD_DS1_V2 = "Standard_DS1_v2" - STANDARD_DS2_V2 = "Standard_DS2_v2" - STANDARD_DS3_V2 = "Standard_DS3_v2" - STANDARD_DS4_V2 = "Standard_DS4_v2" - STANDARD_DS5_V2 = "Standard_DS5_v2" - STANDARD_DS11_V2 = "Standard_DS11_v2" - STANDARD_DS12_V2 = "Standard_DS12_v2" - STANDARD_DS13_V2 = "Standard_DS13_v2" - STANDARD_DS14_V2 = "Standard_DS14_v2" - STANDARD_DS15_V2 = "Standard_DS15_v2" - STANDARD_DS13_4_V2 = "Standard_DS13-4_v2" - STANDARD_DS13_2_V2 = "Standard_DS13-2_v2" - STANDARD_DS14_8_V2 = "Standard_DS14-8_v2" - STANDARD_DS14_4_V2 = "Standard_DS14-4_v2" - STANDARD_E2_V3 = "Standard_E2_v3" - STANDARD_E4_V3 = "Standard_E4_v3" - STANDARD_E8_V3 = "Standard_E8_v3" - STANDARD_E16_V3 = "Standard_E16_v3" - STANDARD_E32_V3 = "Standard_E32_v3" - STANDARD_E64_V3 = "Standard_E64_v3" - STANDARD_E2_S_V3 = "Standard_E2s_v3" - STANDARD_E4_S_V3 = "Standard_E4s_v3" - STANDARD_E8_S_V3 = "Standard_E8s_v3" - STANDARD_E16_S_V3 = "Standard_E16s_v3" - STANDARD_E32_S_V3 = "Standard_E32s_v3" - STANDARD_E64_S_V3 = "Standard_E64s_v3" - STANDARD_E32_16_V3 = "Standard_E32-16_v3" - STANDARD_E32_8_S_V3 = "Standard_E32-8s_v3" - STANDARD_E64_32_S_V3 = "Standard_E64-32s_v3" - STANDARD_E64_16_S_V3 = "Standard_E64-16s_v3" - STANDARD_F1 = "Standard_F1" - STANDARD_F2 = "Standard_F2" - STANDARD_F4 = "Standard_F4" - STANDARD_F8 = "Standard_F8" - STANDARD_F16 = "Standard_F16" - STANDARD_F1_S = "Standard_F1s" - STANDARD_F2_S = "Standard_F2s" - STANDARD_F4_S = "Standard_F4s" - STANDARD_F8_S = "Standard_F8s" - STANDARD_F16_S = "Standard_F16s" - STANDARD_F2_S_V2 = "Standard_F2s_v2" - STANDARD_F4_S_V2 = "Standard_F4s_v2" - STANDARD_F8_S_V2 = "Standard_F8s_v2" - STANDARD_F16_S_V2 = "Standard_F16s_v2" - STANDARD_F32_S_V2 = "Standard_F32s_v2" - STANDARD_F64_S_V2 = "Standard_F64s_v2" - STANDARD_F72_S_V2 = "Standard_F72s_v2" - STANDARD_G1 = "Standard_G1" - STANDARD_G2 = "Standard_G2" - STANDARD_G3 = "Standard_G3" - STANDARD_G4 = "Standard_G4" - STANDARD_G5 = "Standard_G5" - STANDARD_GS1 = "Standard_GS1" - STANDARD_GS2 = "Standard_GS2" - STANDARD_GS3 = "Standard_GS3" - STANDARD_GS4 = "Standard_GS4" - STANDARD_GS5 = "Standard_GS5" - STANDARD_GS4_8 = "Standard_GS4-8" - STANDARD_GS4_4 = "Standard_GS4-4" - STANDARD_GS5_16 = "Standard_GS5-16" - STANDARD_GS5_8 = "Standard_GS5-8" - STANDARD_H8 = "Standard_H8" - STANDARD_H16 = "Standard_H16" - STANDARD_H8_M = "Standard_H8m" - STANDARD_H16_M = "Standard_H16m" - STANDARD_H16_R = "Standard_H16r" - STANDARD_H16_MR = "Standard_H16mr" - STANDARD_L4_S = "Standard_L4s" - STANDARD_L8_S = "Standard_L8s" - STANDARD_L16_S = "Standard_L16s" - STANDARD_L32_S = "Standard_L32s" - STANDARD_M64_S = "Standard_M64s" - STANDARD_M64_MS = "Standard_M64ms" - STANDARD_M128_S = "Standard_M128s" - STANDARD_M128_MS = "Standard_M128ms" - STANDARD_M64_32_MS = "Standard_M64-32ms" - STANDARD_M64_16_MS = "Standard_M64-16ms" - STANDARD_M128_64_MS = "Standard_M128-64ms" - STANDARD_M128_32_MS = "Standard_M128-32ms" - STANDARD_NC6 = "Standard_NC6" - STANDARD_NC12 = "Standard_NC12" - STANDARD_NC24 = "Standard_NC24" - STANDARD_NC24_R = "Standard_NC24r" - STANDARD_NC6_S_V2 = "Standard_NC6s_v2" - STANDARD_NC12_S_V2 = "Standard_NC12s_v2" - STANDARD_NC24_S_V2 = "Standard_NC24s_v2" - STANDARD_NC24_RS_V2 = "Standard_NC24rs_v2" - STANDARD_NC6_S_V3 = "Standard_NC6s_v3" - STANDARD_NC12_S_V3 = "Standard_NC12s_v3" - STANDARD_NC24_S_V3 = "Standard_NC24s_v3" - STANDARD_NC24_RS_V3 = "Standard_NC24rs_v3" - STANDARD_ND6_S = "Standard_ND6s" - STANDARD_ND12_S = "Standard_ND12s" - STANDARD_ND24_S = "Standard_ND24s" - STANDARD_ND24_RS = "Standard_ND24rs" - STANDARD_NV6 = "Standard_NV6" - STANDARD_NV12 = "Standard_NV12" - STANDARD_NV24 = "Standard_NV24" - - -class VmDiskTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """VM disk types which are disallowed.""" - - NONE = "None" - UNMANAGED = "Unmanaged" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/_models_py3.py deleted file mode 100644 index ab7a53cadd8d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/_models_py3.py +++ /dev/null @@ -1,11618 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from collections.abc import MutableMapping -import datetime -from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models -JSON = MutableMapping[str, Any] - - -class AdditionalCapabilities(_serialization.Model): - """Enables or disables a capability on the virtual machine or virtual machine scale set. - - :ivar ultra_ssd_enabled: The flag that enables or disables a capability to have one or more - managed data disks with UltraSSD_LRS storage account type on the VM or VMSS. Managed disks with - storage account type UltraSSD_LRS can be added to a virtual machine or virtual machine scale - set only if this property is enabled. - :vartype ultra_ssd_enabled: bool - """ - - _attribute_map = { - "ultra_ssd_enabled": {"key": "ultraSSDEnabled", "type": "bool"}, - } - - def __init__(self, *, ultra_ssd_enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword ultra_ssd_enabled: The flag that enables or disables a capability to have one or more - managed data disks with UltraSSD_LRS storage account type on the VM or VMSS. Managed disks with - storage account type UltraSSD_LRS can be added to a virtual machine or virtual machine scale - set only if this property is enabled. - :paramtype ultra_ssd_enabled: bool - """ - super().__init__(**kwargs) - self.ultra_ssd_enabled = ultra_ssd_enabled - - -class AdditionalUnattendContent(_serialization.Model): - """Specifies additional XML formatted information that can be included in the Unattend.xml file, - which is used by Windows Setup. Contents are defined by setting name, component name, and the - pass in which the content is applied. - - :ivar pass_name: The pass name. Currently, the only allowable value is OobeSystem. Default - value is "OobeSystem". - :vartype pass_name: str - :ivar component_name: The component name. Currently, the only allowable value is - Microsoft-Windows-Shell-Setup. Default value is "Microsoft-Windows-Shell-Setup". - :vartype component_name: str - :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon" and - "FirstLogonCommands". - :vartype setting_name: str or ~azure.mgmt.compute.v2020_06_01.models.SettingNames - :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for - the specified path and component. The XML must be less than 4KB and must include the root - element for the setting or feature that is being inserted. - :vartype content: str - """ - - _attribute_map = { - "pass_name": {"key": "passName", "type": "str"}, - "component_name": {"key": "componentName", "type": "str"}, - "setting_name": {"key": "settingName", "type": "str"}, - "content": {"key": "content", "type": "str"}, - } - - def __init__( - self, - *, - pass_name: Optional[Literal["OobeSystem"]] = None, - component_name: Optional[Literal["Microsoft-Windows-Shell-Setup"]] = None, - setting_name: Optional[Union[str, "_models.SettingNames"]] = None, - content: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword pass_name: The pass name. Currently, the only allowable value is OobeSystem. Default - value is "OobeSystem". - :paramtype pass_name: str - :keyword component_name: The component name. Currently, the only allowable value is - Microsoft-Windows-Shell-Setup. Default value is "Microsoft-Windows-Shell-Setup". - :paramtype component_name: str - :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon" and - "FirstLogonCommands". - :paramtype setting_name: str or ~azure.mgmt.compute.v2020_06_01.models.SettingNames - :keyword content: Specifies the XML formatted content that is added to the unattend.xml file - for the specified path and component. The XML must be less than 4KB and must include the root - element for the setting or feature that is being inserted. - :paramtype content: str - """ - super().__init__(**kwargs) - self.pass_name = pass_name - self.component_name = component_name - self.setting_name = setting_name - self.content = content - - -class ApiEntityReference(_serialization.Model): - """The API entity reference. - - :ivar id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class ApiError(_serialization.Model): - """Api error. - - :ivar details: The Api error details. - :vartype details: list[~azure.mgmt.compute.v2020_06_01.models.ApiErrorBase] - :ivar innererror: The Api inner error. - :vartype innererror: ~azure.mgmt.compute.v2020_06_01.models.InnerError - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "details": {"key": "details", "type": "[ApiErrorBase]"}, - "innererror": {"key": "innererror", "type": "InnerError"}, - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - details: Optional[List["_models.ApiErrorBase"]] = None, - innererror: Optional["_models.InnerError"] = None, - code: Optional[str] = None, - target: Optional[str] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword details: The Api error details. - :paramtype details: list[~azure.mgmt.compute.v2020_06_01.models.ApiErrorBase] - :keyword innererror: The Api inner error. - :paramtype innererror: ~azure.mgmt.compute.v2020_06_01.models.InnerError - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.details = details - self.innererror = innererror - self.code = code - self.target = target - self.message = message - - -class ApiErrorBase(_serialization.Model): - """Api error base. - - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.target = target - self.message = message - - -class AutomaticOSUpgradePolicy(_serialization.Model): - """The configuration parameters used for performing automatic OS upgrade. - - :ivar enable_automatic_os_upgrade: Indicates whether OS upgrades should automatically be - applied to scale set instances in a rolling fashion when a newer version of the OS image - becomes available. Default value is false. :code:`
    `\\ :code:`
    ` If this is set to true - for Windows based scale sets, `enableAutomaticUpdates - `_ - is automatically set to false and cannot be set to true. - :vartype enable_automatic_os_upgrade: bool - :ivar disable_automatic_rollback: Whether OS image rollback feature should be disabled. Default - value is false. - :vartype disable_automatic_rollback: bool - """ - - _attribute_map = { - "enable_automatic_os_upgrade": {"key": "enableAutomaticOSUpgrade", "type": "bool"}, - "disable_automatic_rollback": {"key": "disableAutomaticRollback", "type": "bool"}, - } - - def __init__( - self, - *, - enable_automatic_os_upgrade: Optional[bool] = None, - disable_automatic_rollback: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword enable_automatic_os_upgrade: Indicates whether OS upgrades should automatically be - applied to scale set instances in a rolling fashion when a newer version of the OS image - becomes available. Default value is false. :code:`
    `\\ :code:`
    ` If this is set to true - for Windows based scale sets, `enableAutomaticUpdates - `_ - is automatically set to false and cannot be set to true. - :paramtype enable_automatic_os_upgrade: bool - :keyword disable_automatic_rollback: Whether OS image rollback feature should be disabled. - Default value is false. - :paramtype disable_automatic_rollback: bool - """ - super().__init__(**kwargs) - self.enable_automatic_os_upgrade = enable_automatic_os_upgrade - self.disable_automatic_rollback = disable_automatic_rollback - - -class AutomaticOSUpgradeProperties(_serialization.Model): - """Describes automatic OS upgrade properties on the image. - - All required parameters must be populated in order to send to server. - - :ivar automatic_os_upgrade_supported: Specifies whether automatic OS upgrade is supported on - the image. Required. - :vartype automatic_os_upgrade_supported: bool - """ - - _validation = { - "automatic_os_upgrade_supported": {"required": True}, - } - - _attribute_map = { - "automatic_os_upgrade_supported": {"key": "automaticOSUpgradeSupported", "type": "bool"}, - } - - def __init__(self, *, automatic_os_upgrade_supported: bool, **kwargs: Any) -> None: - """ - :keyword automatic_os_upgrade_supported: Specifies whether automatic OS upgrade is supported on - the image. Required. - :paramtype automatic_os_upgrade_supported: bool - """ - super().__init__(**kwargs) - self.automatic_os_upgrade_supported = automatic_os_upgrade_supported - - -class AutomaticRepairsPolicy(_serialization.Model): - """Specifies the configuration parameters for automatic repairs on the virtual machine scale set. - - :ivar enabled: Specifies whether automatic repairs should be enabled on the virtual machine - scale set. The default value is false. - :vartype enabled: bool - :ivar grace_period: The amount of time for which automatic repairs are suspended due to a state - change on VM. The grace time starts after the state change has completed. This helps avoid - premature or accidental repairs. The time duration should be specified in ISO 8601 format. The - minimum allowed grace period is 30 minutes (PT30M), which is also the default value. The - maximum allowed grace period is 90 minutes (PT90M). - :vartype grace_period: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "grace_period": {"key": "gracePeriod", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, grace_period: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Specifies whether automatic repairs should be enabled on the virtual machine - scale set. The default value is false. - :paramtype enabled: bool - :keyword grace_period: The amount of time for which automatic repairs are suspended due to a - state change on VM. The grace time starts after the state change has completed. This helps - avoid premature or accidental repairs. The time duration should be specified in ISO 8601 - format. The minimum allowed grace period is 30 minutes (PT30M), which is also the default - value. The maximum allowed grace period is 90 minutes (PT90M). - :paramtype grace_period: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.grace_period = grace_period - - -class Resource(_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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - - -class AvailabilitySet(Resource): - """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 `Manage the - availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability 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. - :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] - :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 - 'Classic'. - :vartype sku: ~azure.mgmt.compute.v2020_06_01.models.Sku - :ivar platform_update_domain_count: Update Domain count. - :vartype platform_update_domain_count: int - :ivar platform_fault_domain_count: Fault Domain count. - :vartype platform_fault_domain_count: int - :ivar virtual_machines: A list of references to all virtual machines in the availability set. - :vartype virtual_machines: list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the availability set should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "statuses": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "Sku"}, - "platform_update_domain_count": {"key": "properties.platformUpdateDomainCount", "type": "int"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResource]"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "statuses": {"key": "properties.statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - platform_update_domain_count: Optional[int] = None, - platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["_models.SubResource"]] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - 'Classic'. - :paramtype sku: ~azure.mgmt.compute.v2020_06_01.models.Sku - :keyword platform_update_domain_count: Update Domain count. - :paramtype platform_update_domain_count: int - :keyword platform_fault_domain_count: Fault Domain count. - :paramtype platform_fault_domain_count: int - :keyword virtual_machines: A list of references to all virtual machines in the availability - set. - :paramtype virtual_machines: list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the availability set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.platform_update_domain_count = platform_update_domain_count - self.platform_fault_domain_count = platform_fault_domain_count - self.virtual_machines = virtual_machines - self.proximity_placement_group = proximity_placement_group - self.statuses: Optional[List["_models.InstanceViewStatus"]] = None - - -class AvailabilitySetListResult(_serialization.Model): - """The List Availability Set operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of availability sets. Required. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet] - :ivar next_link: The URI to fetch the next page of AvailabilitySets. Call ListNext() with this - URI to fetch the next page of AvailabilitySets. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AvailabilitySet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of availability sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet] - :keyword next_link: The URI to fetch the next page of AvailabilitySets. Call ListNext() with - this URI to fetch the next page of AvailabilitySets. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class UpdateResource(_serialization.Model): - """The Update Resource model definition. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class AvailabilitySetUpdate(UpdateResource): - """Specifies information about the availability set that the virtual machine should be assigned - to. Only tags may be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: Sku of the availability set. - :vartype sku: ~azure.mgmt.compute.v2020_06_01.models.Sku - :ivar platform_update_domain_count: Update Domain count. - :vartype platform_update_domain_count: int - :ivar platform_fault_domain_count: Fault Domain count. - :vartype platform_fault_domain_count: int - :ivar virtual_machines: A list of references to all virtual machines in the availability set. - :vartype virtual_machines: list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the availability set should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - """ - - _validation = { - "statuses": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "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"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResource]"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "statuses": {"key": "properties.statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - platform_update_domain_count: Optional[int] = None, - platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["_models.SubResource"]] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: Sku of the availability set. - :paramtype sku: ~azure.mgmt.compute.v2020_06_01.models.Sku - :keyword platform_update_domain_count: Update Domain count. - :paramtype platform_update_domain_count: int - :keyword platform_fault_domain_count: Fault Domain count. - :paramtype platform_fault_domain_count: int - :keyword virtual_machines: A list of references to all virtual machines in the availability - set. - :paramtype virtual_machines: list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the availability set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - """ - super().__init__(tags=tags, **kwargs) - self.sku = sku - self.platform_update_domain_count = platform_update_domain_count - self.platform_fault_domain_count = platform_fault_domain_count - self.virtual_machines = virtual_machines - self.proximity_placement_group = proximity_placement_group - self.statuses: Optional[List["_models.InstanceViewStatus"]] = None - - -class AvailablePatchSummary(_serialization.Model): - """Describes the properties of an virtual machine instance view for available patch summary. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The overall success or failure status of the operation. It remains "InProgress" - until the operation completes. At that point it will become "Failed", "Succeeded", or - "CompletedWithWarnings.". Known values are: "InProgress", "Failed", "Succeeded", and - "CompletedWithWarnings". - :vartype status: str or ~azure.mgmt.compute.v2020_06_01.models.PatchOperationStatus - :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is - used to correlate across CRP and extension logs. - :vartype assessment_activity_id: str - :ivar reboot_pending: The overall reboot status of the VM. It will be true when partially - installed patches require a reboot to complete installation but the reboot has not yet - occurred. - :vartype reboot_pending: bool - :ivar critical_and_security_patch_count: The number of critical or security patches that have - been detected as available and not yet installed. - :vartype critical_and_security_patch_count: int - :ivar other_patch_count: The number of all available patches excluding critical and security. - :vartype other_patch_count: int - :ivar start_time: The UTC timestamp when the operation began. - :vartype start_time: ~datetime.datetime - :ivar last_modified_time: The UTC timestamp when the operation began. - :vartype last_modified_time: ~datetime.datetime - :ivar error: The errors that were encountered during execution of the operation. The details - array contains the list of them. - :vartype error: ~azure.mgmt.compute.v2020_06_01.models.ApiError - """ - - _validation = { - "status": {"readonly": True}, - "assessment_activity_id": {"readonly": True}, - "reboot_pending": {"readonly": True}, - "critical_and_security_patch_count": {"readonly": True}, - "other_patch_count": {"readonly": True}, - "start_time": {"readonly": True}, - "last_modified_time": {"readonly": True}, - "error": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "assessment_activity_id": {"key": "assessmentActivityId", "type": "str"}, - "reboot_pending": {"key": "rebootPending", "type": "bool"}, - "critical_and_security_patch_count": {"key": "criticalAndSecurityPatchCount", "type": "int"}, - "other_patch_count": {"key": "otherPatchCount", "type": "int"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "last_modified_time": {"key": "lastModifiedTime", "type": "iso-8601"}, - "error": {"key": "error", "type": "ApiError"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional[Union[str, "_models.PatchOperationStatus"]] = None - self.assessment_activity_id: Optional[str] = None - self.reboot_pending: Optional[bool] = None - self.critical_and_security_patch_count: Optional[int] = None - self.other_patch_count: Optional[int] = None - self.start_time: Optional[datetime.datetime] = None - self.last_modified_time: Optional[datetime.datetime] = None - self.error: Optional["_models.ApiError"] = None - - -class BillingProfile(_serialization.Model): - """Specifies the billing related details of a Azure Spot VM or VMSS. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. - - :ivar max_price: Specifies the maximum price you are willing to pay for a Azure Spot VM/VMSS. - This price is in US Dollars. :code:`
    `\\ :code:`
    ` This price will be compared with the - current Azure Spot price for the VM size. Also, the prices are compared at the time of - create/update of Azure Spot VM/VMSS and the operation will only succeed if the maxPrice is - greater than the current Azure Spot price. :code:`
    `\\ :code:`
    ` The maxPrice will also - be used for evicting a Azure Spot VM/VMSS if the current Azure Spot price goes beyond the - maxPrice after creation of VM/VMSS. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` - Any decimal value greater than zero. Example: 0.01538 - :code:`
    `\\ :code:`
    ` -1 – indicates default price to be up-to on-demand. :code:`
    `\\ - :code:`
    ` You can set the maxPrice to -1 to indicate that the Azure Spot VM/VMSS should not - be evicted for price reasons. Also, the default max price is -1 if it is not provided by you. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype max_price: float - """ - - _attribute_map = { - "max_price": {"key": "maxPrice", "type": "float"}, - } - - def __init__(self, *, max_price: Optional[float] = None, **kwargs: Any) -> None: - """ - :keyword max_price: Specifies the maximum price you are willing to pay for a Azure Spot - VM/VMSS. This price is in US Dollars. :code:`
    `\\ :code:`
    ` This price will be compared - with the current Azure Spot price for the VM size. Also, the prices are compared at the time of - create/update of Azure Spot VM/VMSS and the operation will only succeed if the maxPrice is - greater than the current Azure Spot price. :code:`
    `\\ :code:`
    ` The maxPrice will also - be used for evicting a Azure Spot VM/VMSS if the current Azure Spot price goes beyond the - maxPrice after creation of VM/VMSS. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` - Any decimal value greater than zero. Example: 0.01538 - :code:`
    `\\ :code:`
    ` -1 – indicates default price to be up-to on-demand. :code:`
    `\\ - :code:`
    ` You can set the maxPrice to -1 to indicate that the Azure Spot VM/VMSS should not - be evicted for price reasons. Also, the default max price is -1 if it is not provided by you. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype max_price: float - """ - super().__init__(**kwargs) - self.max_price = max_price - - -class BootDiagnostics(_serialization.Model): - """Boot Diagnostics is a debugging feature which allows you to view Console Output and Screenshot - to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily view the output of your - console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see a screenshot of the VM - from the hypervisor. - - :ivar enabled: Whether boot diagnostics should be enabled on the Virtual Machine. - :vartype enabled: bool - :ivar storage_uri: Uri of the storage account to use for placing the console output and - screenshot. :code:`
    `\\ :code:`
    `If storageUri is not specified while enabling boot - diagnostics, managed storage will be used. - :vartype storage_uri: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "storage_uri": {"key": "storageUri", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, storage_uri: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Whether boot diagnostics should be enabled on the Virtual Machine. - :paramtype enabled: bool - :keyword storage_uri: Uri of the storage account to use for placing the console output and - screenshot. :code:`
    `\\ :code:`
    `If storageUri is not specified while enabling boot - diagnostics, managed storage will be used. - :paramtype storage_uri: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.storage_uri = storage_uri - - -class BootDiagnosticsInstanceView(_serialization.Model): - """The instance view of a virtual machine boot diagnostics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar console_screenshot_blob_uri: The console screenshot blob URI. :code:`
    `\\ - :code:`
    `NOTE: This will **not** be set if boot diagnostics is currently enabled with - managed storage. - :vartype console_screenshot_blob_uri: str - :ivar serial_console_log_blob_uri: The serial console log blob Uri. :code:`
    `\\ - :code:`
    `NOTE: This will **not** be set if boot diagnostics is currently enabled with - managed storage. - :vartype serial_console_log_blob_uri: str - :ivar status: The boot diagnostics status information for the VM. :code:`
    `\\ :code:`
    ` - NOTE: It will be set only if there are errors encountered in enabling boot diagnostics. - :vartype status: ~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus - """ - - _validation = { - "console_screenshot_blob_uri": {"readonly": True}, - "serial_console_log_blob_uri": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "console_screenshot_blob_uri": {"key": "consoleScreenshotBlobUri", "type": "str"}, - "serial_console_log_blob_uri": {"key": "serialConsoleLogBlobUri", "type": "str"}, - "status": {"key": "status", "type": "InstanceViewStatus"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.console_screenshot_blob_uri: Optional[str] = None - self.serial_console_log_blob_uri: Optional[str] = None - self.status: Optional["_models.InstanceViewStatus"] = 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.v2020_06_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: Optional[List["_models.ComputeOperationValue"]] = None - - -class ComputeOperationValue(_serialization.Model): - """Describes the properties of a Compute Operation value. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar origin: The origin of the compute operation. - :vartype origin: str - :ivar name: The name of the compute operation. - :vartype name: str - :ivar operation: The display name of the compute operation. - :vartype operation: str - :ivar resource: The display name of the resource the operation applies to. - :vartype resource: str - :ivar description: The description of the operation. - :vartype description: str - :ivar provider: The resource provider for the operation. - :vartype provider: str - """ - - _validation = { - "origin": {"readonly": True}, - "name": {"readonly": True}, - "operation": {"readonly": True}, - "resource": {"readonly": True}, - "description": {"readonly": True}, - "provider": {"readonly": True}, - } - - _attribute_map = { - "origin": {"key": "origin", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "operation": {"key": "display.operation", "type": "str"}, - "resource": {"key": "display.resource", "type": "str"}, - "description": {"key": "display.description", "type": "str"}, - "provider": {"key": "display.provider", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.origin: Optional[str] = None - self.name: Optional[str] = None - self.operation: Optional[str] = None - self.resource: Optional[str] = None - self.description: Optional[str] = None - self.provider: Optional[str] = None - - -class DataDisk(_serialization.Model): - """Describes a data disk. - - 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 lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - :ivar name: The disk name. - :vartype name: str - :ivar vhd: The virtual hard disk. - :vartype vhd: ~azure.mgmt.compute.v2020_06_01.models.VirtualHardDisk - :ivar image: 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. - :vartype image: ~azure.mgmt.compute.v2020_06_01.models.VirtualHardDisk - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2020_06_01.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: ~azure.mgmt.compute.v2020_06_01.models.ManagedDiskParameters - :ivar to_be_detached: Specifies whether the data disk is in process of detachment from the - VirtualMachine/VirtualMachineScaleset. - :vartype to_be_detached: bool - :ivar disk_iops_read_write: Specifies the Read-Write IOPS for the managed disk when - StorageAccountType is UltraSSD_LRS. Returned only for VirtualMachine ScaleSet VM disks. Can be - updated only via updates to the VirtualMachine Scale Set. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: Specifies the bandwidth in MB per second for the managed disk when - StorageAccountType is UltraSSD_LRS. Returned only for VirtualMachine ScaleSet VM disks. Can be - updated only via updates to the VirtualMachine Scale Set. - :vartype disk_m_bps_read_write: int - """ - - _validation = { - "lun": {"required": True}, - "create_option": {"required": True}, - "disk_iops_read_write": {"readonly": True}, - "disk_m_bps_read_write": {"readonly": True}, - } - - _attribute_map = { - "lun": {"key": "lun", "type": "int"}, - "name": {"key": "name", "type": "str"}, - "vhd": {"key": "vhd", "type": "VirtualHardDisk"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, - "to_be_detached": {"key": "toBeDetached", "type": "bool"}, - "disk_iops_read_write": {"key": "diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "diskMBpsReadWrite", "type": "int"}, - } - - def __init__( - self, - *, - lun: int, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - vhd: Optional["_models.VirtualHardDisk"] = None, - image: Optional["_models.VirtualHardDisk"] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.ManagedDiskParameters"] = None, - to_be_detached: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - :keyword name: The disk name. - :paramtype name: str - :keyword vhd: The virtual hard disk. - :paramtype vhd: ~azure.mgmt.compute.v2020_06_01.models.VirtualHardDisk - :keyword image: 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. - :paramtype image: ~azure.mgmt.compute.v2020_06_01.models.VirtualHardDisk - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2020_06_01.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: ~azure.mgmt.compute.v2020_06_01.models.ManagedDiskParameters - :keyword to_be_detached: Specifies whether the data disk is in process of detachment from the - VirtualMachine/VirtualMachineScaleset. - :paramtype to_be_detached: bool - """ - super().__init__(**kwargs) - self.lun = lun - self.name = name - self.vhd = vhd - self.image = image - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - self.to_be_detached = to_be_detached - self.disk_iops_read_write: Optional[int] = None - self.disk_m_bps_read_write: Optional[int] = None - - -class DataDiskImage(_serialization.Model): - """Contains the data disk images information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - :vartype lun: int - """ - - _validation = { - "lun": {"readonly": True}, - } - - _attribute_map = { - "lun": {"key": "lun", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.lun: Optional[int] = None - - -class DedicatedHost(Resource): - """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. - :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] - :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.v2020_06_01.models.Sku - :ivar platform_fault_domain: Fault domain of the dedicated host within a dedicated host group. - :vartype platform_fault_domain: int - :ivar auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :vartype auto_replace_on_failure: bool - :ivar host_id: A unique id generated and assigned to the dedicated host by the platform. - :code:`
    `\\ :code:`
    ` Does not change throughout the lifetime of the host. - :vartype host_id: str - :ivar virtual_machines: A list of references to all virtual machines in the Dedicated Host. - :vartype virtual_machines: list[~azure.mgmt.compute.v2020_06_01.models.SubResourceReadOnly] - :ivar license_type: Specifies the software license type that will be applied to the VMs - deployed on the dedicated host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ - :code:`
    ` **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. Known - values are: "None", "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :vartype license_type: str or ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostLicenseTypes - :ivar provisioning_time: The date when the host was first provisioned. - :vartype provisioning_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The dedicated host instance view. - :vartype instance_view: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostInstanceView - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"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}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "Sku"}, - "platform_fault_domain": {"key": "properties.platformFaultDomain", "type": "int"}, - "auto_replace_on_failure": {"key": "properties.autoReplaceOnFailure", "type": "bool"}, - "host_id": {"key": "properties.hostId", "type": "str"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResourceReadOnly]"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "provisioning_time": {"key": "properties.provisioningTime", "type": "iso-8601"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostInstanceView"}, - } - - def __init__( - self, - *, - location: str, - sku: "_models.Sku", - tags: Optional[Dict[str, str]] = None, - platform_fault_domain: Optional[int] = None, - auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2020_06_01.models.Sku - :keyword platform_fault_domain: Fault domain of the dedicated host within a dedicated host - group. - :paramtype platform_fault_domain: int - :keyword auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :paramtype auto_replace_on_failure: bool - :keyword license_type: Specifies the software license type that will be applied to the VMs - deployed on the dedicated host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ - :code:`
    ` **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. Known - values are: "None", "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :paramtype license_type: str or - ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostLicenseTypes - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.platform_fault_domain = platform_fault_domain - self.auto_replace_on_failure = auto_replace_on_failure - self.host_id: Optional[str] = None - self.virtual_machines: Optional[List["_models.SubResourceReadOnly"]] = None - self.license_type = license_type - self.provisioning_time: Optional[datetime.datetime] = None - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.DedicatedHostInstanceView"] = None - - -class DedicatedHostAllocatableVM(_serialization.Model): - """Represents the dedicated host unutilized capacity in terms of a specific VM size. - - :ivar vm_size: VM size in terms of which the unutilized capacity is represented. - :vartype vm_size: str - :ivar count: Maximum number of VMs of size vmSize that can fit in the dedicated host's - remaining capacity. - :vartype count: float - """ - - _attribute_map = { - "vm_size": {"key": "vmSize", "type": "str"}, - "count": {"key": "count", "type": "float"}, - } - - def __init__(self, *, vm_size: Optional[str] = None, count: Optional[float] = None, **kwargs: Any) -> None: - """ - :keyword vm_size: VM size in terms of which the unutilized capacity is represented. - :paramtype vm_size: str - :keyword count: Maximum number of VMs of size vmSize that can fit in the dedicated host's - remaining capacity. - :paramtype count: float - """ - super().__init__(**kwargs) - self.vm_size = vm_size - self.count = count - - -class DedicatedHostAvailableCapacity(_serialization.Model): - """Dedicated host unutilized capacity. - - :ivar allocatable_v_ms: The unutilized capacity of the dedicated host represented in terms of - each VM size that is allowed to be deployed to the dedicated host. - :vartype allocatable_v_ms: - list[~azure.mgmt.compute.v2020_06_01.models.DedicatedHostAllocatableVM] - """ - - _attribute_map = { - "allocatable_v_ms": {"key": "allocatableVMs", "type": "[DedicatedHostAllocatableVM]"}, - } - - def __init__( - self, *, allocatable_v_ms: Optional[List["_models.DedicatedHostAllocatableVM"]] = None, **kwargs: Any - ) -> None: - """ - :keyword allocatable_v_ms: The unutilized capacity of the dedicated host represented in terms - of each VM size that is allowed to be deployed to the dedicated host. - :paramtype allocatable_v_ms: - list[~azure.mgmt.compute.v2020_06_01.models.DedicatedHostAllocatableVM] - """ - super().__init__(**kwargs) - self.allocatable_v_ms = allocatable_v_ms - - -class DedicatedHostGroup(Resource): - """Specifies information about the dedicated host group that the dedicated hosts should be - assigned to. :code:`
    `\\ :code:`
    ` 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. - - 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] - :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. - :vartype zones: list[str] - :ivar platform_fault_domain_count: Number of fault domains that the host group can span. - :vartype platform_fault_domain_count: int - :ivar hosts: A list of references to all dedicated hosts in the dedicated host group. - :vartype hosts: list[~azure.mgmt.compute.v2020_06_01.models.SubResourceReadOnly] - :ivar instance_view: The dedicated host group instance view, which has the list of instance - view of the dedicated hosts under the dedicated host group. - :vartype instance_view: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroupInstanceView - :ivar support_automatic_placement: Specifies whether virtual machines or virtual machine scale - sets can be placed automatically on the dedicated host group. Automatic placement means - resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host - group. The value is defaulted to 'false' when not provided. :code:`
    `\\ :code:`
    `Minimum - api-version: 2020-06-01. - :vartype support_automatic_placement: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "platform_fault_domain_count": {"minimum": 1}, - "hosts": {"readonly": True}, - "instance_view": {"readonly": 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}"}, - "zones": {"key": "zones", "type": "[str]"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "hosts": {"key": "properties.hosts", "type": "[SubResourceReadOnly]"}, - "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostGroupInstanceView"}, - "support_automatic_placement": {"key": "properties.supportAutomaticPlacement", "type": "bool"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - zones: Optional[List[str]] = None, - platform_fault_domain_count: Optional[int] = None, - support_automatic_placement: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword zones: Availability Zone to use for this host group. Only single zone is supported. - The zone can be assigned only during creation. If not provided, the group supports all zones in - the region. If provided, enforces each host in the group to be in the same zone. - :paramtype zones: list[str] - :keyword platform_fault_domain_count: Number of fault domains that the host group can span. - :paramtype platform_fault_domain_count: int - :keyword support_automatic_placement: Specifies whether virtual machines or virtual machine - scale sets can be placed automatically on the dedicated host group. Automatic placement means - resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host - group. The value is defaulted to 'false' when not provided. :code:`
    `\\ :code:`
    `Minimum - api-version: 2020-06-01. - :paramtype support_automatic_placement: bool - """ - super().__init__(location=location, tags=tags, **kwargs) - self.zones = zones - self.platform_fault_domain_count = platform_fault_domain_count - self.hosts: Optional[List["_models.SubResourceReadOnly"]] = None - self.instance_view: Optional["_models.DedicatedHostGroupInstanceView"] = None - self.support_automatic_placement = support_automatic_placement - - -class DedicatedHostGroupInstanceView(_serialization.Model): - """DedicatedHostGroupInstanceView. - - :ivar hosts: List of instance view of the dedicated hosts under the dedicated host group. - :vartype hosts: list[~azure.mgmt.compute.v2020_06_01.models.DedicatedHostInstanceViewWithName] - """ - - _attribute_map = { - "hosts": {"key": "hosts", "type": "[DedicatedHostInstanceViewWithName]"}, - } - - def __init__( - self, *, hosts: Optional[List["_models.DedicatedHostInstanceViewWithName"]] = None, **kwargs: Any - ) -> None: - """ - :keyword hosts: List of instance view of the dedicated hosts under the dedicated host group. - :paramtype hosts: - list[~azure.mgmt.compute.v2020_06_01.models.DedicatedHostInstanceViewWithName] - """ - super().__init__(**kwargs) - self.hosts = hosts - - -class DedicatedHostGroupListResult(_serialization.Model): - """The List Dedicated Host Group with resource group response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of dedicated host groups. Required. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroup] - :ivar next_link: The URI to fetch the next page of Dedicated Host Groups. Call ListNext() with - this URI to fetch the next page of Dedicated Host Groups. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DedicatedHostGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DedicatedHostGroup"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of dedicated host groups. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroup] - :keyword next_link: The URI to fetch the next page of Dedicated Host Groups. Call ListNext() - with this URI to fetch the next page of Dedicated Host Groups. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DedicatedHostGroupUpdate(UpdateResource): - """Specifies information about the dedicated host group that the dedicated host should be assigned - to. Only tags may be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar zones: Availability Zone to use for this host group. Only single zone is supported. The - zone can be assigned only during creation. If not provided, the group supports all zones in the - region. If provided, enforces each host in the group to be in the same zone. - :vartype zones: list[str] - :ivar platform_fault_domain_count: Number of fault domains that the host group can span. - :vartype platform_fault_domain_count: int - :ivar hosts: A list of references to all dedicated hosts in the dedicated host group. - :vartype hosts: list[~azure.mgmt.compute.v2020_06_01.models.SubResourceReadOnly] - :ivar instance_view: The dedicated host group instance view, which has the list of instance - view of the dedicated hosts under the dedicated host group. - :vartype instance_view: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroupInstanceView - :ivar support_automatic_placement: Specifies whether virtual machines or virtual machine scale - sets can be placed automatically on the dedicated host group. Automatic placement means - resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host - group. The value is defaulted to 'false' when not provided. :code:`
    `\\ :code:`
    `Minimum - api-version: 2020-06-01. - :vartype support_automatic_placement: bool - """ - - _validation = { - "platform_fault_domain_count": {"minimum": 1}, - "hosts": {"readonly": True}, - "instance_view": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "zones": {"key": "zones", "type": "[str]"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "hosts": {"key": "properties.hosts", "type": "[SubResourceReadOnly]"}, - "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostGroupInstanceView"}, - "support_automatic_placement": {"key": "properties.supportAutomaticPlacement", "type": "bool"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - zones: Optional[List[str]] = None, - platform_fault_domain_count: Optional[int] = None, - support_automatic_placement: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword zones: Availability Zone to use for this host group. Only single zone is supported. - The zone can be assigned only during creation. If not provided, the group supports all zones in - the region. If provided, enforces each host in the group to be in the same zone. - :paramtype zones: list[str] - :keyword platform_fault_domain_count: Number of fault domains that the host group can span. - :paramtype platform_fault_domain_count: int - :keyword support_automatic_placement: Specifies whether virtual machines or virtual machine - scale sets can be placed automatically on the dedicated host group. Automatic placement means - resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host - group. The value is defaulted to 'false' when not provided. :code:`
    `\\ :code:`
    `Minimum - api-version: 2020-06-01. - :paramtype support_automatic_placement: bool - """ - super().__init__(tags=tags, **kwargs) - self.zones = zones - self.platform_fault_domain_count = platform_fault_domain_count - self.hosts: Optional[List["_models.SubResourceReadOnly"]] = None - self.instance_view: Optional["_models.DedicatedHostGroupInstanceView"] = None - self.support_automatic_placement = support_automatic_placement - - -class DedicatedHostInstanceView(_serialization.Model): - """The instance view of a dedicated host. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar asset_id: Specifies the unique id of the dedicated physical machine on which the - dedicated host resides. - :vartype asset_id: str - :ivar available_capacity: Unutilized capacity of the dedicated host. - :vartype available_capacity: - ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostAvailableCapacity - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - """ - - _validation = { - "asset_id": {"readonly": True}, - } - - _attribute_map = { - "asset_id": {"key": "assetId", "type": "str"}, - "available_capacity": {"key": "availableCapacity", "type": "DedicatedHostAvailableCapacity"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword available_capacity: Unutilized capacity of the dedicated host. - :paramtype available_capacity: - ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostAvailableCapacity - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.asset_id: Optional[str] = None - self.available_capacity = available_capacity - self.statuses = statuses - - -class DedicatedHostInstanceViewWithName(DedicatedHostInstanceView): - """The instance view of a dedicated host that includes the name of the dedicated host. It is used - for the response to the instance view of a dedicated host group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar asset_id: Specifies the unique id of the dedicated physical machine on which the - dedicated host resides. - :vartype asset_id: str - :ivar available_capacity: Unutilized capacity of the dedicated host. - :vartype available_capacity: - ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostAvailableCapacity - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - :ivar name: The name of the dedicated host. - :vartype name: str - """ - - _validation = { - "asset_id": {"readonly": True}, - "name": {"readonly": True}, - } - - _attribute_map = { - "asset_id": {"key": "assetId", "type": "str"}, - "available_capacity": {"key": "availableCapacity", "type": "DedicatedHostAvailableCapacity"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword available_capacity: Unutilized capacity of the dedicated host. - :paramtype available_capacity: - ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostAvailableCapacity - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - """ - super().__init__(available_capacity=available_capacity, statuses=statuses, **kwargs) - self.name: Optional[str] = None - - -class DedicatedHostListResult(_serialization.Model): - """The list dedicated host operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of dedicated hosts. Required. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.DedicatedHost] - :ivar next_link: The URI to fetch the next page of dedicated hosts. Call ListNext() with this - URI to fetch the next page of dedicated hosts. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DedicatedHost]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.DedicatedHost"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of dedicated hosts. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_06_01.models.DedicatedHost] - :keyword next_link: The URI to fetch the next page of dedicated hosts. Call ListNext() with - this URI to fetch the next page of dedicated hosts. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DedicatedHostUpdate(UpdateResource): - """Specifies information about the dedicated host. Only tags, autoReplaceOnFailure and licenseType - may be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar platform_fault_domain: Fault domain of the dedicated host within a dedicated host group. - :vartype platform_fault_domain: int - :ivar auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :vartype auto_replace_on_failure: bool - :ivar host_id: A unique id generated and assigned to the dedicated host by the platform. - :code:`
    `\\ :code:`
    ` Does not change throughout the lifetime of the host. - :vartype host_id: str - :ivar virtual_machines: A list of references to all virtual machines in the Dedicated Host. - :vartype virtual_machines: list[~azure.mgmt.compute.v2020_06_01.models.SubResourceReadOnly] - :ivar license_type: Specifies the software license type that will be applied to the VMs - deployed on the dedicated host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ - :code:`
    ` **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. Known - values are: "None", "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :vartype license_type: str or ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostLicenseTypes - :ivar provisioning_time: The date when the host was first provisioned. - :vartype provisioning_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The dedicated host instance view. - :vartype instance_view: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostInstanceView - """ - - _validation = { - "platform_fault_domain": {"minimum": 0}, - "host_id": {"readonly": True}, - "virtual_machines": {"readonly": True}, - "provisioning_time": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "platform_fault_domain": {"key": "properties.platformFaultDomain", "type": "int"}, - "auto_replace_on_failure": {"key": "properties.autoReplaceOnFailure", "type": "bool"}, - "host_id": {"key": "properties.hostId", "type": "str"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResourceReadOnly]"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "provisioning_time": {"key": "properties.provisioningTime", "type": "iso-8601"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostInstanceView"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - platform_fault_domain: Optional[int] = None, - auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword platform_fault_domain: Fault domain of the dedicated host within a dedicated host - group. - :paramtype platform_fault_domain: int - :keyword auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :paramtype auto_replace_on_failure: bool - :keyword license_type: Specifies the software license type that will be applied to the VMs - deployed on the dedicated host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ - :code:`
    ` **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. Known - values are: "None", "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :paramtype license_type: str or - ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostLicenseTypes - """ - super().__init__(tags=tags, **kwargs) - self.platform_fault_domain = platform_fault_domain - self.auto_replace_on_failure = auto_replace_on_failure - self.host_id: Optional[str] = None - self.virtual_machines: Optional[List["_models.SubResourceReadOnly"]] = None - self.license_type = license_type - self.provisioning_time: Optional[datetime.datetime] = None - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.DedicatedHostInstanceView"] = None - - -class DiagnosticsProfile(_serialization.Model): - """Specifies the boot diagnostic settings state. :code:`
    `\\ :code:`
    `Minimum api-version: - 2015-06-15. - - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2020_06_01.models.BootDiagnostics - """ - - _attribute_map = { - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnostics"}, - } - - def __init__(self, *, boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs: Any) -> None: - """ - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2020_06_01.models.BootDiagnostics - """ - super().__init__(**kwargs) - self.boot_diagnostics = boot_diagnostics - - -class DiffDiskSettings(_serialization.Model): - """Describes the parameters of ephemeral disk settings that can be specified for operating system - disk. :code:`
    `\\ :code:`
    ` NOTE: The ephemeral disk settings can only be specified for - managed disk. - - :ivar option: Specifies the ephemeral disk settings for operating system disk. "Local" - :vartype option: str or ~azure.mgmt.compute.v2020_06_01.models.DiffDiskOptions - :ivar placement: Specifies the ephemeral disk placement for operating system disk.\\ - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **CacheDisk** - :code:`
    `\\ :code:`
    ` **ResourceDisk** :code:`
    `\\ :code:`
    ` Default: **CacheDisk** - if one is configured for the VM size otherwise **ResourceDisk** is used.\\ :code:`
    `\\ - :code:`
    ` Refer to VM size documentation for Windows VM at - https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sizes and Linux VM at - https://docs.microsoft.com/en-us/azure/virtual-machines/linux/sizes to check which VM sizes - exposes a cache disk. Known values are: "CacheDisk" and "ResourceDisk". - :vartype placement: str or ~azure.mgmt.compute.v2020_06_01.models.DiffDiskPlacement - """ - - _attribute_map = { - "option": {"key": "option", "type": "str"}, - "placement": {"key": "placement", "type": "str"}, - } - - def __init__( - self, - *, - option: Optional[Union[str, "_models.DiffDiskOptions"]] = None, - placement: Optional[Union[str, "_models.DiffDiskPlacement"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword option: Specifies the ephemeral disk settings for operating system disk. "Local" - :paramtype option: str or ~azure.mgmt.compute.v2020_06_01.models.DiffDiskOptions - :keyword placement: Specifies the ephemeral disk placement for operating system disk.\\ - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **CacheDisk** - :code:`
    `\\ :code:`
    ` **ResourceDisk** :code:`
    `\\ :code:`
    ` Default: **CacheDisk** - if one is configured for the VM size otherwise **ResourceDisk** is used.\\ :code:`
    `\\ - :code:`
    ` Refer to VM size documentation for Windows VM at - https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sizes and Linux VM at - https://docs.microsoft.com/en-us/azure/virtual-machines/linux/sizes to check which VM sizes - exposes a cache disk. Known values are: "CacheDisk" and "ResourceDisk". - :paramtype placement: str or ~azure.mgmt.compute.v2020_06_01.models.DiffDiskPlacement - """ - super().__init__(**kwargs) - self.option = option - self.placement = placement - - -class DisallowedConfiguration(_serialization.Model): - """Specifies the disallowed configuration for a virtual machine image. - - :ivar vm_disk_type: VM disk types which are disallowed. Known values are: "None" and - "Unmanaged". - :vartype vm_disk_type: str or ~azure.mgmt.compute.v2020_06_01.models.VmDiskTypes - """ - - _attribute_map = { - "vm_disk_type": {"key": "vmDiskType", "type": "str"}, - } - - def __init__(self, *, vm_disk_type: Optional[Union[str, "_models.VmDiskTypes"]] = None, **kwargs: Any) -> None: - """ - :keyword vm_disk_type: VM disk types which are disallowed. Known values are: "None" and - "Unmanaged". - :paramtype vm_disk_type: str or ~azure.mgmt.compute.v2020_06_01.models.VmDiskTypes - """ - super().__init__(**kwargs) - self.vm_disk_type = vm_disk_type - - -class SubResource(_serialization.Model): - """SubResource. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class DiskEncryptionSetParameters(SubResource): - """Describes the parameter of customer managed disk encryption set resource id that can be - specified for disk. :code:`
    `\\ :code:`
    ` NOTE: The disk encryption set resource id can - only be specified for managed disk. Please refer https://aka.ms/mdssewithcmkoverview for more - details. - - :ivar id: Resource Id. - :vartype id: str - """ - - -class DiskEncryptionSettings(_serialization.Model): - """Describes a Encryption Settings for a Disk. - - :ivar disk_encryption_key: Specifies the location of the disk encryption key, which is a Key - Vault Secret. - :vartype disk_encryption_key: ~azure.mgmt.compute.v2020_06_01.models.KeyVaultSecretReference - :ivar key_encryption_key: Specifies the location of the key encryption key in Key Vault. - :vartype key_encryption_key: ~azure.mgmt.compute.v2020_06_01.models.KeyVaultKeyReference - :ivar enabled: Specifies whether disk encryption should be enabled on the virtual machine. - :vartype enabled: bool - """ - - _attribute_map = { - "disk_encryption_key": {"key": "diskEncryptionKey", "type": "KeyVaultSecretReference"}, - "key_encryption_key": {"key": "keyEncryptionKey", "type": "KeyVaultKeyReference"}, - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__( - self, - *, - disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, - key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, - enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_key: Specifies the location of the disk encryption key, which is a Key - Vault Secret. - :paramtype disk_encryption_key: ~azure.mgmt.compute.v2020_06_01.models.KeyVaultSecretReference - :keyword key_encryption_key: Specifies the location of the key encryption key in Key Vault. - :paramtype key_encryption_key: ~azure.mgmt.compute.v2020_06_01.models.KeyVaultKeyReference - :keyword enabled: Specifies whether disk encryption should be enabled on the virtual machine. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.disk_encryption_key = disk_encryption_key - self.key_encryption_key = key_encryption_key - self.enabled = enabled - - -class DiskInstanceView(_serialization.Model): - """The instance view of the disk. - - :ivar name: The disk name. - :vartype name: str - :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :vartype encryption_settings: - list[~azure.mgmt.compute.v2020_06_01.models.DiskEncryptionSettings] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "encryption_settings": {"key": "encryptionSettings", "type": "[DiskEncryptionSettings]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype encryption_settings: - list[~azure.mgmt.compute.v2020_06_01.models.DiskEncryptionSettings] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.name = name - self.encryption_settings = encryption_settings - self.statuses = statuses - - -class HardwareProfile(_serialization.Model): - """Specifies the hardware settings for the virtual machine. - - :ivar vm_size: Specifies the size of the virtual machine. For more information about virtual - machine sizes, see `Sizes for virtual machines - `_. :code:`
    `\\ :code:`
    ` - The available VM sizes depend on region and availability set. For a list of available sizes use - these APIs: :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in an - availability set - `_ - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in a region - `_ :code:`
    `\\ - :code:`
    ` `List all available virtual machine sizes for resizing - `_. - :code:`
    `\\ :code:`
    ` This list of sizes is no longer updated and the - **VirtualMachineSizeTypes** string constants will be removed from the subsequent REST API - specification. Use `List all available virtual machine sizes in a region - `_ to get the latest - sizes. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", - "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", - "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", - "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", - "Standard_A4m_v2", "Standard_A8m_v2", "Standard_B1s", "Standard_B1ms", "Standard_B2s", - "Standard_B2ms", "Standard_B4ms", "Standard_B8ms", "Standard_D1", "Standard_D2", "Standard_D3", - "Standard_D4", "Standard_D11", "Standard_D12", "Standard_D13", "Standard_D14", - "Standard_D1_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", "Standard_D5_v2", - "Standard_D2_v3", "Standard_D4_v3", "Standard_D8_v3", "Standard_D16_v3", "Standard_D32_v3", - "Standard_D64_v3", "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", "Standard_D16s_v3", - "Standard_D32s_v3", "Standard_D64s_v3", "Standard_D11_v2", "Standard_D12_v2", - "Standard_D13_v2", "Standard_D14_v2", "Standard_D15_v2", "Standard_DS1", "Standard_DS2", - "Standard_DS3", "Standard_DS4", "Standard_DS11", "Standard_DS12", "Standard_DS13", - "Standard_DS14", "Standard_DS1_v2", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", - "Standard_DS5_v2", "Standard_DS11_v2", "Standard_DS12_v2", "Standard_DS13_v2", - "Standard_DS14_v2", "Standard_DS15_v2", "Standard_DS13-4_v2", "Standard_DS13-2_v2", - "Standard_DS14-8_v2", "Standard_DS14-4_v2", "Standard_E2_v3", "Standard_E4_v3", - "Standard_E8_v3", "Standard_E16_v3", "Standard_E32_v3", "Standard_E64_v3", "Standard_E2s_v3", - "Standard_E4s_v3", "Standard_E8s_v3", "Standard_E16s_v3", "Standard_E32s_v3", - "Standard_E64s_v3", "Standard_E32-16_v3", "Standard_E32-8s_v3", "Standard_E64-32s_v3", - "Standard_E64-16s_v3", "Standard_F1", "Standard_F2", "Standard_F4", "Standard_F8", - "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", - "Standard_F16s", "Standard_F2s_v2", "Standard_F4s_v2", "Standard_F8s_v2", "Standard_F16s_v2", - "Standard_F32s_v2", "Standard_F64s_v2", "Standard_F72s_v2", "Standard_G1", "Standard_G2", - "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", "Standard_GS3", - "Standard_GS4", "Standard_GS5", "Standard_GS4-8", "Standard_GS4-4", "Standard_GS5-16", - "Standard_GS5-8", "Standard_H8", "Standard_H16", "Standard_H8m", "Standard_H16m", - "Standard_H16r", "Standard_H16mr", "Standard_L4s", "Standard_L8s", "Standard_L16s", - "Standard_L32s", "Standard_M64s", "Standard_M64ms", "Standard_M128s", "Standard_M128ms", - "Standard_M64-32ms", "Standard_M64-16ms", "Standard_M128-64ms", "Standard_M128-32ms", - "Standard_NC6", "Standard_NC12", "Standard_NC24", "Standard_NC24r", "Standard_NC6s_v2", - "Standard_NC12s_v2", "Standard_NC24s_v2", "Standard_NC24rs_v2", "Standard_NC6s_v3", - "Standard_NC12s_v3", "Standard_NC24s_v3", "Standard_NC24rs_v3", "Standard_ND6s", - "Standard_ND12s", "Standard_ND24s", "Standard_ND24rs", "Standard_NV6", "Standard_NV12", and - "Standard_NV24". - :vartype vm_size: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineSizeTypes - """ - - _attribute_map = { - "vm_size": {"key": "vmSize", "type": "str"}, - } - - def __init__( - self, *, vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs: Any - ) -> None: - """ - :keyword vm_size: Specifies the size of the virtual machine. For more information about virtual - machine sizes, see `Sizes for virtual machines - `_. :code:`
    `\\ :code:`
    ` - The available VM sizes depend on region and availability set. For a list of available sizes use - these APIs: :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in an - availability set - `_ - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in a region - `_ :code:`
    `\\ - :code:`
    ` `List all available virtual machine sizes for resizing - `_. - :code:`
    `\\ :code:`
    ` This list of sizes is no longer updated and the - **VirtualMachineSizeTypes** string constants will be removed from the subsequent REST API - specification. Use `List all available virtual machine sizes in a region - `_ to get the latest - sizes. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", - "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", - "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", - "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", - "Standard_A4m_v2", "Standard_A8m_v2", "Standard_B1s", "Standard_B1ms", "Standard_B2s", - "Standard_B2ms", "Standard_B4ms", "Standard_B8ms", "Standard_D1", "Standard_D2", "Standard_D3", - "Standard_D4", "Standard_D11", "Standard_D12", "Standard_D13", "Standard_D14", - "Standard_D1_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", "Standard_D5_v2", - "Standard_D2_v3", "Standard_D4_v3", "Standard_D8_v3", "Standard_D16_v3", "Standard_D32_v3", - "Standard_D64_v3", "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", "Standard_D16s_v3", - "Standard_D32s_v3", "Standard_D64s_v3", "Standard_D11_v2", "Standard_D12_v2", - "Standard_D13_v2", "Standard_D14_v2", "Standard_D15_v2", "Standard_DS1", "Standard_DS2", - "Standard_DS3", "Standard_DS4", "Standard_DS11", "Standard_DS12", "Standard_DS13", - "Standard_DS14", "Standard_DS1_v2", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", - "Standard_DS5_v2", "Standard_DS11_v2", "Standard_DS12_v2", "Standard_DS13_v2", - "Standard_DS14_v2", "Standard_DS15_v2", "Standard_DS13-4_v2", "Standard_DS13-2_v2", - "Standard_DS14-8_v2", "Standard_DS14-4_v2", "Standard_E2_v3", "Standard_E4_v3", - "Standard_E8_v3", "Standard_E16_v3", "Standard_E32_v3", "Standard_E64_v3", "Standard_E2s_v3", - "Standard_E4s_v3", "Standard_E8s_v3", "Standard_E16s_v3", "Standard_E32s_v3", - "Standard_E64s_v3", "Standard_E32-16_v3", "Standard_E32-8s_v3", "Standard_E64-32s_v3", - "Standard_E64-16s_v3", "Standard_F1", "Standard_F2", "Standard_F4", "Standard_F8", - "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", - "Standard_F16s", "Standard_F2s_v2", "Standard_F4s_v2", "Standard_F8s_v2", "Standard_F16s_v2", - "Standard_F32s_v2", "Standard_F64s_v2", "Standard_F72s_v2", "Standard_G1", "Standard_G2", - "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", "Standard_GS3", - "Standard_GS4", "Standard_GS5", "Standard_GS4-8", "Standard_GS4-4", "Standard_GS5-16", - "Standard_GS5-8", "Standard_H8", "Standard_H16", "Standard_H8m", "Standard_H16m", - "Standard_H16r", "Standard_H16mr", "Standard_L4s", "Standard_L8s", "Standard_L16s", - "Standard_L32s", "Standard_M64s", "Standard_M64ms", "Standard_M128s", "Standard_M128ms", - "Standard_M64-32ms", "Standard_M64-16ms", "Standard_M128-64ms", "Standard_M128-32ms", - "Standard_NC6", "Standard_NC12", "Standard_NC24", "Standard_NC24r", "Standard_NC6s_v2", - "Standard_NC12s_v2", "Standard_NC24s_v2", "Standard_NC24rs_v2", "Standard_NC6s_v3", - "Standard_NC12s_v3", "Standard_NC24s_v3", "Standard_NC24rs_v3", "Standard_ND6s", - "Standard_ND12s", "Standard_ND24s", "Standard_ND24rs", "Standard_NV6", "Standard_NV12", and - "Standard_NV24". - :paramtype vm_size: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineSizeTypes - """ - super().__init__(**kwargs) - self.vm_size = vm_size - - -class Image(Resource): - """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. - - 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] - :ivar source_virtual_machine: The source virtual machine from which Image is created. - :vartype source_virtual_machine: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2020_06_01.models.ImageStorageProfile - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str - :ivar hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from the - image. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or - ~azure.mgmt.compute.v2020_06_01.models.HyperVGenerationTypes - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "source_virtual_machine": {"key": "properties.sourceVirtualMachine", "type": "SubResource"}, - "storage_profile": {"key": "properties.storageProfile", "type": "ImageStorageProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["_models.SubResource"] = None, - storage_profile: Optional["_models.ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword source_virtual_machine: The source virtual machine from which Image is created. - :paramtype source_virtual_machine: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2020_06_01.models.ImageStorageProfile - :keyword hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from - the image. Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2020_06_01.models.HyperVGenerationTypes - """ - super().__init__(location=location, tags=tags, **kwargs) - self.source_virtual_machine = source_virtual_machine - self.storage_profile = storage_profile - self.provisioning_state: Optional[str] = None - self.hyper_v_generation = hyper_v_generation - - -class ImageDisk(_serialization.Model): - """Describes a image disk. - - :ivar snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed image disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2020_06_01.models.DiskEncryptionSetParameters - """ - - _attribute_map = { - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - } - - def __init__( - self, - *, - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed image disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2020_06_01.models.DiskEncryptionSetParameters - """ - super().__init__(**kwargs) - self.snapshot = snapshot - self.managed_disk = managed_disk - self.blob_uri = blob_uri - self.caching = caching - self.disk_size_gb = disk_size_gb - self.storage_account_type = storage_account_type - self.disk_encryption_set = disk_encryption_set - - -class ImageDataDisk(ImageDisk): - """Describes a data disk. - - All required parameters must be populated in order to send to server. - - :ivar snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed image disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2020_06_01.models.DiskEncryptionSetParameters - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - """ - - _validation = { - "lun": {"required": True}, - } - - _attribute_map = { - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__( - self, - *, - lun: int, - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed image disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2020_06_01.models.DiskEncryptionSetParameters - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - """ - super().__init__( - snapshot=snapshot, - managed_disk=managed_disk, - blob_uri=blob_uri, - caching=caching, - disk_size_gb=disk_size_gb, - storage_account_type=storage_account_type, - disk_encryption_set=disk_encryption_set, - **kwargs - ) - self.lun = lun - - -class ImageListResult(_serialization.Model): - """The List Image operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of Images. Required. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.Image] - :ivar next_link: The uri to fetch the next page of Images. Call ListNext() with this to fetch - the next page of Images. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Image]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Image"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of Images. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_06_01.models.Image] - :keyword next_link: The uri to fetch the next page of Images. Call ListNext() with this to - fetch the next page of Images. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ImageOSDisk(ImageDisk): - """Describes an Operating System disk. - - All required parameters must be populated in order to send to server. - - :ivar snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed image disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2020_06_01.models.DiskEncryptionSetParameters - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from a custom image. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Required. Known - values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes - :ivar os_state: The OS State. Required. Known values are: "Generalized" and "Specialized". - :vartype os_state: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemStateTypes - """ - - _validation = { - "os_type": {"required": True}, - "os_state": {"required": True}, - } - - _attribute_map = { - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - "os_type": {"key": "osType", "type": "str"}, - "os_state": {"key": "osState", "type": "str"}, - } - - def __init__( - self, - *, - os_type: Union[str, "_models.OperatingSystemTypes"], - os_state: Union[str, "_models.OperatingSystemStateTypes"], - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed image disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2020_06_01.models.DiskEncryptionSetParameters - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from a custom image. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Required. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes - :keyword os_state: The OS State. Required. Known values are: "Generalized" and "Specialized". - :paramtype os_state: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemStateTypes - """ - super().__init__( - snapshot=snapshot, - managed_disk=managed_disk, - blob_uri=blob_uri, - caching=caching, - disk_size_gb=disk_size_gb, - storage_account_type=storage_account_type, - disk_encryption_set=disk_encryption_set, - **kwargs - ) - self.os_type = os_type - self.os_state = os_state - - -class ImageReference(SubResource): - """Specifies information about the image to use. You can specify information about platform - images, marketplace images, or virtual machine images. This element is required when you want - to use a platform image, marketplace image, or virtual machine image, but is not used in other - creation operations. NOTE: Image reference publisher and offer can only be set when you create - the scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar publisher: The image publisher. - :vartype publisher: str - :ivar offer: Specifies the offer of the platform image or marketplace image used to create the - virtual machine. - :vartype offer: str - :ivar sku: The image SKU. - :vartype sku: str - :ivar version: Specifies the version of the platform image or marketplace image used to create - the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and - Build are decimal numbers. Specify 'latest' to use the latest version of an image available at - deploy time. Even if you use 'latest', the VM image will not automatically update after deploy - time even if a new version becomes available. - :vartype version: str - :ivar exact_version: Specifies in decimal numbers, the version of platform image or marketplace - image used to create the virtual machine. This readonly field differs from 'version', only if - the value specified in 'version' field is 'latest'. - :vartype exact_version: str - """ - - _validation = { - "exact_version": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "offer": {"key": "offer", "type": "str"}, - "sku": {"key": "sku", "type": "str"}, - "version": {"key": "version", "type": "str"}, - "exact_version": {"key": "exactVersion", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - publisher: Optional[str] = None, - offer: Optional[str] = None, - sku: Optional[str] = None, - version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword publisher: The image publisher. - :paramtype publisher: str - :keyword offer: Specifies the offer of the platform image or marketplace image used to create - the virtual machine. - :paramtype offer: str - :keyword sku: The image SKU. - :paramtype sku: str - :keyword version: Specifies the version of the platform image or marketplace image used to - create the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, - Minor, and Build are decimal numbers. Specify 'latest' to use the latest version of an image - available at deploy time. Even if you use 'latest', the VM image will not automatically update - after deploy time even if a new version becomes available. - :paramtype version: str - """ - super().__init__(id=id, **kwargs) - self.publisher = publisher - self.offer = offer - self.sku = sku - self.version = version - self.exact_version: Optional[str] = None - - -class ImageStorageProfile(_serialization.Model): - """Describes a storage profile. - - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2020_06_01.models.ImageOSDisk - :ivar data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype data_disks: list[~azure.mgmt.compute.v2020_06_01.models.ImageDataDisk] - :ivar zone_resilient: Specifies whether an image is zone resilient or not. Default is false. - Zone resilient images can be created only in regions that provide Zone Redundant Storage (ZRS). - :vartype zone_resilient: bool - """ - - _attribute_map = { - "os_disk": {"key": "osDisk", "type": "ImageOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[ImageDataDisk]"}, - "zone_resilient": {"key": "zoneResilient", "type": "bool"}, - } - - def __init__( - self, - *, - os_disk: Optional["_models.ImageOSDisk"] = None, - data_disks: Optional[List["_models.ImageDataDisk"]] = None, - zone_resilient: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2020_06_01.models.ImageOSDisk - :keyword data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype data_disks: list[~azure.mgmt.compute.v2020_06_01.models.ImageDataDisk] - :keyword zone_resilient: Specifies whether an image is zone resilient or not. Default is false. - Zone resilient images can be created only in regions that provide Zone Redundant Storage (ZRS). - :paramtype zone_resilient: bool - """ - super().__init__(**kwargs) - self.os_disk = os_disk - self.data_disks = data_disks - self.zone_resilient = zone_resilient - - -class ImageUpdate(UpdateResource): - """The source user image virtual hard disk. Only tags may be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar source_virtual_machine: The source virtual machine from which Image is created. - :vartype source_virtual_machine: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2020_06_01.models.ImageStorageProfile - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str - :ivar hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from the - image. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or - ~azure.mgmt.compute.v2020_06_01.models.HyperVGenerationTypes - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "source_virtual_machine": {"key": "properties.sourceVirtualMachine", "type": "SubResource"}, - "storage_profile": {"key": "properties.storageProfile", "type": "ImageStorageProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["_models.SubResource"] = None, - storage_profile: Optional["_models.ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword source_virtual_machine: The source virtual machine from which Image is created. - :paramtype source_virtual_machine: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2020_06_01.models.ImageStorageProfile - :keyword hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from - the image. Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2020_06_01.models.HyperVGenerationTypes - """ - super().__init__(tags=tags, **kwargs) - self.source_virtual_machine = source_virtual_machine - self.storage_profile = storage_profile - self.provisioning_state: Optional[str] = None - self.hyper_v_generation = hyper_v_generation - - -class InnerError(_serialization.Model): - """Inner error details. - - :ivar exceptiontype: The exception type. - :vartype exceptiontype: str - :ivar errordetail: The internal error message or exception dump. - :vartype errordetail: str - """ - - _attribute_map = { - "exceptiontype": {"key": "exceptiontype", "type": "str"}, - "errordetail": {"key": "errordetail", "type": "str"}, - } - - def __init__( - self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword exceptiontype: The exception type. - :paramtype exceptiontype: str - :keyword errordetail: The internal error message or exception dump. - :paramtype errordetail: str - """ - super().__init__(**kwargs) - self.exceptiontype = exceptiontype - self.errordetail = errordetail - - -class InstanceViewStatus(_serialization.Model): - """Instance view status. - - :ivar code: The status code. - :vartype code: str - :ivar level: The level code. Known values are: "Info", "Warning", and "Error". - :vartype level: str or ~azure.mgmt.compute.v2020_06_01.models.StatusLevelTypes - :ivar display_status: The short localizable label for the status. - :vartype display_status: str - :ivar message: The detailed status message, including for alerts and error messages. - :vartype message: str - :ivar time: The time of the status. - :vartype time: ~datetime.datetime - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "level": {"key": "level", "type": "str"}, - "display_status": {"key": "displayStatus", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "time": {"key": "time", "type": "iso-8601"}, - } - - def __init__( - self, - *, - code: Optional[str] = None, - level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, - display_status: Optional[str] = None, - message: Optional[str] = None, - time: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword code: The status code. - :paramtype code: str - :keyword level: The level code. Known values are: "Info", "Warning", and "Error". - :paramtype level: str or ~azure.mgmt.compute.v2020_06_01.models.StatusLevelTypes - :keyword display_status: The short localizable label for the status. - :paramtype display_status: str - :keyword message: The detailed status message, including for alerts and error messages. - :paramtype message: str - :keyword time: The time of the status. - :paramtype time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.code = code - self.level = level - self.display_status = display_status - self.message = message - self.time = time - - -class KeyVaultKeyReference(_serialization.Model): - """Describes a reference to Key Vault Key. - - All required parameters must be populated in order to send to server. - - :ivar key_url: The URL referencing a key encryption key in Key Vault. Required. - :vartype key_url: str - :ivar source_vault: The relative URL of the Key Vault containing the key. Required. - :vartype source_vault: ~azure.mgmt.compute.v2020_06_01.models.SubResource - """ - - _validation = { - "key_url": {"required": True}, - "source_vault": {"required": True}, - } - - _attribute_map = { - "key_url": {"key": "keyUrl", "type": "str"}, - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - } - - def __init__(self, *, key_url: str, source_vault: "_models.SubResource", **kwargs: Any) -> None: - """ - :keyword key_url: The URL referencing a key encryption key in Key Vault. Required. - :paramtype key_url: str - :keyword source_vault: The relative URL of the Key Vault containing the key. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2020_06_01.models.SubResource - """ - super().__init__(**kwargs) - self.key_url = key_url - self.source_vault = source_vault - - -class KeyVaultSecretReference(_serialization.Model): - """Describes a reference to Key Vault Secret. - - All required parameters must be populated in order to send to server. - - :ivar secret_url: The URL referencing a secret in a Key Vault. Required. - :vartype secret_url: str - :ivar source_vault: The relative URL of the Key Vault containing the secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2020_06_01.models.SubResource - """ - - _validation = { - "secret_url": {"required": True}, - "source_vault": {"required": True}, - } - - _attribute_map = { - "secret_url": {"key": "secretUrl", "type": "str"}, - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - } - - def __init__(self, *, secret_url: str, source_vault: "_models.SubResource", **kwargs: Any) -> None: - """ - :keyword secret_url: The URL referencing a secret in a Key Vault. Required. - :paramtype secret_url: str - :keyword source_vault: The relative URL of the Key Vault containing the secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2020_06_01.models.SubResource - """ - super().__init__(**kwargs) - self.secret_url = secret_url - self.source_vault = source_vault - - -class LastPatchInstallationSummary(_serialization.Model): - """Describes the properties of the last installed patch summary. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The overall success or failure status of the operation. It remains "InProgress" - until the operation completes. At that point it will become "Failed", "Succeeded", or - "CompletedWithWarnings.". Known values are: "InProgress", "Failed", "Succeeded", and - "CompletedWithWarnings". - :vartype status: str or ~azure.mgmt.compute.v2020_06_01.models.PatchOperationStatus - :ivar installation_activity_id: The activity ID of the operation that produced this result. It - is used to correlate across CRP and extension logs. - :vartype installation_activity_id: str - :ivar maintenance_window_exceeded: Describes whether the operation ran out of time before it - completed all its intended actions. - :vartype maintenance_window_exceeded: bool - :ivar reboot_status: The reboot status of the machine after the patch operation. It will be in - "NotNeeded" status if reboot is not needed after the patch operation. "Required" will be the - status once the patch is applied and machine is required to reboot. "Started" will be the - reboot status when the machine has started to reboot. "Failed" will be the status if the - machine is failed to reboot. "Completed" will be the status once the machine is rebooted - successfully. Known values are: "NotNeeded", "Required", "Started", "Failed", and "Completed". - :vartype reboot_status: str or ~azure.mgmt.compute.v2020_06_01.models.RebootStatus - :ivar not_selected_patch_count: The number of all available patches but not going to be - installed because it didn't match a classification or inclusion list entry. - :vartype not_selected_patch_count: int - :ivar excluded_patch_count: The number of all available patches but excluded explicitly by a - customer-specified exclusion list match. - :vartype excluded_patch_count: int - :ivar pending_patch_count: The number of all available patches expected to be installed over - the course of the patch installation operation. - :vartype pending_patch_count: int - :ivar installed_patch_count: The count of patches that successfully installed. - :vartype installed_patch_count: int - :ivar failed_patch_count: The count of patches that failed installation. - :vartype failed_patch_count: int - :ivar start_time: The UTC timestamp when the operation began. - :vartype start_time: ~datetime.datetime - :ivar last_modified_time: The UTC timestamp when the operation began. - :vartype last_modified_time: ~datetime.datetime - :ivar started_by: The person or system account that started the operation. - :vartype started_by: str - :ivar error: The errors that were encountered during execution of the operation. The details - array contains the list of them. - :vartype error: ~azure.mgmt.compute.v2020_06_01.models.ApiError - """ - - _validation = { - "status": {"readonly": True}, - "installation_activity_id": {"readonly": True}, - "maintenance_window_exceeded": {"readonly": True}, - "reboot_status": {"readonly": True}, - "not_selected_patch_count": {"readonly": True}, - "excluded_patch_count": {"readonly": True}, - "pending_patch_count": {"readonly": True}, - "installed_patch_count": {"readonly": True}, - "failed_patch_count": {"readonly": True}, - "start_time": {"readonly": True}, - "last_modified_time": {"readonly": True}, - "started_by": {"readonly": True}, - "error": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "installation_activity_id": {"key": "installationActivityId", "type": "str"}, - "maintenance_window_exceeded": {"key": "maintenanceWindowExceeded", "type": "bool"}, - "reboot_status": {"key": "rebootStatus", "type": "str"}, - "not_selected_patch_count": {"key": "notSelectedPatchCount", "type": "int"}, - "excluded_patch_count": {"key": "excludedPatchCount", "type": "int"}, - "pending_patch_count": {"key": "pendingPatchCount", "type": "int"}, - "installed_patch_count": {"key": "installedPatchCount", "type": "int"}, - "failed_patch_count": {"key": "failedPatchCount", "type": "int"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "last_modified_time": {"key": "lastModifiedTime", "type": "iso-8601"}, - "started_by": {"key": "startedBy", "type": "str"}, - "error": {"key": "error", "type": "ApiError"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional[Union[str, "_models.PatchOperationStatus"]] = None - self.installation_activity_id: Optional[str] = None - self.maintenance_window_exceeded: Optional[bool] = None - self.reboot_status: Optional[Union[str, "_models.RebootStatus"]] = None - self.not_selected_patch_count: Optional[int] = None - self.excluded_patch_count: Optional[int] = None - self.pending_patch_count: Optional[int] = None - self.installed_patch_count: Optional[int] = None - self.failed_patch_count: Optional[int] = None - self.start_time: Optional[datetime.datetime] = None - self.last_modified_time: Optional[datetime.datetime] = None - self.started_by: Optional[str] = None - self.error: Optional["_models.ApiError"] = None - - -class LinuxConfiguration(_serialization.Model): - """Specifies the Linux operating system settings on the virtual machine. :code:`
    `\\ - :code:`
    `For a list of supported Linux distributions, see `Linux on Azure-Endorsed - Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - - :ivar disable_password_authentication: Specifies whether password authentication should be - disabled. - :vartype disable_password_authentication: bool - :ivar ssh: Specifies the ssh key configuration for a Linux OS. - :vartype ssh: ~azure.mgmt.compute.v2020_06_01.models.SshConfiguration - :ivar provision_vm_agent: Indicates whether virtual machine agent should be provisioned on the - virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the request - body, default behavior is to set it to true. This will ensure that VM Agent is installed on - the VM so that extensions can be added to the VM later. - :vartype provision_vm_agent: bool - """ - - _attribute_map = { - "disable_password_authentication": {"key": "disablePasswordAuthentication", "type": "bool"}, - "ssh": {"key": "ssh", "type": "SshConfiguration"}, - "provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"}, - } - - def __init__( - self, - *, - disable_password_authentication: Optional[bool] = None, - ssh: Optional["_models.SshConfiguration"] = None, - provision_vm_agent: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword disable_password_authentication: Specifies whether password authentication should be - disabled. - :paramtype disable_password_authentication: bool - :keyword ssh: Specifies the ssh key configuration for a Linux OS. - :paramtype ssh: ~azure.mgmt.compute.v2020_06_01.models.SshConfiguration - :keyword provision_vm_agent: Indicates whether virtual machine agent should be provisioned on - the virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the - request body, default behavior is to set it to true. This will ensure that VM Agent is - installed on the VM so that extensions can be added to the VM later. - :paramtype provision_vm_agent: bool - """ - super().__init__(**kwargs) - self.disable_password_authentication = disable_password_authentication - self.ssh = ssh - self.provision_vm_agent = provision_vm_agent - - -class ListUsagesResult(_serialization.Model): - """The List Usages operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of compute resource usages. Required. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.Usage] - :ivar next_link: The URI to fetch the next page of compute resource usage information. Call - ListNext() with this to fetch the next page of compute resource usage information. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Usage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of compute resource usages. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_06_01.models.Usage] - :keyword next_link: The URI to fetch the next page of compute resource usage information. Call - ListNext() with this to fetch the next page of compute resource usage information. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class LogAnalyticsInputBase(_serialization.Model): - """Api input base class for LogAnalytics Api. - - All required parameters must be populated in order to send to server. - - :ivar blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api - writes output logs to. Required. - :vartype blob_container_sas_uri: str - :ivar from_time: From time of the query. Required. - :vartype from_time: ~datetime.datetime - :ivar to_time: To time of the query. Required. - :vartype to_time: ~datetime.datetime - :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. - :vartype group_by_throttle_policy: bool - :ivar group_by_operation_name: Group query result by Operation Name. - :vartype group_by_operation_name: bool - :ivar group_by_resource_name: Group query result by Resource Name. - :vartype group_by_resource_name: bool - :ivar group_by_client_application_id: Group query result by Client Application ID. - :vartype group_by_client_application_id: bool - :ivar group_by_user_agent: Group query result by User Agent. - :vartype group_by_user_agent: bool - """ - - _validation = { - "blob_container_sas_uri": {"required": True}, - "from_time": {"required": True}, - "to_time": {"required": True}, - } - - _attribute_map = { - "blob_container_sas_uri": {"key": "blobContainerSasUri", "type": "str"}, - "from_time": {"key": "fromTime", "type": "iso-8601"}, - "to_time": {"key": "toTime", "type": "iso-8601"}, - "group_by_throttle_policy": {"key": "groupByThrottlePolicy", "type": "bool"}, - "group_by_operation_name": {"key": "groupByOperationName", "type": "bool"}, - "group_by_resource_name": {"key": "groupByResourceName", "type": "bool"}, - "group_by_client_application_id": {"key": "groupByClientApplicationId", "type": "bool"}, - "group_by_user_agent": {"key": "groupByUserAgent", "type": "bool"}, - } - - def __init__( - self, - *, - blob_container_sas_uri: str, - from_time: datetime.datetime, - to_time: datetime.datetime, - group_by_throttle_policy: Optional[bool] = None, - group_by_operation_name: Optional[bool] = None, - group_by_resource_name: Optional[bool] = None, - group_by_client_application_id: Optional[bool] = None, - group_by_user_agent: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics - Api writes output logs to. Required. - :paramtype blob_container_sas_uri: str - :keyword from_time: From time of the query. Required. - :paramtype from_time: ~datetime.datetime - :keyword to_time: To time of the query. Required. - :paramtype to_time: ~datetime.datetime - :keyword group_by_throttle_policy: Group query result by Throttle Policy applied. - :paramtype group_by_throttle_policy: bool - :keyword group_by_operation_name: Group query result by Operation Name. - :paramtype group_by_operation_name: bool - :keyword group_by_resource_name: Group query result by Resource Name. - :paramtype group_by_resource_name: bool - :keyword group_by_client_application_id: Group query result by Client Application ID. - :paramtype group_by_client_application_id: bool - :keyword group_by_user_agent: Group query result by User Agent. - :paramtype group_by_user_agent: bool - """ - super().__init__(**kwargs) - self.blob_container_sas_uri = blob_container_sas_uri - self.from_time = from_time - self.to_time = to_time - self.group_by_throttle_policy = group_by_throttle_policy - self.group_by_operation_name = group_by_operation_name - self.group_by_resource_name = group_by_resource_name - self.group_by_client_application_id = group_by_client_application_id - self.group_by_user_agent = group_by_user_agent - - -class LogAnalyticsOperationResult(_serialization.Model): - """LogAnalytics operation status response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar properties: LogAnalyticsOutput. - :vartype properties: ~azure.mgmt.compute.v2020_06_01.models.LogAnalyticsOutput - """ - - _validation = { - "properties": {"readonly": True}, - } - - _attribute_map = { - "properties": {"key": "properties", "type": "LogAnalyticsOutput"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.properties: Optional["_models.LogAnalyticsOutput"] = None - - -class LogAnalyticsOutput(_serialization.Model): - """LogAnalytics output properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar output: Output file Uri path to blob container. - :vartype output: str - """ - - _validation = { - "output": {"readonly": True}, - } - - _attribute_map = { - "output": {"key": "output", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.output: Optional[str] = None - - -class MaintenanceRedeployStatus(_serialization.Model): - """Maintenance Operation Status. - - :ivar is_customer_initiated_maintenance_allowed: True, if customer is allowed to perform - Maintenance. - :vartype is_customer_initiated_maintenance_allowed: bool - :ivar pre_maintenance_window_start_time: Start Time for the Pre Maintenance Window. - :vartype pre_maintenance_window_start_time: ~datetime.datetime - :ivar pre_maintenance_window_end_time: End Time for the Pre Maintenance Window. - :vartype pre_maintenance_window_end_time: ~datetime.datetime - :ivar maintenance_window_start_time: Start Time for the Maintenance Window. - :vartype maintenance_window_start_time: ~datetime.datetime - :ivar maintenance_window_end_time: End Time for the Maintenance Window. - :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: - "None", "RetryLater", "MaintenanceAborted", and "MaintenanceCompleted". - :vartype last_operation_result_code: str or - ~azure.mgmt.compute.v2020_06_01.models.MaintenanceOperationResultCodeTypes - :ivar last_operation_message: Message returned for the last Maintenance Operation. - :vartype last_operation_message: str - """ - - _attribute_map = { - "is_customer_initiated_maintenance_allowed": {"key": "isCustomerInitiatedMaintenanceAllowed", "type": "bool"}, - "pre_maintenance_window_start_time": {"key": "preMaintenanceWindowStartTime", "type": "iso-8601"}, - "pre_maintenance_window_end_time": {"key": "preMaintenanceWindowEndTime", "type": "iso-8601"}, - "maintenance_window_start_time": {"key": "maintenanceWindowStartTime", "type": "iso-8601"}, - "maintenance_window_end_time": {"key": "maintenanceWindowEndTime", "type": "iso-8601"}, - "last_operation_result_code": {"key": "lastOperationResultCode", "type": "str"}, - "last_operation_message": {"key": "lastOperationMessage", "type": "str"}, - } - - def __init__( - self, - *, - is_customer_initiated_maintenance_allowed: Optional[bool] = None, - pre_maintenance_window_start_time: Optional[datetime.datetime] = None, - pre_maintenance_window_end_time: Optional[datetime.datetime] = None, - maintenance_window_start_time: Optional[datetime.datetime] = None, - maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, - last_operation_message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_customer_initiated_maintenance_allowed: True, if customer is allowed to perform - Maintenance. - :paramtype is_customer_initiated_maintenance_allowed: bool - :keyword pre_maintenance_window_start_time: Start Time for the Pre Maintenance Window. - :paramtype pre_maintenance_window_start_time: ~datetime.datetime - :keyword pre_maintenance_window_end_time: End Time for the Pre Maintenance Window. - :paramtype pre_maintenance_window_end_time: ~datetime.datetime - :keyword maintenance_window_start_time: Start Time for the Maintenance Window. - :paramtype maintenance_window_start_time: ~datetime.datetime - :keyword maintenance_window_end_time: End Time for the Maintenance Window. - :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values - are: "None", "RetryLater", "MaintenanceAborted", and "MaintenanceCompleted". - :paramtype last_operation_result_code: str or - ~azure.mgmt.compute.v2020_06_01.models.MaintenanceOperationResultCodeTypes - :keyword last_operation_message: Message returned for the last Maintenance Operation. - :paramtype last_operation_message: str - """ - super().__init__(**kwargs) - self.is_customer_initiated_maintenance_allowed = is_customer_initiated_maintenance_allowed - self.pre_maintenance_window_start_time = pre_maintenance_window_start_time - self.pre_maintenance_window_end_time = pre_maintenance_window_end_time - self.maintenance_window_start_time = maintenance_window_start_time - self.maintenance_window_end_time = maintenance_window_end_time - self.last_operation_result_code = last_operation_result_code - self.last_operation_message = last_operation_message - - -class ManagedDiskParameters(SubResource): - """The parameters of a managed disk. - - :ivar id: Resource Id. - :vartype id: str - :ivar storage_account_type: Specifies the storage account type for the managed disk. Managed OS - disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS can - only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", - "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2020_06_01.models.DiskEncryptionSetParameters - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword storage_account_type: Specifies the storage account type for the managed disk. Managed - OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS - can only be used with data disks, it cannot be used with OS Disk. Known values are: - "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2020_06_01.models.DiskEncryptionSetParameters - """ - super().__init__(id=id, **kwargs) - self.storage_account_type = storage_account_type - self.disk_encryption_set = disk_encryption_set - - -class NetworkInterfaceReference(SubResource): - """Describes a network interface reference. - - :ivar id: Resource Id. - :vartype id: str - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - primary: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - """ - super().__init__(id=id, **kwargs) - self.primary = primary - - -class NetworkProfile(_serialization.Model): - """Specifies the network interfaces of the virtual machine. - - :ivar network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the virtual machine. - :vartype network_interfaces: - list[~azure.mgmt.compute.v2020_06_01.models.NetworkInterfaceReference] - """ - - _attribute_map = { - "network_interfaces": {"key": "networkInterfaces", "type": "[NetworkInterfaceReference]"}, - } - - def __init__( - self, *, network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs: Any - ) -> None: - """ - :keyword network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the virtual machine. - :paramtype network_interfaces: - list[~azure.mgmt.compute.v2020_06_01.models.NetworkInterfaceReference] - """ - super().__init__(**kwargs) - self.network_interfaces = network_interfaces - - -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. "AutomaticRepairs" - :vartype service_name: str or ~azure.mgmt.compute.v2020_06_01.models.OrchestrationServiceNames - :ivar action: The action to be performed. Required. Known values are: "Resume" and "Suspend". - :vartype action: str or ~azure.mgmt.compute.v2020_06_01.models.OrchestrationServiceStateAction - """ - - _validation = { - "service_name": {"required": True}, - "action": {"required": True}, - } - - _attribute_map = { - "service_name": {"key": "serviceName", "type": "str"}, - "action": {"key": "action", "type": "str"}, - } - - def __init__( - self, - *, - service_name: Union[str, "_models.OrchestrationServiceNames"], - action: Union[str, "_models.OrchestrationServiceStateAction"], - **kwargs: Any - ) -> None: - """ - :keyword service_name: The name of the service. Required. "AutomaticRepairs" - :paramtype service_name: str or - ~azure.mgmt.compute.v2020_06_01.models.OrchestrationServiceNames - :keyword action: The action to be performed. Required. Known values are: "Resume" and - "Suspend". - :paramtype action: str or - ~azure.mgmt.compute.v2020_06_01.models.OrchestrationServiceStateAction - """ - super().__init__(**kwargs) - self.service_name = service_name - self.action = action - - -class OrchestrationServiceSummary(_serialization.Model): - """Summary for an orchestration service of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar service_name: The name of the service. "AutomaticRepairs" - :vartype service_name: str or ~azure.mgmt.compute.v2020_06_01.models.OrchestrationServiceNames - :ivar service_state: The current state of the service. Known values are: "NotRunning", - "Running", and "Suspended". - :vartype service_state: str or ~azure.mgmt.compute.v2020_06_01.models.OrchestrationServiceState - """ - - _validation = { - "service_name": {"readonly": True}, - "service_state": {"readonly": True}, - } - - _attribute_map = { - "service_name": {"key": "serviceName", "type": "str"}, - "service_state": {"key": "serviceState", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.service_name: Optional[Union[str, "_models.OrchestrationServiceNames"]] = None - self.service_state: Optional[Union[str, "_models.OrchestrationServiceState"]] = None - - -class OSDisk(_serialization.Model): - """Specifies information about the operating system disk used by the virtual machine. - :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and VHDs for - Azure virtual machines - `_. - - All required parameters must be populated in order to send to server. - - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes - :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :vartype encryption_settings: ~azure.mgmt.compute.v2020_06_01.models.DiskEncryptionSettings - :ivar name: The disk name. - :vartype name: str - :ivar vhd: The virtual hard disk. - :vartype vhd: ~azure.mgmt.compute.v2020_06_01.models.VirtualHardDisk - :ivar image: 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. - :vartype image: ~azure.mgmt.compute.v2020_06_01.models.VirtualHardDisk - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None** for - Standard storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar diff_disk_settings: Specifies the ephemeral Disk Settings for the operating system disk - used by the virtual machine. - :vartype diff_disk_settings: ~azure.mgmt.compute.v2020_06_01.models.DiffDiskSettings - :ivar create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2020_06_01.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: ~azure.mgmt.compute.v2020_06_01.models.ManagedDiskParameters - """ - - _validation = { - "create_option": {"required": True}, - } - - _attribute_map = { - "os_type": {"key": "osType", "type": "str"}, - "encryption_settings": {"key": "encryptionSettings", "type": "DiskEncryptionSettings"}, - "name": {"key": "name", "type": "str"}, - "vhd": {"key": "vhd", "type": "VirtualHardDisk"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "diff_disk_settings": {"key": "diffDiskSettings", "type": "DiffDiskSettings"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, - name: Optional[str] = None, - vhd: Optional["_models.VirtualHardDisk"] = None, - image: Optional["_models.VirtualHardDisk"] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.ManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes - :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype encryption_settings: ~azure.mgmt.compute.v2020_06_01.models.DiskEncryptionSettings - :keyword name: The disk name. - :paramtype name: str - :keyword vhd: The virtual hard disk. - :paramtype vhd: ~azure.mgmt.compute.v2020_06_01.models.VirtualHardDisk - :keyword image: 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. - :paramtype image: ~azure.mgmt.compute.v2020_06_01.models.VirtualHardDisk - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None** for - Standard storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword diff_disk_settings: Specifies the ephemeral Disk Settings for the operating system - disk used by the virtual machine. - :paramtype diff_disk_settings: ~azure.mgmt.compute.v2020_06_01.models.DiffDiskSettings - :keyword create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2020_06_01.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: ~azure.mgmt.compute.v2020_06_01.models.ManagedDiskParameters - """ - super().__init__(**kwargs) - self.os_type = os_type - self.encryption_settings = encryption_settings - self.name = name - self.vhd = vhd - self.image = image - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.diff_disk_settings = diff_disk_settings - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - - -class OSDiskImage(_serialization.Model): - """Contains the os disk image information. - - All required parameters must be populated in order to send to server. - - :ivar operating_system: The operating system of the osDiskImage. Required. Known values are: - "Windows" and "Linux". - :vartype operating_system: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes - """ - - _validation = { - "operating_system": {"required": True}, - } - - _attribute_map = { - "operating_system": {"key": "operatingSystem", "type": "str"}, - } - - def __init__(self, *, operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs: Any) -> None: - """ - :keyword operating_system: The operating system of the osDiskImage. Required. Known values are: - "Windows" and "Linux". - :paramtype operating_system: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes - """ - super().__init__(**kwargs) - self.operating_system = operating_system - - -class OSProfile(_serialization.Model): - """Specifies the operating system settings for the virtual machine. Some of the settings cannot be - changed once VM is provisioned. - - :ivar computer_name: Specifies the host OS name of the virtual machine. :code:`
    `\\ - :code:`
    ` This name cannot be updated after the VM is created. :code:`
    `\\ :code:`
    ` - **Max-length (Windows):** 15 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 - characters. :code:`
    `\\ :code:`
    ` For naming conventions and restrictions see `Azure - infrastructure services implementation guidelines - `_. - :vartype computer_name: str - :ivar admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` This property cannot be updated after the VM is created. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :vartype admin_username: str - :ivar admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :vartype admin_password: str - :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` **Note: Do not pass any - secrets or passwords in customData property** :code:`
    `\\ :code:`
    ` This property cannot - be updated after the VM is created. :code:`
    `\\ :code:`
    ` customData is passed to the VM - to be saved as a file, for more information see `Custom Data on Azure VMs - `_ - :code:`
    `\\ :code:`
    ` For using cloud-init for your Linux VM, see `Using cloud-init to - customize a Linux VM during creation - `_. - :vartype custom_data: str - :ivar windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :vartype windows_configuration: ~azure.mgmt.compute.v2020_06_01.models.WindowsConfiguration - :ivar linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :vartype linux_configuration: ~azure.mgmt.compute.v2020_06_01.models.LinuxConfiguration - :ivar secrets: Specifies set of certificates that should be installed onto the virtual machine. - :vartype secrets: list[~azure.mgmt.compute.v2020_06_01.models.VaultSecretGroup] - :ivar allow_extension_operations: Specifies whether extension operations should be allowed on - the virtual machine. :code:`
    `\\ :code:`
    `This may only be set to False when no - extensions are present on the virtual machine. - :vartype allow_extension_operations: bool - :ivar require_guest_provision_signal: Specifies whether the guest provision signal is required - to infer provision success of the virtual machine. **Note: This property is for private - testing only, and all customers must not set the property to false.**. - :vartype require_guest_provision_signal: bool - """ - - _attribute_map = { - "computer_name": {"key": "computerName", "type": "str"}, - "admin_username": {"key": "adminUsername", "type": "str"}, - "admin_password": {"key": "adminPassword", "type": "str"}, - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - "allow_extension_operations": {"key": "allowExtensionOperations", "type": "bool"}, - "require_guest_provision_signal": {"key": "requireGuestProvisionSignal", "type": "bool"}, - } - - def __init__( - self, - *, - computer_name: Optional[str] = None, - admin_username: Optional[str] = None, - admin_password: Optional[str] = None, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - allow_extension_operations: Optional[bool] = None, - require_guest_provision_signal: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword computer_name: Specifies the host OS name of the virtual machine. :code:`
    `\\ - :code:`
    ` This name cannot be updated after the VM is created. :code:`
    `\\ :code:`
    ` - **Max-length (Windows):** 15 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 - characters. :code:`
    `\\ :code:`
    ` For naming conventions and restrictions see `Azure - infrastructure services implementation guidelines - `_. - :paramtype computer_name: str - :keyword admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` This property cannot be updated after the VM is created. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :paramtype admin_username: str - :keyword admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :paramtype admin_password: str - :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` **Note: Do not pass any - secrets or passwords in customData property** :code:`
    `\\ :code:`
    ` This property cannot - be updated after the VM is created. :code:`
    `\\ :code:`
    ` customData is passed to the VM - to be saved as a file, for more information see `Custom Data on Azure VMs - `_ - :code:`
    `\\ :code:`
    ` For using cloud-init for your Linux VM, see `Using cloud-init to - customize a Linux VM during creation - `_. - :paramtype custom_data: str - :keyword windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :paramtype windows_configuration: ~azure.mgmt.compute.v2020_06_01.models.WindowsConfiguration - :keyword linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :paramtype linux_configuration: ~azure.mgmt.compute.v2020_06_01.models.LinuxConfiguration - :keyword secrets: Specifies set of certificates that should be installed onto the virtual - machine. - :paramtype secrets: list[~azure.mgmt.compute.v2020_06_01.models.VaultSecretGroup] - :keyword allow_extension_operations: Specifies whether extension operations should be allowed - on the virtual machine. :code:`
    `\\ :code:`
    `This may only be set to False when no - extensions are present on the virtual machine. - :paramtype allow_extension_operations: bool - :keyword require_guest_provision_signal: Specifies whether the guest provision signal is - required to infer provision success of the virtual machine. **Note: This property is for - private testing only, and all customers must not set the property to false.**. - :paramtype require_guest_provision_signal: bool - """ - super().__init__(**kwargs) - self.computer_name = computer_name - self.admin_username = admin_username - self.admin_password = admin_password - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - self.allow_extension_operations = allow_extension_operations - self.require_guest_provision_signal = require_guest_provision_signal - - -class PatchSettings(_serialization.Model): - """PatchSettings. - - :ivar patch_mode: Specifies the mode of in-guest patching to IaaS virtual machine.\\ :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Manual** - You - control the application of patches to a virtual machine. You do this by applying patches - manually inside the VM. In this mode, automatic updates are disabled; the property - WindowsConfiguration.enableAutomaticUpdates must be false\\ :code:`
    `\\ :code:`
    ` - **AutomaticByOS** - The virtual machine will automatically be updated by the OS. The property - WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
    `\\ :code:`
    ` - **AutomaticByPlatform** - the virtual machine will automatically updated by the platform. The - properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. Known - values are: "Manual", "AutomaticByOS", and "AutomaticByPlatform". - :vartype patch_mode: str or ~azure.mgmt.compute.v2020_06_01.models.InGuestPatchMode - """ - - _attribute_map = { - "patch_mode": {"key": "patchMode", "type": "str"}, - } - - def __init__(self, *, patch_mode: Optional[Union[str, "_models.InGuestPatchMode"]] = None, **kwargs: Any) -> None: - """ - :keyword patch_mode: Specifies the mode of in-guest patching to IaaS virtual machine.\\ - :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` - **Manual** - You control the application of patches to a virtual machine. You do this by - applying patches manually inside the VM. In this mode, automatic updates are disabled; the - property WindowsConfiguration.enableAutomaticUpdates must be false\\ :code:`
    `\\ - :code:`
    ` **AutomaticByOS** - The virtual machine will automatically be updated by the OS. - The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
    `\\ - :code:`
    ` **AutomaticByPlatform** - the virtual machine will automatically updated by the - platform. The properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must - be true. Known values are: "Manual", "AutomaticByOS", and "AutomaticByPlatform". - :paramtype patch_mode: str or ~azure.mgmt.compute.v2020_06_01.models.InGuestPatchMode - """ - super().__init__(**kwargs) - self.patch_mode = patch_mode - - -class Plan(_serialization.Model): - """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 the marketplace - image that you want to use and then click **Want to deploy programmatically, Get Started ->**. - Enter any required information and then click **Save**. - - :ivar name: The plan ID. - :vartype name: str - :ivar publisher: The publisher ID. - :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. - :vartype product: str - :ivar promotion_code: The promotion code. - :vartype promotion_code: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - "promotion_code": {"key": "promotionCode", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - publisher: Optional[str] = None, - product: Optional[str] = None, - promotion_code: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The plan ID. - :paramtype name: str - :keyword publisher: The publisher ID. - :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. - :paramtype product: str - :keyword promotion_code: The promotion code. - :paramtype promotion_code: str - """ - super().__init__(**kwargs) - self.name = name - self.publisher = publisher - self.product = product - self.promotion_code = promotion_code - - -class ProximityPlacementGroup(Resource): - """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. - :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] - :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Standard** : - Co-locate resources within an Azure region or Availability Zone. :code:`
    `\\ :code:`
    ` - **Ultra** : For future use. Known values are: "Standard" and "Ultra". - :vartype proximity_placement_group_type: str or - ~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroupType - :ivar virtual_machines: A list of references to all virtual machines in the proximity placement - group. - :vartype virtual_machines: - list[~azure.mgmt.compute.v2020_06_01.models.SubResourceWithColocationStatus] - :ivar virtual_machine_scale_sets: A list of references to all virtual machine scale sets in the - proximity placement group. - :vartype virtual_machine_scale_sets: - list[~azure.mgmt.compute.v2020_06_01.models.SubResourceWithColocationStatus] - :ivar availability_sets: A list of references to all availability sets in the proximity - placement group. - :vartype availability_sets: - list[~azure.mgmt.compute.v2020_06_01.models.SubResourceWithColocationStatus] - :ivar colocation_status: Describes colocation status of the Proximity Placement Group. - :vartype colocation_status: ~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "virtual_machines": {"readonly": True}, - "virtual_machine_scale_sets": {"readonly": True}, - "availability_sets": {"readonly": 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}"}, - "proximity_placement_group_type": {"key": "properties.proximityPlacementGroupType", "type": "str"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResourceWithColocationStatus]"}, - "virtual_machine_scale_sets": { - "key": "properties.virtualMachineScaleSets", - "type": "[SubResourceWithColocationStatus]", - }, - "availability_sets": {"key": "properties.availabilitySets", "type": "[SubResourceWithColocationStatus]"}, - "colocation_status": {"key": "properties.colocationStatus", "type": "InstanceViewStatus"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, - colocation_status: Optional["_models.InstanceViewStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Standard** : - Co-locate resources within an Azure region or Availability Zone. :code:`
    `\\ :code:`
    ` - **Ultra** : For future use. Known values are: "Standard" and "Ultra". - :paramtype proximity_placement_group_type: str or - ~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroupType - :keyword colocation_status: Describes colocation status of the Proximity Placement Group. - :paramtype colocation_status: ~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus - """ - super().__init__(location=location, tags=tags, **kwargs) - self.proximity_placement_group_type = proximity_placement_group_type - self.virtual_machines: Optional[List["_models.SubResourceWithColocationStatus"]] = None - self.virtual_machine_scale_sets: Optional[List["_models.SubResourceWithColocationStatus"]] = None - self.availability_sets: Optional[List["_models.SubResourceWithColocationStatus"]] = None - self.colocation_status = colocation_status - - -class ProximityPlacementGroupListResult(_serialization.Model): - """The List Proximity Placement Group operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of proximity placement groups. Required. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroup] - :ivar next_link: The URI to fetch the next page of proximity placement groups. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ProximityPlacementGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of proximity placement groups. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroup] - :keyword next_link: The URI to fetch the next page of proximity placement groups. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ProximityPlacementGroupUpdate(UpdateResource): - """Specifies information about the proximity placement group. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - -class PurchasePlan(_serialization.Model): - """Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. - - All required parameters must be populated in order to send to server. - - :ivar publisher: The publisher ID. Required. - :vartype publisher: str - :ivar name: The plan ID. Required. - :vartype name: 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 - """ - - _validation = { - "publisher": {"required": True}, - "name": {"required": True}, - "product": {"required": True}, - } - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "product": {"key": "product", "type": "str"}, - } - - def __init__(self, *, publisher: str, name: str, product: str, **kwargs: Any) -> None: - """ - :keyword publisher: The publisher ID. Required. - :paramtype publisher: str - :keyword name: The plan ID. Required. - :paramtype name: 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 - """ - super().__init__(**kwargs) - self.publisher = publisher - self.name = name - self.product = product - - -class RecoveryWalkResponse(_serialization.Model): - """Response after calling a manual recovery walk. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar walk_performed: Whether the recovery walk was performed. - :vartype walk_performed: bool - :ivar next_platform_update_domain: The next update domain that needs to be walked. Null means - walk spanning all update domains has been completed. - :vartype next_platform_update_domain: int - """ - - _validation = { - "walk_performed": {"readonly": True}, - "next_platform_update_domain": {"readonly": True}, - } - - _attribute_map = { - "walk_performed": {"key": "walkPerformed", "type": "bool"}, - "next_platform_update_domain": {"key": "nextPlatformUpdateDomain", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.walk_performed: Optional[bool] = None - self.next_platform_update_domain: Optional[int] = None - - -class RequestRateByIntervalInput(LogAnalyticsInputBase): - """Api request input for LogAnalytics getRequestRateByInterval Api. - - All required parameters must be populated in order to send to server. - - :ivar blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api - writes output logs to. Required. - :vartype blob_container_sas_uri: str - :ivar from_time: From time of the query. Required. - :vartype from_time: ~datetime.datetime - :ivar to_time: To time of the query. Required. - :vartype to_time: ~datetime.datetime - :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. - :vartype group_by_throttle_policy: bool - :ivar group_by_operation_name: Group query result by Operation Name. - :vartype group_by_operation_name: bool - :ivar group_by_resource_name: Group query result by Resource Name. - :vartype group_by_resource_name: bool - :ivar group_by_client_application_id: Group query result by Client Application ID. - :vartype group_by_client_application_id: bool - :ivar group_by_user_agent: Group query result by User Agent. - :vartype group_by_user_agent: bool - :ivar interval_length: Interval value in minutes used to create LogAnalytics call rate logs. - Required. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", and "SixtyMins". - :vartype interval_length: str or ~azure.mgmt.compute.v2020_06_01.models.IntervalInMins - """ - - _validation = { - "blob_container_sas_uri": {"required": True}, - "from_time": {"required": True}, - "to_time": {"required": True}, - "interval_length": {"required": True}, - } - - _attribute_map = { - "blob_container_sas_uri": {"key": "blobContainerSasUri", "type": "str"}, - "from_time": {"key": "fromTime", "type": "iso-8601"}, - "to_time": {"key": "toTime", "type": "iso-8601"}, - "group_by_throttle_policy": {"key": "groupByThrottlePolicy", "type": "bool"}, - "group_by_operation_name": {"key": "groupByOperationName", "type": "bool"}, - "group_by_resource_name": {"key": "groupByResourceName", "type": "bool"}, - "group_by_client_application_id": {"key": "groupByClientApplicationId", "type": "bool"}, - "group_by_user_agent": {"key": "groupByUserAgent", "type": "bool"}, - "interval_length": {"key": "intervalLength", "type": "str"}, - } - - def __init__( - self, - *, - blob_container_sas_uri: str, - from_time: datetime.datetime, - to_time: datetime.datetime, - interval_length: Union[str, "_models.IntervalInMins"], - group_by_throttle_policy: Optional[bool] = None, - group_by_operation_name: Optional[bool] = None, - group_by_resource_name: Optional[bool] = None, - group_by_client_application_id: Optional[bool] = None, - group_by_user_agent: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics - Api writes output logs to. Required. - :paramtype blob_container_sas_uri: str - :keyword from_time: From time of the query. Required. - :paramtype from_time: ~datetime.datetime - :keyword to_time: To time of the query. Required. - :paramtype to_time: ~datetime.datetime - :keyword group_by_throttle_policy: Group query result by Throttle Policy applied. - :paramtype group_by_throttle_policy: bool - :keyword group_by_operation_name: Group query result by Operation Name. - :paramtype group_by_operation_name: bool - :keyword group_by_resource_name: Group query result by Resource Name. - :paramtype group_by_resource_name: bool - :keyword group_by_client_application_id: Group query result by Client Application ID. - :paramtype group_by_client_application_id: bool - :keyword group_by_user_agent: Group query result by User Agent. - :paramtype group_by_user_agent: bool - :keyword interval_length: Interval value in minutes used to create LogAnalytics call rate logs. - Required. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", and "SixtyMins". - :paramtype interval_length: str or ~azure.mgmt.compute.v2020_06_01.models.IntervalInMins - """ - super().__init__( - blob_container_sas_uri=blob_container_sas_uri, - from_time=from_time, - to_time=to_time, - group_by_throttle_policy=group_by_throttle_policy, - group_by_operation_name=group_by_operation_name, - group_by_resource_name=group_by_resource_name, - group_by_client_application_id=group_by_client_application_id, - group_by_user_agent=group_by_user_agent, - **kwargs - ) - self.interval_length = interval_length - - -class RetrieveBootDiagnosticsDataResult(_serialization.Model): - """The SAS URIs of the console screenshot and serial log blobs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar console_screenshot_blob_uri: The console screenshot blob URI. - :vartype console_screenshot_blob_uri: str - :ivar serial_console_log_blob_uri: The serial console log blob URI. - :vartype serial_console_log_blob_uri: str - """ - - _validation = { - "console_screenshot_blob_uri": {"readonly": True}, - "serial_console_log_blob_uri": {"readonly": True}, - } - - _attribute_map = { - "console_screenshot_blob_uri": {"key": "consoleScreenshotBlobUri", "type": "str"}, - "serial_console_log_blob_uri": {"key": "serialConsoleLogBlobUri", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.console_screenshot_blob_uri: Optional[str] = None - self.serial_console_log_blob_uri: Optional[str] = None - - -class RollbackStatusInfo(_serialization.Model): - """Information about rollback on failed VM instances after a OS Upgrade operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar successfully_rolledback_instance_count: The number of instances which have been - successfully rolled back. - :vartype successfully_rolledback_instance_count: int - :ivar failed_rolledback_instance_count: The number of instances which failed to rollback. - :vartype failed_rolledback_instance_count: int - :ivar rollback_error: Error details if OS rollback failed. - :vartype rollback_error: ~azure.mgmt.compute.v2020_06_01.models.ApiError - """ - - _validation = { - "successfully_rolledback_instance_count": {"readonly": True}, - "failed_rolledback_instance_count": {"readonly": True}, - "rollback_error": {"readonly": True}, - } - - _attribute_map = { - "successfully_rolledback_instance_count": {"key": "successfullyRolledbackInstanceCount", "type": "int"}, - "failed_rolledback_instance_count": {"key": "failedRolledbackInstanceCount", "type": "int"}, - "rollback_error": {"key": "rollbackError", "type": "ApiError"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.successfully_rolledback_instance_count: Optional[int] = None - self.failed_rolledback_instance_count: Optional[int] = None - self.rollback_error: Optional["_models.ApiError"] = None - - -class RollingUpgradePolicy(_serialization.Model): - """The configuration parameters used while performing a rolling upgrade. - - :ivar max_batch_instance_percent: The maximum percent of total virtual machine instances that - will be upgraded simultaneously by the rolling upgrade in one batch. As this is a maximum, - unhealthy instances in previous or future batches can cause the percentage of instances in a - batch to decrease to ensure higher reliability. The default value for this parameter is 20%. - :vartype max_batch_instance_percent: int - :ivar max_unhealthy_instance_percent: The maximum percentage of the total virtual machine - instances in the scale set that can be simultaneously unhealthy, either as a result of being - upgraded, or by being found in an unhealthy state by the virtual machine health checks before - the rolling upgrade aborts. This constraint will be checked prior to starting any batch. The - default value for this parameter is 20%. - :vartype max_unhealthy_instance_percent: int - :ivar max_unhealthy_upgraded_instance_percent: The maximum percentage of upgraded virtual - machine instances that can be found to be in an unhealthy state. This check will happen after - each batch is upgraded. If this percentage is ever exceeded, the rolling update aborts. The - default value for this parameter is 20%. - :vartype max_unhealthy_upgraded_instance_percent: int - :ivar pause_time_between_batches: The wait time between completing the update for all virtual - machines in one batch and starting the next batch. The time duration should be specified in ISO - 8601 format. The default value is 0 seconds (PT0S). - :vartype pause_time_between_batches: str - """ - - _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}, - } - - _attribute_map = { - "max_batch_instance_percent": {"key": "maxBatchInstancePercent", "type": "int"}, - "max_unhealthy_instance_percent": {"key": "maxUnhealthyInstancePercent", "type": "int"}, - "max_unhealthy_upgraded_instance_percent": {"key": "maxUnhealthyUpgradedInstancePercent", "type": "int"}, - "pause_time_between_batches": {"key": "pauseTimeBetweenBatches", "type": "str"}, - } - - def __init__( - self, - *, - max_batch_instance_percent: Optional[int] = None, - max_unhealthy_instance_percent: Optional[int] = None, - max_unhealthy_upgraded_instance_percent: Optional[int] = None, - pause_time_between_batches: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword max_batch_instance_percent: The maximum percent of total virtual machine instances - that will be upgraded simultaneously by the rolling upgrade in one batch. As this is a maximum, - unhealthy instances in previous or future batches can cause the percentage of instances in a - batch to decrease to ensure higher reliability. The default value for this parameter is 20%. - :paramtype max_batch_instance_percent: int - :keyword max_unhealthy_instance_percent: The maximum percentage of the total virtual machine - instances in the scale set that can be simultaneously unhealthy, either as a result of being - upgraded, or by being found in an unhealthy state by the virtual machine health checks before - the rolling upgrade aborts. This constraint will be checked prior to starting any batch. The - default value for this parameter is 20%. - :paramtype max_unhealthy_instance_percent: int - :keyword max_unhealthy_upgraded_instance_percent: The maximum percentage of upgraded virtual - machine instances that can be found to be in an unhealthy state. This check will happen after - each batch is upgraded. If this percentage is ever exceeded, the rolling update aborts. The - default value for this parameter is 20%. - :paramtype max_unhealthy_upgraded_instance_percent: int - :keyword pause_time_between_batches: The wait time between completing the update for all - virtual machines in one batch and starting the next batch. The time duration should be - specified in ISO 8601 format. The default value is 0 seconds (PT0S). - :paramtype pause_time_between_batches: str - """ - super().__init__(**kwargs) - self.max_batch_instance_percent = max_batch_instance_percent - self.max_unhealthy_instance_percent = max_unhealthy_instance_percent - self.max_unhealthy_upgraded_instance_percent = max_unhealthy_upgraded_instance_percent - self.pause_time_between_batches = pause_time_between_batches - - -class RollingUpgradeProgressInfo(_serialization.Model): - """Information about the number of virtual machine instances in each upgrade state. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar successful_instance_count: The number of instances that have been successfully upgraded. - :vartype successful_instance_count: int - :ivar failed_instance_count: The number of instances that have failed to be upgraded - successfully. - :vartype failed_instance_count: int - :ivar in_progress_instance_count: The number of instances that are currently being upgraded. - :vartype in_progress_instance_count: int - :ivar pending_instance_count: The number of instances that have not yet begun to be upgraded. - :vartype pending_instance_count: int - """ - - _validation = { - "successful_instance_count": {"readonly": True}, - "failed_instance_count": {"readonly": True}, - "in_progress_instance_count": {"readonly": True}, - "pending_instance_count": {"readonly": True}, - } - - _attribute_map = { - "successful_instance_count": {"key": "successfulInstanceCount", "type": "int"}, - "failed_instance_count": {"key": "failedInstanceCount", "type": "int"}, - "in_progress_instance_count": {"key": "inProgressInstanceCount", "type": "int"}, - "pending_instance_count": {"key": "pendingInstanceCount", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.successful_instance_count: Optional[int] = None - self.failed_instance_count: Optional[int] = None - self.in_progress_instance_count: Optional[int] = None - self.pending_instance_count: Optional[int] = None - - -class RollingUpgradeRunningStatus(_serialization.Model): - """Information about the current running state of the overall upgrade. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Code indicating the current status of the upgrade. Known values are: - "RollingForward", "Cancelled", "Completed", and "Faulted". - :vartype code: str or ~azure.mgmt.compute.v2020_06_01.models.RollingUpgradeStatusCode - :ivar start_time: Start time of the upgrade. - :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start" - and "Cancel". - :vartype last_action: str or ~azure.mgmt.compute.v2020_06_01.models.RollingUpgradeActionType - :ivar last_action_time: Last action time of the upgrade. - :vartype last_action_time: ~datetime.datetime - """ - - _validation = { - "code": {"readonly": True}, - "start_time": {"readonly": True}, - "last_action": {"readonly": True}, - "last_action_time": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "last_action": {"key": "lastAction", "type": "str"}, - "last_action_time": {"key": "lastActionTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[Union[str, "_models.RollingUpgradeStatusCode"]] = None - self.start_time: Optional[datetime.datetime] = None - self.last_action: Optional[Union[str, "_models.RollingUpgradeActionType"]] = None - self.last_action_time: Optional[datetime.datetime] = None - - -class RollingUpgradeStatusInfo(Resource): - """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. - :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] - :ivar policy: The rolling upgrade policies applied for this upgrade. - :vartype policy: ~azure.mgmt.compute.v2020_06_01.models.RollingUpgradePolicy - :ivar running_status: Information about the current running state of the overall upgrade. - :vartype running_status: ~azure.mgmt.compute.v2020_06_01.models.RollingUpgradeRunningStatus - :ivar progress: Information about the number of virtual machine instances in each upgrade - state. - :vartype progress: ~azure.mgmt.compute.v2020_06_01.models.RollingUpgradeProgressInfo - :ivar error: Error details for this upgrade, if there are any. - :vartype error: ~azure.mgmt.compute.v2020_06_01.models.ApiError - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "policy": {"readonly": True}, - "running_status": {"readonly": True}, - "progress": {"readonly": True}, - "error": {"readonly": 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}"}, - "policy": {"key": "properties.policy", "type": "RollingUpgradePolicy"}, - "running_status": {"key": "properties.runningStatus", "type": "RollingUpgradeRunningStatus"}, - "progress": {"key": "properties.progress", "type": "RollingUpgradeProgressInfo"}, - "error": {"key": "properties.error", "type": "ApiError"}, - } - - 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__(location=location, tags=tags, **kwargs) - self.policy: Optional["_models.RollingUpgradePolicy"] = None - self.running_status: Optional["_models.RollingUpgradeRunningStatus"] = None - self.progress: Optional["_models.RollingUpgradeProgressInfo"] = None - self.error: Optional["_models.ApiError"] = None - - -class RunCommandDocumentBase(_serialization.Model): - """Describes the properties of a Run Command metadata. - - All required parameters must be populated in order to send to server. - - :ivar schema: The VM run command schema. Required. - :vartype schema: str - :ivar id: The VM run command id. Required. - :vartype id: str - :ivar os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes - :ivar label: The VM run command label. Required. - :vartype label: str - :ivar description: The VM run command description. Required. - :vartype description: str - """ - - _validation = { - "schema": {"required": True}, - "id": {"required": True}, - "os_type": {"required": True}, - "label": {"required": True}, - "description": {"required": True}, - } - - _attribute_map = { - "schema": {"key": "$schema", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "os_type": {"key": "osType", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - schema: str, - id: str, # pylint: disable=redefined-builtin - os_type: Union[str, "_models.OperatingSystemTypes"], - label: str, - description: str, - **kwargs: Any - ) -> None: - """ - :keyword schema: The VM run command schema. Required. - :paramtype schema: str - :keyword id: The VM run command id. Required. - :paramtype id: str - :keyword os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes - :keyword label: The VM run command label. Required. - :paramtype label: str - :keyword description: The VM run command description. Required. - :paramtype description: str - """ - super().__init__(**kwargs) - self.schema = schema - self.id = id - self.os_type = os_type - self.label = label - self.description = description - - -class RunCommandDocument(RunCommandDocumentBase): - """Describes the properties of a Run Command. - - All required parameters must be populated in order to send to server. - - :ivar schema: The VM run command schema. Required. - :vartype schema: str - :ivar id: The VM run command id. Required. - :vartype id: str - :ivar os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes - :ivar label: The VM run command label. Required. - :vartype label: str - :ivar description: The VM run command description. Required. - :vartype description: str - :ivar script: The script to be executed. Required. - :vartype script: list[str] - :ivar parameters: The parameters used by the script. - :vartype parameters: list[~azure.mgmt.compute.v2020_06_01.models.RunCommandParameterDefinition] - """ - - _validation = { - "schema": {"required": True}, - "id": {"required": True}, - "os_type": {"required": True}, - "label": {"required": True}, - "description": {"required": True}, - "script": {"required": True}, - } - - _attribute_map = { - "schema": {"key": "$schema", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "os_type": {"key": "osType", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "script": {"key": "script", "type": "[str]"}, - "parameters": {"key": "parameters", "type": "[RunCommandParameterDefinition]"}, - } - - def __init__( - self, - *, - schema: str, - id: str, # pylint: disable=redefined-builtin - os_type: Union[str, "_models.OperatingSystemTypes"], - label: str, - description: str, - script: List[str], - parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword schema: The VM run command schema. Required. - :paramtype schema: str - :keyword id: The VM run command id. Required. - :paramtype id: str - :keyword os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes - :keyword label: The VM run command label. Required. - :paramtype label: str - :keyword description: The VM run command description. Required. - :paramtype description: str - :keyword script: The script to be executed. Required. - :paramtype script: list[str] - :keyword parameters: The parameters used by the script. - :paramtype parameters: - list[~azure.mgmt.compute.v2020_06_01.models.RunCommandParameterDefinition] - """ - super().__init__(schema=schema, id=id, os_type=os_type, label=label, description=description, **kwargs) - self.script = script - self.parameters = parameters - - -class RunCommandInput(_serialization.Model): - """Capture Virtual Machine parameters. - - All required parameters must be populated in order to send to server. - - :ivar command_id: The run command id. Required. - :vartype command_id: str - :ivar script: Optional. The script to be executed. When this value is given, the given script - will override the default script of the command. - :vartype script: list[str] - :ivar parameters: The run command parameters. - :vartype parameters: list[~azure.mgmt.compute.v2020_06_01.models.RunCommandInputParameter] - """ - - _validation = { - "command_id": {"required": True}, - } - - _attribute_map = { - "command_id": {"key": "commandId", "type": "str"}, - "script": {"key": "script", "type": "[str]"}, - "parameters": {"key": "parameters", "type": "[RunCommandInputParameter]"}, - } - - def __init__( - self, - *, - command_id: str, - script: Optional[List[str]] = None, - parameters: Optional[List["_models.RunCommandInputParameter"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword command_id: The run command id. Required. - :paramtype command_id: str - :keyword script: Optional. The script to be executed. When this value is given, the given - script will override the default script of the command. - :paramtype script: list[str] - :keyword parameters: The run command parameters. - :paramtype parameters: list[~azure.mgmt.compute.v2020_06_01.models.RunCommandInputParameter] - """ - super().__init__(**kwargs) - self.command_id = command_id - self.script = script - self.parameters = parameters - - -class RunCommandInputParameter(_serialization.Model): - """Describes the properties of a run command parameter. - - All required parameters must be populated in order to send to server. - - :ivar name: The run command parameter name. Required. - :vartype name: str - :ivar value: The run command parameter value. Required. - :vartype value: str - """ - - _validation = { - "name": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: - """ - :keyword name: The run command parameter name. Required. - :paramtype name: str - :keyword value: The run command parameter value. Required. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class RunCommandListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine run commands. Required. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.RunCommandDocumentBase] - :ivar next_link: The uri to fetch the next page of run commands. Call ListNext() with this to - fetch the next page of run commands. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RunCommandDocumentBase]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine run commands. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_06_01.models.RunCommandDocumentBase] - :keyword next_link: The uri to fetch the next page of run commands. Call ListNext() with this - to fetch the next page of run commands. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RunCommandParameterDefinition(_serialization.Model): - """Describes the properties of a run command parameter. - - All required parameters must be populated in order to send to server. - - :ivar name: The run command parameter name. Required. - :vartype name: str - :ivar type: The run command parameter type. Required. - :vartype type: str - :ivar default_value: The run command parameter default value. - :vartype default_value: str - :ivar required: The run command parameter required. - :vartype required: bool - """ - - _validation = { - "name": {"required": True}, - "type": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "default_value": {"key": "defaultValue", "type": "str"}, - "required": {"key": "required", "type": "bool"}, - } - - def __init__( - self, *, name: str, type: str, default_value: Optional[str] = None, required: bool = False, **kwargs: Any - ) -> None: - """ - :keyword name: The run command parameter name. Required. - :paramtype name: str - :keyword type: The run command parameter type. Required. - :paramtype type: str - :keyword default_value: The run command parameter default value. - :paramtype default_value: str - :keyword required: The run command parameter required. - :paramtype required: bool - """ - super().__init__(**kwargs) - self.name = name - self.type = type - self.default_value = default_value - self.required = required - - -class RunCommandResult(_serialization.Model): - """RunCommandResult. - - :ivar value: Run command operation response. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[InstanceViewStatus]"}, - } - - def __init__(self, *, value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Run command operation response. - :paramtype value: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.value = value - - -class ScaleInPolicy(_serialization.Model): - """Describes a scale-in policy for a virtual machine scale set. - - :ivar rules: The rules to be followed when scaling-in a virtual machine scale set. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Default** When a - virtual machine scale set is scaled in, the scale set will first be balanced across zones if it - is a zonal scale set. Then, it will be balanced across Fault Domains as far as possible. Within - each Fault Domain, the virtual machines chosen for removal will be the newest ones that are not - protected from scale-in. :code:`
    `\\ :code:`
    ` **OldestVM** When a virtual machine scale - set is being scaled-in, the oldest virtual machines that are not protected from scale-in will - be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the oldest virtual machines that are not protected - will be chosen for removal. :code:`
    `\\ :code:`
    ` **NewestVM** When a virtual machine - scale set is being scaled-in, the newest virtual machines that are not protected from scale-in - will be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the newest virtual machines that are not protected - will be chosen for removal. :code:`
    `\\ :code:`
    `. - :vartype rules: list[str or - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetScaleInRules] - """ - - _attribute_map = { - "rules": {"key": "rules", "type": "[str]"}, - } - - def __init__( - self, *, rules: Optional[List[Union[str, "_models.VirtualMachineScaleSetScaleInRules"]]] = None, **kwargs: Any - ) -> None: - """ - :keyword rules: The rules to be followed when scaling-in a virtual machine scale set. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Default** When a - virtual machine scale set is scaled in, the scale set will first be balanced across zones if it - is a zonal scale set. Then, it will be balanced across Fault Domains as far as possible. Within - each Fault Domain, the virtual machines chosen for removal will be the newest ones that are not - protected from scale-in. :code:`
    `\\ :code:`
    ` **OldestVM** When a virtual machine scale - set is being scaled-in, the oldest virtual machines that are not protected from scale-in will - be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the oldest virtual machines that are not protected - will be chosen for removal. :code:`
    `\\ :code:`
    ` **NewestVM** When a virtual machine - scale set is being scaled-in, the newest virtual machines that are not protected from scale-in - will be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the newest virtual machines that are not protected - will be chosen for removal. :code:`
    `\\ :code:`
    `. - :paramtype rules: list[str or - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetScaleInRules] - """ - super().__init__(**kwargs) - self.rules = rules - - -class ScheduledEventsProfile(_serialization.Model): - """ScheduledEventsProfile. - - :ivar terminate_notification_profile: Specifies Terminate Scheduled Event related - configurations. - :vartype terminate_notification_profile: - ~azure.mgmt.compute.v2020_06_01.models.TerminateNotificationProfile - """ - - _attribute_map = { - "terminate_notification_profile": { - "key": "terminateNotificationProfile", - "type": "TerminateNotificationProfile", - }, - } - - def __init__( - self, *, terminate_notification_profile: Optional["_models.TerminateNotificationProfile"] = None, **kwargs: Any - ) -> None: - """ - :keyword terminate_notification_profile: Specifies Terminate Scheduled Event related - configurations. - :paramtype terminate_notification_profile: - ~azure.mgmt.compute.v2020_06_01.models.TerminateNotificationProfile - """ - super().__init__(**kwargs) - self.terminate_notification_profile = terminate_notification_profile - - -class SecurityProfile(_serialization.Model): - """Specifies the Security profile settings for the virtual machine or virtual machine scale set. - - :ivar encryption_at_host: This property can be used by user in the request to enable or disable - the Host Encryption for the virtual machine or virtual machine scale set. This will enable the - encryption for all the disks including Resource/Temp disk at host itself. :code:`
    `\\ - :code:`
    ` Default: The Encryption at host will be disabled unless this property is set to - true for the resource. - :vartype encryption_at_host: bool - """ - - _attribute_map = { - "encryption_at_host": {"key": "encryptionAtHost", "type": "bool"}, - } - - def __init__(self, *, encryption_at_host: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword encryption_at_host: This property can be used by user in the request to enable or - disable the Host Encryption for the virtual machine or virtual machine scale set. This will - enable the encryption for all the disks including Resource/Temp disk at host itself. - :code:`
    `\\ :code:`
    ` Default: The Encryption at host will be disabled unless this - property is set to true for the resource. - :paramtype encryption_at_host: bool - """ - super().__init__(**kwargs) - self.encryption_at_host = encryption_at_host - - -class Sku(_serialization.Model): - """Describes a virtual machine scale set sku. NOTE: If the new VM SKU is not supported on the - hardware the scale set is currently on, you need to deallocate the VMs in the scale set before - you modify the SKU name. - - :ivar name: The sku name. - :vartype name: str - :ivar tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
    `\\ - :code:`
    ` Possible Values:\\ :code:`
    `\\ :code:`
    ` **Standard**\\ :code:`
    `\\ :code:`
    ` **Basic**. - :vartype tier: str - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: int - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "capacity": {"key": "capacity", "type": "int"}, - } - - def __init__( - self, *, name: Optional[str] = None, tier: Optional[str] = None, capacity: Optional[int] = None, **kwargs: Any - ) -> None: - """ - :keyword name: The sku name. - :paramtype name: str - :keyword tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
    `\\ - :code:`
    ` Possible Values:\\ :code:`
    `\\ :code:`
    ` **Standard**\\ :code:`
    `\\ :code:`
    ` **Basic**. - :paramtype tier: str - :keyword capacity: Specifies the number of virtual machines in the scale set. - :paramtype capacity: int - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - self.capacity = capacity - - -class SshConfiguration(_serialization.Model): - """SSH configuration for Linux based VMs running on Azure. - - :ivar public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :vartype public_keys: list[~azure.mgmt.compute.v2020_06_01.models.SshPublicKey] - """ - - _attribute_map = { - "public_keys": {"key": "publicKeys", "type": "[SshPublicKey]"}, - } - - def __init__(self, *, public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs: Any) -> None: - """ - :keyword public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :paramtype public_keys: list[~azure.mgmt.compute.v2020_06_01.models.SshPublicKey] - """ - super().__init__(**kwargs) - self.public_keys = public_keys - - -class SshPublicKey(_serialization.Model): - """Contains information about SSH certificate public key and the path on the Linux VM where the - public key is placed. - - :ivar path: Specifies the full path on the created VM where ssh public key is stored. If the - file already exists, the specified key is appended to the file. Example: - /home/user/.ssh/authorized_keys. - :vartype path: str - :ivar key_data: SSH public key certificate used to authenticate with the VM through ssh. The - key needs to be at least 2048-bit and in ssh-rsa format. :code:`
    `\\ :code:`
    ` For - creating ssh keys, see `Create SSH keys on Linux and Mac for Linux VMs in Azure - `_. - :vartype key_data: str - """ - - _attribute_map = { - "path": {"key": "path", "type": "str"}, - "key_data": {"key": "keyData", "type": "str"}, - } - - def __init__(self, *, path: Optional[str] = None, key_data: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword path: Specifies the full path on the created VM where ssh public key is stored. If the - file already exists, the specified key is appended to the file. Example: - /home/user/.ssh/authorized_keys. - :paramtype path: str - :keyword key_data: SSH public key certificate used to authenticate with the VM through ssh. The - key needs to be at least 2048-bit and in ssh-rsa format. :code:`
    `\\ :code:`
    ` For - creating ssh keys, see `Create SSH keys on Linux and Mac for Linux VMs in Azure - `_. - :paramtype key_data: str - """ - super().__init__(**kwargs) - self.path = path - self.key_data = key_data - - -class SshPublicKeyGenerateKeyPairResult(_serialization.Model): - """Response from generation of an SSH key pair. - - All required parameters must be populated in order to send to server. - - :ivar private_key: Private key portion of the key pair used to authenticate to a virtual - machine through ssh. The private key is returned in RFC3447 format and should be treated as a - secret. Required. - :vartype private_key: str - :ivar public_key: Public key portion of the key pair used to authenticate to a virtual machine - through ssh. The public key is in ssh-rsa format. Required. - :vartype public_key: str - :ivar id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{SshPublicKeyName}. - Required. - :vartype id: str - """ - - _validation = { - "private_key": {"required": True}, - "public_key": {"required": True}, - "id": {"required": True}, - } - - _attribute_map = { - "private_key": {"key": "privateKey", "type": "str"}, - "public_key": {"key": "publicKey", "type": "str"}, - "id": {"key": "id", "type": "str"}, - } - - def __init__( - self, *, private_key: str, public_key: str, id: str, **kwargs: Any # pylint: disable=redefined-builtin - ) -> None: - """ - :keyword private_key: Private key portion of the key pair used to authenticate to a virtual - machine through ssh. The private key is returned in RFC3447 format and should be treated as a - secret. Required. - :paramtype private_key: str - :keyword public_key: Public key portion of the key pair used to authenticate to a virtual - machine through ssh. The public key is in ssh-rsa format. Required. - :paramtype public_key: str - :keyword id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{SshPublicKeyName}. - Required. - :paramtype id: str - """ - super().__init__(**kwargs) - self.private_key = private_key - self.public_key = public_key - self.id = id - - -class SshPublicKeyResource(Resource): - """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. - :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] - :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, - the provided public key needs to be at least 2048-bit and in ssh-rsa format. - :vartype public_key: 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}"}, - "public_key": {"key": "properties.publicKey", "type": "str"}, - } - - 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 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) - self.public_key = public_key - - -class SshPublicKeysGroupListResult(_serialization.Model): - """The list SSH public keys operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of SSH public keys. Required. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.SshPublicKeyResource] - :ivar next_link: The URI to fetch the next page of SSH public keys. Call ListNext() with this - URI to fetch the next page of SSH public keys. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SshPublicKeyResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.SshPublicKeyResource"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of SSH public keys. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_06_01.models.SshPublicKeyResource] - :keyword next_link: The URI to fetch the next page of SSH public keys. Call ListNext() with - this URI to fetch the next page of SSH public keys. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SshPublicKeyUpdateResource(UpdateResource): - """Specifies information about the SSH public key. - - :ivar tags: Resource tags. - :vartype tags: dict[str, 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, - the provided public key needs to be at least 2048-bit and in ssh-rsa format. - :vartype public_key: str - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "public_key": {"key": "properties.publicKey", "type": "str"}, - } - - def __init__( - self, *, tags: Optional[Dict[str, str]] = None, public_key: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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__(tags=tags, **kwargs) - self.public_key = public_key - - -class StorageProfile(_serialization.Model): - """Specifies the storage settings for the virtual machine disks. - - :ivar image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :vartype image_reference: ~azure.mgmt.compute.v2020_06_01.models.ImageReference - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2020_06_01.models.OSDisk - :ivar data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype data_disks: list[~azure.mgmt.compute.v2020_06_01.models.DataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "OSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[DataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.OSDisk"] = None, - data_disks: Optional[List["_models.DataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :paramtype image_reference: ~azure.mgmt.compute.v2020_06_01.models.ImageReference - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2020_06_01.models.OSDisk - :keyword data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype data_disks: list[~azure.mgmt.compute.v2020_06_01.models.DataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class SubResourceReadOnly(_serialization.Model): - """SubResourceReadOnly. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class SubResourceWithColocationStatus(SubResource): - """SubResourceWithColocationStatus. - - :ivar id: Resource Id. - :vartype id: str - :ivar colocation_status: Describes colocation status of a resource in the Proximity Placement - Group. - :vartype colocation_status: ~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "colocation_status": {"key": "colocationStatus", "type": "InstanceViewStatus"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - colocation_status: Optional["_models.InstanceViewStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword colocation_status: Describes colocation status of a resource in the Proximity - Placement Group. - :paramtype colocation_status: ~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus - """ - super().__init__(id=id, **kwargs) - self.colocation_status = colocation_status - - -class TerminateNotificationProfile(_serialization.Model): - """TerminateNotificationProfile. - - :ivar not_before_timeout: Configurable length of time a Virtual Machine being deleted will have - to potentially approve the Terminate Scheduled Event before the event is auto approved (timed - out). The configuration must be specified in ISO 8601 format, the default value is 5 minutes - (PT5M). - :vartype not_before_timeout: str - :ivar enable: Specifies whether the Terminate Scheduled event is enabled or disabled. - :vartype enable: bool - """ - - _attribute_map = { - "not_before_timeout": {"key": "notBeforeTimeout", "type": "str"}, - "enable": {"key": "enable", "type": "bool"}, - } - - def __init__( - self, *, not_before_timeout: Optional[str] = None, enable: Optional[bool] = None, **kwargs: Any - ) -> None: - """ - :keyword not_before_timeout: Configurable length of time a Virtual Machine being deleted will - have to potentially approve the Terminate Scheduled Event before the event is auto approved - (timed out). The configuration must be specified in ISO 8601 format, the default value is 5 - minutes (PT5M). - :paramtype not_before_timeout: str - :keyword enable: Specifies whether the Terminate Scheduled event is enabled or disabled. - :paramtype enable: bool - """ - super().__init__(**kwargs) - self.not_before_timeout = not_before_timeout - self.enable = enable - - -class ThrottledRequestsInput(LogAnalyticsInputBase): - """Api request input for LogAnalytics getThrottledRequests Api. - - All required parameters must be populated in order to send to server. - - :ivar blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api - writes output logs to. Required. - :vartype blob_container_sas_uri: str - :ivar from_time: From time of the query. Required. - :vartype from_time: ~datetime.datetime - :ivar to_time: To time of the query. Required. - :vartype to_time: ~datetime.datetime - :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. - :vartype group_by_throttle_policy: bool - :ivar group_by_operation_name: Group query result by Operation Name. - :vartype group_by_operation_name: bool - :ivar group_by_resource_name: Group query result by Resource Name. - :vartype group_by_resource_name: bool - :ivar group_by_client_application_id: Group query result by Client Application ID. - :vartype group_by_client_application_id: bool - :ivar group_by_user_agent: Group query result by User Agent. - :vartype group_by_user_agent: bool - """ - - -class UpgradeOperationHistoricalStatusInfo(_serialization.Model): - """Virtual Machine Scale Set OS Upgrade History operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar properties: Information about the properties of the upgrade operation. - :vartype properties: - ~azure.mgmt.compute.v2020_06_01.models.UpgradeOperationHistoricalStatusInfoProperties - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - """ - - _validation = { - "properties": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "properties": {"key": "properties", "type": "UpgradeOperationHistoricalStatusInfoProperties"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.properties: Optional["_models.UpgradeOperationHistoricalStatusInfoProperties"] = None - self.type: Optional[str] = None - self.location: Optional[str] = None - - -class UpgradeOperationHistoricalStatusInfoProperties(_serialization.Model): # pylint: disable=name-too-long - """Describes each OS upgrade on the Virtual Machine Scale Set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar running_status: Information about the overall status of the upgrade operation. - :vartype running_status: ~azure.mgmt.compute.v2020_06_01.models.UpgradeOperationHistoryStatus - :ivar progress: Counts of the VMs in each state. - :vartype progress: ~azure.mgmt.compute.v2020_06_01.models.RollingUpgradeProgressInfo - :ivar error: Error Details for this upgrade if there are any. - :vartype error: ~azure.mgmt.compute.v2020_06_01.models.ApiError - :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", and - "Platform". - :vartype started_by: str or ~azure.mgmt.compute.v2020_06_01.models.UpgradeOperationInvoker - :ivar target_image_reference: Image Reference details. - :vartype target_image_reference: ~azure.mgmt.compute.v2020_06_01.models.ImageReference - :ivar rollback_info: Information about OS rollback if performed. - :vartype rollback_info: ~azure.mgmt.compute.v2020_06_01.models.RollbackStatusInfo - """ - - _validation = { - "running_status": {"readonly": True}, - "progress": {"readonly": True}, - "error": {"readonly": True}, - "started_by": {"readonly": True}, - "target_image_reference": {"readonly": True}, - "rollback_info": {"readonly": True}, - } - - _attribute_map = { - "running_status": {"key": "runningStatus", "type": "UpgradeOperationHistoryStatus"}, - "progress": {"key": "progress", "type": "RollingUpgradeProgressInfo"}, - "error": {"key": "error", "type": "ApiError"}, - "started_by": {"key": "startedBy", "type": "str"}, - "target_image_reference": {"key": "targetImageReference", "type": "ImageReference"}, - "rollback_info": {"key": "rollbackInfo", "type": "RollbackStatusInfo"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.running_status: Optional["_models.UpgradeOperationHistoryStatus"] = None - self.progress: Optional["_models.RollingUpgradeProgressInfo"] = None - self.error: Optional["_models.ApiError"] = None - self.started_by: Optional[Union[str, "_models.UpgradeOperationInvoker"]] = None - self.target_image_reference: Optional["_models.ImageReference"] = None - self.rollback_info: Optional["_models.RollbackStatusInfo"] = None - - -class UpgradeOperationHistoryStatus(_serialization.Model): - """Information about the current running state of the overall upgrade. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Code indicating the current status of the upgrade. Known values are: - "RollingForward", "Cancelled", "Completed", and "Faulted". - :vartype code: str or ~azure.mgmt.compute.v2020_06_01.models.UpgradeState - :ivar start_time: Start time of the upgrade. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the upgrade. - :vartype end_time: ~datetime.datetime - """ - - _validation = { - "code": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[Union[str, "_models.UpgradeState"]] = None - self.start_time: Optional[datetime.datetime] = None - self.end_time: Optional[datetime.datetime] = None - - -class UpgradePolicy(_serialization.Model): - """Describes an upgrade policy - automatic, manual, or rolling. - - :ivar mode: Specifies the mode of an upgrade to virtual machines in the scale set.\\ :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Manual** - You - control the application of updates to virtual machines in the scale set. You do this by using - the manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - All virtual - machines in the scale set are automatically updated at the same time. Known values are: - "Automatic", "Manual", and "Rolling". - :vartype mode: str or ~azure.mgmt.compute.v2020_06_01.models.UpgradeMode - :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling - upgrade. - :vartype rolling_upgrade_policy: ~azure.mgmt.compute.v2020_06_01.models.RollingUpgradePolicy - :ivar automatic_os_upgrade_policy: Configuration parameters used for performing automatic OS - Upgrade. - :vartype automatic_os_upgrade_policy: - ~azure.mgmt.compute.v2020_06_01.models.AutomaticOSUpgradePolicy - """ - - _attribute_map = { - "mode": {"key": "mode", "type": "str"}, - "rolling_upgrade_policy": {"key": "rollingUpgradePolicy", "type": "RollingUpgradePolicy"}, - "automatic_os_upgrade_policy": {"key": "automaticOSUpgradePolicy", "type": "AutomaticOSUpgradePolicy"}, - } - - def __init__( - self, - *, - mode: Optional[Union[str, "_models.UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, - automatic_os_upgrade_policy: Optional["_models.AutomaticOSUpgradePolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword mode: Specifies the mode of an upgrade to virtual machines in the scale set.\\ - :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` - **Manual** - You control the application of updates to virtual machines in the scale set. You - do this by using the manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - - All virtual machines in the scale set are automatically updated at the same time. Known values - are: "Automatic", "Manual", and "Rolling". - :paramtype mode: str or ~azure.mgmt.compute.v2020_06_01.models.UpgradeMode - :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling - upgrade. - :paramtype rolling_upgrade_policy: ~azure.mgmt.compute.v2020_06_01.models.RollingUpgradePolicy - :keyword automatic_os_upgrade_policy: Configuration parameters used for performing automatic OS - Upgrade. - :paramtype automatic_os_upgrade_policy: - ~azure.mgmt.compute.v2020_06_01.models.AutomaticOSUpgradePolicy - """ - super().__init__(**kwargs) - self.mode = mode - self.rolling_upgrade_policy = rolling_upgrade_policy - self.automatic_os_upgrade_policy = automatic_os_upgrade_policy - - -class Usage(_serialization.Model): - """Describes Compute Resource Usage. - - 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 unit: An enum describing the unit of usage measurement. Required. Default value is - "Count". - :vartype unit: str - :ivar current_value: The current usage of the resource. Required. - :vartype current_value: int - :ivar limit: The maximum permitted usage of the resource. Required. - :vartype limit: int - :ivar name: The name of the type of usage. Required. - :vartype name: ~azure.mgmt.compute.v2020_06_01.models.UsageName - """ - - _validation = { - "unit": {"required": True, "constant": True}, - "current_value": {"required": True}, - "limit": {"required": True}, - "name": {"required": True}, - } - - _attribute_map = { - "unit": {"key": "unit", "type": "str"}, - "current_value": {"key": "currentValue", "type": "int"}, - "limit": {"key": "limit", "type": "int"}, - "name": {"key": "name", "type": "UsageName"}, - } - - unit = "Count" - - def __init__(self, *, current_value: int, limit: int, name: "_models.UsageName", **kwargs: Any) -> None: - """ - :keyword current_value: The current usage of the resource. Required. - :paramtype current_value: int - :keyword limit: The maximum permitted usage of the resource. Required. - :paramtype limit: int - :keyword name: The name of the type of usage. Required. - :paramtype name: ~azure.mgmt.compute.v2020_06_01.models.UsageName - """ - super().__init__(**kwargs) - self.current_value = current_value - self.limit = limit - self.name = name - - -class UsageName(_serialization.Model): - """The Usage Names. - - :ivar value: The name of the resource. - :vartype value: str - :ivar localized_value: The localized name of the resource. - :vartype localized_value: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, - } - - def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The name of the resource. - :paramtype value: str - :keyword localized_value: The localized name of the resource. - :paramtype localized_value: str - """ - super().__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - -class UserAssignedIdentitiesValue(_serialization.Model): - """UserAssignedIdentitiesValue. - - 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: Optional[str] = None - self.client_id: Optional[str] = None - - -class VaultCertificate(_serialization.Model): - """Describes a single certificate reference in a Key Vault, and where the certificate should - reside on the VM. - - :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as - a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :vartype certificate_url: str - :ivar certificate_store: For Windows VMs, specifies the certificate store on the Virtual - Machine to which the certificate should be added. The specified certificate store is implicitly - in the LocalMachine account. :code:`
    `\\ :code:`
    `For Linux VMs, the certificate file is - placed under the /var/lib/waagent directory, with the file name <UppercaseThumbprint>.crt - for the X509 certificate file and <UppercaseThumbprint>.prv for private key. Both of - these files are .pem formatted. - :vartype certificate_store: str - """ - - _attribute_map = { - "certificate_url": {"key": "certificateUrl", "type": "str"}, - "certificate_store": {"key": "certificateStore", "type": "str"}, - } - - def __init__( - self, *, certificate_url: Optional[str] = None, certificate_store: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault - as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :paramtype certificate_url: str - :keyword certificate_store: For Windows VMs, specifies the certificate store on the Virtual - Machine to which the certificate should be added. The specified certificate store is implicitly - in the LocalMachine account. :code:`
    `\\ :code:`
    `For Linux VMs, the certificate file is - placed under the /var/lib/waagent directory, with the file name <UppercaseThumbprint>.crt - for the X509 certificate file and <UppercaseThumbprint>.prv for private key. Both of - these files are .pem formatted. - :paramtype certificate_store: str - """ - super().__init__(**kwargs) - self.certificate_url = certificate_url - self.certificate_store = certificate_store - - -class VaultSecretGroup(_serialization.Model): - """Describes a set of certificates which are all in the same Key Vault. - - :ivar source_vault: The relative URL of the Key Vault containing all of the certificates in - VaultCertificates. - :vartype source_vault: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar vault_certificates: The list of key vault references in SourceVault which contain - certificates. - :vartype vault_certificates: list[~azure.mgmt.compute.v2020_06_01.models.VaultCertificate] - """ - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - "vault_certificates": {"key": "vaultCertificates", "type": "[VaultCertificate]"}, - } - - def __init__( - self, - *, - source_vault: Optional["_models.SubResource"] = None, - vault_certificates: Optional[List["_models.VaultCertificate"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source_vault: The relative URL of the Key Vault containing all of the certificates in - VaultCertificates. - :paramtype source_vault: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword vault_certificates: The list of key vault references in SourceVault which contain - certificates. - :paramtype vault_certificates: list[~azure.mgmt.compute.v2020_06_01.models.VaultCertificate] - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.vault_certificates = vault_certificates - - -class VirtualHardDisk(_serialization.Model): - """Describes the uri of a disk. - - :ivar uri: Specifies the virtual hard disk's uri. - :vartype uri: str - """ - - _attribute_map = { - "uri": {"key": "uri", "type": "str"}, - } - - def __init__(self, *, uri: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword uri: Specifies the virtual hard disk's uri. - :paramtype uri: str - """ - super().__init__(**kwargs) - self.uri = uri - - -class VirtualMachine(Resource): - """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. - :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] - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2020_06_01.models.Plan - :ivar resources: The virtual machine child extension resources. - :vartype resources: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtension] - :ivar identity: The identity of the virtual machine, if configured. - :vartype identity: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineIdentity - :ivar zones: The virtual machine zones. - :vartype zones: list[str] - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2020_06_01.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2020_06_01.models.StorageProfile - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine. - :vartype additional_capabilities: ~azure.mgmt.compute.v2020_06_01.models.AdditionalCapabilities - :ivar os_profile: Specifies the operating system settings used while creating the virtual - machine. Some of the settings cannot be changed once VM is provisioned. - :vartype os_profile: ~azure.mgmt.compute.v2020_06_01.models.OSProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2020_06_01.models.NetworkProfile - :ivar security_profile: Specifies the Security related profile settings for the virtual - machine. - :vartype security_profile: ~azure.mgmt.compute.v2020_06_01.models.SecurityProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2020_06_01.models.DiagnosticsProfile - :ivar availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. The availability set to which the VM is being added should be under the same resource - group as the availability set resource. An existing VM cannot be added to an availability set. - :code:`
    `\\ :code:`
    `This property cannot exist along with a non-null - properties.virtualMachineScaleSet reference. - :vartype availability_set: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar virtual_machine_scale_set: Specifies information about the virtual machine scale set that - the virtual machine should be assigned to. Virtual machines specified in the same virtual - machine scale set are allocated to different nodes to maximize availability. Currently, a VM - can only be added to virtual machine scale set at creation time. An existing VM cannot be added - to a virtual machine scale set. :code:`
    `\\ :code:`
    `This property cannot exist along - with a non-null properties.availabilitySet reference. :code:`
    `\\ :code:`
    `Minimum - api‐version: 2019‐03‐01. - :vartype virtual_machine_scale_set: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the virtual machine should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar priority: Specifies the priority for the virtual machine. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :vartype priority: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachinePriorityTypes - :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, both - 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. - :code:`
    `\\ :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are - supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and - "Delete". - :vartype eviction_policy: str or - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineEvictionPolicyTypes - :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2020_06_01.models.BillingProfile - :ivar host: Specifies information about the dedicated host that the virtual machine resides in. - :code:`
    `\\ :code:`
    `Minimum api-version: 2018-10-01. - :vartype host: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar host_group: Specifies information about the dedicated host group that the virtual machine - resides in. :code:`
    `\\ :code:`
    `Minimum api-version: 2020-06-01. :code:`
    `\\ - :code:`
    `NOTE: User cannot specify both host and hostGroup properties. - :vartype host_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineInstanceView - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. :code:`
    `\\ :code:`
    ` Possible values for Windows Server operating system - are: :code:`
    `\\ :code:`
    ` Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server - :code:`
    `\\ :code:`
    ` Possible values for Linux Server operating system are: - :code:`
    `\\ :code:`
    ` RHEL_BYOS (for RHEL) :code:`
    `\\ :code:`
    ` SLES_BYOS (for - SUSE) :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid Use Benefit for - Windows Server - `_ - :code:`
    `\\ :code:`
    ` `Azure Hybrid Use Benefit for Linux Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar vm_id: Specifies the VM unique ID which is a 128-bits identifier that is encoded and - stored in all Azure IaaS VMs SMBIOS and can be read using platform BIOS commands. - :vartype vm_id: str - :ivar extensions_time_budget: Specifies the time alloted for all extensions to start. The time - duration should be between 15 minutes and 120 minutes (inclusive) and should be specified in - ISO 8601 format. The default value is 90 minutes (PT1H30M). :code:`
    `\\ :code:`
    ` Minimum - api-version: 2020-06-01. - :vartype extensions_time_budget: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "resources": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - "vm_id": {"readonly": 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}"}, - "plan": {"key": "plan", "type": "Plan"}, - "resources": {"key": "resources", "type": "[VirtualMachineExtension]"}, - "identity": {"key": "identity", "type": "VirtualMachineIdentity"}, - "zones": {"key": "zones", "type": "[str]"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "security_profile": {"key": "properties.securityProfile", "type": "SecurityProfile"}, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "virtual_machine_scale_set": {"key": "properties.virtualMachineScaleSet", "type": "SubResource"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "priority": {"key": "properties.priority", "type": "str"}, - "eviction_policy": {"key": "properties.evictionPolicy", "type": "str"}, - "billing_profile": {"key": "properties.billingProfile", "type": "BillingProfile"}, - "host": {"key": "properties.host", "type": "SubResource"}, - "host_group": {"key": "properties.hostGroup", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineInstanceView"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - "extensions_time_budget": {"key": "properties.extensionsTimeBudget", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineIdentity"] = None, - zones: Optional[List[str]] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - os_profile: Optional["_models.OSProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - security_profile: Optional["_models.SecurityProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - virtual_machine_scale_set: Optional["_models.SubResource"] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["_models.BillingProfile"] = None, - host: Optional["_models.SubResource"] = None, - host_group: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - extensions_time_budget: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2020_06_01.models.Plan - :keyword identity: The identity of the virtual machine, if configured. - :paramtype identity: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineIdentity - :keyword zones: The virtual machine zones. - :paramtype zones: list[str] - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2020_06_01.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2020_06_01.models.StorageProfile - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2020_06_01.models.AdditionalCapabilities - :keyword os_profile: Specifies the operating system settings used while creating the virtual - machine. Some of the settings cannot be changed once VM is provisioned. - :paramtype os_profile: ~azure.mgmt.compute.v2020_06_01.models.OSProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2020_06_01.models.NetworkProfile - :keyword security_profile: Specifies the Security related profile settings for the virtual - machine. - :paramtype security_profile: ~azure.mgmt.compute.v2020_06_01.models.SecurityProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2020_06_01.models.DiagnosticsProfile - :keyword availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. The availability set to which the VM is being added should be under the same resource - group as the availability set resource. An existing VM cannot be added to an availability set. - :code:`
    `\\ :code:`
    `This property cannot exist along with a non-null - properties.virtualMachineScaleSet reference. - :paramtype availability_set: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword virtual_machine_scale_set: Specifies information about the virtual machine scale set - that the virtual machine should be assigned to. Virtual machines specified in the same virtual - machine scale set are allocated to different nodes to maximize availability. Currently, a VM - can only be added to virtual machine scale set at creation time. An existing VM cannot be added - to a virtual machine scale set. :code:`
    `\\ :code:`
    `This property cannot exist along - with a non-null properties.availabilitySet reference. :code:`
    `\\ :code:`
    `Minimum - api‐version: 2019‐03‐01. - :paramtype virtual_machine_scale_set: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the virtual machine should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword priority: Specifies the priority for the virtual machine. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :paramtype priority: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachinePriorityTypes - :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, both - 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. - :code:`
    `\\ :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are - supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and - "Delete". - :paramtype eviction_policy: str or - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineEvictionPolicyTypes - :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual - machine. :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2020_06_01.models.BillingProfile - :keyword host: Specifies information about the dedicated host that the virtual machine resides - in. :code:`
    `\\ :code:`
    `Minimum api-version: 2018-10-01. - :paramtype host: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword host_group: Specifies information about the dedicated host group that the virtual - machine resides in. :code:`
    `\\ :code:`
    `Minimum api-version: 2020-06-01. :code:`
    `\\ - :code:`
    `NOTE: User cannot specify both host and hostGroup properties. - :paramtype host_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. :code:`
    `\\ :code:`
    ` Possible values for Windows Server operating system - are: :code:`
    `\\ :code:`
    ` Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server - :code:`
    `\\ :code:`
    ` Possible values for Linux Server operating system are: - :code:`
    `\\ :code:`
    ` RHEL_BYOS (for RHEL) :code:`
    `\\ :code:`
    ` SLES_BYOS (for - SUSE) :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid Use Benefit for - Windows Server - `_ - :code:`
    `\\ :code:`
    ` `Azure Hybrid Use Benefit for Linux Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - :keyword extensions_time_budget: Specifies the time alloted for all extensions to start. The - time duration should be between 15 minutes and 120 minutes (inclusive) and should be specified - in ISO 8601 format. The default value is 90 minutes (PT1H30M). :code:`
    `\\ :code:`
    ` - Minimum api-version: 2020-06-01. - :paramtype extensions_time_budget: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.plan = plan - self.resources: Optional[List["_models.VirtualMachineExtension"]] = None - self.identity = identity - self.zones = zones - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.additional_capabilities = additional_capabilities - self.os_profile = os_profile - self.network_profile = network_profile - self.security_profile = security_profile - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.virtual_machine_scale_set = virtual_machine_scale_set - self.proximity_placement_group = proximity_placement_group - self.priority = priority - self.eviction_policy = eviction_policy - self.billing_profile = billing_profile - self.host = host - self.host_group = host_group - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineInstanceView"] = None - self.license_type = license_type - self.vm_id: Optional[str] = None - self.extensions_time_budget = extensions_time_budget - - -class VirtualMachineAgentInstanceView(_serialization.Model): - """The instance view of the VM Agent running on the virtual machine. - - :ivar vm_agent_version: The VM Agent full version. - :vartype vm_agent_version: str - :ivar extension_handlers: The virtual machine extension handler instance view. - :vartype extension_handlers: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionHandlerInstanceView] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "vm_agent_version": {"key": "vmAgentVersion", "type": "str"}, - "extension_handlers": {"key": "extensionHandlers", "type": "[VirtualMachineExtensionHandlerInstanceView]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword vm_agent_version: The VM Agent full version. - :paramtype vm_agent_version: str - :keyword extension_handlers: The virtual machine extension handler instance view. - :paramtype extension_handlers: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionHandlerInstanceView] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.vm_agent_version = vm_agent_version - self.extension_handlers = extension_handlers - self.statuses = statuses - - -class VirtualMachineAssessPatchesResult(_serialization.Model): - """Describes the properties of an AssessPatches result. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The overall success or failure status of the operation. It remains "InProgress" - until the operation completes. At that point it will become "Failed", "Succeeded", or - "CompletedWithWarnings.". Known values are: "InProgress", "Failed", "Succeeded", and - "CompletedWithWarnings". - :vartype status: str or ~azure.mgmt.compute.v2020_06_01.models.PatchOperationStatus - :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is - used to correlate across CRP and extension logs. - :vartype assessment_activity_id: str - :ivar reboot_pending: The overall reboot status of the VM. It will be true when partially - installed patches require a reboot to complete installation but the reboot has not yet - occurred. - :vartype reboot_pending: bool - :ivar critical_and_security_patch_count: The number of critical or security patches that have - been detected as available and not yet installed. - :vartype critical_and_security_patch_count: int - :ivar other_patch_count: The number of all available patches excluding critical and security. - :vartype other_patch_count: int - :ivar start_date_time: The UTC timestamp when the operation began. - :vartype start_date_time: ~datetime.datetime - :ivar patches: The list of patches that have been detected as available for installation. - :vartype patches: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineSoftwarePatchProperties] - :ivar error: The errors that were encountered during execution of the operation. The details - array contains the list of them. - :vartype error: ~azure.mgmt.compute.v2020_06_01.models.ApiError - """ - - _validation = { - "status": {"readonly": True}, - "assessment_activity_id": {"readonly": True}, - "reboot_pending": {"readonly": True}, - "critical_and_security_patch_count": {"readonly": True}, - "other_patch_count": {"readonly": True}, - "start_date_time": {"readonly": True}, - "patches": {"readonly": True}, - "error": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "assessment_activity_id": {"key": "assessmentActivityId", "type": "str"}, - "reboot_pending": {"key": "rebootPending", "type": "bool"}, - "critical_and_security_patch_count": {"key": "criticalAndSecurityPatchCount", "type": "int"}, - "other_patch_count": {"key": "otherPatchCount", "type": "int"}, - "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, - "patches": {"key": "patches", "type": "[VirtualMachineSoftwarePatchProperties]"}, - "error": {"key": "error", "type": "ApiError"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional[Union[str, "_models.PatchOperationStatus"]] = None - self.assessment_activity_id: Optional[str] = None - self.reboot_pending: Optional[bool] = None - self.critical_and_security_patch_count: Optional[int] = None - self.other_patch_count: Optional[int] = None - self.start_date_time: Optional[datetime.datetime] = None - self.patches: Optional[List["_models.VirtualMachineSoftwarePatchProperties"]] = None - self.error: Optional["_models.ApiError"] = None - - -class VirtualMachineCaptureParameters(_serialization.Model): - """Capture Virtual Machine parameters. - - All required parameters must be populated in order to send to server. - - :ivar vhd_prefix: The captured virtual hard disk's name prefix. Required. - :vartype vhd_prefix: str - :ivar destination_container_name: The destination container name. Required. - :vartype destination_container_name: str - :ivar overwrite_vhds: Specifies whether to overwrite the destination virtual hard disk, in case - of conflict. Required. - :vartype overwrite_vhds: bool - """ - - _validation = { - "vhd_prefix": {"required": True}, - "destination_container_name": {"required": True}, - "overwrite_vhds": {"required": True}, - } - - _attribute_map = { - "vhd_prefix": {"key": "vhdPrefix", "type": "str"}, - "destination_container_name": {"key": "destinationContainerName", "type": "str"}, - "overwrite_vhds": {"key": "overwriteVhds", "type": "bool"}, - } - - def __init__( - self, *, vhd_prefix: str, destination_container_name: str, overwrite_vhds: bool, **kwargs: Any - ) -> None: - """ - :keyword vhd_prefix: The captured virtual hard disk's name prefix. Required. - :paramtype vhd_prefix: str - :keyword destination_container_name: The destination container name. Required. - :paramtype destination_container_name: str - :keyword overwrite_vhds: Specifies whether to overwrite the destination virtual hard disk, in - case of conflict. Required. - :paramtype overwrite_vhds: bool - """ - super().__init__(**kwargs) - self.vhd_prefix = vhd_prefix - self.destination_container_name = destination_container_name - self.overwrite_vhds = overwrite_vhds - - -class VirtualMachineCaptureResult(SubResource): - """Output of virtual machine capture operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar schema: the schema of the captured virtual machine. - :vartype schema: str - :ivar content_version: the version of the content. - :vartype content_version: str - :ivar parameters: parameters of the captured virtual machine. - :vartype parameters: JSON - :ivar resources: a list of resource items of the captured virtual machine. - :vartype resources: list[JSON] - """ - - _validation = { - "schema": {"readonly": True}, - "content_version": {"readonly": True}, - "parameters": {"readonly": True}, - "resources": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "schema": {"key": "$schema", "type": "str"}, - "content_version": {"key": "contentVersion", "type": "str"}, - "parameters": {"key": "parameters", "type": "object"}, - "resources": {"key": "resources", "type": "[object]"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(id=id, **kwargs) - self.schema: Optional[str] = None - self.content_version: Optional[str] = None - self.parameters: Optional[JSON] = None - self.resources: Optional[List[JSON]] = None - - -class VirtualMachineExtension(Resource): - """Describes a Virtual Machine Extension. - - 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] - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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. - :vartype instance_view: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionInstanceView - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "enable_automatic_upgrade": {"key": "properties.enableAutomaticUpgrade", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineExtensionInstanceView"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, 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, - instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :keyword instance_view: The virtual machine extension instance view. - :paramtype instance_view: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionInstanceView - """ - super().__init__(location=location, tags=tags, **kwargs) - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.enable_automatic_upgrade = enable_automatic_upgrade - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - self.instance_view = instance_view - - -class VirtualMachineExtensionHandlerInstanceView(_serialization.Model): # pylint: disable=name-too-long - """The instance view of a virtual machine extension handler. - - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar status: The extension handler status. - :vartype status: ~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "status": {"key": "status", "type": "InstanceViewStatus"}, - } - - def __init__( - self, - *, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - status: Optional["_models.InstanceViewStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword status: The extension handler status. - :paramtype status: ~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus - """ - super().__init__(**kwargs) - self.type = type - self.type_handler_version = type_handler_version - self.status = status - - -class VirtualMachineExtensionImage(Resource): - """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. - :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] - :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. - :vartype compute_role: str - :ivar handler_schema: The schema defined by publisher, where extension consumers should provide - settings in a matching schema. - :vartype handler_schema: str - :ivar vm_scale_set_enabled: Whether the extension can be used on xRP VMScaleSets. By default - existing extensions are usable on scalesets, but there might be cases where a publisher wants - to explicitly indicate the extension is only enabled for CRP VMs but not VMSS. - :vartype vm_scale_set_enabled: bool - :ivar supports_multiple_extensions: Whether the handler can support multiple extensions. - :vartype supports_multiple_extensions: bool - """ - - _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}"}, - "operating_system": {"key": "properties.operatingSystem", "type": "str"}, - "compute_role": {"key": "properties.computeRole", "type": "str"}, - "handler_schema": {"key": "properties.handlerSchema", "type": "str"}, - "vm_scale_set_enabled": {"key": "properties.vmScaleSetEnabled", "type": "bool"}, - "supports_multiple_extensions": {"key": "properties.supportsMultipleExtensions", "type": "bool"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - operating_system: Optional[str] = None, - compute_role: Optional[str] = None, - handler_schema: Optional[str] = None, - vm_scale_set_enabled: Optional[bool] = None, - supports_multiple_extensions: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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. - :paramtype compute_role: str - :keyword handler_schema: The schema defined by publisher, where extension consumers should - provide settings in a matching schema. - :paramtype handler_schema: str - :keyword vm_scale_set_enabled: Whether the extension can be used on xRP VMScaleSets. By default - existing extensions are usable on scalesets, but there might be cases where a publisher wants - to explicitly indicate the extension is only enabled for CRP VMs but not VMSS. - :paramtype vm_scale_set_enabled: bool - :keyword supports_multiple_extensions: Whether the handler can support multiple extensions. - :paramtype supports_multiple_extensions: bool - """ - super().__init__(location=location, tags=tags, **kwargs) - self.operating_system = operating_system - self.compute_role = compute_role - self.handler_schema = handler_schema - self.vm_scale_set_enabled = vm_scale_set_enabled - self.supports_multiple_extensions = supports_multiple_extensions - - -class VirtualMachineExtensionInstanceView(_serialization.Model): - """The instance view of a virtual machine extension. - - :ivar name: The virtual machine extension name. - :vartype name: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar substatuses: The resource status information. - :vartype substatuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "substatuses": {"key": "substatuses", "type": "[InstanceViewStatus]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - substatuses: Optional[List["_models.InstanceViewStatus"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The virtual machine extension name. - :paramtype name: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword substatuses: The resource status information. - :paramtype substatuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.name = name - self.type = type - self.type_handler_version = type_handler_version - self.substatuses = substatuses - self.statuses = statuses - - -class VirtualMachineExtensionsListResult(_serialization.Model): - """The List Extension operation response. - - :ivar value: The list of extensions. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtension] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineExtension]"}, - } - - def __init__(self, *, value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of extensions. - :paramtype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtension] - """ - super().__init__(**kwargs) - self.value = value - - -class VirtualMachineExtensionUpdate(UpdateResource): - """Describes a Virtual Machine Extension. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "enable_automatic_upgrade": {"key": "properties.enableAutomaticUpgrade", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - force_update_tag: Optional[str] = None, - publisher: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - auto_upgrade_minor_version: Optional[bool] = None, - enable_automatic_upgrade: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - """ - super().__init__(tags=tags, **kwargs) - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type = type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.enable_automatic_upgrade = enable_automatic_upgrade - self.settings = settings - self.protected_settings = protected_settings - - -class VirtualMachineHealthStatus(_serialization.Model): - """The health status of the VM. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The health status information for the VM. - :vartype status: ~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus - """ - - _validation = { - "status": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "InstanceViewStatus"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional["_models.InstanceViewStatus"] = None - - -class VirtualMachineIdentity(_serialization.Model): - """Identity for the virtual machine. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of virtual machine identity. This property will only be - provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the virtual machine. This property will only be - provided for a system assigned identity. - :vartype tenant_id: str - :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, - UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Known values - are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :vartype type: str or ~azure.mgmt.compute.v2020_06_01.models.ResourceIdentityType - :ivar user_assigned_identities: The list of user identities associated with the Virtual - Machine. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2020_06_01.models.UserAssignedIdentitiesValue] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentitiesValue}"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, - UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Known values - are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :paramtype type: str or ~azure.mgmt.compute.v2020_06_01.models.ResourceIdentityType - :keyword user_assigned_identities: The list of user identities associated with the Virtual - Machine. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2020_06_01.models.UserAssignedIdentitiesValue] - """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.type = type - self.user_assigned_identities = user_assigned_identities - - -class VirtualMachineImageResource(SubResource): - """Virtual machine image resource information. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar location: The supported Azure location of the resource. Required. - :vartype location: str - :ivar tags: Specifies the tags that are assigned to the virtual machine. For more information - about using tags, see `Using tags to organize your Azure resources - `_. - :vartype tags: dict[str, str] - """ - - _validation = { - "name": {"required": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__( - self, - *, - name: str, - location: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The name of the resource. Required. - :paramtype name: str - :keyword location: The supported Azure location of the resource. Required. - :paramtype location: str - :keyword tags: Specifies the tags that are assigned to the virtual machine. For more - information about using tags, see `Using tags to organize your Azure resources - `_. - :paramtype tags: dict[str, str] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.location = location - self.tags = tags - - -class VirtualMachineImage(VirtualMachineImageResource): - """Describes a Virtual Machine Image. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar location: The supported Azure location of the resource. Required. - :vartype location: str - :ivar tags: Specifies the tags that are assigned to the virtual machine. For more information - about using tags, see `Using tags to organize your Azure resources - `_. - :vartype tags: dict[str, str] - :ivar plan: Used for establishing the purchase context of any 3rd Party artifact through - MarketPlace. - :vartype plan: ~azure.mgmt.compute.v2020_06_01.models.PurchasePlan - :ivar os_disk_image: Contains the os disk image information. - :vartype os_disk_image: ~azure.mgmt.compute.v2020_06_01.models.OSDiskImage - :ivar data_disk_images: - :vartype data_disk_images: list[~azure.mgmt.compute.v2020_06_01.models.DataDiskImage] - :ivar automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. - :vartype automatic_os_upgrade_properties: - ~azure.mgmt.compute.v2020_06_01.models.AutomaticOSUpgradeProperties - :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or - ~azure.mgmt.compute.v2020_06_01.models.HyperVGenerationTypes - :ivar disallowed: Specifies disallowed configuration for the VirtualMachine created from the - image. - :vartype disallowed: ~azure.mgmt.compute.v2020_06_01.models.DisallowedConfiguration - """ - - _validation = { - "name": {"required": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "plan": {"key": "properties.plan", "type": "PurchasePlan"}, - "os_disk_image": {"key": "properties.osDiskImage", "type": "OSDiskImage"}, - "data_disk_images": {"key": "properties.dataDiskImages", "type": "[DataDiskImage]"}, - "automatic_os_upgrade_properties": { - "key": "properties.automaticOSUpgradeProperties", - "type": "AutomaticOSUpgradeProperties", - }, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "disallowed": {"key": "properties.disallowed", "type": "DisallowedConfiguration"}, - } - - def __init__( - self, - *, - name: str, - location: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.PurchasePlan"] = None, - os_disk_image: Optional["_models.OSDiskImage"] = None, - data_disk_images: Optional[List["_models.DataDiskImage"]] = None, - automatic_os_upgrade_properties: Optional["_models.AutomaticOSUpgradeProperties"] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, - disallowed: Optional["_models.DisallowedConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The name of the resource. Required. - :paramtype name: str - :keyword location: The supported Azure location of the resource. Required. - :paramtype location: str - :keyword tags: Specifies the tags that are assigned to the virtual machine. For more - information about using tags, see `Using tags to organize your Azure resources - `_. - :paramtype tags: dict[str, str] - :keyword plan: Used for establishing the purchase context of any 3rd Party artifact through - MarketPlace. - :paramtype plan: ~azure.mgmt.compute.v2020_06_01.models.PurchasePlan - :keyword os_disk_image: Contains the os disk image information. - :paramtype os_disk_image: ~azure.mgmt.compute.v2020_06_01.models.OSDiskImage - :keyword data_disk_images: - :paramtype data_disk_images: list[~azure.mgmt.compute.v2020_06_01.models.DataDiskImage] - :keyword automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the - image. - :paramtype automatic_os_upgrade_properties: - ~azure.mgmt.compute.v2020_06_01.models.AutomaticOSUpgradeProperties - :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1" and - "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2020_06_01.models.HyperVGenerationTypes - :keyword disallowed: Specifies disallowed configuration for the VirtualMachine created from the - image. - :paramtype disallowed: ~azure.mgmt.compute.v2020_06_01.models.DisallowedConfiguration - """ - super().__init__(id=id, name=name, location=location, tags=tags, **kwargs) - self.plan = plan - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - self.automatic_os_upgrade_properties = automatic_os_upgrade_properties - self.hyper_v_generation = hyper_v_generation - self.disallowed = disallowed - - -class VirtualMachineInstanceView(_serialization.Model): - """The instance view of a virtual machine. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar platform_update_domain: Specifies the update domain of the virtual machine. - :vartype platform_update_domain: int - :ivar platform_fault_domain: Specifies the fault domain of the virtual machine. - :vartype platform_fault_domain: int - :ivar computer_name: The computer name assigned to the virtual machine. - :vartype computer_name: str - :ivar os_name: The Operating System running on the virtual machine. - :vartype os_name: str - :ivar os_version: The version of Operating System running on the virtual machine. - :vartype os_version: str - :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. Known - values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_06_01.models.HyperVGenerationType - :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. - :vartype rdp_thumb_print: str - :ivar vm_agent: The VM Agent running on the virtual machine. - :vartype vm_agent: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineAgentInstanceView - :ivar maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :vartype maintenance_redeploy_status: - ~azure.mgmt.compute.v2020_06_01.models.MaintenanceRedeployStatus - :ivar disks: The virtual machine disk information. - :vartype disks: list[~azure.mgmt.compute.v2020_06_01.models.DiskInstanceView] - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionInstanceView] - :ivar vm_health: The health status for the VM. - :vartype vm_health: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineHealthStatus - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2020_06_01.models.BootDiagnosticsInstanceView - :ivar assigned_host: Resource id of the dedicated host, on which the virtual machine is - allocated through automatic placement, when the virtual machine is associated with a dedicated - host group that has automatic placement enabled. :code:`
    `\\ :code:`
    `Minimum - api-version: 2020-06-01. - :vartype assigned_host: str - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - :ivar patch_status: The status of virtual machine patch operations. - :vartype patch_status: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachinePatchStatus - """ - - _validation = { - "vm_health": {"readonly": True}, - "assigned_host": {"readonly": True}, - } - - _attribute_map = { - "platform_update_domain": {"key": "platformUpdateDomain", "type": "int"}, - "platform_fault_domain": {"key": "platformFaultDomain", "type": "int"}, - "computer_name": {"key": "computerName", "type": "str"}, - "os_name": {"key": "osName", "type": "str"}, - "os_version": {"key": "osVersion", "type": "str"}, - "hyper_v_generation": {"key": "hyperVGeneration", "type": "str"}, - "rdp_thumb_print": {"key": "rdpThumbPrint", "type": "str"}, - "vm_agent": {"key": "vmAgent", "type": "VirtualMachineAgentInstanceView"}, - "maintenance_redeploy_status": {"key": "maintenanceRedeployStatus", "type": "MaintenanceRedeployStatus"}, - "disks": {"key": "disks", "type": "[DiskInstanceView]"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineExtensionInstanceView]"}, - "vm_health": {"key": "vmHealth", "type": "VirtualMachineHealthStatus"}, - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnosticsInstanceView"}, - "assigned_host": {"key": "assignedHost", "type": "str"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - "patch_status": {"key": "patchStatus", "type": "VirtualMachinePatchStatus"}, - } - - def __init__( - self, - *, - platform_update_domain: Optional[int] = None, - platform_fault_domain: Optional[int] = None, - computer_name: Optional[str] = None, - os_name: Optional[str] = None, - os_version: Optional[str] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationType"]] = None, - rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, - disks: Optional[List["_models.DiskInstanceView"]] = None, - extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - patch_status: Optional["_models.VirtualMachinePatchStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword platform_update_domain: Specifies the update domain of the virtual machine. - :paramtype platform_update_domain: int - :keyword platform_fault_domain: Specifies the fault domain of the virtual machine. - :paramtype platform_fault_domain: int - :keyword computer_name: The computer name assigned to the virtual machine. - :paramtype computer_name: str - :keyword os_name: The Operating System running on the virtual machine. - :paramtype os_name: str - :keyword os_version: The version of Operating System running on the virtual machine. - :paramtype os_version: str - :keyword hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2020_06_01.models.HyperVGenerationType - :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. - :paramtype rdp_thumb_print: str - :keyword vm_agent: The VM Agent running on the virtual machine. - :paramtype vm_agent: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineAgentInstanceView - :keyword maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :paramtype maintenance_redeploy_status: - ~azure.mgmt.compute.v2020_06_01.models.MaintenanceRedeployStatus - :keyword disks: The virtual machine disk information. - :paramtype disks: list[~azure.mgmt.compute.v2020_06_01.models.DiskInstanceView] - :keyword extensions: The extensions information. - :paramtype extensions: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionInstanceView] - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2020_06_01.models.BootDiagnosticsInstanceView - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - :keyword patch_status: The status of virtual machine patch operations. - :paramtype patch_status: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachinePatchStatus - """ - super().__init__(**kwargs) - self.platform_update_domain = platform_update_domain - self.platform_fault_domain = platform_fault_domain - self.computer_name = computer_name - self.os_name = os_name - self.os_version = os_version - self.hyper_v_generation = hyper_v_generation - self.rdp_thumb_print = rdp_thumb_print - self.vm_agent = vm_agent - self.maintenance_redeploy_status = maintenance_redeploy_status - self.disks = disks - self.extensions = extensions - self.vm_health: Optional["_models.VirtualMachineHealthStatus"] = None - self.boot_diagnostics = boot_diagnostics - self.assigned_host: Optional[str] = None - self.statuses = statuses - self.patch_status = patch_status - - -class VirtualMachineListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machines. Required. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachine] - :ivar next_link: The URI to fetch the next page of VMs. Call ListNext() with this URI to fetch - the next page of Virtual Machines. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachine]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machines. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachine] - :keyword next_link: The URI to fetch the next page of VMs. Call ListNext() with this URI to - fetch the next page of Virtual Machines. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachinePatchStatus(_serialization.Model): - """The status of virtual machine patch operations. - - :ivar available_patch_summary: The available patch summary of the latest assessment operation - for the virtual machine. - :vartype available_patch_summary: ~azure.mgmt.compute.v2020_06_01.models.AvailablePatchSummary - :ivar last_patch_installation_summary: The installation summary of the latest installation - operation for the virtual machine. - :vartype last_patch_installation_summary: - ~azure.mgmt.compute.v2020_06_01.models.LastPatchInstallationSummary - """ - - _attribute_map = { - "available_patch_summary": {"key": "availablePatchSummary", "type": "AvailablePatchSummary"}, - "last_patch_installation_summary": { - "key": "lastPatchInstallationSummary", - "type": "LastPatchInstallationSummary", - }, - } - - def __init__( - self, - *, - available_patch_summary: Optional["_models.AvailablePatchSummary"] = None, - last_patch_installation_summary: Optional["_models.LastPatchInstallationSummary"] = None, - **kwargs: Any - ) -> None: - """ - :keyword available_patch_summary: The available patch summary of the latest assessment - operation for the virtual machine. - :paramtype available_patch_summary: - ~azure.mgmt.compute.v2020_06_01.models.AvailablePatchSummary - :keyword last_patch_installation_summary: The installation summary of the latest installation - operation for the virtual machine. - :paramtype last_patch_installation_summary: - ~azure.mgmt.compute.v2020_06_01.models.LastPatchInstallationSummary - """ - super().__init__(**kwargs) - self.available_patch_summary = available_patch_summary - self.last_patch_installation_summary = last_patch_installation_summary - - -class VirtualMachineReimageParameters(_serialization.Model): - """Parameters for Reimaging Virtual Machine. NOTE: Virtual Machine OS disk will always be - reimaged. - - :ivar temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This temp - disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :vartype temp_disk: bool - """ - - _attribute_map = { - "temp_disk": {"key": "tempDisk", "type": "bool"}, - } - - def __init__(self, *, temp_disk: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This - temp disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :paramtype temp_disk: bool - """ - super().__init__(**kwargs) - self.temp_disk = temp_disk - - -class VirtualMachineRunCommand(Resource): - """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. - :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] - :ivar source: The source of the run command script. - :vartype source: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommandScriptSource - :ivar parameters: The parameters used by the script. - :vartype parameters: list[~azure.mgmt.compute.v2020_06_01.models.RunCommandInputParameter] - :ivar protected_parameters: The parameters used by the script. - :vartype protected_parameters: - list[~azure.mgmt.compute.v2020_06_01.models.RunCommandInputParameter] - :ivar async_execution: Optional. If set to true, provisioning will complete as soon as the - script starts and will not wait for script to complete. - :vartype async_execution: bool - :ivar run_as_user: Specifies the user account on the VM when executing the run command. - :vartype run_as_user: str - :ivar run_as_password: Specifies the user account password on the VM when executing the run - command. - :vartype run_as_password: str - :ivar timeout_in_seconds: The timeout in seconds to execute the run command. - :vartype timeout_in_seconds: int - :ivar output_blob_uri: Specifies the Azure storage blob where script output stream will be - uploaded. - :vartype output_blob_uri: str - :ivar error_blob_uri: Specifies the Azure storage blob where script error stream will be - uploaded. - :vartype error_blob_uri: str - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The virtual machine run command instance view. - :vartype instance_view: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommandInstanceView - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": 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}"}, - "source": {"key": "properties.source", "type": "VirtualMachineRunCommandScriptSource"}, - "parameters": {"key": "properties.parameters", "type": "[RunCommandInputParameter]"}, - "protected_parameters": {"key": "properties.protectedParameters", "type": "[RunCommandInputParameter]"}, - "async_execution": {"key": "properties.asyncExecution", "type": "bool"}, - "run_as_user": {"key": "properties.runAsUser", "type": "str"}, - "run_as_password": {"key": "properties.runAsPassword", "type": "str"}, - "timeout_in_seconds": {"key": "properties.timeoutInSeconds", "type": "int"}, - "output_blob_uri": {"key": "properties.outputBlobUri", "type": "str"}, - "error_blob_uri": {"key": "properties.errorBlobUri", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineRunCommandInstanceView"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, - parameters: Optional[List["_models.RunCommandInputParameter"]] = None, - protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, - async_execution: bool = False, - run_as_user: Optional[str] = None, - run_as_password: Optional[str] = None, - timeout_in_seconds: Optional[int] = None, - output_blob_uri: Optional[str] = None, - error_blob_uri: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword source: The source of the run command script. - :paramtype source: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommandScriptSource - :keyword parameters: The parameters used by the script. - :paramtype parameters: list[~azure.mgmt.compute.v2020_06_01.models.RunCommandInputParameter] - :keyword protected_parameters: The parameters used by the script. - :paramtype protected_parameters: - list[~azure.mgmt.compute.v2020_06_01.models.RunCommandInputParameter] - :keyword async_execution: Optional. If set to true, provisioning will complete as soon as the - script starts and will not wait for script to complete. - :paramtype async_execution: bool - :keyword run_as_user: Specifies the user account on the VM when executing the run command. - :paramtype run_as_user: str - :keyword run_as_password: Specifies the user account password on the VM when executing the run - command. - :paramtype run_as_password: str - :keyword timeout_in_seconds: The timeout in seconds to execute the run command. - :paramtype timeout_in_seconds: int - :keyword output_blob_uri: Specifies the Azure storage blob where script output stream will be - uploaded. - :paramtype output_blob_uri: str - :keyword error_blob_uri: Specifies the Azure storage blob where script error stream will be - uploaded. - :paramtype error_blob_uri: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.source = source - self.parameters = parameters - self.protected_parameters = protected_parameters - self.async_execution = async_execution - self.run_as_user = run_as_user - self.run_as_password = run_as_password - self.timeout_in_seconds = timeout_in_seconds - self.output_blob_uri = output_blob_uri - self.error_blob_uri = error_blob_uri - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineRunCommandInstanceView"] = None - - -class VirtualMachineRunCommandInstanceView(_serialization.Model): - """The instance view of a virtual machine run command. - - :ivar execution_state: Script execution status. Known values are: "Unknown", "Pending", - "Running", "Failed", "Succeeded", "TimedOut", and "Canceled". - :vartype execution_state: str or ~azure.mgmt.compute.v2020_06_01.models.ExecutionState - :ivar execution_message: Communicate script configuration errors or execution messages. - :vartype execution_message: str - :ivar exit_code: Exit code returned from script execution. - :vartype exit_code: int - :ivar output: Script output stream. - :vartype output: str - :ivar error: Script error stream. - :vartype error: str - :ivar start_time: Script start time. - :vartype start_time: ~datetime.datetime - :ivar end_time: Script end time. - :vartype end_time: ~datetime.datetime - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "execution_state": {"key": "executionState", "type": "str"}, - "execution_message": {"key": "executionMessage", "type": "str"}, - "exit_code": {"key": "exitCode", "type": "int"}, - "output": {"key": "output", "type": "str"}, - "error": {"key": "error", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - execution_state: Optional[Union[str, "_models.ExecutionState"]] = None, - execution_message: Optional[str] = None, - exit_code: Optional[int] = None, - output: Optional[str] = None, - error: Optional[str] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword execution_state: Script execution status. Known values are: "Unknown", "Pending", - "Running", "Failed", "Succeeded", "TimedOut", and "Canceled". - :paramtype execution_state: str or ~azure.mgmt.compute.v2020_06_01.models.ExecutionState - :keyword execution_message: Communicate script configuration errors or execution messages. - :paramtype execution_message: str - :keyword exit_code: Exit code returned from script execution. - :paramtype exit_code: int - :keyword output: Script output stream. - :paramtype output: str - :keyword error: Script error stream. - :paramtype error: str - :keyword start_time: Script start time. - :paramtype start_time: ~datetime.datetime - :keyword end_time: Script end time. - :paramtype end_time: ~datetime.datetime - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.execution_state = execution_state - self.execution_message = execution_message - self.exit_code = exit_code - self.output = output - self.error = error - self.start_time = start_time - self.end_time = end_time - self.statuses = statuses - - -class VirtualMachineRunCommandScriptSource(_serialization.Model): - """Describes the script sources for run command. - - :ivar script: Specifies the script content to be executed on the VM. - :vartype script: str - :ivar script_uri: Specifies the script download location. - :vartype script_uri: str - :ivar command_id: Specifies a commandId of predefined built-in script. - :vartype command_id: str - """ - - _attribute_map = { - "script": {"key": "script", "type": "str"}, - "script_uri": {"key": "scriptUri", "type": "str"}, - "command_id": {"key": "commandId", "type": "str"}, - } - - def __init__( - self, - *, - script: Optional[str] = None, - script_uri: Optional[str] = None, - command_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword script: Specifies the script content to be executed on the VM. - :paramtype script: str - :keyword script_uri: Specifies the script download location. - :paramtype script_uri: str - :keyword command_id: Specifies a commandId of predefined built-in script. - :paramtype command_id: str - """ - super().__init__(**kwargs) - self.script = script - self.script_uri = script_uri - self.command_id = command_id - - -class VirtualMachineRunCommandsListResult(_serialization.Model): - """The List run command operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of run commands. Required. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand] - :ivar next_link: The uri to fetch the next page of run commands. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineRunCommand]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineRunCommand"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of run commands. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand] - :keyword next_link: The uri to fetch the next page of run commands. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineRunCommandUpdate(UpdateResource): - """Describes a Virtual Machine run command. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar source: The source of the run command script. - :vartype source: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommandScriptSource - :ivar parameters: The parameters used by the script. - :vartype parameters: list[~azure.mgmt.compute.v2020_06_01.models.RunCommandInputParameter] - :ivar protected_parameters: The parameters used by the script. - :vartype protected_parameters: - list[~azure.mgmt.compute.v2020_06_01.models.RunCommandInputParameter] - :ivar async_execution: Optional. If set to true, provisioning will complete as soon as the - script starts and will not wait for script to complete. - :vartype async_execution: bool - :ivar run_as_user: Specifies the user account on the VM when executing the run command. - :vartype run_as_user: str - :ivar run_as_password: Specifies the user account password on the VM when executing the run - command. - :vartype run_as_password: str - :ivar timeout_in_seconds: The timeout in seconds to execute the run command. - :vartype timeout_in_seconds: int - :ivar output_blob_uri: Specifies the Azure storage blob where script output stream will be - uploaded. - :vartype output_blob_uri: str - :ivar error_blob_uri: Specifies the Azure storage blob where script error stream will be - uploaded. - :vartype error_blob_uri: str - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The virtual machine run command instance view. - :vartype instance_view: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommandInstanceView - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "source": {"key": "properties.source", "type": "VirtualMachineRunCommandScriptSource"}, - "parameters": {"key": "properties.parameters", "type": "[RunCommandInputParameter]"}, - "protected_parameters": {"key": "properties.protectedParameters", "type": "[RunCommandInputParameter]"}, - "async_execution": {"key": "properties.asyncExecution", "type": "bool"}, - "run_as_user": {"key": "properties.runAsUser", "type": "str"}, - "run_as_password": {"key": "properties.runAsPassword", "type": "str"}, - "timeout_in_seconds": {"key": "properties.timeoutInSeconds", "type": "int"}, - "output_blob_uri": {"key": "properties.outputBlobUri", "type": "str"}, - "error_blob_uri": {"key": "properties.errorBlobUri", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineRunCommandInstanceView"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, - parameters: Optional[List["_models.RunCommandInputParameter"]] = None, - protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, - async_execution: bool = False, - run_as_user: Optional[str] = None, - run_as_password: Optional[str] = None, - timeout_in_seconds: Optional[int] = None, - output_blob_uri: Optional[str] = None, - error_blob_uri: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword source: The source of the run command script. - :paramtype source: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommandScriptSource - :keyword parameters: The parameters used by the script. - :paramtype parameters: list[~azure.mgmt.compute.v2020_06_01.models.RunCommandInputParameter] - :keyword protected_parameters: The parameters used by the script. - :paramtype protected_parameters: - list[~azure.mgmt.compute.v2020_06_01.models.RunCommandInputParameter] - :keyword async_execution: Optional. If set to true, provisioning will complete as soon as the - script starts and will not wait for script to complete. - :paramtype async_execution: bool - :keyword run_as_user: Specifies the user account on the VM when executing the run command. - :paramtype run_as_user: str - :keyword run_as_password: Specifies the user account password on the VM when executing the run - command. - :paramtype run_as_password: str - :keyword timeout_in_seconds: The timeout in seconds to execute the run command. - :paramtype timeout_in_seconds: int - :keyword output_blob_uri: Specifies the Azure storage blob where script output stream will be - uploaded. - :paramtype output_blob_uri: str - :keyword error_blob_uri: Specifies the Azure storage blob where script error stream will be - uploaded. - :paramtype error_blob_uri: str - """ - super().__init__(tags=tags, **kwargs) - self.source = source - self.parameters = parameters - self.protected_parameters = protected_parameters - self.async_execution = async_execution - self.run_as_user = run_as_user - self.run_as_password = run_as_password - self.timeout_in_seconds = timeout_in_seconds - self.output_blob_uri = output_blob_uri - self.error_blob_uri = error_blob_uri - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineRunCommandInstanceView"] = None - - -class VirtualMachineScaleSet(Resource): - """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. - :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] - :ivar sku: The virtual machine scale set sku. - :vartype sku: ~azure.mgmt.compute.v2020_06_01.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2020_06_01.models.Plan - :ivar identity: The identity of the virtual machine scale set, if configured. - :vartype identity: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetIdentity - :ivar zones: The virtual machine scale set zones. NOTE: Availability zones can only be set when - you create the scale set. - :vartype zones: list[str] - :ivar upgrade_policy: The upgrade policy. - :vartype upgrade_policy: ~azure.mgmt.compute.v2020_06_01.models.UpgradePolicy - :ivar automatic_repairs_policy: Policy for automatic repairs. - :vartype automatic_repairs_policy: - ~azure.mgmt.compute.v2020_06_01.models.AutomaticRepairsPolicy - :ivar virtual_machine_profile: The virtual machine profile. - :vartype virtual_machine_profile: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar overprovision: Specifies whether the Virtual Machine Scale Set should be overprovisioned. - :vartype overprovision: bool - :ivar do_not_run_extensions_on_overprovisioned_v_ms: When Overprovision is enabled, extensions - are launched only on the requested number of VMs which are finally kept. This property will - hence ensure that the extensions do not run on the extra overprovisioned VMs. - :vartype do_not_run_extensions_on_overprovisioned_v_ms: bool - :ivar unique_id: Specifies the ID which uniquely identifies a Virtual Machine Scale Set. - :vartype unique_id: str - :ivar single_placement_group: When true this limits the scale set to a single placement group, - of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be modified to - false. However, if singlePlacementGroup is false, it may not be modified to true. - :vartype single_placement_group: bool - :ivar zone_balance: Whether to force strictly even Virtual Machine distribution cross x-zones - in case there is zone outage. - :vartype zone_balance: bool - :ivar platform_fault_domain_count: Fault Domain count for each placement group. - :vartype platform_fault_domain_count: int - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the virtual machine scale set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar host_group: Specifies information about the dedicated host group that the virtual machine - scale set resides in. :code:`
    `\\ :code:`
    `Minimum api-version: 2020-06-01. - :vartype host_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines - have the capability to support attaching managed data disks with UltraSSD_LRS storage account - type. - :vartype additional_capabilities: ~azure.mgmt.compute.v2020_06_01.models.AdditionalCapabilities - :ivar scale_in_policy: Specifies the scale-in policy that decides which virtual machines are - chosen for removal when a Virtual Machine Scale Set is scaled-in. - :vartype scale_in_policy: ~azure.mgmt.compute.v2020_06_01.models.ScaleInPolicy - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "unique_id": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "identity": {"key": "identity", "type": "VirtualMachineScaleSetIdentity"}, - "zones": {"key": "zones", "type": "[str]"}, - "upgrade_policy": {"key": "properties.upgradePolicy", "type": "UpgradePolicy"}, - "automatic_repairs_policy": {"key": "properties.automaticRepairsPolicy", "type": "AutomaticRepairsPolicy"}, - "virtual_machine_profile": { - "key": "properties.virtualMachineProfile", - "type": "VirtualMachineScaleSetVMProfile", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "overprovision": {"key": "properties.overprovision", "type": "bool"}, - "do_not_run_extensions_on_overprovisioned_v_ms": { - "key": "properties.doNotRunExtensionsOnOverprovisionedVMs", - "type": "bool", - }, - "unique_id": {"key": "properties.uniqueId", "type": "str"}, - "single_placement_group": {"key": "properties.singlePlacementGroup", "type": "bool"}, - "zone_balance": {"key": "properties.zoneBalance", "type": "bool"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "host_group": {"key": "properties.hostGroup", "type": "SubResource"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "scale_in_policy": {"key": "properties.scaleInPolicy", "type": "ScaleInPolicy"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, - zones: Optional[List[str]] = None, - upgrade_policy: Optional["_models.UpgradePolicy"] = None, - automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, - overprovision: Optional[bool] = None, - do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, - single_placement_group: Optional[bool] = None, - zone_balance: Optional[bool] = None, - platform_fault_domain_count: Optional[int] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - host_group: Optional["_models.SubResource"] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - scale_in_policy: Optional["_models.ScaleInPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The virtual machine scale set sku. - :paramtype sku: ~azure.mgmt.compute.v2020_06_01.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2020_06_01.models.Plan - :keyword identity: The identity of the virtual machine scale set, if configured. - :paramtype identity: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetIdentity - :keyword zones: The virtual machine scale set zones. NOTE: Availability zones can only be set - when you create the scale set. - :paramtype zones: list[str] - :keyword upgrade_policy: The upgrade policy. - :paramtype upgrade_policy: ~azure.mgmt.compute.v2020_06_01.models.UpgradePolicy - :keyword automatic_repairs_policy: Policy for automatic repairs. - :paramtype automatic_repairs_policy: - ~azure.mgmt.compute.v2020_06_01.models.AutomaticRepairsPolicy - :keyword virtual_machine_profile: The virtual machine profile. - :paramtype virtual_machine_profile: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMProfile - :keyword overprovision: Specifies whether the Virtual Machine Scale Set should be - overprovisioned. - :paramtype overprovision: bool - :keyword do_not_run_extensions_on_overprovisioned_v_ms: When Overprovision is enabled, - extensions are launched only on the requested number of VMs which are finally kept. This - property will hence ensure that the extensions do not run on the extra overprovisioned VMs. - :paramtype do_not_run_extensions_on_overprovisioned_v_ms: bool - :keyword single_placement_group: When true this limits the scale set to a single placement - group, of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be - modified to false. However, if singlePlacementGroup is false, it may not be modified to true. - :paramtype single_placement_group: bool - :keyword zone_balance: Whether to force strictly even Virtual Machine distribution cross - x-zones in case there is zone outage. - :paramtype zone_balance: bool - :keyword platform_fault_domain_count: Fault Domain count for each placement group. - :paramtype platform_fault_domain_count: int - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the virtual machine scale set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword host_group: Specifies information about the dedicated host group that the virtual - machine scale set resides in. :code:`
    `\\ :code:`
    `Minimum api-version: 2020-06-01. - :paramtype host_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines - have the capability to support attaching managed data disks with UltraSSD_LRS storage account - type. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2020_06_01.models.AdditionalCapabilities - :keyword scale_in_policy: Specifies the scale-in policy that decides which virtual machines are - chosen for removal when a Virtual Machine Scale Set is scaled-in. - :paramtype scale_in_policy: ~azure.mgmt.compute.v2020_06_01.models.ScaleInPolicy - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.plan = plan - self.identity = identity - self.zones = zones - self.upgrade_policy = upgrade_policy - self.automatic_repairs_policy = automatic_repairs_policy - self.virtual_machine_profile = virtual_machine_profile - self.provisioning_state: Optional[str] = None - self.overprovision = overprovision - self.do_not_run_extensions_on_overprovisioned_v_ms = do_not_run_extensions_on_overprovisioned_v_ms - self.unique_id: Optional[str] = None - self.single_placement_group = single_placement_group - self.zone_balance = zone_balance - self.platform_fault_domain_count = platform_fault_domain_count - self.proximity_placement_group = proximity_placement_group - self.host_group = host_group - self.additional_capabilities = additional_capabilities - self.scale_in_policy = scale_in_policy - - -class VirtualMachineScaleSetDataDisk(_serialization.Model): - """Describes a virtual machine scale set data disk. - - All required parameters must be populated in order to send to server. - - :ivar name: The disk name. - :vartype name: str - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar create_option: The create option. Required. Known values are: "FromImage", "Empty", and - "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2020_06_01.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetManagedDiskParameters - :ivar disk_iops_read_write: Specifies the Read-Write IOPS for the managed disk. Should be used - only when StorageAccountType is UltraSSD_LRS. If not specified, a default value would be - assigned based on diskSizeGB. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: Specifies the bandwidth in MB per second for the managed disk. - Should be used only when StorageAccountType is UltraSSD_LRS. If not specified, a default value - would be assigned based on diskSizeGB. - :vartype disk_m_bps_read_write: int - """ - - _validation = { - "lun": {"required": True}, - "create_option": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "VirtualMachineScaleSetManagedDiskParameters"}, - "disk_iops_read_write": {"key": "diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "diskMBpsReadWrite", "type": "int"}, - } - - def __init__( - self, - *, - lun: int, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, - disk_iops_read_write: Optional[int] = None, - disk_m_bps_read_write: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword create_option: The create option. Required. Known values are: "FromImage", "Empty", - and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2020_06_01.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetManagedDiskParameters - :keyword disk_iops_read_write: Specifies the Read-Write IOPS for the managed disk. Should be - used only when StorageAccountType is UltraSSD_LRS. If not specified, a default value would be - assigned based on diskSizeGB. - :paramtype disk_iops_read_write: int - :keyword disk_m_bps_read_write: Specifies the bandwidth in MB per second for the managed disk. - Should be used only when StorageAccountType is UltraSSD_LRS. If not specified, a default value - would be assigned based on diskSizeGB. - :paramtype disk_m_bps_read_write: int - """ - super().__init__(**kwargs) - self.name = name - self.lun = lun - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - self.disk_iops_read_write = disk_iops_read_write - self.disk_m_bps_read_write = disk_m_bps_read_write - - -class VirtualMachineScaleSetExtension(SubResourceReadOnly): - """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. - :vartype id: str - :ivar name: The name of the extension. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar force_update_tag: If a value is provided and is different from the previous value, the - extension handler will be forced to update even if the extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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 - needs to be provisioned. - :vartype provision_after_extensions: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "enable_automatic_upgrade": {"key": "properties.enableAutomaticUpgrade", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "provision_after_extensions": {"key": "properties.provisionAfterExtensions", "type": "[str]"}, - } - - 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, - provision_after_extensions: Optional[List[str]] = 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :keyword provision_after_extensions: Collection of extension names after which this extension - needs to be provisioned. - :paramtype provision_after_extensions: list[str] - """ - super().__init__(**kwargs) - self.name = name - self.type: Optional[str] = None - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.enable_automatic_upgrade = enable_automatic_upgrade - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - self.provision_after_extensions = provision_after_extensions - - -class VirtualMachineScaleSetExtensionListResult(_serialization.Model): # pylint: disable=name-too-long - """The List VM scale set extension operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of VM scale set extensions. Required. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtension] - :ivar next_link: The uri to fetch the next page of VM scale set extensions. Call ListNext() - with this to fetch the next page of VM scale set extensions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetExtension]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of VM scale set extensions. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtension] - :keyword next_link: The uri to fetch the next page of VM scale set extensions. Call ListNext() - with this to fetch the next page of VM scale set extensions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetExtensionProfile(_serialization.Model): - """Describes a virtual machine scale set extension profile. - - :ivar extensions: The virtual machine scale set child extension resources. - :vartype extensions: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtension] - :ivar extensions_time_budget: Specifies the time alloted for all extensions to start. The time - duration should be between 15 minutes and 120 minutes (inclusive) and should be specified in - ISO 8601 format. The default value is 90 minutes (PT1H30M). :code:`
    `\\ :code:`
    ` Minimum - api-version: 2020-06-01. - :vartype extensions_time_budget: str - """ - - _attribute_map = { - "extensions": {"key": "extensions", "type": "[VirtualMachineScaleSetExtension]"}, - "extensions_time_budget": {"key": "extensionsTimeBudget", "type": "str"}, - } - - def __init__( - self, - *, - extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, - extensions_time_budget: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword extensions: The virtual machine scale set child extension resources. - :paramtype extensions: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtension] - :keyword extensions_time_budget: Specifies the time alloted for all extensions to start. The - time duration should be between 15 minutes and 120 minutes (inclusive) and should be specified - in ISO 8601 format. The default value is 90 minutes (PT1H30M). :code:`
    `\\ :code:`
    ` - Minimum api-version: 2020-06-01. - :paramtype extensions_time_budget: str - """ - super().__init__(**kwargs) - self.extensions = extensions - self.extensions_time_budget = extensions_time_budget - - -class VirtualMachineScaleSetExtensionUpdate(SubResourceReadOnly): - """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. - :vartype id: str - :ivar name: The name of the extension. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar force_update_tag: If a value is provided and is different from the previous value, the - extension handler will be forced to update even if the extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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 - needs to be provisioned. - :vartype provision_after_extensions: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "enable_automatic_upgrade": {"key": "properties.enableAutomaticUpgrade", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "provision_after_extensions": {"key": "properties.provisionAfterExtensions", "type": "[str]"}, - } - - def __init__( - self, - *, - 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, - provision_after_extensions: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword force_update_tag: If a value is provided and is different from the previous value, the - extension handler will be forced to update even if the extension configuration has not changed. - :paramtype force_update_tag: str - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :keyword provision_after_extensions: Collection of extension names after which this extension - needs to be provisioned. - :paramtype provision_after_extensions: list[str] - """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.type: Optional[str] = None - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.enable_automatic_upgrade = enable_automatic_upgrade - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - self.provision_after_extensions = provision_after_extensions - - -class VirtualMachineScaleSetIdentity(_serialization.Model): - """Identity for the virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of virtual machine scale set identity. This property will - only be provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the virtual machine scale set. This property - will only be provided for a system assigned identity. - :vartype tenant_id: str - :ivar type: The type of identity used for the virtual machine scale set. The type - 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user - assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and - "None". - :vartype type: str or ~azure.mgmt.compute.v2020_06_01.models.ResourceIdentityType - :ivar user_assigned_identities: The list of user identities associated with the virtual machine - scale set. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": { - "key": "userAssignedIdentities", - "type": "{VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue}", - }, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, - user_assigned_identities: Optional[ - Dict[str, "_models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of identity used for the virtual machine scale set. The type - 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user - assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and - "None". - :paramtype type: str or ~azure.mgmt.compute.v2020_06_01.models.ResourceIdentityType - :keyword user_assigned_identities: The list of user identities associated with the virtual - machine scale set. The user identity dictionary key references will be ARM resource ids in the - form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue] - """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.type = type - self.user_assigned_identities = user_assigned_identities - - -class VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue(_serialization.Model): # pylint: disable=name-too-long - """VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue. - - 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: Optional[str] = None - self.client_id: Optional[str] = None - - -class VirtualMachineScaleSetInstanceView(_serialization.Model): - """The instance view of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar virtual_machine: The instance view status summary for the virtual machine scale set. - :vartype virtual_machine: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetInstanceViewStatusesSummary - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMExtensionsSummary] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - :ivar orchestration_services: The orchestration services information. - :vartype orchestration_services: - list[~azure.mgmt.compute.v2020_06_01.models.OrchestrationServiceSummary] - """ - - _validation = { - "virtual_machine": {"readonly": True}, - "extensions": {"readonly": True}, - "orchestration_services": {"readonly": True}, - } - - _attribute_map = { - "virtual_machine": {"key": "virtualMachine", "type": "VirtualMachineScaleSetInstanceViewStatusesSummary"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineScaleSetVMExtensionsSummary]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - "orchestration_services": {"key": "orchestrationServices", "type": "[OrchestrationServiceSummary]"}, - } - - def __init__(self, *, statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs: Any) -> None: - """ - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.virtual_machine: Optional["_models.VirtualMachineScaleSetInstanceViewStatusesSummary"] = None - self.extensions: Optional[List["_models.VirtualMachineScaleSetVMExtensionsSummary"]] = None - self.statuses = statuses - self.orchestration_services: Optional[List["_models.OrchestrationServiceSummary"]] = None - - -class VirtualMachineScaleSetInstanceViewStatusesSummary(_serialization.Model): # pylint: disable=name-too-long - """Instance view statuses summary for virtual machines of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar statuses_summary: The extensions information. - :vartype statuses_summary: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineStatusCodeCount] - """ - - _validation = { - "statuses_summary": {"readonly": True}, - } - - _attribute_map = { - "statuses_summary": {"key": "statusesSummary", "type": "[VirtualMachineStatusCodeCount]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.statuses_summary: Optional[List["_models.VirtualMachineStatusCodeCount"]] = None - - -class VirtualMachineScaleSetIPConfiguration(SubResource): - """Describes a virtual machine scale set network profile's IP configuration. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The IP configuration name. Required. - :vartype name: str - :ivar subnet: Specifies the identifier of the subnet. - :vartype subnet: ~azure.mgmt.compute.v2020_06_01.models.ApiEntityReference - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - :ivar public_ip_address_configuration: The publicIPAddressConfiguration. - :vartype public_ip_address_configuration: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration - :ivar private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2020_06_01.models.IPVersion - :ivar application_gateway_backend_address_pools: Specifies an array of references to backend - address pools of application gateways. A scale set can reference backend address pools of - multiple application gateways. Multiple scale sets cannot use the same application gateway. - :vartype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - :ivar application_security_groups: Specifies an array of references to application security - group. - :vartype application_security_groups: list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - :ivar load_balancer_backend_address_pools: Specifies an array of references to backend address - pools of load balancers. A scale set can reference backend address pools of one public and one - internal load balancer. Multiple scale sets cannot use the same basic sku load balancer. - :vartype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - :ivar load_balancer_inbound_nat_pools: Specifies an array of references to inbound Nat pools of - the load balancers. A scale set can reference inbound nat pools of one public and one internal - load balancer. Multiple scale sets cannot use the same basic sku load balancer. - :vartype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subnet": {"key": "properties.subnet", "type": "ApiEntityReference"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "public_ip_address_configuration": { - "key": "properties.publicIPAddressConfiguration", - "type": "VirtualMachineScaleSetPublicIPAddressConfiguration", - }, - "private_ip_address_version": {"key": "properties.privateIPAddressVersion", "type": "str"}, - "application_gateway_backend_address_pools": { - "key": "properties.applicationGatewayBackendAddressPools", - "type": "[SubResource]", - }, - "application_security_groups": {"key": "properties.applicationSecurityGroups", "type": "[SubResource]"}, - "load_balancer_backend_address_pools": { - "key": "properties.loadBalancerBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_inbound_nat_pools": {"key": "properties.loadBalancerInboundNatPools", "type": "[SubResource]"}, - } - - def __init__( - self, - *, - name: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - subnet: Optional["_models.ApiEntityReference"] = None, - primary: Optional[bool] = None, - public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, - application_security_groups: Optional[List["_models.SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The IP configuration name. Required. - :paramtype name: str - :keyword subnet: Specifies the identifier of the subnet. - :paramtype subnet: ~azure.mgmt.compute.v2020_06_01.models.ApiEntityReference - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - :keyword public_ip_address_configuration: The publicIPAddressConfiguration. - :paramtype public_ip_address_configuration: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration - :keyword private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2020_06_01.models.IPVersion - :keyword application_gateway_backend_address_pools: Specifies an array of references to backend - address pools of application gateways. A scale set can reference backend address pools of - multiple application gateways. Multiple scale sets cannot use the same application gateway. - :paramtype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - :keyword application_security_groups: Specifies an array of references to application security - group. - :paramtype application_security_groups: - list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - :keyword load_balancer_backend_address_pools: Specifies an array of references to backend - address pools of load balancers. A scale set can reference backend address pools of one public - and one internal load balancer. Multiple scale sets cannot use the same basic sku load - balancer. - :paramtype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - :keyword load_balancer_inbound_nat_pools: Specifies an array of references to inbound Nat pools - of the load balancers. A scale set can reference inbound nat pools of one public and one - internal load balancer. Multiple scale sets cannot use the same basic sku load balancer. - :paramtype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.subnet = subnet - self.primary = primary - self.public_ip_address_configuration = public_ip_address_configuration - self.private_ip_address_version = private_ip_address_version - self.application_gateway_backend_address_pools = application_gateway_backend_address_pools - self.application_security_groups = application_security_groups - self.load_balancer_backend_address_pools = load_balancer_backend_address_pools - self.load_balancer_inbound_nat_pools = load_balancer_inbound_nat_pools - - -class VirtualMachineScaleSetIpTag(_serialization.Model): - """Contains the IP tag associated with the public IP address. - - :ivar ip_tag_type: IP tag type. Example: FirstPartyUsage. - :vartype ip_tag_type: str - :ivar tag: IP tag associated with the public IP. Example: SQL, Storage etc. - :vartype tag: str - """ - - _attribute_map = { - "ip_tag_type": {"key": "ipTagType", "type": "str"}, - "tag": {"key": "tag", "type": "str"}, - } - - def __init__(self, *, ip_tag_type: Optional[str] = None, tag: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword ip_tag_type: IP tag type. Example: FirstPartyUsage. - :paramtype ip_tag_type: str - :keyword tag: IP tag associated with the public IP. Example: SQL, Storage etc. - :paramtype tag: str - """ - super().__init__(**kwargs) - self.ip_tag_type = ip_tag_type - self.tag = tag - - -class VirtualMachineScaleSetListOSUpgradeHistory(_serialization.Model): # pylint: disable=name-too-long - """List of Virtual Machine Scale Set OS Upgrade History operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of OS upgrades performed on the virtual machine scale set. Required. - :vartype value: - list[~azure.mgmt.compute.v2020_06_01.models.UpgradeOperationHistoricalStatusInfo] - :ivar next_link: The uri to fetch the next page of OS Upgrade History. Call ListNext() with - this to fetch the next page of history of upgrades. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[UpgradeOperationHistoricalStatusInfo]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: List["_models.UpgradeOperationHistoricalStatusInfo"], - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of OS upgrades performed on the virtual machine scale set. Required. - :paramtype value: - list[~azure.mgmt.compute.v2020_06_01.models.UpgradeOperationHistoricalStatusInfo] - :keyword next_link: The uri to fetch the next page of OS Upgrade History. Call ListNext() with - this to fetch the next page of history of upgrades. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets. Required. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSet] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call ListNext() - with this to fetch the next page of VMSS. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSet] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call - ListNext() with this to fetch the next page of VMSS. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListSkusResult(_serialization.Model): - """The Virtual Machine Scale Set List Skus operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of skus available for the virtual machine scale set. Required. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetSku] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Set Skus. Call - ListNext() with this to fetch the next page of VMSS Skus. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetSku]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of skus available for the virtual machine scale set. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetSku] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Set Skus. Call - ListNext() with this to fetch the next page of VMSS Skus. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListWithLinkResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets. Required. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSet] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call ListNext() - with this to fetch the next page of Virtual Machine Scale Sets. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSet] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call - ListNext() with this to fetch the next page of Virtual Machine Scale Sets. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetManagedDiskParameters(_serialization.Model): # pylint: disable=name-too-long - """Describes the parameters of a ScaleSet managed disk. - - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2020_06_01.models.DiskEncryptionSetParameters - """ - - _attribute_map = { - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - } - - def __init__( - self, - *, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", and "UltraSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2020_06_01.models.DiskEncryptionSetParameters - """ - super().__init__(**kwargs) - self.storage_account_type = storage_account_type - self.disk_encryption_set = disk_encryption_set - - -class VirtualMachineScaleSetNetworkConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's network configurations. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The network configuration name. Required. - :vartype name: str - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :vartype enable_accelerated_networking: bool - :ivar enable_fpga: Specifies whether the network interface is FPGA networking-enabled. - :vartype enable_fpga: bool - :ivar network_security_group: The network security group. - :vartype network_security_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar dns_settings: The dns settings to be applied on the network interfaces. - :vartype dns_settings: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :ivar ip_configurations: Specifies the IP configurations of the network interface. - :vartype ip_configurations: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetIPConfiguration] - :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :vartype enable_ip_forwarding: bool - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "enable_accelerated_networking": {"key": "properties.enableAcceleratedNetworking", "type": "bool"}, - "enable_fpga": {"key": "properties.enableFpga", "type": "bool"}, - "network_security_group": {"key": "properties.networkSecurityGroup", "type": "SubResource"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetNetworkConfigurationDnsSettings", - }, - "ip_configurations": {"key": "properties.ipConfigurations", "type": "[VirtualMachineScaleSetIPConfiguration]"}, - "enable_ip_forwarding": {"key": "properties.enableIPForwarding", "type": "bool"}, - } - - def __init__( - self, - *, - name: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - primary: Optional[bool] = None, - enable_accelerated_networking: Optional[bool] = None, - enable_fpga: Optional[bool] = None, - network_security_group: Optional["_models.SubResource"] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, - enable_ip_forwarding: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The network configuration name. Required. - :paramtype name: str - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :paramtype enable_accelerated_networking: bool - :keyword enable_fpga: Specifies whether the network interface is FPGA networking-enabled. - :paramtype enable_fpga: bool - :keyword network_security_group: The network security group. - :paramtype network_security_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword dns_settings: The dns settings to be applied on the network interfaces. - :paramtype dns_settings: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :keyword ip_configurations: Specifies the IP configurations of the network interface. - :paramtype ip_configurations: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetIPConfiguration] - :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :paramtype enable_ip_forwarding: bool - """ - super().__init__(id=id, **kwargs) - self.name = name - self.primary = primary - self.enable_accelerated_networking = enable_accelerated_networking - self.enable_fpga = enable_fpga - self.network_security_group = network_security_group - self.dns_settings = dns_settings - self.ip_configurations = ip_configurations - self.enable_ip_forwarding = enable_ip_forwarding - - -class VirtualMachineScaleSetNetworkConfigurationDnsSettings(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines scale sets network configuration's DNS settings. - - :ivar dns_servers: List of DNS servers IP addresses. - :vartype dns_servers: list[str] - """ - - _attribute_map = { - "dns_servers": {"key": "dnsServers", "type": "[str]"}, - } - - def __init__(self, *, dns_servers: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword dns_servers: List of DNS servers IP addresses. - :paramtype dns_servers: list[str] - """ - super().__init__(**kwargs) - self.dns_servers = dns_servers - - -class VirtualMachineScaleSetNetworkProfile(_serialization.Model): - """Describes a virtual machine scale set network profile. - - :ivar health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :vartype health_probe: ~azure.mgmt.compute.v2020_06_01.models.ApiEntityReference - :ivar network_interface_configurations: The list of network configurations. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetNetworkConfiguration] - """ - - _attribute_map = { - "health_probe": {"key": "healthProbe", "type": "ApiEntityReference"}, - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineScaleSetNetworkConfiguration]", - }, - } - - def __init__( - self, - *, - health_probe: Optional["_models.ApiEntityReference"] = None, - network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :paramtype health_probe: ~azure.mgmt.compute.v2020_06_01.models.ApiEntityReference - :keyword network_interface_configurations: The list of network configurations. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetNetworkConfiguration] - """ - super().__init__(**kwargs) - self.health_probe = health_probe - self.network_interface_configurations = network_interface_configurations - - -class VirtualMachineScaleSetOSDisk(_serialization.Model): - """Describes a virtual machine scale set operating system disk. - - All required parameters must be populated in order to send to server. - - :ivar name: The disk name. - :vartype name: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar create_option: Specifies how the virtual machines in the scale set should be created.\\ - :code:`
    `\\ :code:`
    ` The only allowed value is: **FromImage** \\u2013 This value is used - when you are using an image to create the virtual machine. If you are using a platform image, - you also use the imageReference element described above. If you are using a marketplace image, - you also use the plan element previously described. Required. Known values are: "FromImage", - "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2020_06_01.models.DiskCreateOptionTypes - :ivar diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk - used by the virtual machine scale set. - :vartype diff_disk_settings: ~azure.mgmt.compute.v2020_06_01.models.DiffDiskSettings - :ivar disk_size_gb: Specifies the size of the operating system disk in gigabytes. This element - can be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes - :ivar image: Specifies information about the unmanaged user image to base the scale set on. - :vartype image: ~azure.mgmt.compute.v2020_06_01.models.VirtualHardDisk - :ivar vhd_containers: Specifies the container urls that are used to store operating system - disks for the scale set. - :vartype vhd_containers: list[str] - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - - _validation = { - "create_option": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "create_option": {"key": "createOption", "type": "str"}, - "diff_disk_settings": {"key": "diffDiskSettings", "type": "DiffDiskSettings"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "os_type": {"key": "osType", "type": "str"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "vhd_containers": {"key": "vhdContainers", "type": "[str]"}, - "managed_disk": {"key": "managedDisk", "type": "VirtualMachineScaleSetManagedDiskParameters"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, - disk_size_gb: Optional[int] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - image: Optional["_models.VirtualHardDisk"] = None, - vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword create_option: Specifies how the virtual machines in the scale set should be - created.\\ :code:`
    `\\ :code:`
    ` The only allowed value is: **FromImage** \\u2013 This - value is used when you are using an image to create the virtual machine. If you are using a - platform image, you also use the imageReference element described above. If you are using a - marketplace image, you also use the plan element previously described. Required. Known values - are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2020_06_01.models.DiskCreateOptionTypes - :keyword diff_disk_settings: Specifies the ephemeral disk Settings for the operating system - disk used by the virtual machine scale set. - :paramtype diff_disk_settings: ~azure.mgmt.compute.v2020_06_01.models.DiffDiskSettings - :keyword disk_size_gb: Specifies the size of the operating system disk in gigabytes. This - element can be used to overwrite the size of the disk in a virtual machine image. - :code:`
    `\\ :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes - :keyword image: Specifies information about the unmanaged user image to base the scale set on. - :paramtype image: ~azure.mgmt.compute.v2020_06_01.models.VirtualHardDisk - :keyword vhd_containers: Specifies the container urls that are used to store operating system - disks for the scale set. - :paramtype vhd_containers: list[str] - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - super().__init__(**kwargs) - self.name = name - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.create_option = create_option - self.diff_disk_settings = diff_disk_settings - self.disk_size_gb = disk_size_gb - self.os_type = os_type - self.image = image - self.vhd_containers = vhd_containers - self.managed_disk = managed_disk - - -class VirtualMachineScaleSetOSProfile(_serialization.Model): - """Describes a virtual machine scale set OS profile. - - :ivar computer_name_prefix: Specifies the computer name prefix for all of the virtual machines - in the scale set. Computer name prefixes must be 1 to 15 characters long. - :vartype computer_name_prefix: str - :ivar admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :vartype admin_username: str - :ivar admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :vartype admin_password: str - :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` For using cloud-init for - your VM, see `Using cloud-init to customize a Linux VM during creation - `_. - :vartype custom_data: str - :ivar windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :vartype windows_configuration: ~azure.mgmt.compute.v2020_06_01.models.WindowsConfiguration - :ivar linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :vartype linux_configuration: ~azure.mgmt.compute.v2020_06_01.models.LinuxConfiguration - :ivar secrets: Specifies set of certificates that should be installed onto the virtual machines - in the scale set. - :vartype secrets: list[~azure.mgmt.compute.v2020_06_01.models.VaultSecretGroup] - """ - - _attribute_map = { - "computer_name_prefix": {"key": "computerNamePrefix", "type": "str"}, - "admin_username": {"key": "adminUsername", "type": "str"}, - "admin_password": {"key": "adminPassword", "type": "str"}, - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - } - - def __init__( - self, - *, - computer_name_prefix: Optional[str] = None, - admin_username: Optional[str] = None, - admin_password: Optional[str] = None, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword computer_name_prefix: Specifies the computer name prefix for all of the virtual - machines in the scale set. Computer name prefixes must be 1 to 15 characters long. - :paramtype computer_name_prefix: str - :keyword admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters :code:`
    `\\ - :code:`
    `\\ :code:`
  • ` For root access to the Linux VM, see `Using root privileges on - Linux virtual machines in Azure - `_\\ - :code:`
    `\\ :code:`
  • ` For a list of built-in system users on Linux that should not be - used in this field, see `Selecting User Names for Linux on Azure - `_. - :paramtype admin_username: str - :keyword admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM - `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :paramtype admin_password: str - :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` For using cloud-init for - your VM, see `Using cloud-init to customize a Linux VM during creation - `_. - :paramtype custom_data: str - :keyword windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :paramtype windows_configuration: ~azure.mgmt.compute.v2020_06_01.models.WindowsConfiguration - :keyword linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_ - :code:`
    `\\ :code:`
    ` For running non-endorsed distributions, see `Information for - Non-Endorsed Distributions - `_. - :paramtype linux_configuration: ~azure.mgmt.compute.v2020_06_01.models.LinuxConfiguration - :keyword secrets: Specifies set of certificates that should be installed onto the virtual - machines in the scale set. - :paramtype secrets: list[~azure.mgmt.compute.v2020_06_01.models.VaultSecretGroup] - """ - super().__init__(**kwargs) - self.computer_name_prefix = computer_name_prefix - self.admin_username = admin_username - self.admin_password = admin_password - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - - -class VirtualMachineScaleSetPublicIPAddressConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines scale set IP Configuration's PublicIPAddress configuration. - - All required parameters must be populated in order to send to server. - - :ivar name: The publicIP address configuration name. Required. - :vartype name: str - :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. - :vartype idle_timeout_in_minutes: int - :ivar dns_settings: The dns settings to be applied on the publicIP addresses . - :vartype dns_settings: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - :ivar ip_tags: The list of IP tags associated with the public IP address. - :vartype ip_tags: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetIpTag] - :ivar public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. - :vartype public_ip_prefix: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar public_ip_address_version: 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 'IPv6'. Known values are: "IPv4" and "IPv6". - :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2020_06_01.models.IPVersion - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "idle_timeout_in_minutes": {"key": "properties.idleTimeoutInMinutes", "type": "int"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings", - }, - "ip_tags": {"key": "properties.ipTags", "type": "[VirtualMachineScaleSetIpTag]"}, - "public_ip_prefix": {"key": "properties.publicIPPrefix", "type": "SubResource"}, - "public_ip_address_version": {"key": "properties.publicIPAddressVersion", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - ip_tags: Optional[List["_models.VirtualMachineScaleSetIpTag"]] = None, - public_ip_prefix: Optional["_models.SubResource"] = None, - public_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The publicIP address configuration name. Required. - :paramtype name: str - :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. - :paramtype idle_timeout_in_minutes: int - :keyword dns_settings: The dns settings to be applied on the publicIP addresses . - :paramtype dns_settings: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - :keyword ip_tags: The list of IP tags associated with the public IP address. - :paramtype ip_tags: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetIpTag] - :keyword public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. - :paramtype public_ip_prefix: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword public_ip_address_version: 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 'IPv6'. Known values are: "IPv4" and "IPv6". - :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2020_06_01.models.IPVersion - """ - super().__init__(**kwargs) - self.name = name - self.idle_timeout_in_minutes = idle_timeout_in_minutes - self.dns_settings = dns_settings - self.ip_tags = ip_tags - self.public_ip_prefix = public_ip_prefix - self.public_ip_address_version = public_ip_address_version - - -class VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings( - _serialization.Model -): # pylint: disable=name-too-long - """Describes a virtual machines scale sets network configuration's DNS settings. - - All required parameters must be populated in order to send to server. - - :ivar domain_name_label: The Domain name label.The concatenation of the domain name label and - vm index will be the domain name labels of the PublicIPAddress resources that will be created. - Required. - :vartype domain_name_label: str - """ - - _validation = { - "domain_name_label": {"required": True}, - } - - _attribute_map = { - "domain_name_label": {"key": "domainNameLabel", "type": "str"}, - } - - def __init__(self, *, domain_name_label: str, **kwargs: Any) -> None: - """ - :keyword domain_name_label: The Domain name label.The concatenation of the domain name label - and vm index will be the domain name labels of the PublicIPAddress resources that will be - created. Required. - :paramtype domain_name_label: str - """ - super().__init__(**kwargs) - self.domain_name_label = domain_name_label - - -class VirtualMachineScaleSetVMReimageParameters(VirtualMachineReimageParameters): # pylint: disable=name-too-long - """Describes a Virtual Machine Scale Set VM Reimage Parameters. - - :ivar temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This temp - disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :vartype temp_disk: bool - """ - - -class VirtualMachineScaleSetReimageParameters(VirtualMachineScaleSetVMReimageParameters): - """Describes a Virtual Machine Scale Set VM Reimage Parameters. - - :ivar temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This temp - disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :vartype temp_disk: bool - :ivar instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :vartype instance_ids: list[str] - """ - - _attribute_map = { - "temp_disk": {"key": "tempDisk", "type": "bool"}, - "instance_ids": {"key": "instanceIds", "type": "[str]"}, - } - - def __init__( - self, *, temp_disk: Optional[bool] = None, instance_ids: Optional[List[str]] = None, **kwargs: Any - ) -> None: - """ - :keyword temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This - temp disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :paramtype temp_disk: bool - :keyword instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :paramtype instance_ids: list[str] - """ - super().__init__(temp_disk=temp_disk, **kwargs) - self.instance_ids = instance_ids - - -class VirtualMachineScaleSetSku(_serialization.Model): - """Describes an available virtual machine scale set sku. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of resource the sku applies to. - :vartype resource_type: str - :ivar sku: The Sku. - :vartype sku: ~azure.mgmt.compute.v2020_06_01.models.Sku - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetSkuCapacity - """ - - _validation = { - "resource_type": {"readonly": True}, - "sku": {"readonly": True}, - "capacity": {"readonly": True}, - } - - _attribute_map = { - "resource_type": {"key": "resourceType", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "capacity": {"key": "capacity", "type": "VirtualMachineScaleSetSkuCapacity"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_type: Optional[str] = None - self.sku: Optional["_models.Sku"] = None - self.capacity: Optional["_models.VirtualMachineScaleSetSkuCapacity"] = None - - -class VirtualMachineScaleSetSkuCapacity(_serialization.Model): - """Describes scaling information of a sku. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar minimum: The minimum capacity. - :vartype minimum: int - :ivar maximum: The maximum capacity that can be set. - :vartype maximum: int - :ivar default_capacity: The default capacity. - :vartype default_capacity: int - :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic" and - "None". - :vartype scale_type: str or - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetSkuScaleType - """ - - _validation = { - "minimum": {"readonly": True}, - "maximum": {"readonly": True}, - "default_capacity": {"readonly": True}, - "scale_type": {"readonly": True}, - } - - _attribute_map = { - "minimum": {"key": "minimum", "type": "int"}, - "maximum": {"key": "maximum", "type": "int"}, - "default_capacity": {"key": "defaultCapacity", "type": "int"}, - "scale_type": {"key": "scaleType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.minimum: Optional[int] = None - self.maximum: Optional[int] = None - self.default_capacity: Optional[int] = None - self.scale_type: Optional[Union[str, "_models.VirtualMachineScaleSetSkuScaleType"]] = None - - -class VirtualMachineScaleSetStorageProfile(_serialization.Model): - """Describes a virtual machine scale set storage profile. - - :ivar image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :vartype image_reference: ~azure.mgmt.compute.v2020_06_01.models.ImageReference - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetOSDisk - :ivar data_disks: Specifies the parameters that are used to add data disks to the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :vartype data_disks: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetDataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "VirtualMachineScaleSetOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[VirtualMachineScaleSetDataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :paramtype image_reference: ~azure.mgmt.compute.v2020_06_01.models.ImageReference - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetOSDisk - :keyword data_disks: Specifies the parameters that are used to add data disks to the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :paramtype data_disks: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetDataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class VirtualMachineScaleSetUpdate(UpdateResource): - """Describes a Virtual Machine Scale Set. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The virtual machine scale set sku. - :vartype sku: ~azure.mgmt.compute.v2020_06_01.models.Sku - :ivar plan: The purchase plan when deploying a virtual machine scale set from VM Marketplace - images. - :vartype plan: ~azure.mgmt.compute.v2020_06_01.models.Plan - :ivar identity: The identity of the virtual machine scale set, if configured. - :vartype identity: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetIdentity - :ivar upgrade_policy: The upgrade policy. - :vartype upgrade_policy: ~azure.mgmt.compute.v2020_06_01.models.UpgradePolicy - :ivar automatic_repairs_policy: Policy for automatic repairs. - :vartype automatic_repairs_policy: - ~azure.mgmt.compute.v2020_06_01.models.AutomaticRepairsPolicy - :ivar virtual_machine_profile: The virtual machine profile. - :vartype virtual_machine_profile: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetUpdateVMProfile - :ivar overprovision: Specifies whether the Virtual Machine Scale Set should be overprovisioned. - :vartype overprovision: bool - :ivar do_not_run_extensions_on_overprovisioned_v_ms: When Overprovision is enabled, extensions - are launched only on the requested number of VMs which are finally kept. This property will - hence ensure that the extensions do not run on the extra overprovisioned VMs. - :vartype do_not_run_extensions_on_overprovisioned_v_ms: bool - :ivar single_placement_group: When true this limits the scale set to a single placement group, - of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be modified to - false. However, if singlePlacementGroup is false, it may not be modified to true. - :vartype single_placement_group: bool - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines - have the capability to support attaching managed data disks with UltraSSD_LRS storage account - type. - :vartype additional_capabilities: ~azure.mgmt.compute.v2020_06_01.models.AdditionalCapabilities - :ivar scale_in_policy: Specifies the scale-in policy that decides which virtual machines are - chosen for removal when a Virtual Machine Scale Set is scaled-in. - :vartype scale_in_policy: ~azure.mgmt.compute.v2020_06_01.models.ScaleInPolicy - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the virtual machine scale set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "identity": {"key": "identity", "type": "VirtualMachineScaleSetIdentity"}, - "upgrade_policy": {"key": "properties.upgradePolicy", "type": "UpgradePolicy"}, - "automatic_repairs_policy": {"key": "properties.automaticRepairsPolicy", "type": "AutomaticRepairsPolicy"}, - "virtual_machine_profile": { - "key": "properties.virtualMachineProfile", - "type": "VirtualMachineScaleSetUpdateVMProfile", - }, - "overprovision": {"key": "properties.overprovision", "type": "bool"}, - "do_not_run_extensions_on_overprovisioned_v_ms": { - "key": "properties.doNotRunExtensionsOnOverprovisionedVMs", - "type": "bool", - }, - "single_placement_group": {"key": "properties.singlePlacementGroup", "type": "bool"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "scale_in_policy": {"key": "properties.scaleInPolicy", "type": "ScaleInPolicy"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["_models.UpgradePolicy"] = None, - automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, - overprovision: Optional[bool] = None, - do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, - single_placement_group: Optional[bool] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - scale_in_policy: Optional["_models.ScaleInPolicy"] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The virtual machine scale set sku. - :paramtype sku: ~azure.mgmt.compute.v2020_06_01.models.Sku - :keyword plan: The purchase plan when deploying a virtual machine scale set from VM Marketplace - images. - :paramtype plan: ~azure.mgmt.compute.v2020_06_01.models.Plan - :keyword identity: The identity of the virtual machine scale set, if configured. - :paramtype identity: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetIdentity - :keyword upgrade_policy: The upgrade policy. - :paramtype upgrade_policy: ~azure.mgmt.compute.v2020_06_01.models.UpgradePolicy - :keyword automatic_repairs_policy: Policy for automatic repairs. - :paramtype automatic_repairs_policy: - ~azure.mgmt.compute.v2020_06_01.models.AutomaticRepairsPolicy - :keyword virtual_machine_profile: The virtual machine profile. - :paramtype virtual_machine_profile: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetUpdateVMProfile - :keyword overprovision: Specifies whether the Virtual Machine Scale Set should be - overprovisioned. - :paramtype overprovision: bool - :keyword do_not_run_extensions_on_overprovisioned_v_ms: When Overprovision is enabled, - extensions are launched only on the requested number of VMs which are finally kept. This - property will hence ensure that the extensions do not run on the extra overprovisioned VMs. - :paramtype do_not_run_extensions_on_overprovisioned_v_ms: bool - :keyword single_placement_group: When true this limits the scale set to a single placement - group, of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be - modified to false. However, if singlePlacementGroup is false, it may not be modified to true. - :paramtype single_placement_group: bool - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines - have the capability to support attaching managed data disks with UltraSSD_LRS storage account - type. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2020_06_01.models.AdditionalCapabilities - :keyword scale_in_policy: Specifies the scale-in policy that decides which virtual machines are - chosen for removal when a Virtual Machine Scale Set is scaled-in. - :paramtype scale_in_policy: ~azure.mgmt.compute.v2020_06_01.models.ScaleInPolicy - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the virtual machine scale set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - """ - super().__init__(tags=tags, **kwargs) - self.sku = sku - self.plan = plan - self.identity = identity - self.upgrade_policy = upgrade_policy - self.automatic_repairs_policy = automatic_repairs_policy - self.virtual_machine_profile = virtual_machine_profile - self.overprovision = overprovision - self.do_not_run_extensions_on_overprovisioned_v_ms = do_not_run_extensions_on_overprovisioned_v_ms - self.single_placement_group = single_placement_group - self.additional_capabilities = additional_capabilities - self.scale_in_policy = scale_in_policy - self.proximity_placement_group = proximity_placement_group - - -class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's IP configuration. NOTE: The subnet of a - scale set may be modified as long as the original subnet and the new subnet are in the same - virtual network. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The IP configuration name. - :vartype name: str - :ivar subnet: The subnet. - :vartype subnet: ~azure.mgmt.compute.v2020_06_01.models.ApiEntityReference - :ivar primary: Specifies the primary IP Configuration in case the network interface has more - than one IP Configuration. - :vartype primary: bool - :ivar public_ip_address_configuration: The publicIPAddressConfiguration. - :vartype public_ip_address_configuration: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration - :ivar private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2020_06_01.models.IPVersion - :ivar application_gateway_backend_address_pools: The application gateway backend address pools. - :vartype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - :ivar application_security_groups: Specifies an array of references to application security - group. - :vartype application_security_groups: list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - :ivar load_balancer_backend_address_pools: The load balancer backend address pools. - :vartype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - :ivar load_balancer_inbound_nat_pools: The load balancer inbound nat pools. - :vartype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subnet": {"key": "properties.subnet", "type": "ApiEntityReference"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "public_ip_address_configuration": { - "key": "properties.publicIPAddressConfiguration", - "type": "VirtualMachineScaleSetUpdatePublicIPAddressConfiguration", - }, - "private_ip_address_version": {"key": "properties.privateIPAddressVersion", "type": "str"}, - "application_gateway_backend_address_pools": { - "key": "properties.applicationGatewayBackendAddressPools", - "type": "[SubResource]", - }, - "application_security_groups": {"key": "properties.applicationSecurityGroups", "type": "[SubResource]"}, - "load_balancer_backend_address_pools": { - "key": "properties.loadBalancerBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_inbound_nat_pools": {"key": "properties.loadBalancerInboundNatPools", "type": "[SubResource]"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - subnet: Optional["_models.ApiEntityReference"] = None, - primary: Optional[bool] = None, - public_ip_address_configuration: Optional[ - "_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration" - ] = None, - private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, - application_security_groups: Optional[List["_models.SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The IP configuration name. - :paramtype name: str - :keyword subnet: The subnet. - :paramtype subnet: ~azure.mgmt.compute.v2020_06_01.models.ApiEntityReference - :keyword primary: Specifies the primary IP Configuration in case the network interface has more - than one IP Configuration. - :paramtype primary: bool - :keyword public_ip_address_configuration: The publicIPAddressConfiguration. - :paramtype public_ip_address_configuration: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration - :keyword private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2020_06_01.models.IPVersion - :keyword application_gateway_backend_address_pools: The application gateway backend address - pools. - :paramtype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - :keyword application_security_groups: Specifies an array of references to application security - group. - :paramtype application_security_groups: - list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - :keyword load_balancer_backend_address_pools: The load balancer backend address pools. - :paramtype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - :keyword load_balancer_inbound_nat_pools: The load balancer inbound nat pools. - :paramtype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2020_06_01.models.SubResource] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.subnet = subnet - self.primary = primary - self.public_ip_address_configuration = public_ip_address_configuration - self.private_ip_address_version = private_ip_address_version - self.application_gateway_backend_address_pools = application_gateway_backend_address_pools - self.application_security_groups = application_security_groups - self.load_balancer_backend_address_pools = load_balancer_backend_address_pools - self.load_balancer_inbound_nat_pools = load_balancer_inbound_nat_pools - - -class VirtualMachineScaleSetUpdateNetworkConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's network configurations. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The network configuration name. - :vartype name: str - :ivar primary: Whether this is a primary NIC on a virtual machine. - :vartype primary: bool - :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :vartype enable_accelerated_networking: bool - :ivar enable_fpga: Specifies whether the network interface is FPGA networking-enabled. - :vartype enable_fpga: bool - :ivar network_security_group: The network security group. - :vartype network_security_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar dns_settings: The dns settings to be applied on the network interfaces. - :vartype dns_settings: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :ivar ip_configurations: The virtual machine scale set IP Configuration. - :vartype ip_configurations: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetUpdateIPConfiguration] - :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :vartype enable_ip_forwarding: bool - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "enable_accelerated_networking": {"key": "properties.enableAcceleratedNetworking", "type": "bool"}, - "enable_fpga": {"key": "properties.enableFpga", "type": "bool"}, - "network_security_group": {"key": "properties.networkSecurityGroup", "type": "SubResource"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetNetworkConfigurationDnsSettings", - }, - "ip_configurations": { - "key": "properties.ipConfigurations", - "type": "[VirtualMachineScaleSetUpdateIPConfiguration]", - }, - "enable_ip_forwarding": {"key": "properties.enableIPForwarding", "type": "bool"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - primary: Optional[bool] = None, - enable_accelerated_networking: Optional[bool] = None, - enable_fpga: Optional[bool] = None, - network_security_group: Optional["_models.SubResource"] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, - enable_ip_forwarding: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The network configuration name. - :paramtype name: str - :keyword primary: Whether this is a primary NIC on a virtual machine. - :paramtype primary: bool - :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :paramtype enable_accelerated_networking: bool - :keyword enable_fpga: Specifies whether the network interface is FPGA networking-enabled. - :paramtype enable_fpga: bool - :keyword network_security_group: The network security group. - :paramtype network_security_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword dns_settings: The dns settings to be applied on the network interfaces. - :paramtype dns_settings: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :keyword ip_configurations: The virtual machine scale set IP Configuration. - :paramtype ip_configurations: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetUpdateIPConfiguration] - :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :paramtype enable_ip_forwarding: bool - """ - super().__init__(id=id, **kwargs) - self.name = name - self.primary = primary - self.enable_accelerated_networking = enable_accelerated_networking - self.enable_fpga = enable_fpga - self.network_security_group = network_security_group - self.dns_settings = dns_settings - self.ip_configurations = ip_configurations - self.enable_ip_forwarding = enable_ip_forwarding - - -class VirtualMachineScaleSetUpdateNetworkProfile(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile. - - :ivar health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :vartype health_probe: ~azure.mgmt.compute.v2020_06_01.models.ApiEntityReference - :ivar network_interface_configurations: The list of network configurations. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] - """ - - _attribute_map = { - "health_probe": {"key": "healthProbe", "type": "ApiEntityReference"}, - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineScaleSetUpdateNetworkConfiguration]", - }, - } - - def __init__( - self, - *, - health_probe: Optional["_models.ApiEntityReference"] = None, - network_interface_configurations: Optional[ - List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :paramtype health_probe: ~azure.mgmt.compute.v2020_06_01.models.ApiEntityReference - :keyword network_interface_configurations: The list of network configurations. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] - """ - super().__init__(**kwargs) - self.health_probe = health_probe - self.network_interface_configurations = network_interface_configurations - - -class VirtualMachineScaleSetUpdateOSDisk(_serialization.Model): - """Describes virtual machine scale set operating system disk Update Object. This should be used - for Updating VMSS OS Disk. - - :ivar caching: The caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar disk_size_gb: Specifies the size of the operating system disk in gigabytes. This element - can be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before - using it to attach to the Virtual Machine. If SourceImage is provided, the destination - VirtualHardDisk should not exist. - :vartype image: ~azure.mgmt.compute.v2020_06_01.models.VirtualHardDisk - :ivar vhd_containers: The list of virtual hard disk container uris. - :vartype vhd_containers: list[str] - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - - _attribute_map = { - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "vhd_containers": {"key": "vhdContainers", "type": "[str]"}, - "managed_disk": {"key": "managedDisk", "type": "VirtualMachineScaleSetManagedDiskParameters"}, - } - - def __init__( - self, - *, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - disk_size_gb: Optional[int] = None, - image: Optional["_models.VirtualHardDisk"] = None, - vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword caching: The caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword disk_size_gb: Specifies the size of the operating system disk in gigabytes. This - element can be used to overwrite the size of the disk in a virtual machine image. - :code:`
    `\\ :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied - before using it to attach to the Virtual Machine. If SourceImage is provided, the destination - VirtualHardDisk should not exist. - :paramtype image: ~azure.mgmt.compute.v2020_06_01.models.VirtualHardDisk - :keyword vhd_containers: The list of virtual hard disk container uris. - :paramtype vhd_containers: list[str] - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - super().__init__(**kwargs) - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.disk_size_gb = disk_size_gb - self.image = image - self.vhd_containers = vhd_containers - self.managed_disk = managed_disk - - -class VirtualMachineScaleSetUpdateOSProfile(_serialization.Model): - """Describes a virtual machine scale set OS profile. - - :ivar custom_data: A base-64 encoded string of custom data. - :vartype custom_data: str - :ivar windows_configuration: The Windows Configuration of the OS profile. - :vartype windows_configuration: ~azure.mgmt.compute.v2020_06_01.models.WindowsConfiguration - :ivar linux_configuration: The Linux Configuration of the OS profile. - :vartype linux_configuration: ~azure.mgmt.compute.v2020_06_01.models.LinuxConfiguration - :ivar secrets: The List of certificates for addition to the VM. - :vartype secrets: list[~azure.mgmt.compute.v2020_06_01.models.VaultSecretGroup] - """ - - _attribute_map = { - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - } - - def __init__( - self, - *, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword custom_data: A base-64 encoded string of custom data. - :paramtype custom_data: str - :keyword windows_configuration: The Windows Configuration of the OS profile. - :paramtype windows_configuration: ~azure.mgmt.compute.v2020_06_01.models.WindowsConfiguration - :keyword linux_configuration: The Linux Configuration of the OS profile. - :paramtype linux_configuration: ~azure.mgmt.compute.v2020_06_01.models.LinuxConfiguration - :keyword secrets: The List of certificates for addition to the VM. - :paramtype secrets: list[~azure.mgmt.compute.v2020_06_01.models.VaultSecretGroup] - """ - super().__init__(**kwargs) - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - - -class VirtualMachineScaleSetUpdatePublicIPAddressConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines scale set IP Configuration's PublicIPAddress configuration. - - :ivar name: The publicIP address configuration name. - :vartype name: str - :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. - :vartype idle_timeout_in_minutes: int - :ivar dns_settings: The dns settings to be applied on the publicIP addresses . - :vartype dns_settings: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "idle_timeout_in_minutes": {"key": "properties.idleTimeoutInMinutes", "type": "int"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings", - }, - } - - def __init__( - self, - *, - name: Optional[str] = None, - idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The publicIP address configuration name. - :paramtype name: str - :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. - :paramtype idle_timeout_in_minutes: int - :keyword dns_settings: The dns settings to be applied on the publicIP addresses . - :paramtype dns_settings: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - """ - super().__init__(**kwargs) - self.name = name - self.idle_timeout_in_minutes = idle_timeout_in_minutes - self.dns_settings = dns_settings - - -class VirtualMachineScaleSetUpdateStorageProfile(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machine scale set storage profile. - - :ivar image_reference: The image reference. - :vartype image_reference: ~azure.mgmt.compute.v2020_06_01.models.ImageReference - :ivar os_disk: The OS disk. - :vartype os_disk: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetUpdateOSDisk - :ivar data_disks: The data disks. - :vartype data_disks: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetDataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "VirtualMachineScaleSetUpdateOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[VirtualMachineScaleSetDataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: The image reference. - :paramtype image_reference: ~azure.mgmt.compute.v2020_06_01.models.ImageReference - :keyword os_disk: The OS disk. - :paramtype os_disk: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetUpdateOSDisk - :keyword data_disks: The data disks. - :paramtype data_disks: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetDataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class VirtualMachineScaleSetUpdateVMProfile(_serialization.Model): - """Describes a virtual machine scale set virtual machine profile. - - :ivar os_profile: The virtual machine scale set OS profile. - :vartype os_profile: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetUpdateOSProfile - :ivar storage_profile: The virtual machine scale set storage profile. - :vartype storage_profile: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetUpdateStorageProfile - :ivar network_profile: The virtual machine scale set network profile. - :vartype network_profile: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetUpdateNetworkProfile - :ivar security_profile: The virtual machine scale set Security profile. - :vartype security_profile: ~azure.mgmt.compute.v2020_06_01.models.SecurityProfile - :ivar diagnostics_profile: The virtual machine scale set diagnostics profile. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2020_06_01.models.DiagnosticsProfile - :ivar extension_profile: The virtual machine scale set extension profile. - :vartype extension_profile: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtensionProfile - :ivar license_type: The license type, which is for bring your own license scenario. - :vartype license_type: str - :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2020_06_01.models.BillingProfile - :ivar scheduled_events_profile: Specifies Scheduled Event related configurations. - :vartype scheduled_events_profile: - ~azure.mgmt.compute.v2020_06_01.models.ScheduledEventsProfile - """ - - _attribute_map = { - "os_profile": {"key": "osProfile", "type": "VirtualMachineScaleSetUpdateOSProfile"}, - "storage_profile": {"key": "storageProfile", "type": "VirtualMachineScaleSetUpdateStorageProfile"}, - "network_profile": {"key": "networkProfile", "type": "VirtualMachineScaleSetUpdateNetworkProfile"}, - "security_profile": {"key": "securityProfile", "type": "SecurityProfile"}, - "diagnostics_profile": {"key": "diagnosticsProfile", "type": "DiagnosticsProfile"}, - "extension_profile": {"key": "extensionProfile", "type": "VirtualMachineScaleSetExtensionProfile"}, - "license_type": {"key": "licenseType", "type": "str"}, - "billing_profile": {"key": "billingProfile", "type": "BillingProfile"}, - "scheduled_events_profile": {"key": "scheduledEventsProfile", "type": "ScheduledEventsProfile"}, - } - - def __init__( - self, - *, - os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, - security_profile: Optional["_models.SecurityProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, - license_type: Optional[str] = None, - billing_profile: Optional["_models.BillingProfile"] = None, - scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_profile: The virtual machine scale set OS profile. - :paramtype os_profile: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetUpdateOSProfile - :keyword storage_profile: The virtual machine scale set storage profile. - :paramtype storage_profile: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetUpdateStorageProfile - :keyword network_profile: The virtual machine scale set network profile. - :paramtype network_profile: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetUpdateNetworkProfile - :keyword security_profile: The virtual machine scale set Security profile. - :paramtype security_profile: ~azure.mgmt.compute.v2020_06_01.models.SecurityProfile - :keyword diagnostics_profile: The virtual machine scale set diagnostics profile. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2020_06_01.models.DiagnosticsProfile - :keyword extension_profile: The virtual machine scale set extension profile. - :paramtype extension_profile: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtensionProfile - :keyword license_type: The license type, which is for bring your own license scenario. - :paramtype license_type: str - :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2020_06_01.models.BillingProfile - :keyword scheduled_events_profile: Specifies Scheduled Event related configurations. - :paramtype scheduled_events_profile: - ~azure.mgmt.compute.v2020_06_01.models.ScheduledEventsProfile - """ - super().__init__(**kwargs) - self.os_profile = os_profile - self.storage_profile = storage_profile - self.network_profile = network_profile - self.security_profile = security_profile - self.diagnostics_profile = diagnostics_profile - self.extension_profile = extension_profile - self.license_type = license_type - self.billing_profile = billing_profile - self.scheduled_events_profile = scheduled_events_profile - - -class VirtualMachineScaleSetVM(Resource): - """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. - :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] - :ivar instance_id: The virtual machine instance ID. - :vartype instance_id: str - :ivar sku: The virtual machine SKU. - :vartype sku: ~azure.mgmt.compute.v2020_06_01.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2020_06_01.models.Plan - :ivar resources: The virtual machine child extension resources. - :vartype resources: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtension] - :ivar zones: The virtual machine zones. - :vartype zones: list[str] - :ivar latest_model_applied: Specifies whether the latest model has been applied to the virtual - machine. - :vartype latest_model_applied: bool - :ivar vm_id: Azure VM unique ID. - :vartype vm_id: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMInstanceView - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2020_06_01.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2020_06_01.models.StorageProfile - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine in the scale set. For instance: whether the virtual machine has the capability - to support attaching managed data disks with UltraSSD_LRS storage account type. - :vartype additional_capabilities: ~azure.mgmt.compute.v2020_06_01.models.AdditionalCapabilities - :ivar os_profile: Specifies the operating system settings for the virtual machine. - :vartype os_profile: ~azure.mgmt.compute.v2020_06_01.models.OSProfile - :ivar security_profile: Specifies the Security related profile settings for the virtual - machine. - :vartype security_profile: ~azure.mgmt.compute.v2020_06_01.models.SecurityProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2020_06_01.models.NetworkProfile - :ivar network_profile_configuration: Specifies the network profile configuration of the virtual - machine. - :vartype network_profile_configuration: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMNetworkProfileConfiguration - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2020_06_01.models.DiagnosticsProfile - :ivar availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :vartype availability_set: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. :code:`
    `\\ :code:`
    ` Possible values for Windows Server operating system - are: :code:`
    `\\ :code:`
    ` Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server - :code:`
    `\\ :code:`
    ` Possible values for Linux Server operating system are: - :code:`
    `\\ :code:`
    ` RHEL_BYOS (for RHEL) :code:`
    `\\ :code:`
    ` SLES_BYOS (for - SUSE) :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid Use Benefit for - Windows Server - `_ - :code:`
    `\\ :code:`
    ` `Azure Hybrid Use Benefit for Linux Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar model_definition_applied: Specifies whether the model applied to the virtual machine is - the model of the virtual machine scale set or the customized model for the virtual machine. - :vartype model_definition_applied: str - :ivar protection_policy: Specifies the protection policy of the virtual machine. - :vartype protection_policy: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMProtectionPolicy - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "instance_id": {"readonly": True}, - "sku": {"readonly": True}, - "resources": {"readonly": True}, - "zones": {"readonly": True}, - "latest_model_applied": {"readonly": True}, - "vm_id": {"readonly": True}, - "instance_view": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "model_definition_applied": {"readonly": 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}"}, - "instance_id": {"key": "instanceId", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "resources": {"key": "resources", "type": "[VirtualMachineExtension]"}, - "zones": {"key": "zones", "type": "[str]"}, - "latest_model_applied": {"key": "properties.latestModelApplied", "type": "bool"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineScaleSetVMInstanceView"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "security_profile": {"key": "properties.securityProfile", "type": "SecurityProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "network_profile_configuration": { - "key": "properties.networkProfileConfiguration", - "type": "VirtualMachineScaleSetVMNetworkProfileConfiguration", - }, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "model_definition_applied": {"key": "properties.modelDefinitionApplied", "type": "str"}, - "protection_policy": {"key": "properties.protectionPolicy", "type": "VirtualMachineScaleSetVMProtectionPolicy"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - os_profile: Optional["_models.OSProfile"] = None, - security_profile: Optional["_models.SecurityProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - network_profile_configuration: Optional["_models.VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - protection_policy: Optional["_models.VirtualMachineScaleSetVMProtectionPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2020_06_01.models.Plan - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2020_06_01.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2020_06_01.models.StorageProfile - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine in the scale set. For instance: whether the virtual machine has the capability - to support attaching managed data disks with UltraSSD_LRS storage account type. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2020_06_01.models.AdditionalCapabilities - :keyword os_profile: Specifies the operating system settings for the virtual machine. - :paramtype os_profile: ~azure.mgmt.compute.v2020_06_01.models.OSProfile - :keyword security_profile: Specifies the Security related profile settings for the virtual - machine. - :paramtype security_profile: ~azure.mgmt.compute.v2020_06_01.models.SecurityProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2020_06_01.models.NetworkProfile - :keyword network_profile_configuration: Specifies the network profile configuration of the - virtual machine. - :paramtype network_profile_configuration: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMNetworkProfileConfiguration - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2020_06_01.models.DiagnosticsProfile - :keyword availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. An existing VM cannot be added to an availability set. - :paramtype availability_set: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. :code:`
    `\\ :code:`
    ` Possible values for Windows Server operating system - are: :code:`
    `\\ :code:`
    ` Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server - :code:`
    `\\ :code:`
    ` Possible values for Linux Server operating system are: - :code:`
    `\\ :code:`
    ` RHEL_BYOS (for RHEL) :code:`
    `\\ :code:`
    ` SLES_BYOS (for - SUSE) :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid Use Benefit for - Windows Server - `_ - :code:`
    `\\ :code:`
    ` `Azure Hybrid Use Benefit for Linux Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - :keyword protection_policy: Specifies the protection policy of the virtual machine. - :paramtype protection_policy: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMProtectionPolicy - """ - super().__init__(location=location, tags=tags, **kwargs) - self.instance_id: Optional[str] = None - self.sku: Optional["_models.Sku"] = None - self.plan = plan - self.resources: Optional[List["_models.VirtualMachineExtension"]] = None - self.zones: Optional[List[str]] = None - self.latest_model_applied: Optional[bool] = None - self.vm_id: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineScaleSetVMInstanceView"] = None - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.additional_capabilities = additional_capabilities - self.os_profile = os_profile - self.security_profile = security_profile - self.network_profile = network_profile - self.network_profile_configuration = network_profile_configuration - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.provisioning_state: Optional[str] = None - self.license_type = license_type - self.model_definition_applied: Optional[str] = None - self.protection_policy = protection_policy - - -class VirtualMachineScaleSetVMExtension(SubResourceReadOnly): - """Describes a VMSS VM Extension. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the extension. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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. - :vartype instance_view: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionInstanceView - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "enable_automatic_upgrade": {"key": "properties.enableAutomaticUpgrade", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineExtensionInstanceView"}, - } - - def __init__( - self, - *, - 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, - instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, - **kwargs: Any - ) -> None: - """ - :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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :keyword instance_view: The virtual machine extension instance view. - :paramtype instance_view: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionInstanceView - """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.type: Optional[str] = None - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.enable_automatic_upgrade = enable_automatic_upgrade - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - self.instance_view = instance_view - - -class VirtualMachineScaleSetVMExtensionsListResult(_serialization.Model): # pylint: disable=name-too-long - """The List VMSS VM Extension operation response. - - :ivar value: The list of VMSS VM extensions. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMExtension] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetVMExtension]"}, - } - - def __init__( - self, *, value: Optional[List["_models.VirtualMachineScaleSetVMExtension"]] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of VMSS VM extensions. - :paramtype value: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMExtension] - """ - super().__init__(**kwargs) - self.value = value - - -class VirtualMachineScaleSetVMExtensionsSummary(_serialization.Model): # pylint: disable=name-too-long - """Extensions summary for virtual machines of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The extension name. - :vartype name: str - :ivar statuses_summary: The extensions information. - :vartype statuses_summary: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineStatusCodeCount] - """ - - _validation = { - "name": {"readonly": True}, - "statuses_summary": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "statuses_summary": {"key": "statusesSummary", "type": "[VirtualMachineStatusCodeCount]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.statuses_summary: Optional[List["_models.VirtualMachineStatusCodeCount"]] = None - - -class VirtualMachineScaleSetVMExtensionUpdate(SubResourceReadOnly): - """Describes a VMSS VM Extension. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the extension. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - """ - - _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"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "enable_automatic_upgrade": {"key": "properties.enableAutomaticUpgrade", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - } - - def __init__( - self, - *, - 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, - **kwargs: Any - ) -> None: - """ - :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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.type: Optional[str] = None - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.enable_automatic_upgrade = enable_automatic_upgrade - self.settings = settings - self.protected_settings = protected_settings - - -class VirtualMachineScaleSetVMInstanceIDs(_serialization.Model): - """Specifies a list of virtual machine instance IDs from the VM scale set. - - :ivar instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :vartype instance_ids: list[str] - """ - - _attribute_map = { - "instance_ids": {"key": "instanceIds", "type": "[str]"}, - } - - def __init__(self, *, instance_ids: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :paramtype instance_ids: list[str] - """ - super().__init__(**kwargs) - self.instance_ids = instance_ids - - -class VirtualMachineScaleSetVMInstanceRequiredIDs(_serialization.Model): # pylint: disable=name-too-long - """Specifies a list of virtual machine instance IDs from the VM scale set. - - All required parameters must be populated in order to send to server. - - :ivar instance_ids: The virtual machine scale set instance ids. Required. - :vartype instance_ids: list[str] - """ - - _validation = { - "instance_ids": {"required": True}, - } - - _attribute_map = { - "instance_ids": {"key": "instanceIds", "type": "[str]"}, - } - - def __init__(self, *, instance_ids: List[str], **kwargs: Any) -> None: - """ - :keyword instance_ids: The virtual machine scale set instance ids. Required. - :paramtype instance_ids: list[str] - """ - super().__init__(**kwargs) - self.instance_ids = instance_ids - - -class VirtualMachineScaleSetVMInstanceView(_serialization.Model): - """The instance view of a virtual machine scale set VM. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar platform_update_domain: The Update Domain count. - :vartype platform_update_domain: int - :ivar platform_fault_domain: The Fault Domain count. - :vartype platform_fault_domain: int - :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. - :vartype rdp_thumb_print: str - :ivar vm_agent: The VM Agent running on the virtual machine. - :vartype vm_agent: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineAgentInstanceView - :ivar maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :vartype maintenance_redeploy_status: - ~azure.mgmt.compute.v2020_06_01.models.MaintenanceRedeployStatus - :ivar disks: The disks information. - :vartype disks: list[~azure.mgmt.compute.v2020_06_01.models.DiskInstanceView] - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionInstanceView] - :ivar vm_health: The health status for the VM. - :vartype vm_health: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineHealthStatus - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2020_06_01.models.BootDiagnosticsInstanceView - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - :ivar assigned_host: Resource id of the dedicated host, on which the virtual machine is - allocated through automatic placement, when the virtual machine is associated with a dedicated - host group that has automatic placement enabled. :code:`
    `\\ :code:`
    `Minimum - api-version: 2020-06-01. - :vartype assigned_host: str - :ivar placement_group_id: The placement group in which the VM is running. If the VM is - deallocated it will not have a placementGroupId. - :vartype placement_group_id: str - """ - - _validation = { - "vm_health": {"readonly": True}, - "assigned_host": {"readonly": True}, - } - - _attribute_map = { - "platform_update_domain": {"key": "platformUpdateDomain", "type": "int"}, - "platform_fault_domain": {"key": "platformFaultDomain", "type": "int"}, - "rdp_thumb_print": {"key": "rdpThumbPrint", "type": "str"}, - "vm_agent": {"key": "vmAgent", "type": "VirtualMachineAgentInstanceView"}, - "maintenance_redeploy_status": {"key": "maintenanceRedeployStatus", "type": "MaintenanceRedeployStatus"}, - "disks": {"key": "disks", "type": "[DiskInstanceView]"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineExtensionInstanceView]"}, - "vm_health": {"key": "vmHealth", "type": "VirtualMachineHealthStatus"}, - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnosticsInstanceView"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - "assigned_host": {"key": "assignedHost", "type": "str"}, - "placement_group_id": {"key": "placementGroupId", "type": "str"}, - } - - def __init__( - self, - *, - platform_update_domain: Optional[int] = None, - platform_fault_domain: Optional[int] = None, - rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, - disks: Optional[List["_models.DiskInstanceView"]] = None, - extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - placement_group_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword platform_update_domain: The Update Domain count. - :paramtype platform_update_domain: int - :keyword platform_fault_domain: The Fault Domain count. - :paramtype platform_fault_domain: int - :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. - :paramtype rdp_thumb_print: str - :keyword vm_agent: The VM Agent running on the virtual machine. - :paramtype vm_agent: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineAgentInstanceView - :keyword maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :paramtype maintenance_redeploy_status: - ~azure.mgmt.compute.v2020_06_01.models.MaintenanceRedeployStatus - :keyword disks: The disks information. - :paramtype disks: list[~azure.mgmt.compute.v2020_06_01.models.DiskInstanceView] - :keyword extensions: The extensions information. - :paramtype extensions: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionInstanceView] - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2020_06_01.models.BootDiagnosticsInstanceView - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2020_06_01.models.InstanceViewStatus] - :keyword placement_group_id: The placement group in which the VM is running. If the VM is - deallocated it will not have a placementGroupId. - :paramtype placement_group_id: str - """ - super().__init__(**kwargs) - self.platform_update_domain = platform_update_domain - self.platform_fault_domain = platform_fault_domain - self.rdp_thumb_print = rdp_thumb_print - self.vm_agent = vm_agent - self.maintenance_redeploy_status = maintenance_redeploy_status - self.disks = disks - self.extensions = extensions - self.vm_health: Optional["_models.VirtualMachineHealthStatus"] = None - self.boot_diagnostics = boot_diagnostics - self.statuses = statuses - self.assigned_host: Optional[str] = None - self.placement_group_id = placement_group_id - - -class VirtualMachineScaleSetVMListResult(_serialization.Model): - """The List Virtual Machine Scale Set VMs operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets VMs. Required. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVM] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Set VMs. Call - ListNext() with this to fetch the next page of VMSS VMs. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetVM]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets VMs. Required. - :paramtype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVM] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Set VMs. Call - ListNext() with this to fetch the next page of VMSS VMs. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetVMNetworkProfileConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machine scale set VM network profile. - - :ivar network_interface_configurations: The list of network configurations. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetNetworkConfiguration] - """ - - _attribute_map = { - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineScaleSetNetworkConfiguration]", - }, - } - - def __init__( - self, - *, - network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword network_interface_configurations: The list of network configurations. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetNetworkConfiguration] - """ - super().__init__(**kwargs) - self.network_interface_configurations = network_interface_configurations - - -class VirtualMachineScaleSetVMProfile(_serialization.Model): - """Describes a virtual machine scale set virtual machine profile. - - :ivar os_profile: Specifies the operating system settings for the virtual machines in the scale - set. - :vartype os_profile: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetOSProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetStorageProfile - :ivar network_profile: Specifies properties of the network interfaces of the virtual machines - in the scale set. - :vartype network_profile: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetNetworkProfile - :ivar security_profile: Specifies the Security related profile settings for the virtual - machines in the scale set. - :vartype security_profile: ~azure.mgmt.compute.v2020_06_01.models.SecurityProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2020_06_01.models.DiagnosticsProfile - :ivar extension_profile: Specifies a collection of settings for extensions installed on virtual - machines in the scale set. - :vartype extension_profile: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtensionProfile - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. :code:`
    `\\ :code:`
    ` Possible values for Windows Server operating system - are: :code:`
    `\\ :code:`
    ` Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server - :code:`
    `\\ :code:`
    ` Possible values for Linux Server operating system are: - :code:`
    `\\ :code:`
    ` RHEL_BYOS (for RHEL) :code:`
    `\\ :code:`
    ` SLES_BYOS (for - SUSE) :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid Use Benefit for - Windows Server - `_ - :code:`
    `\\ :code:`
    ` `Azure Hybrid Use Benefit for Linux Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
    `\\ :code:`
    `Minimum api-version: 2017-10-30-preview. Known values are: - "Regular", "Low", and "Spot". - :vartype priority: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachinePriorityTypes - :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, both - 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. - :code:`
    `\\ :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are - supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and - "Delete". - :vartype eviction_policy: str or - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineEvictionPolicyTypes - :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2020_06_01.models.BillingProfile - :ivar scheduled_events_profile: Specifies Scheduled Event related configurations. - :vartype scheduled_events_profile: - ~azure.mgmt.compute.v2020_06_01.models.ScheduledEventsProfile - """ - - _attribute_map = { - "os_profile": {"key": "osProfile", "type": "VirtualMachineScaleSetOSProfile"}, - "storage_profile": {"key": "storageProfile", "type": "VirtualMachineScaleSetStorageProfile"}, - "network_profile": {"key": "networkProfile", "type": "VirtualMachineScaleSetNetworkProfile"}, - "security_profile": {"key": "securityProfile", "type": "SecurityProfile"}, - "diagnostics_profile": {"key": "diagnosticsProfile", "type": "DiagnosticsProfile"}, - "extension_profile": {"key": "extensionProfile", "type": "VirtualMachineScaleSetExtensionProfile"}, - "license_type": {"key": "licenseType", "type": "str"}, - "priority": {"key": "priority", "type": "str"}, - "eviction_policy": {"key": "evictionPolicy", "type": "str"}, - "billing_profile": {"key": "billingProfile", "type": "BillingProfile"}, - "scheduled_events_profile": {"key": "scheduledEventsProfile", "type": "ScheduledEventsProfile"}, - } - - def __init__( - self, - *, - os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, - security_profile: Optional["_models.SecurityProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, - license_type: Optional[str] = None, - priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["_models.BillingProfile"] = None, - scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_profile: Specifies the operating system settings for the virtual machines in the - scale set. - :paramtype os_profile: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetOSProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetStorageProfile - :keyword network_profile: Specifies properties of the network interfaces of the virtual - machines in the scale set. - :paramtype network_profile: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetNetworkProfile - :keyword security_profile: Specifies the Security related profile settings for the virtual - machines in the scale set. - :paramtype security_profile: ~azure.mgmt.compute.v2020_06_01.models.SecurityProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2020_06_01.models.DiagnosticsProfile - :keyword extension_profile: Specifies a collection of settings for extensions installed on - virtual machines in the scale set. - :paramtype extension_profile: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtensionProfile - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. :code:`
    `\\ :code:`
    ` Possible values for Windows Server operating system - are: :code:`
    `\\ :code:`
    ` Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server - :code:`
    `\\ :code:`
    ` Possible values for Linux Server operating system are: - :code:`
    `\\ :code:`
    ` RHEL_BYOS (for RHEL) :code:`
    `\\ :code:`
    ` SLES_BYOS (for - SUSE) :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid Use Benefit for - Windows Server - `_ - :code:`
    `\\ :code:`
    ` `Azure Hybrid Use Benefit for Linux Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
    `\\ :code:`
    `Minimum api-version: 2017-10-30-preview. Known values are: - "Regular", "Low", and "Spot". - :paramtype priority: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachinePriorityTypes - :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, both - 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. - :code:`
    `\\ :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are - supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and - "Delete". - :paramtype eviction_policy: str or - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineEvictionPolicyTypes - :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2020_06_01.models.BillingProfile - :keyword scheduled_events_profile: Specifies Scheduled Event related configurations. - :paramtype scheduled_events_profile: - ~azure.mgmt.compute.v2020_06_01.models.ScheduledEventsProfile - """ - super().__init__(**kwargs) - self.os_profile = os_profile - self.storage_profile = storage_profile - self.network_profile = network_profile - self.security_profile = security_profile - self.diagnostics_profile = diagnostics_profile - self.extension_profile = extension_profile - self.license_type = license_type - self.priority = priority - self.eviction_policy = eviction_policy - self.billing_profile = billing_profile - self.scheduled_events_profile = scheduled_events_profile - - -class VirtualMachineScaleSetVMProtectionPolicy(_serialization.Model): - """The protection policy of a virtual machine scale set VM. - - :ivar protect_from_scale_in: Indicates that the virtual machine scale set VM shouldn't be - considered for deletion during a scale-in operation. - :vartype protect_from_scale_in: bool - :ivar protect_from_scale_set_actions: Indicates that model updates or actions (including - scale-in) initiated on the virtual machine scale set should not be applied to the virtual - machine scale set VM. - :vartype protect_from_scale_set_actions: bool - """ - - _attribute_map = { - "protect_from_scale_in": {"key": "protectFromScaleIn", "type": "bool"}, - "protect_from_scale_set_actions": {"key": "protectFromScaleSetActions", "type": "bool"}, - } - - def __init__( - self, - *, - protect_from_scale_in: Optional[bool] = None, - protect_from_scale_set_actions: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword protect_from_scale_in: Indicates that the virtual machine scale set VM shouldn't be - considered for deletion during a scale-in operation. - :paramtype protect_from_scale_in: bool - :keyword protect_from_scale_set_actions: Indicates that model updates or actions (including - scale-in) initiated on the virtual machine scale set should not be applied to the virtual - machine scale set VM. - :paramtype protect_from_scale_set_actions: bool - """ - super().__init__(**kwargs) - self.protect_from_scale_in = protect_from_scale_in - self.protect_from_scale_set_actions = protect_from_scale_set_actions - - -class VirtualMachineSize(_serialization.Model): - """Describes the properties of a VM size. - - :ivar name: The name of the virtual machine size. - :vartype name: str - :ivar number_of_cores: The number of cores supported by the virtual machine size. - :vartype number_of_cores: int - :ivar os_disk_size_in_mb: The OS disk size, in MB, allowed by the virtual machine size. - :vartype os_disk_size_in_mb: int - :ivar resource_disk_size_in_mb: The resource disk size, in MB, allowed by the virtual machine - size. - :vartype resource_disk_size_in_mb: int - :ivar memory_in_mb: The amount of memory, in MB, supported by the virtual machine size. - :vartype memory_in_mb: int - :ivar max_data_disk_count: The maximum number of data disks that can be attached to the virtual - machine size. - :vartype max_data_disk_count: int - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "number_of_cores": {"key": "numberOfCores", "type": "int"}, - "os_disk_size_in_mb": {"key": "osDiskSizeInMB", "type": "int"}, - "resource_disk_size_in_mb": {"key": "resourceDiskSizeInMB", "type": "int"}, - "memory_in_mb": {"key": "memoryInMB", "type": "int"}, - "max_data_disk_count": {"key": "maxDataDiskCount", "type": "int"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - number_of_cores: Optional[int] = None, - os_disk_size_in_mb: Optional[int] = None, - resource_disk_size_in_mb: Optional[int] = None, - memory_in_mb: Optional[int] = None, - max_data_disk_count: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the virtual machine size. - :paramtype name: str - :keyword number_of_cores: The number of cores supported by the virtual machine size. - :paramtype number_of_cores: int - :keyword os_disk_size_in_mb: The OS disk size, in MB, allowed by the virtual machine size. - :paramtype os_disk_size_in_mb: int - :keyword resource_disk_size_in_mb: The resource disk size, in MB, allowed by the virtual - machine size. - :paramtype resource_disk_size_in_mb: int - :keyword memory_in_mb: The amount of memory, in MB, supported by the virtual machine size. - :paramtype memory_in_mb: int - :keyword max_data_disk_count: The maximum number of data disks that can be attached to the - virtual machine size. - :paramtype max_data_disk_count: int - """ - super().__init__(**kwargs) - self.name = name - self.number_of_cores = number_of_cores - self.os_disk_size_in_mb = os_disk_size_in_mb - self.resource_disk_size_in_mb = resource_disk_size_in_mb - self.memory_in_mb = memory_in_mb - self.max_data_disk_count = max_data_disk_count - - -class VirtualMachineSizeListResult(_serialization.Model): - """The List Virtual Machine operation response. - - :ivar value: The list of virtual machine sizes. - :vartype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineSize] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineSize]"}, - } - - def __init__(self, *, value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of virtual machine sizes. - :paramtype value: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineSize] - """ - super().__init__(**kwargs) - self.value = value - - -class VirtualMachineSoftwarePatchProperties(_serialization.Model): - """Describes the properties of a Virtual Machine software patch. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar patch_id: A unique identifier for the patch. - :vartype patch_id: str - :ivar name: The friendly name of the patch. - :vartype name: str - :ivar version: The version number of the patch. This property applies only to Linux patches. - :vartype version: str - :ivar kbid: The KBID of the patch. Only applies to Windows patches. - :vartype kbid: str - :ivar classifications: The classification(s) of the patch as provided by the patch publisher. - :vartype classifications: list[str] - :ivar reboot_behavior: Describes the reboot requirements of the patch. Known values are: - "NeverReboots", "AlwaysRequiresReboot", and "CanRequestReboot". - :vartype reboot_behavior: str or - ~azure.mgmt.compute.v2020_06_01.models.SoftwareUpdateRebootBehavior - :ivar activity_id: The activity ID of the operation that produced this result. It is used to - correlate across CRP and extension logs. - :vartype activity_id: str - :ivar published_date: The UTC timestamp when the repository published this patch. - :vartype published_date: ~datetime.datetime - :ivar last_modified_date_time: The UTC timestamp of the last update to this patch record. - :vartype last_modified_date_time: ~datetime.datetime - :ivar assessment_state: Describes the outcome of an install operation for a given patch. Known - values are: "Installed", "Failed", "Excluded", "NotSelected", "Pending", and "Available". - :vartype assessment_state: str or ~azure.mgmt.compute.v2020_06_01.models.PatchAssessmentState - """ - - _validation = { - "patch_id": {"readonly": True}, - "name": {"readonly": True}, - "version": {"readonly": True}, - "kbid": {"readonly": True}, - "classifications": {"readonly": True}, - "reboot_behavior": {"readonly": True}, - "activity_id": {"readonly": True}, - "published_date": {"readonly": True}, - "last_modified_date_time": {"readonly": True}, - "assessment_state": {"readonly": True}, - } - - _attribute_map = { - "patch_id": {"key": "patchId", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "version": {"key": "version", "type": "str"}, - "kbid": {"key": "kbid", "type": "str"}, - "classifications": {"key": "classifications", "type": "[str]"}, - "reboot_behavior": {"key": "rebootBehavior", "type": "str"}, - "activity_id": {"key": "activityId", "type": "str"}, - "published_date": {"key": "publishedDate", "type": "iso-8601"}, - "last_modified_date_time": {"key": "lastModifiedDateTime", "type": "iso-8601"}, - "assessment_state": {"key": "assessmentState", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.patch_id: Optional[str] = None - self.name: Optional[str] = None - self.version: Optional[str] = None - self.kbid: Optional[str] = None - self.classifications: Optional[List[str]] = None - self.reboot_behavior: Optional[Union[str, "_models.SoftwareUpdateRebootBehavior"]] = None - self.activity_id: Optional[str] = None - self.published_date: Optional[datetime.datetime] = None - self.last_modified_date_time: Optional[datetime.datetime] = None - self.assessment_state: Optional[Union[str, "_models.PatchAssessmentState"]] = None - - -class VirtualMachineStatusCodeCount(_serialization.Model): - """The status code and count of the virtual machine scale set instance view status summary. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The instance view status code. - :vartype code: str - :ivar count: The number of instances having a particular status code. - :vartype count: int - """ - - _validation = { - "code": {"readonly": True}, - "count": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "count": {"key": "count", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.count: Optional[int] = None - - -class VirtualMachineUpdate(UpdateResource): - """Describes a Virtual Machine Update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2020_06_01.models.Plan - :ivar identity: The identity of the virtual machine, if configured. - :vartype identity: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineIdentity - :ivar zones: The virtual machine zones. - :vartype zones: list[str] - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2020_06_01.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2020_06_01.models.StorageProfile - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine. - :vartype additional_capabilities: ~azure.mgmt.compute.v2020_06_01.models.AdditionalCapabilities - :ivar os_profile: Specifies the operating system settings used while creating the virtual - machine. Some of the settings cannot be changed once VM is provisioned. - :vartype os_profile: ~azure.mgmt.compute.v2020_06_01.models.OSProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2020_06_01.models.NetworkProfile - :ivar security_profile: Specifies the Security related profile settings for the virtual - machine. - :vartype security_profile: ~azure.mgmt.compute.v2020_06_01.models.SecurityProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2020_06_01.models.DiagnosticsProfile - :ivar availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. The availability set to which the VM is being added should be under the same resource - group as the availability set resource. An existing VM cannot be added to an availability set. - :code:`
    `\\ :code:`
    `This property cannot exist along with a non-null - properties.virtualMachineScaleSet reference. - :vartype availability_set: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar virtual_machine_scale_set: Specifies information about the virtual machine scale set that - the virtual machine should be assigned to. Virtual machines specified in the same virtual - machine scale set are allocated to different nodes to maximize availability. Currently, a VM - can only be added to virtual machine scale set at creation time. An existing VM cannot be added - to a virtual machine scale set. :code:`
    `\\ :code:`
    `This property cannot exist along - with a non-null properties.availabilitySet reference. :code:`
    `\\ :code:`
    `Minimum - api‐version: 2019‐03‐01. - :vartype virtual_machine_scale_set: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the virtual machine should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar priority: Specifies the priority for the virtual machine. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :vartype priority: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachinePriorityTypes - :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, both - 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. - :code:`
    `\\ :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are - supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and - "Delete". - :vartype eviction_policy: str or - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineEvictionPolicyTypes - :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2020_06_01.models.BillingProfile - :ivar host: Specifies information about the dedicated host that the virtual machine resides in. - :code:`
    `\\ :code:`
    `Minimum api-version: 2018-10-01. - :vartype host: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar host_group: Specifies information about the dedicated host group that the virtual machine - resides in. :code:`
    `\\ :code:`
    `Minimum api-version: 2020-06-01. :code:`
    `\\ - :code:`
    `NOTE: User cannot specify both host and hostGroup properties. - :vartype host_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineInstanceView - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. :code:`
    `\\ :code:`
    ` Possible values for Windows Server operating system - are: :code:`
    `\\ :code:`
    ` Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server - :code:`
    `\\ :code:`
    ` Possible values for Linux Server operating system are: - :code:`
    `\\ :code:`
    ` RHEL_BYOS (for RHEL) :code:`
    `\\ :code:`
    ` SLES_BYOS (for - SUSE) :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid Use Benefit for - Windows Server - `_ - :code:`
    `\\ :code:`
    ` `Azure Hybrid Use Benefit for Linux Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar vm_id: Specifies the VM unique ID which is a 128-bits identifier that is encoded and - stored in all Azure IaaS VMs SMBIOS and can be read using platform BIOS commands. - :vartype vm_id: str - :ivar extensions_time_budget: Specifies the time alloted for all extensions to start. The time - duration should be between 15 minutes and 120 minutes (inclusive) and should be specified in - ISO 8601 format. The default value is 90 minutes (PT1H30M). :code:`
    `\\ :code:`
    ` Minimum - api-version: 2020-06-01. - :vartype extensions_time_budget: str - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - "vm_id": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "plan": {"key": "plan", "type": "Plan"}, - "identity": {"key": "identity", "type": "VirtualMachineIdentity"}, - "zones": {"key": "zones", "type": "[str]"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "security_profile": {"key": "properties.securityProfile", "type": "SecurityProfile"}, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "virtual_machine_scale_set": {"key": "properties.virtualMachineScaleSet", "type": "SubResource"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "priority": {"key": "properties.priority", "type": "str"}, - "eviction_policy": {"key": "properties.evictionPolicy", "type": "str"}, - "billing_profile": {"key": "properties.billingProfile", "type": "BillingProfile"}, - "host": {"key": "properties.host", "type": "SubResource"}, - "host_group": {"key": "properties.hostGroup", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineInstanceView"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - "extensions_time_budget": {"key": "properties.extensionsTimeBudget", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineIdentity"] = None, - zones: Optional[List[str]] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - os_profile: Optional["_models.OSProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - security_profile: Optional["_models.SecurityProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - virtual_machine_scale_set: Optional["_models.SubResource"] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["_models.BillingProfile"] = None, - host: Optional["_models.SubResource"] = None, - host_group: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - extensions_time_budget: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2020_06_01.models.Plan - :keyword identity: The identity of the virtual machine, if configured. - :paramtype identity: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineIdentity - :keyword zones: The virtual machine zones. - :paramtype zones: list[str] - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2020_06_01.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2020_06_01.models.StorageProfile - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2020_06_01.models.AdditionalCapabilities - :keyword os_profile: Specifies the operating system settings used while creating the virtual - machine. Some of the settings cannot be changed once VM is provisioned. - :paramtype os_profile: ~azure.mgmt.compute.v2020_06_01.models.OSProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2020_06_01.models.NetworkProfile - :keyword security_profile: Specifies the Security related profile settings for the virtual - machine. - :paramtype security_profile: ~azure.mgmt.compute.v2020_06_01.models.SecurityProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2020_06_01.models.DiagnosticsProfile - :keyword availability_set: 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 `Manage the availability of virtual machines - `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Planned - maintenance for virtual machines in Azure - `_ - :code:`
    `\\ :code:`
    ` Currently, a VM can only be added to availability set at creation - time. The availability set to which the VM is being added should be under the same resource - group as the availability set resource. An existing VM cannot be added to an availability set. - :code:`
    `\\ :code:`
    `This property cannot exist along with a non-null - properties.virtualMachineScaleSet reference. - :paramtype availability_set: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword virtual_machine_scale_set: Specifies information about the virtual machine scale set - that the virtual machine should be assigned to. Virtual machines specified in the same virtual - machine scale set are allocated to different nodes to maximize availability. Currently, a VM - can only be added to virtual machine scale set at creation time. An existing VM cannot be added - to a virtual machine scale set. :code:`
    `\\ :code:`
    `This property cannot exist along - with a non-null properties.availabilitySet reference. :code:`
    `\\ :code:`
    `Minimum - api‐version: 2019‐03‐01. - :paramtype virtual_machine_scale_set: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the virtual machine should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword priority: Specifies the priority for the virtual machine. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :paramtype priority: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachinePriorityTypes - :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, both - 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. - :code:`
    `\\ :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are - supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and - "Delete". - :paramtype eviction_policy: str or - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineEvictionPolicyTypes - :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual - machine. :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2020_06_01.models.BillingProfile - :keyword host: Specifies information about the dedicated host that the virtual machine resides - in. :code:`
    `\\ :code:`
    `Minimum api-version: 2018-10-01. - :paramtype host: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword host_group: Specifies information about the dedicated host group that the virtual - machine resides in. :code:`
    `\\ :code:`
    `Minimum api-version: 2020-06-01. :code:`
    `\\ - :code:`
    `NOTE: User cannot specify both host and hostGroup properties. - :paramtype host_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. :code:`
    `\\ :code:`
    ` Possible values for Windows Server operating system - are: :code:`
    `\\ :code:`
    ` Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server - :code:`
    `\\ :code:`
    ` Possible values for Linux Server operating system are: - :code:`
    `\\ :code:`
    ` RHEL_BYOS (for RHEL) :code:`
    `\\ :code:`
    ` SLES_BYOS (for - SUSE) :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid Use Benefit for - Windows Server - `_ - :code:`
    `\\ :code:`
    ` `Azure Hybrid Use Benefit for Linux Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - :keyword extensions_time_budget: Specifies the time alloted for all extensions to start. The - time duration should be between 15 minutes and 120 minutes (inclusive) and should be specified - in ISO 8601 format. The default value is 90 minutes (PT1H30M). :code:`
    `\\ :code:`
    ` - Minimum api-version: 2020-06-01. - :paramtype extensions_time_budget: str - """ - super().__init__(tags=tags, **kwargs) - self.plan = plan - self.identity = identity - self.zones = zones - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.additional_capabilities = additional_capabilities - self.os_profile = os_profile - self.network_profile = network_profile - self.security_profile = security_profile - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.virtual_machine_scale_set = virtual_machine_scale_set - self.proximity_placement_group = proximity_placement_group - self.priority = priority - self.eviction_policy = eviction_policy - self.billing_profile = billing_profile - self.host = host - self.host_group = host_group - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineInstanceView"] = None - self.license_type = license_type - self.vm_id: Optional[str] = None - self.extensions_time_budget = extensions_time_budget - - -class VMScaleSetConvertToSinglePlacementGroupInput(_serialization.Model): # pylint: disable=name-too-long - """VMScaleSetConvertToSinglePlacementGroupInput. - - :ivar active_placement_group_id: Id of the placement group in which you want future virtual - machine instances to be placed. To query placement group Id, please use Virtual Machine Scale - Set VMs - Get API. If not provided, the platform will choose one with maximum number of virtual - machine instances. - :vartype active_placement_group_id: str - """ - - _attribute_map = { - "active_placement_group_id": {"key": "activePlacementGroupId", "type": "str"}, - } - - def __init__(self, *, active_placement_group_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword active_placement_group_id: Id of the placement group in which you want future virtual - machine instances to be placed. To query placement group Id, please use Virtual Machine Scale - Set VMs - Get API. If not provided, the platform will choose one with maximum number of virtual - machine instances. - :paramtype active_placement_group_id: str - """ - super().__init__(**kwargs) - self.active_placement_group_id = active_placement_group_id - - -class WindowsConfiguration(_serialization.Model): - """Specifies Windows operating system settings on the virtual machine. - - :ivar provision_vm_agent: Indicates whether virtual machine agent should be provisioned on the - virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the request - body, default behavior is to set it to true. This will ensure that VM Agent is installed on - the VM so that extensions can be added to the VM later. - :vartype provision_vm_agent: bool - :ivar enable_automatic_updates: Indicates whether Automatic Updates is enabled for the Windows - virtual machine. Default value is true. :code:`
    `\\ :code:`
    ` For virtual machine scale - sets, this property can be updated and updates will take effect on OS reprovisioning. - :vartype enable_automatic_updates: bool - :ivar time_zone: Specifies the time zone of the virtual machine. e.g. "Pacific Standard Time". - :code:`
    `\\ :code:`
    ` Possible values can be `TimeZoneInfo.Id - `_ - value from time zones returned by `TimeZoneInfo.GetSystemTimeZones - `_. - :vartype time_zone: str - :ivar additional_unattend_content: Specifies additional base-64 encoded XML formatted - information that can be included in the Unattend.xml file, which is used by Windows Setup. - :vartype additional_unattend_content: - list[~azure.mgmt.compute.v2020_06_01.models.AdditionalUnattendContent] - :ivar patch_settings: Specifies settings related to in-guest patching (KBs). - :vartype patch_settings: ~azure.mgmt.compute.v2020_06_01.models.PatchSettings - :ivar win_rm: Specifies the Windows Remote Management listeners. This enables remote Windows - PowerShell. - :vartype win_rm: ~azure.mgmt.compute.v2020_06_01.models.WinRMConfiguration - """ - - _attribute_map = { - "provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"}, - "enable_automatic_updates": {"key": "enableAutomaticUpdates", "type": "bool"}, - "time_zone": {"key": "timeZone", "type": "str"}, - "additional_unattend_content": {"key": "additionalUnattendContent", "type": "[AdditionalUnattendContent]"}, - "patch_settings": {"key": "patchSettings", "type": "PatchSettings"}, - "win_rm": {"key": "winRM", "type": "WinRMConfiguration"}, - } - - def __init__( - self, - *, - provision_vm_agent: Optional[bool] = None, - enable_automatic_updates: Optional[bool] = None, - time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, - patch_settings: Optional["_models.PatchSettings"] = None, - win_rm: Optional["_models.WinRMConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword provision_vm_agent: Indicates whether virtual machine agent should be provisioned on - the virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the - request body, default behavior is to set it to true. This will ensure that VM Agent is - installed on the VM so that extensions can be added to the VM later. - :paramtype provision_vm_agent: bool - :keyword enable_automatic_updates: Indicates whether Automatic Updates is enabled for the - Windows virtual machine. Default value is true. :code:`
    `\\ :code:`
    ` For virtual machine - scale sets, this property can be updated and updates will take effect on OS reprovisioning. - :paramtype enable_automatic_updates: bool - :keyword time_zone: Specifies the time zone of the virtual machine. e.g. "Pacific Standard - Time". :code:`
    `\\ :code:`
    ` Possible values can be `TimeZoneInfo.Id - `_ - value from time zones returned by `TimeZoneInfo.GetSystemTimeZones - `_. - :paramtype time_zone: str - :keyword additional_unattend_content: Specifies additional base-64 encoded XML formatted - information that can be included in the Unattend.xml file, which is used by Windows Setup. - :paramtype additional_unattend_content: - list[~azure.mgmt.compute.v2020_06_01.models.AdditionalUnattendContent] - :keyword patch_settings: Specifies settings related to in-guest patching (KBs). - :paramtype patch_settings: ~azure.mgmt.compute.v2020_06_01.models.PatchSettings - :keyword win_rm: Specifies the Windows Remote Management listeners. This enables remote Windows - PowerShell. - :paramtype win_rm: ~azure.mgmt.compute.v2020_06_01.models.WinRMConfiguration - """ - super().__init__(**kwargs) - self.provision_vm_agent = provision_vm_agent - self.enable_automatic_updates = enable_automatic_updates - self.time_zone = time_zone - self.additional_unattend_content = additional_unattend_content - self.patch_settings = patch_settings - self.win_rm = win_rm - - -class WinRMConfiguration(_serialization.Model): - """Describes Windows Remote Management configuration of the VM. - - :ivar listeners: The list of Windows Remote Management listeners. - :vartype listeners: list[~azure.mgmt.compute.v2020_06_01.models.WinRMListener] - """ - - _attribute_map = { - "listeners": {"key": "listeners", "type": "[WinRMListener]"}, - } - - def __init__(self, *, listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs: Any) -> None: - """ - :keyword listeners: The list of Windows Remote Management listeners. - :paramtype listeners: list[~azure.mgmt.compute.v2020_06_01.models.WinRMListener] - """ - super().__init__(**kwargs) - self.listeners = listeners - - -class WinRMListener(_serialization.Model): - """Describes Protocol and thumbprint of Windows Remote Management listener. - - :ivar protocol: Specifies the protocol of WinRM listener. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. Known values are: - "Http" and "Https". - :vartype protocol: str or ~azure.mgmt.compute.v2020_06_01.models.ProtocolTypes - :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as - a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :vartype certificate_url: str - """ - - _attribute_map = { - "protocol": {"key": "protocol", "type": "str"}, - "certificate_url": {"key": "certificateUrl", "type": "str"}, - } - - def __init__( - self, - *, - protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, - certificate_url: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword protocol: Specifies the protocol of WinRM listener. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. Known - values are: "Http" and "Https". - :paramtype protocol: str or ~azure.mgmt.compute.v2020_06_01.models.ProtocolTypes - :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault - as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `}. - :paramtype certificate_url: str - """ - super().__init__(**kwargs) - self.protocol = protocol - self.certificate_url = certificate_url diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/__init__.py deleted file mode 100644 index dfc04c351e85..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/__init__.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import Operations # type: ignore -from ._operations import AvailabilitySetsOperations # 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 VirtualMachineExtensionImagesOperations # type: ignore -from ._operations import VirtualMachineExtensionsOperations # type: ignore -from ._operations import VirtualMachineImagesOperations # type: ignore -from ._operations import UsageOperations # type: ignore -from ._operations import VirtualMachinesOperations # type: ignore -from ._operations import VirtualMachineSizesOperations # type: ignore -from ._operations import ImagesOperations # 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 LogAnalyticsOperations # type: ignore -from ._operations import VirtualMachineRunCommandsOperations # type: ignore -from ._operations import VirtualMachineScaleSetVMRunCommandsOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AvailabilitySetsOperations", - "ProximityPlacementGroupsOperations", - "DedicatedHostGroupsOperations", - "DedicatedHostsOperations", - "SshPublicKeysOperations", - "VirtualMachineExtensionImagesOperations", - "VirtualMachineExtensionsOperations", - "VirtualMachineImagesOperations", - "UsageOperations", - "VirtualMachinesOperations", - "VirtualMachineSizesOperations", - "ImagesOperations", - "VirtualMachineScaleSetsOperations", - "VirtualMachineScaleSetExtensionsOperations", - "VirtualMachineScaleSetRollingUpgradesOperations", - "VirtualMachineScaleSetVMExtensionsOperations", - "VirtualMachineScaleSetVMsOperations", - "LogAnalyticsOperations", - "VirtualMachineRunCommandsOperations", - "VirtualMachineScaleSetVMRunCommandsOperations", -] -__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/v2020_06_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_operations.py deleted file mode 100644 index 4cf1ab33fb6c..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_operations.py +++ /dev/null @@ -1,21356 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterator, List, Literal, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import ComputeManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_operations_list_request(**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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/operations") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-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}", - ) - 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"), - } - - _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_availability_sets_delete_request( - resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_availability_sets_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes", - ) - 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"), - } - - _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_proximity_placement_groups_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-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}", - ) - 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"), - } - - _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_proximity_placement_groups_update_request( # pylint: disable=name-too-long - resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-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}", - ) - 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"), - } - - _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_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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 -) -> 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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", - ) - 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"), - } - - _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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dedicated_host_groups_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2020-06-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}", - ) - 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"), - } - - _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_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", "2020-06-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}", - ) - 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"), - } - - _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_dedicated_host_groups_delete_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_dedicated_host_groups_get_request( - resource_group_name: str, - host_group_name: str, - subscription_id: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", - ) - 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"), - } - - _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) - - -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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dedicated_hosts_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2020-06-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}", - ) - 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"), - } - - _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_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", "2020-06-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}", - ) - 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"), - } - - _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_dedicated_hosts_delete_request( - resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_dedicated_hosts_get_request( - resource_group_name: str, - host_group_name: str, - host_name: str, - subscription_id: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", - ) - 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"), - } - - _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) - - -def build_dedicated_hosts_list_by_host_group_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/sshPublicKeys") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2020-06-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}", - ) - 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"), - } - - _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_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", "2020-06-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}", - ) - 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"), - } - - _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_ssh_public_keys_delete_request( - resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", - ) - 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"), - } - - _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_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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}/generateKeyPair", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_extension_images_get_request( # pylint: disable=name-too-long - location: str, publisher_name: str, type: str, version: str, subscription_id: str, **kwargs: Any -) -> 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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types", - ) - 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"), - } - - _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_extension_images_list_versions_request( # pylint: disable=name-too-long - location: str, - publisher_name: str, - type: str, - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - if orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2020-06-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-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}", - ) - 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"), - } - - _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_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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 -) -> 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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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) - - -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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", - ) - 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"), - } - - _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) - - -def build_virtual_machine_images_list_offers_request( # pylint: disable=name-too-long - location: str, publisher_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers" - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_images_list_skus_request( # pylint: disable=name-too-long - location: str, publisher_name: str, offer: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages" - ) - 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines", - ) - 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_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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture", - ) - 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"), - } - - _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_machines_create_or_update_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", "2020-06-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_update_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", "2020-06-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}", - ) - 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"), - } - - _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_virtual_machines_delete_request( - resource_group_name: str, - vm_name: str, - subscription_id: str, - *, - force_deletion: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", - ) - 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"), - } - - _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") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_get_request( - resource_group_name: str, - vm_name: str, - subscription_id: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", - ) - 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"), - } - - _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) - - -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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView", - ) - 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"), - } - - _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_machines_convert_to_managed_disks_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_deallocate_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_generalize_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_list_all_request( - subscription_id: str, *, status_only: 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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if status_only is not None: - _params["statusOnly"] = _SERIALIZER.query("status_only", status_only, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes", - ) - 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"), - } - - _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_machines_power_off_request( - resource_group_name: str, vm_name: str, subscription_id: str, *, skip_shutdown: bool = False, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reapply", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_restart_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_start_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_redeploy_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage", - ) - 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"), - } - - _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") - - 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 -) -> 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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/retrieveBootDiagnosticsData", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if sas_uri_expiration_time_in_minutes is not None: - _params["sasUriExpirationTimeInMinutes"] = _SERIALIZER.query( - "sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, "int" - ) - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/simulateEviction", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/assessPatches", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_run_command_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand", - ) - 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"), - } - - _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_sizes_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes" - ) - 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-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}", - ) - 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"), - } - - _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_images_delete_request( - resource_group_name: str, image_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", - ) - 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"), - } - - _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) - - -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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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, **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", "2020-06-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_update_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", "2020-06-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}", - ) - 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"), - } - - _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_virtual_machine_scale_sets_delete_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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, **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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", - ) - 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"), - } - - _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_scale_sets_deallocate_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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_delete_instances_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_get_instance_view_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_list_all_request( # pylint: disable=name-too-long - subscription_id: str, **kwargs: Any -) -> 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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_list_skus_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory", - ) - 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"), - } - - _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_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 -) -> 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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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, - **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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk", - ) - 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"), - } - - _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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", 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 -) -> 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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/setOrchestrationServiceState", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2020-06-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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", "2020-06-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}", - ) - 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"), - } - - _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_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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 -) -> 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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions", - ) - 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"), - } - - _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_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> 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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest", - ) - 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"), - } - - _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_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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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_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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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) - - -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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions", - ) - 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"), - } - - _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) - - -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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_set_vms_reimage_all_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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, **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", "2020-06-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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: Literal["instanceView"] = "instanceView", - **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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView", - ) - 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"), - } - - _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_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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines", - ) - 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"), - } - - _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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machine_scale_set_vms_redeploy_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - subscription_id: str, - *, - sas_uri_expiration_time_in_minutes: Optional[int] = None, - **kwargs: Any -) -> 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", "2020-06-01")) - 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", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if sas_uri_expiration_time_in_minutes is not None: - _params["sasUriExpirationTimeInMinutes"] = _SERIALIZER.query( - "sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, "int" - ) - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/simulateEviction", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> 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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand", - ) - 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"), - } - - _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_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", "2020-06-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", - ) - 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 -) -> 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", "2020-06-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", - ) - 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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands" - ) - 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", "2020-06-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}", - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"), - "commandId": _SERIALIZER.url("command_id", command_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_run_commands_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, run_command_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_run_commands_update_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, run_command_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="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 -) -> 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", "2020-06-01")) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 - 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - 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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands", - ) - 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"), - } - - _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) - - -def build_virtual_machine_scale_set_vm_run_commands_create_or_update_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, - **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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_set_vm_run_commands_update_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, - **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", "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", - ) - 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"), - } - - _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_virtual_machine_scale_set_vm_run_commands_delete_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, - **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", "2020-06-01")) - 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}/runCommands/{runCommandName}", - ) - 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"), - } - - _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) - - -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", "2020-06-01")) - 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}/runCommands/{runCommandName}", - ) - 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"), - } - - _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) - - -def build_virtual_machine_scale_set_vm_run_commands_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-06-01")) - 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}/runCommands", - ) - 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"), - } - - _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) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.ComputeManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.ComputeOperationValue"]: - """Gets a list of compute operations. - - :return: An iterator like instance of either ComputeOperationValue or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.ComputeOperationValue] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[_models.ComputeOperationListResult] = 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_operations_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def 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) - - 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 AvailabilitySetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.ComputeManagementClient`'s - :attr:`availability_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: _models.AvailabilitySet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySet, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Is either a - AvailabilitySet type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySet") - - _request = build_availability_sets_create_or_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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, - availability_set_name: str, - parameters: _models.AvailabilitySetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySetUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Is either a - AvailabilitySetUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySetUpdate or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySetUpdate") - - _request = build_availability_sets_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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 "2020-06-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.v2020_06_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", 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) - - _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("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription( - self, *, expand: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. - - :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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets 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 AvailabilitySet or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - 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_available_sizes( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes that can be used to create a new virtual machine in - an existing availability set. - - :param resource_group_name: The name of the resource group. Required. - :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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_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 - - if response.status_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 ProximityPlacementGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.ComputeManagementClient`'s - :attr:`proximity_placement_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - resource_group_name: str, - proximity_placement_group_name: str, - parameters: _models.ProximityPlacementGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Create or update a proximity placement group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Create Proximity Placement Group operation. - Required. - :type parameters: ~azure.mgmt.compute.v2020_06_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.v2020_06_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - proximity_placement_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Create or update a proximity placement group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Create Proximity Placement Group operation. - Required. - :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.v2020_06_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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 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. Is - either a ProximityPlacementGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroup or IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("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. 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.v2020_06_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.v2020_06_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. 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.v2020_06_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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 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. Is - either a ProximityPlacementGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroupUpdate or - IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ProximityPlacementGroupUpdate") - - _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, - ) - _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("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any - ) -> None: - """Delete a proximity placement group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - 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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _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, - 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 - - @distributed_trace - 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. 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.v2020_06_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - _request = build_proximity_placement_groups_get_request( - resource_group_name=resource_group_name, - proximity_placement_group_name=proximity_placement_group_name, - subscription_id=self._config.subscription_id, - include_colocation_status=include_colocation_status, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a subscription. - - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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 - ) -> ItemPaged["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a resource group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProximityPlacementGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class DedicatedHostGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.ComputeManagementClient`'s - :attr:`dedicated_host_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: _models.DedicatedHostGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroup, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Is either a - DedicatedHostGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroup or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DedicatedHostGroup") - - _request = build_dedicated_host_groups_create_or_update_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: _models.DedicatedHostGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroupUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :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: IO[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.v2020_06_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroupUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Is either - a DedicatedHostGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroupUpdate or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-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") - - _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) - - _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("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: - """ - 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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_dedicated_host_groups_delete_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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, - host_group_name: str, - *, - expand: Literal["instanceView"] = "instanceView", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Retrieves information about a dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :keyword expand: The expand expression to apply on the operation. The response shows the list - of instance view of the dedicated hosts under the dedicated host group. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", 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) - - _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("DedicatedHostGroup", 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 - ) -> ItemPaged["_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. - :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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 - - if response.status_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, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_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 - - if response.status_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 DedicatedHostsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.ComputeManagementClient`'s - :attr:`dedicated_hosts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, 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 "2020-06-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, "DedicatedHost") - - _request = build_dedicated_hosts_create_or_update_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHost, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHost - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. 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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. Is either a DedicatedHost - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHost or IO[bytes] - :return: An instance of LROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.DedicatedHost] - :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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, 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 "2020-06-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, "DedicatedHostUpdate") - - _request = build_dedicated_hosts_update_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, - 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]: - 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, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHostUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostUpdate - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host 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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Is either a - DedicatedHostUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostUpdate or IO[bytes] - :return: An instance of LROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.DedicatedHost] - :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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_delete_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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, host_group_name: str, host_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete 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 - :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 "2020-06-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, - host_group_name=host_group_name, - host_name=host_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: DedicatedHost or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-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 - ) -> ItemPaged["_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. - :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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.DedicatedHostListResult] = 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_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, - 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("DedicatedHostListResult", 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 SshPublicKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.ComputeManagementClient`'s - :attr:`ssh_public_keys` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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.v2020_06_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 "2020-06-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_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) - - 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 - ) -> ItemPaged["_models.SshPublicKeyResource"]: - """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in - the response to get the next page of SSH public keys. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either SshPublicKeyResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-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 - - def extract_data(pipeline_response): - deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @overload - def create( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: _models.SshPublicKeyResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to create the SSH public key. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_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.v2020_06_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. - - :param resource_group_name: The name of the resource group. 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.v2020_06_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: Union[_models.SshPublicKeyResource, IO[bytes]], - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. - - :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.v2020_06_01.models.SshPublicKeyResource or IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.SshPublicKeyResource - :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 "2020-06-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") - - _request = build_ssh_public_keys_create_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SshPublicKeyResource", 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, - ssh_public_key_name: str, - parameters: _models.SshPublicKeyUpdateResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _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 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.v2020_06_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.v2020_06_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2020_06_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2020_06_01.models.SshPublicKeyUpdateResource or - IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.SshPublicKeyResource - :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 "2020-06-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( - resource_group_name=resource_group_name, - ssh_public_key_name=ssh_public_key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("SshPublicKeyResource", 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, ssh_public_key_name: str, **kwargs: Any - ) -> None: - """Delete an SSH public key. - - :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: - """ - 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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_ssh_public_keys_delete_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) - - _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, 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. - :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.v2020_06_01.models.SshPublicKeyResource - :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 "2020-06-01")) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - - _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) - - _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("SshPublicKeyResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def generate_key_pair( - self, resource_group_name: str, ssh_public_key_name: str, **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. 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: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_01.models.SshPublicKeyGenerateKeyPairResult - :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 "2020-06-01")) - cls: ClsType[_models.SshPublicKeyGenerateKeyPairResult] = kwargs.pop("cls", None) - - _request = build_ssh_public_keys_generate_key_pair_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) - - _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("SshPublicKeyGenerateKeyPairResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class VirtualMachineExtensionImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.ComputeManagementClient`'s - :attr:`virtual_machine_extension_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, type: str, version: str, **kwargs: Any - ) -> _models.VirtualMachineExtensionImage: - """Gets a virtual machine extension image. - - :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.v2020_06_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 "2020-06-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 - - @distributed_trace - def list_types( - self, location: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineExtensionImage]: - """Gets a list of virtual machine extension image types. - - :param location: The name of 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.v2020_06_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 "2020-06-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - - _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) - - _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 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 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.v2020_06_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 "2020-06-01")) - 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 - - -class VirtualMachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.ComputeManagementClient`'s - :attr:`virtual_machine_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, 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 "2020-06-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, "VirtualMachineExtension") - - _request = build_virtual_machine_extensions_create_or_update_request( - resource_group_name=resource_group_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2020_06_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 VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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] - :keyword content_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.v2020_06_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2020_06_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.v2020_06_01.models.VirtualMachineExtension] - :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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - 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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineExtensionUpdate") - - _request = build_virtual_machine_extensions_update_request( - resource_group_name=resource_group_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, - 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]: - 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, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to update the extension. - - :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: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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 - ) -> 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_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 LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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.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.v2020_06_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.v2020_06_01.models.VirtualMachineExtension] - :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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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) - - _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, vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The operation to delete the extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the extension should be deleted. - 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-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, - 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) - - 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_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.v2020_06_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 "2020-06-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) - - deserialized = self._deserialize("VirtualMachineExtension", 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_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.v2020_06_01.models.VirtualMachineExtensionsListResult - :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 "2020-06-01")) - cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_list_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineExtensionsListResult", pipeline_response.http_response) - - 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.v2020_06_01.ComputeManagementClient`'s - :attr:`virtual_machine_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.v2020_06_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 "2020-06-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.v2020_06_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 "2020-06-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. - - :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.v2020_06_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 "2020-06-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_list_offers_request( - location=location, - publisher_name=publisher_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2020_06_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 "2020-06-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 = 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_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 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.v2020_06_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 "2020-06-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _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) - - _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 - - -class UsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.ComputeManagementClient`'s - :attr:`usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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 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.v2020_06_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 "2020-06-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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -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.v2020_06_01.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.VirtualMachine"]: - """Gets all the virtual machines under the specified subscription for the specified location. - - :param location: The location for which virtual machines under the subscription are queried. - Required. - :type location: str - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-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 - - 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) - - def _capture_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2020-06-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 - - 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_capture( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachineCaptureParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. - - :param resource_group_name: The name of the resource group. Required. - :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.v2020_06_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.v2020_06_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. - - :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.v2020_06_01.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_capture( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. - - :param resource_group_name: The name of the resource group. 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.v2020_06_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.v2020_06_01.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineCaptureResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._capture_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineCaptureResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, 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.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 - ) - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, 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 "2020-06-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, "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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachine, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :param resource_group_name: The name of the resource group. 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.v2020_06_01.models.VirtualMachine - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :param resource_group_name: The name of the resource group. 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 content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :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 Create Virtual Machine operation. Is either a - VirtualMachine type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachine or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_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 "2020-06-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._create_or_update_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("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 _update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineUpdate, 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 "2020-06-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, "VirtualMachineUpdate") - - _request = build_virtual_machines_update_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 - - 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 = 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, - vm_name: str, - parameters: _models.VirtualMachineUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. - - :param resource_group_name: The name of the resource group. 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.v2020_06_01.models.VirtualMachineUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. - - :param resource_group_name: The name of the resource group. 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 content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_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]], - **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.v2020_06_01.models.VirtualMachineUpdate or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_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 "2020-06-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, - 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 "2020-06-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 - - @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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword force_deletion: Optional parameter to force delete virtual machines. 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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - force_deletion=force_deletion, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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_name: str, *, expand: Literal["instanceView"] = "instanceView", **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) - - _request = build_virtual_machines_instance_view_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineInstanceView", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _convert_to_managed_disks_initial( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> 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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_convert_to_managed_disks_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. - :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 "2020-06-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._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 - ) - 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 _deallocate_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[Iterator[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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_deallocate(self, resource_group_name: str, vm_name: str, **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. - :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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._deallocate_initial( - resource_group_name=resource_group_name, - vm_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 - - @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. :code:`
    `For Windows, please refer to - `Create a managed image of a generalized VM in Azure - `_.\\ - :code:`
    `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 "2020-06-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 - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-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, - 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, **kwargs: Any) -> ItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-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, - 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_available_sizes( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes to which the specified virtual machine can be - resized. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_available_sizes_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _power_off_initial( - self, resource_group_name: str, vm_name: str, *, skip_shutdown: bool = False, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_power_off_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_power_off( - self, resource_group_name: str, vm_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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool - :return: An instance of 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 "2020-06-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, **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, - 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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_reapply_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. - :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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reapply_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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_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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_restart_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. - :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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._restart_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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_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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_start(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[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 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 "2020-06-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, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_redeploy_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_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 "2020-06-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]: - 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 "2020-06-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( - 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 - - 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_reimage( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[_models.VirtualMachineReimageParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: ~azure.mgmt.compute.v2020_06_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 the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. 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 the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. 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.v2020_06_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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-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_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # 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 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. :code:`
    `\\ :code:`
    `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.v2020_06_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 "2020-06-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 = 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_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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. - :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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_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 - - @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 "2020-06-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]: - 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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. - :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.v2020_06_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 "2020-06-01")) - 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._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 - ) - 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) - 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.VirtualMachineAssessPatchesResult].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 - ) - - def _run_command_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, 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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RunCommandInput") - - _request = build_virtual_machines_run_command_request( - 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 - - 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_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.RunCommandInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_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.v2020_06_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._run_command_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineSizesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.VirtualMachineSize"]: - """This API is deprecated. Use `Resources Skus - `_. - - :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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_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 - - 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 - - if response.status_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 ImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.ComputeManagementClient`'s - :attr:`images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any - ) -> 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 "2020-06-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, "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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: _models.Image, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Create or update 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 - :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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.Image] - :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. - - :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 - :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.v2020_06_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.v2020_06_01.models.Image] - :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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._create_or_update_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: 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.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Image]( - 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]], - **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 "2020-06-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, "ImageUpdate") - - _request = build_images_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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, - image_name: str, - parameters: _models.ImageUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Update 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 - :param parameters: Parameters supplied to the Update Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Update 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 - :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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Update 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 - :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.v2020_06_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.v2020_06_01.models.Image] - :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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: 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.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Image]( - 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]: - 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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_images_delete_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, image_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes an Image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - image_name=image_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, resource_group_name: str, image_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.Image: - """Gets an image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: Image or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.Image] = kwargs.pop("cls", None) - - _request = build_images_get_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Image", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Image"]: - """Gets the list of images 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 Image or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class 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.v2020_06_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, 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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualMachineScaleSet") - - _request = build_virtual_machine_scale_sets_create_or_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSet - :keyword content_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.v2020_06_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. 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 VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 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.v2020_06_01.models.VirtualMachineScaleSet or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_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 "2020-06-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, - 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]], - **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 "2020-06-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, "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, - 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]: - 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, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. - - :param resource_group_name: The name of the resource group. 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.v2020_06_01.models.VirtualMachineScaleSetUpdate - :keyword content_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.v2020_06_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. - - :param resource_group_name: The name of the resource group. 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: IO[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 VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_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]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update 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 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.v2020_06_01.models.VirtualMachineScaleSetUpdate or - IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_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 "2020-06-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, - 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, **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 "2020-06-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, - 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, vm_scale_set_name: str, **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 - :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 "2020-06-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, - 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, **kwargs: Any) -> _models.VirtualMachineScaleSet: - """Display information about a 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 - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _deallocate_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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_deallocate( - 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]: - """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. - :type 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.v2020_06_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_deallocate( - 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]: - """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. - :type 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_deallocate( - 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]: - """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. - :type 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.v2020_06_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 "2020-06-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, - 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 _delete_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2020-06-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") - - _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, - 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_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """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. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2020_06_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: - """ - - @overload - def begin_delete_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]: - """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. - 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_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, 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.v2020_06_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 "2020-06-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, - 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. - - :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.v2020_06_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 "2020-06-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 - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_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 - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-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_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: - 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) -> ItemPaged["_models.VirtualMachineScaleSet"]: - """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource - group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this - till nextLink is null to fetch all the VM Scale Sets. - - :return: An iterator like instance of either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = 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_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("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) - - 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_skus( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineScaleSetSku"]: - """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM - instances allowed for each SKU. - - :param resource_group_name: The name of the resource group. Required. - :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.v2020_06_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 "2020-06-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) - - @distributed_trace - def get_os_upgrade_history( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.UpgradeOperationHistoricalStatusInfo"]: - """Gets list of OS upgrades 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 - :return: An iterator like instance of either UpgradeOperationHistoricalStatusInfo or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_sets_get_os_upgrade_history_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListOSUpgradeHistory", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _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 - ) -> 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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_power_off_request( - resource_group_name=resource_group_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, - 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_power_off( - self, - resource_group_name: str, - vm_scale_set_name: 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) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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.v2020_06_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 - :keyword content_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: 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. - - :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 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 - :keyword content_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_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: bool = False, - **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. Required. - :type 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.v2020_06_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] - :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 "2020-06-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, - 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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_restart_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :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.v2020_06_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 "2020-06-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, - 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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_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 - 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_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.v2020_06_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. - - :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.v2020_06_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 "2020-06-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 _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]: - 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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_redeploy_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_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.v2020_06_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.v2020_06_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 "2020-06-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 - ) -> 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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_perform_maintenance( - 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]: - """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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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.v2020_06_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_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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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_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/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - - :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.v2020_06_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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2020-06-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") - - _request = build_virtual_machine_scale_sets_update_instances_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :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.v2020_06_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: - """ - - @overload - def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _reimage_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2020-06-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( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_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.v2020_06_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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Is either a - VirtualMachineScaleSetReimageParameters type or a IO[bytes] type. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetReimageParameters or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reimage_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_scale_set_reimage_input=vm_scale_set_reimage_input, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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_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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_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.v2020_06_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. - - :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.v2020_06_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 "2020-06-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 - - @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, **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 - :return: RecoveryWalkResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-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, - 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("RecoveryWalkResponse", 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.v2020_06_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. 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 - 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. 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.v2020_06_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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VMScaleSetConvertToSinglePlacementGroupInput") - - _request = build_virtual_machine_scale_sets_convert_to_single_placement_group_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - def _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]: - 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 "2020-06-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") - - _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, - 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_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. - - :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.v2020_06_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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_set_orchestration_service_state( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Changes ServiceState property for a given service. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the virtual machine scale set to create or update. - Required. - :type vm_scale_set_name: str - :param parameters: The input object for SetOrchestrationServiceState API. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_set_orchestration_service_state( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Changes ServiceState property for a given service. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the virtual machine scale set to create or update. - Required. - :type vm_scale_set_name: str - :param parameters: The input object for SetOrchestrationServiceState API. Is either a - OrchestrationServiceStateInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-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) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - -class 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.v2020_06_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtension, 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 "2020-06-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") - - _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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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. - - :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.v2020_06_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.v2020_06_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.v2020_06_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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.v2020_06_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.v2020_06_01.models.VirtualMachineScaleSetExtension] - :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 "2020-06-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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - 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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtensionUpdate") - - _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, - 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]: - 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, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtensionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :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.v2020_06_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.v2020_06_01.models.VirtualMachineScaleSetExtension] - :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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2020-06-01")) - 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, - 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, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The operation to delete the extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be deleted. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSetExtension: - """The operation to get the extension. - - :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.v2020_06_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 "2020-06-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 - - @distributed_trace - def list( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_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.v2020_06_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 "2020-06-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) - - -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.v2020_06_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_rolling_upgrades_cancel_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - 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 - - 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. - - :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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._cancel_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **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, - 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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request( - resource_group_name=resource_group_name, - 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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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 "2020-06-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 - ) -> 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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = 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, - 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 - - return deserialized # type: ignore - - @distributed_trace - def begin_start_extension_upgrade( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Starts a rolling upgrade to move all extensions for all virtual machine scale set instances to - the latest available extension version. Instances which are already running the latest - extension versions are not affected. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-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 - - 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_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.v2020_06_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 "2020-06-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 - ) - - response = pipeline_response.http_response - - if response.status_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.v2020_06_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vm_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - 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 "2020-06-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, "VirtualMachineScaleSetVMExtension") - - _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) - - _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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetVMExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2020_06_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.v2020_06_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Is either a VirtualMachineScaleSetVMExtension type or a IO[bytes] type. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2020_06_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.v2020_06_01.models.VirtualMachineScaleSetVMExtension] - :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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSetVMExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetVMExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2020-06-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( - 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) - - _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]: - 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, - 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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2020_06_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.v2020_06_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2020_06_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2020_06_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.v2020_06_01.models.VirtualMachineScaleSetVMExtension] - :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 "2020-06-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 - ) - - 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, - 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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_extensions_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - 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, 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 resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :return: An instance of 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 "2020-06-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) - - 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, - 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. - :type 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.v2020_06_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 "2020-06-01")) - 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 - - @distributed_trace - def list( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: - """The operation to get all extensions of an instance in Virtual Machine Scaleset. - - :param resource_group_name: The name of the resource group. Required. - :type 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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_extensions_list_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_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 - - -class VirtualMachineScaleSetVMsOperations: # 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.v2020_06_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _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 - ) -> 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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_scale_set_vm_reimage_input, (IOBase, bytes)): - _content = vm_scale_set_vm_reimage_input - else: - if vm_scale_set_vm_reimage_input is not None: - _json = self._serialize.body(vm_scale_set_vm_reimage_input, "VirtualMachineScaleSetVMReimageParameters") - else: - _json = None - - _request = build_virtual_machine_scale_set_vms_reimage_request( - 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 - 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_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Default value is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMReimageParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Default value is None. - :type vm_scale_set_vm_reimage_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[ - Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] - ] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Is either a VirtualMachineScaleSetVMReimageParameters type or a IO[bytes] type. Default value - is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2020_06_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 "2020-06-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, **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, - 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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_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. - :type 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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reimage_all_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - 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 "2020-06-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) - - 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_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. - :type 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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._deallocate_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, 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 "2020-06-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, "VirtualMachineScaleSetVM") - - _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, - 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, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.VirtualMachineScaleSetVM, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVM - :keyword content_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.v2020_06_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - 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 VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. - Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVM or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVM] - :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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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, - 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("VirtualMachineScaleSetVM", 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.VirtualMachineScaleSetVM].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetVM]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, 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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - 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, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes 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: 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 "2020-06-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, - 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, - instance_id: str, - *, - expand: Literal["instanceView"] = "instanceView", - **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. Known values are - "instanceView" and None. Default value is "instanceView". - :paramtype expand: str - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2020_06_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 "2020-06-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.v2020_06_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 "2020-06-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 - ) -> ItemPaged["_models.VirtualMachineScaleSetVM"]: - """Gets a list of all virtual machines in a VM scale sets. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param virtual_machine_scale_set_name: The name of the VM scale set. Required. - :type virtual_machine_scale_set_name: str - :keyword filter: The filter to apply to the operation. Allowed values are - 'startswith(instanceView/statuses/code, 'PowerState') eq true', 'properties/latestModelApplied - eq true', 'properties/latestModelApplied eq false'. Default value is None. - :paramtype filter: str - :keyword select: The list parameters. Allowed values are 'instanceView', - 'instanceView/statuses'. Default value is None. - :paramtype select: str - :keyword expand: The expand expression to apply to the operation. Allowed values are - 'instanceView'. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_set_vms_list_request( - resource_group_name=resource_group_name, - virtual_machine_scale_set_name=virtual_machine_scale_set_name, - subscription_id=self._config.subscription_id, - filter=filter, - select=select, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVMListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _power_off_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - skip_shutdown: bool = False, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_power_off_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - skip_shutdown: bool = False, - **kwargs: Any - ) -> LROPoller[None]: - """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached - and you are getting charged for the resources. Instead, use deallocate to release resources and - avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-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 "2020-06-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 - - return deserialized # type: ignore - - @distributed_trace - def begin_restart( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Restarts a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type 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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._restart_initial( - resource_group_name=resource_group_name, - vm_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 - - 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, - 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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_start_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 - - return deserialized # type: ignore - - @distributed_trace - def begin_start( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Starts a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM 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 "2020-06-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_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 - - 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, - 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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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 vm_scale_set_name: The name of the VM 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 "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._redeploy_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **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_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. Required. - :type 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. :code:`
    `\\ :code:`
    `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.v2020_06_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 "2020-06-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, - 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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_perform_maintenance( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Performs maintenance on a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def simulate_eviction( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> None: - """The operation to simulate the eviction of spot virtual machine in a VM scale set. - - :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 "2020-06-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 _run_command_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, 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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RunCommandInput") - - _request = build_virtual_machine_scale_set_vms_run_command_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 - 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_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - :type 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.v2020_06_01.models.RunCommandInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> 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. - :type 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.v2020_06_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.v2020_06_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._run_command_initial( - resource_group_name=resource_group_name, - vm_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("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, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class LogAnalyticsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.ComputeManagementClient`'s - :attr:`log_analytics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - 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 "2020-06-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, "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, - ) - _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_export_request_rate_by_interval( - self, - location: str, - parameters: _models.RequestRateByIntervalInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. - - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. - Required. - :type parameters: ~azure.mgmt.compute.v2020_06_01.models.RequestRateByIntervalInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.LogAnalyticsOperationResult] - :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. - - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_export_request_rate_by_interval( - self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. - - :param location: The 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.v2020_06_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.v2020_06_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 "2020-06-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, 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, - 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("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, 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.LogAnalyticsOperationResult].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 - ) - - def _export_throttled_requests_initial( - self, location: str, parameters: Union[_models.ThrottledRequestsInput, 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 "2020-06-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, - 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_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.v2020_06_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.v2020_06_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.v2020_06_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. - - :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.v2020_06_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.v2020_06_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 "2020-06-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, 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, - 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("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, 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.LogAnalyticsOperationResult].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 - ) - - -class VirtualMachineRunCommandsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2020_06_01.ComputeManagementClient`'s - :attr:`virtual_machine_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.RunCommandDocumentBase"]: - """Lists all available run commands for a subscription in a location. - - :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 - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_run_commands_list_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RunCommandListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - 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, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: - """Gets specific run command for a subscription in a location. - - :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.v2020_06_01.models.RunCommandDocument - :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 "2020-06-01")) - cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) - - _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, - 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("RunCommandDocument", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 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 "2020-06-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(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_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, - ) - _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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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. - :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. - :type run_command_name: str - :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. - Required. - :type run_command: ~azure.mgmt.compute.v2020_06_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.v2020_06_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - run_command: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update the run command. - - :param resource_group_name: The name of the resource group. 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. - :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". - :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.v2020_06_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. 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. - :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.v2020_06_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.v2020_06_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 "2020-06-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): - deserialized = self._deserialize("VirtualMachineRunCommand", 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.VirtualMachineRunCommand].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineRunCommand]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommandUpdate, 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 "2020-06-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(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_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, - ) - _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]: - 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, - vm_name: 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. - - :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. - Required. - :type vm_name: 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. - Required. - :type run_command: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - run_command: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the run command. - - :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. - Required. - :type vm_name: 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. - 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". - :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.v2020_06_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the run command. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be updated. - Required. - :type vm_name: 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.v2020_06_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.v2020_06_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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - run_command_name=run_command_name, - run_command=run_command, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommand", 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.VirtualMachineRunCommand].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineRunCommand]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, vm_name: str, run_command_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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_run_commands_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - run_command_name=run_command_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, 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. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be deleted. - Required. - :type vm_name: str - :param run_command_name: The name of the virtual machine run command. 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-06-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) - - 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_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. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine containing the run command. 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.v2020_06_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 "2020-06-01")) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - - _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) - - _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_by_virtual_machine( - self, resource_group_name: str, vm_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineRunCommand"]: - """The operation to get all run commands 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 run command. 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.v2020_06_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 "2020-06-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_run_commands_list_by_virtual_machine_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommandsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -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.v2020_06_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vm_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommand, 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 "2020-06-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(run_command, (IOBase, bytes)): - _content = run_command - else: - _json = self._serialize.body(run_command, "VirtualMachineRunCommand") - - _request = build_virtual_machine_scale_set_vm_run_commands_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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 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 - :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. - Required. - :type run_command: ~azure.mgmt.compute.v2020_06_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.v2020_06_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update 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 - :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". - :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.v2020_06_01.models.VirtualMachineRunCommand] - :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, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update 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 - :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.v2020_06_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.v2020_06_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 "2020-06-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_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, - 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("VirtualMachineRunCommand", 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.VirtualMachineRunCommand].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineRunCommand]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _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]], - **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 "2020-06-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(run_command, (IOBase, bytes)): - _content = run_command - else: - _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") - - _request = build_virtual_machine_scale_set_vm_run_commands_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, - 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]: - 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, - 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 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 - :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. - Required. - :type run_command: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_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 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 - :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. - Known values are: 'application/json', 'text/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) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand] - :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]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """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_scale_set_name: The name of the VM 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.v2020_06_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.v2020_06_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 "2020-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - vm_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, - 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("VirtualMachineRunCommand", 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.VirtualMachineRunCommand].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineRunCommand]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - 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, - 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 "2020-06-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_run_commands_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, - 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, vm_scale_set_name: str, instance_id: str, run_command_name: str, **kwargs: Any - ) -> LROPoller[None]: - """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_scale_set_name: The name of the VM 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 - :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 "2020-06-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, - 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) - - 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, - 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.v2020_06_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 "2020-06-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 - ) -> ItemPaged["_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.v2020_06_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 "2020-06-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/v2020_06_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2021_07_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_compute_management_client.py deleted file mode 100644 index 235ecdb624ca..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_compute_management_client.py +++ /dev/null @@ -1,373 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ( - AvailabilitySetsOperations, - CapacityReservationGroupsOperations, - CapacityReservationsOperations, - CommunityGalleriesOperations, - CommunityGalleryImageVersionsOperations, - CommunityGalleryImagesOperations, - DedicatedHostGroupsOperations, - DedicatedHostsOperations, - GalleriesOperations, - GalleryApplicationVersionsOperations, - GalleryApplicationsOperations, - GalleryImageVersionsOperations, - GalleryImagesOperations, - GallerySharingProfileOperations, - ImagesOperations, - LogAnalyticsOperations, - Operations, - ProximityPlacementGroupsOperations, - ResourceSkusOperations, - RestorePointCollectionsOperations, - RestorePointsOperations, - SharedGalleriesOperations, - SharedGalleryImageVersionsOperations, - SharedGalleryImagesOperations, - SshPublicKeysOperations, - UsageOperations, - VirtualMachineExtensionImagesOperations, - VirtualMachineExtensionsOperations, - VirtualMachineImagesEdgeZoneOperations, - VirtualMachineImagesOperations, - VirtualMachineRunCommandsOperations, - VirtualMachineScaleSetExtensionsOperations, - VirtualMachineScaleSetRollingUpgradesOperations, - VirtualMachineScaleSetVMExtensionsOperations, - VirtualMachineScaleSetVMRunCommandsOperations, - VirtualMachineScaleSetVMsOperations, - VirtualMachineScaleSetsOperations, - VirtualMachineSizesOperations, - VirtualMachinesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.compute.v2021_07_01.operations.Operations - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2021_07_01.operations.AvailabilitySetsOperations - :ivar proximity_placement_groups: ProximityPlacementGroupsOperations operations - :vartype proximity_placement_groups: - azure.mgmt.compute.v2021_07_01.operations.ProximityPlacementGroupsOperations - :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations - :vartype dedicated_host_groups: - azure.mgmt.compute.v2021_07_01.operations.DedicatedHostGroupsOperations - :ivar dedicated_hosts: DedicatedHostsOperations operations - :vartype dedicated_hosts: azure.mgmt.compute.v2021_07_01.operations.DedicatedHostsOperations - :ivar ssh_public_keys: SshPublicKeysOperations operations - :vartype ssh_public_keys: azure.mgmt.compute.v2021_07_01.operations.SshPublicKeysOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2021_07_01.operations.VirtualMachineExtensionImagesOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2021_07_01.operations.VirtualMachineExtensionsOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2021_07_01.operations.VirtualMachineImagesOperations - :ivar virtual_machine_images_edge_zone: VirtualMachineImagesEdgeZoneOperations operations - :vartype virtual_machine_images_edge_zone: - azure.mgmt.compute.v2021_07_01.operations.VirtualMachineImagesEdgeZoneOperations - :ivar usage: UsageOperations operations - :vartype usage: azure.mgmt.compute.v2021_07_01.operations.UsageOperations - :ivar virtual_machines: VirtualMachinesOperations operations - :vartype virtual_machines: azure.mgmt.compute.v2021_07_01.operations.VirtualMachinesOperations - :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations - :vartype virtual_machine_scale_sets: - azure.mgmt.compute.v2021_07_01.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2021_07_01.operations.VirtualMachineSizesOperations - :ivar images: ImagesOperations operations - :vartype images: azure.mgmt.compute.v2021_07_01.operations.ImagesOperations - :ivar restore_point_collections: RestorePointCollectionsOperations operations - :vartype restore_point_collections: - azure.mgmt.compute.v2021_07_01.operations.RestorePointCollectionsOperations - :ivar restore_points: RestorePointsOperations operations - :vartype restore_points: azure.mgmt.compute.v2021_07_01.operations.RestorePointsOperations - :ivar capacity_reservation_groups: CapacityReservationGroupsOperations operations - :vartype capacity_reservation_groups: - azure.mgmt.compute.v2021_07_01.operations.CapacityReservationGroupsOperations - :ivar capacity_reservations: CapacityReservationsOperations operations - :vartype capacity_reservations: - azure.mgmt.compute.v2021_07_01.operations.CapacityReservationsOperations - :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations - operations - :vartype virtual_machine_scale_set_extensions: - azure.mgmt.compute.v2021_07_01.operations.VirtualMachineScaleSetExtensionsOperations - :ivar virtual_machine_scale_set_rolling_upgrades: - VirtualMachineScaleSetRollingUpgradesOperations operations - :vartype virtual_machine_scale_set_rolling_upgrades: - azure.mgmt.compute.v2021_07_01.operations.VirtualMachineScaleSetRollingUpgradesOperations - :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations - operations - :vartype virtual_machine_scale_set_vm_extensions: - azure.mgmt.compute.v2021_07_01.operations.VirtualMachineScaleSetVMExtensionsOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2021_07_01.operations.VirtualMachineScaleSetVMsOperations - :ivar log_analytics: LogAnalyticsOperations operations - :vartype log_analytics: azure.mgmt.compute.v2021_07_01.operations.LogAnalyticsOperations - :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations - :vartype virtual_machine_run_commands: - azure.mgmt.compute.v2021_07_01.operations.VirtualMachineRunCommandsOperations - :ivar virtual_machine_scale_set_vm_run_commands: VirtualMachineScaleSetVMRunCommandsOperations - operations - :vartype virtual_machine_scale_set_vm_run_commands: - azure.mgmt.compute.v2021_07_01.operations.VirtualMachineScaleSetVMRunCommandsOperations - :ivar resource_skus: ResourceSkusOperations operations - :vartype resource_skus: azure.mgmt.compute.v2021_07_01.operations.ResourceSkusOperations - :ivar galleries: GalleriesOperations operations - :vartype galleries: azure.mgmt.compute.v2021_07_01.operations.GalleriesOperations - :ivar gallery_images: GalleryImagesOperations operations - :vartype gallery_images: azure.mgmt.compute.v2021_07_01.operations.GalleryImagesOperations - :ivar gallery_image_versions: GalleryImageVersionsOperations operations - :vartype gallery_image_versions: - azure.mgmt.compute.v2021_07_01.operations.GalleryImageVersionsOperations - :ivar gallery_applications: GalleryApplicationsOperations operations - :vartype gallery_applications: - azure.mgmt.compute.v2021_07_01.operations.GalleryApplicationsOperations - :ivar gallery_application_versions: GalleryApplicationVersionsOperations operations - :vartype gallery_application_versions: - azure.mgmt.compute.v2021_07_01.operations.GalleryApplicationVersionsOperations - :ivar gallery_sharing_profile: GallerySharingProfileOperations operations - :vartype gallery_sharing_profile: - azure.mgmt.compute.v2021_07_01.operations.GallerySharingProfileOperations - :ivar shared_galleries: SharedGalleriesOperations operations - :vartype shared_galleries: azure.mgmt.compute.v2021_07_01.operations.SharedGalleriesOperations - :ivar shared_gallery_images: SharedGalleryImagesOperations operations - :vartype shared_gallery_images: - azure.mgmt.compute.v2021_07_01.operations.SharedGalleryImagesOperations - :ivar shared_gallery_image_versions: SharedGalleryImageVersionsOperations operations - :vartype shared_gallery_image_versions: - azure.mgmt.compute.v2021_07_01.operations.SharedGalleryImageVersionsOperations - :ivar community_galleries: CommunityGalleriesOperations operations - :vartype community_galleries: - azure.mgmt.compute.v2021_07_01.operations.CommunityGalleriesOperations - :ivar community_gallery_images: CommunityGalleryImagesOperations operations - :vartype community_gallery_images: - azure.mgmt.compute.v2021_07_01.operations.CommunityGalleryImagesOperations - :ivar community_gallery_image_versions: CommunityGalleryImageVersionsOperations operations - :vartype community_gallery_image_versions: - azure.mgmt.compute.v2021_07_01.operations.CommunityGalleryImageVersionsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2021-07-01") - self.availability_sets = AvailabilitySetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.proximity_placement_groups = ProximityPlacementGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.dedicated_host_groups = DedicatedHostGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.dedicated_hosts = DedicatedHostsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.ssh_public_keys = SshPublicKeysOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_images = VirtualMachineImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2021-07-01") - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2021-07-01") - self.restore_point_collections = RestorePointCollectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.restore_points = RestorePointsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.capacity_reservation_groups = CapacityReservationGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.capacity_reservations = CapacityReservationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.log_analytics = LogAnalyticsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.resource_skus = ResourceSkusOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.galleries = GalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.gallery_images = GalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.gallery_image_versions = GalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.gallery_applications = GalleryApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.gallery_application_versions = GalleryApplicationVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.gallery_sharing_profile = GallerySharingProfileOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.shared_galleries = SharedGalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.shared_gallery_images = SharedGalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.community_galleries = CommunityGalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.community_gallery_images = CommunityGalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_configuration.py deleted file mode 100644 index 7f81b881095b..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2021-07-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_metadata.json deleted file mode 100644 index 9c8c12473b87..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_metadata.json +++ /dev/null @@ -1,148 +0,0 @@ -{ - "chosen_version": "2021-07-01", - "total_api_version_list": ["2021-07-01"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "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.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "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.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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": { - "operations": "Operations", - "availability_sets": "AvailabilitySetsOperations", - "proximity_placement_groups": "ProximityPlacementGroupsOperations", - "dedicated_host_groups": "DedicatedHostGroupsOperations", - "dedicated_hosts": "DedicatedHostsOperations", - "ssh_public_keys": "SshPublicKeysOperations", - "virtual_machine_extension_images": "VirtualMachineExtensionImagesOperations", - "virtual_machine_extensions": "VirtualMachineExtensionsOperations", - "virtual_machine_images": "VirtualMachineImagesOperations", - "virtual_machine_images_edge_zone": "VirtualMachineImagesEdgeZoneOperations", - "usage": "UsageOperations", - "virtual_machines": "VirtualMachinesOperations", - "virtual_machine_scale_sets": "VirtualMachineScaleSetsOperations", - "virtual_machine_sizes": "VirtualMachineSizesOperations", - "images": "ImagesOperations", - "restore_point_collections": "RestorePointCollectionsOperations", - "restore_points": "RestorePointsOperations", - "capacity_reservation_groups": "CapacityReservationGroupsOperations", - "capacity_reservations": "CapacityReservationsOperations", - "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", - "log_analytics": "LogAnalyticsOperations", - "virtual_machine_run_commands": "VirtualMachineRunCommandsOperations", - "virtual_machine_scale_set_vm_run_commands": "VirtualMachineScaleSetVMRunCommandsOperations", - "resource_skus": "ResourceSkusOperations", - "galleries": "GalleriesOperations", - "gallery_images": "GalleryImagesOperations", - "gallery_image_versions": "GalleryImageVersionsOperations", - "gallery_applications": "GalleryApplicationsOperations", - "gallery_application_versions": "GalleryApplicationVersionsOperations", - "gallery_sharing_profile": "GallerySharingProfileOperations", - "shared_galleries": "SharedGalleriesOperations", - "shared_gallery_images": "SharedGalleryImagesOperations", - "shared_gallery_image_versions": "SharedGalleryImageVersionsOperations", - "community_galleries": "CommunityGalleriesOperations", - "community_gallery_images": "CommunityGalleryImagesOperations", - "community_gallery_image_versions": "CommunityGalleryImageVersionsOperations" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node
    is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj 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 deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2021_07_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/_compute_management_client.py deleted file mode 100644 index a440ad8f57dc..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/_compute_management_client.py +++ /dev/null @@ -1,380 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ( - AvailabilitySetsOperations, - CapacityReservationGroupsOperations, - CapacityReservationsOperations, - CommunityGalleriesOperations, - CommunityGalleryImageVersionsOperations, - CommunityGalleryImagesOperations, - DedicatedHostGroupsOperations, - DedicatedHostsOperations, - GalleriesOperations, - GalleryApplicationVersionsOperations, - GalleryApplicationsOperations, - GalleryImageVersionsOperations, - GalleryImagesOperations, - GallerySharingProfileOperations, - ImagesOperations, - LogAnalyticsOperations, - Operations, - ProximityPlacementGroupsOperations, - ResourceSkusOperations, - RestorePointCollectionsOperations, - RestorePointsOperations, - SharedGalleriesOperations, - SharedGalleryImageVersionsOperations, - SharedGalleryImagesOperations, - SshPublicKeysOperations, - UsageOperations, - VirtualMachineExtensionImagesOperations, - VirtualMachineExtensionsOperations, - VirtualMachineImagesEdgeZoneOperations, - VirtualMachineImagesOperations, - VirtualMachineRunCommandsOperations, - VirtualMachineScaleSetExtensionsOperations, - VirtualMachineScaleSetRollingUpgradesOperations, - VirtualMachineScaleSetVMExtensionsOperations, - VirtualMachineScaleSetVMRunCommandsOperations, - VirtualMachineScaleSetVMsOperations, - VirtualMachineScaleSetsOperations, - VirtualMachineSizesOperations, - VirtualMachinesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.compute.v2021_07_01.aio.operations.Operations - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2021_07_01.aio.operations.AvailabilitySetsOperations - :ivar proximity_placement_groups: ProximityPlacementGroupsOperations operations - :vartype proximity_placement_groups: - azure.mgmt.compute.v2021_07_01.aio.operations.ProximityPlacementGroupsOperations - :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations - :vartype dedicated_host_groups: - azure.mgmt.compute.v2021_07_01.aio.operations.DedicatedHostGroupsOperations - :ivar dedicated_hosts: DedicatedHostsOperations operations - :vartype dedicated_hosts: - azure.mgmt.compute.v2021_07_01.aio.operations.DedicatedHostsOperations - :ivar ssh_public_keys: SshPublicKeysOperations operations - :vartype ssh_public_keys: azure.mgmt.compute.v2021_07_01.aio.operations.SshPublicKeysOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2021_07_01.aio.operations.VirtualMachineExtensionImagesOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2021_07_01.aio.operations.VirtualMachineExtensionsOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2021_07_01.aio.operations.VirtualMachineImagesOperations - :ivar virtual_machine_images_edge_zone: VirtualMachineImagesEdgeZoneOperations operations - :vartype virtual_machine_images_edge_zone: - azure.mgmt.compute.v2021_07_01.aio.operations.VirtualMachineImagesEdgeZoneOperations - :ivar usage: UsageOperations operations - :vartype usage: azure.mgmt.compute.v2021_07_01.aio.operations.UsageOperations - :ivar virtual_machines: VirtualMachinesOperations operations - :vartype virtual_machines: - azure.mgmt.compute.v2021_07_01.aio.operations.VirtualMachinesOperations - :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations - :vartype virtual_machine_scale_sets: - azure.mgmt.compute.v2021_07_01.aio.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2021_07_01.aio.operations.VirtualMachineSizesOperations - :ivar images: ImagesOperations operations - :vartype images: azure.mgmt.compute.v2021_07_01.aio.operations.ImagesOperations - :ivar restore_point_collections: RestorePointCollectionsOperations operations - :vartype restore_point_collections: - azure.mgmt.compute.v2021_07_01.aio.operations.RestorePointCollectionsOperations - :ivar restore_points: RestorePointsOperations operations - :vartype restore_points: azure.mgmt.compute.v2021_07_01.aio.operations.RestorePointsOperations - :ivar capacity_reservation_groups: CapacityReservationGroupsOperations operations - :vartype capacity_reservation_groups: - azure.mgmt.compute.v2021_07_01.aio.operations.CapacityReservationGroupsOperations - :ivar capacity_reservations: CapacityReservationsOperations operations - :vartype capacity_reservations: - azure.mgmt.compute.v2021_07_01.aio.operations.CapacityReservationsOperations - :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations - operations - :vartype virtual_machine_scale_set_extensions: - azure.mgmt.compute.v2021_07_01.aio.operations.VirtualMachineScaleSetExtensionsOperations - :ivar virtual_machine_scale_set_rolling_upgrades: - VirtualMachineScaleSetRollingUpgradesOperations operations - :vartype virtual_machine_scale_set_rolling_upgrades: - azure.mgmt.compute.v2021_07_01.aio.operations.VirtualMachineScaleSetRollingUpgradesOperations - :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations - operations - :vartype virtual_machine_scale_set_vm_extensions: - azure.mgmt.compute.v2021_07_01.aio.operations.VirtualMachineScaleSetVMExtensionsOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2021_07_01.aio.operations.VirtualMachineScaleSetVMsOperations - :ivar log_analytics: LogAnalyticsOperations operations - :vartype log_analytics: azure.mgmt.compute.v2021_07_01.aio.operations.LogAnalyticsOperations - :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations - :vartype virtual_machine_run_commands: - azure.mgmt.compute.v2021_07_01.aio.operations.VirtualMachineRunCommandsOperations - :ivar virtual_machine_scale_set_vm_run_commands: VirtualMachineScaleSetVMRunCommandsOperations - operations - :vartype virtual_machine_scale_set_vm_run_commands: - azure.mgmt.compute.v2021_07_01.aio.operations.VirtualMachineScaleSetVMRunCommandsOperations - :ivar resource_skus: ResourceSkusOperations operations - :vartype resource_skus: azure.mgmt.compute.v2021_07_01.aio.operations.ResourceSkusOperations - :ivar galleries: GalleriesOperations operations - :vartype galleries: azure.mgmt.compute.v2021_07_01.aio.operations.GalleriesOperations - :ivar gallery_images: GalleryImagesOperations operations - :vartype gallery_images: azure.mgmt.compute.v2021_07_01.aio.operations.GalleryImagesOperations - :ivar gallery_image_versions: GalleryImageVersionsOperations operations - :vartype gallery_image_versions: - azure.mgmt.compute.v2021_07_01.aio.operations.GalleryImageVersionsOperations - :ivar gallery_applications: GalleryApplicationsOperations operations - :vartype gallery_applications: - azure.mgmt.compute.v2021_07_01.aio.operations.GalleryApplicationsOperations - :ivar gallery_application_versions: GalleryApplicationVersionsOperations operations - :vartype gallery_application_versions: - azure.mgmt.compute.v2021_07_01.aio.operations.GalleryApplicationVersionsOperations - :ivar gallery_sharing_profile: GallerySharingProfileOperations operations - :vartype gallery_sharing_profile: - azure.mgmt.compute.v2021_07_01.aio.operations.GallerySharingProfileOperations - :ivar shared_galleries: SharedGalleriesOperations operations - :vartype shared_galleries: - azure.mgmt.compute.v2021_07_01.aio.operations.SharedGalleriesOperations - :ivar shared_gallery_images: SharedGalleryImagesOperations operations - :vartype shared_gallery_images: - azure.mgmt.compute.v2021_07_01.aio.operations.SharedGalleryImagesOperations - :ivar shared_gallery_image_versions: SharedGalleryImageVersionsOperations operations - :vartype shared_gallery_image_versions: - azure.mgmt.compute.v2021_07_01.aio.operations.SharedGalleryImageVersionsOperations - :ivar community_galleries: CommunityGalleriesOperations operations - :vartype community_galleries: - azure.mgmt.compute.v2021_07_01.aio.operations.CommunityGalleriesOperations - :ivar community_gallery_images: CommunityGalleryImagesOperations operations - :vartype community_gallery_images: - azure.mgmt.compute.v2021_07_01.aio.operations.CommunityGalleryImagesOperations - :ivar community_gallery_image_versions: CommunityGalleryImageVersionsOperations operations - :vartype community_gallery_image_versions: - azure.mgmt.compute.v2021_07_01.aio.operations.CommunityGalleryImageVersionsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2021-07-01") - self.availability_sets = AvailabilitySetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.proximity_placement_groups = ProximityPlacementGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.dedicated_host_groups = DedicatedHostGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.dedicated_hosts = DedicatedHostsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.ssh_public_keys = SshPublicKeysOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_images = VirtualMachineImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2021-07-01") - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2021-07-01") - self.restore_point_collections = RestorePointCollectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.restore_points = RestorePointsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.capacity_reservation_groups = CapacityReservationGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.capacity_reservations = CapacityReservationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.log_analytics = LogAnalyticsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.resource_skus = ResourceSkusOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.galleries = GalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.gallery_images = GalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.gallery_image_versions = GalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.gallery_applications = GalleryApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.gallery_application_versions = GalleryApplicationVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.gallery_sharing_profile = GallerySharingProfileOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.shared_galleries = SharedGalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.shared_gallery_images = SharedGalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.community_galleries = CommunityGalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.community_gallery_images = CommunityGalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/_configuration.py deleted file mode 100644 index 427c7edc62d1..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2021-07-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/__init__.py deleted file mode 100644 index 240530fe0fdb..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/__init__.py +++ /dev/null @@ -1,101 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import Operations # type: ignore -from ._operations import AvailabilitySetsOperations # 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 VirtualMachineExtensionImagesOperations # type: ignore -from ._operations import VirtualMachineExtensionsOperations # type: ignore -from ._operations import VirtualMachineImagesOperations # type: ignore -from ._operations import VirtualMachineImagesEdgeZoneOperations # type: ignore -from ._operations import UsageOperations # type: ignore -from ._operations import VirtualMachinesOperations # type: ignore -from ._operations import VirtualMachineScaleSetsOperations # type: ignore -from ._operations import VirtualMachineSizesOperations # 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 CapacityReservationsOperations # 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 LogAnalyticsOperations # type: ignore -from ._operations import VirtualMachineRunCommandsOperations # type: ignore -from ._operations import VirtualMachineScaleSetVMRunCommandsOperations # type: ignore -from ._operations import ResourceSkusOperations # type: ignore -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 ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AvailabilitySetsOperations", - "ProximityPlacementGroupsOperations", - "DedicatedHostGroupsOperations", - "DedicatedHostsOperations", - "SshPublicKeysOperations", - "VirtualMachineExtensionImagesOperations", - "VirtualMachineExtensionsOperations", - "VirtualMachineImagesOperations", - "VirtualMachineImagesEdgeZoneOperations", - "UsageOperations", - "VirtualMachinesOperations", - "VirtualMachineScaleSetsOperations", - "VirtualMachineSizesOperations", - "ImagesOperations", - "RestorePointCollectionsOperations", - "RestorePointsOperations", - "CapacityReservationGroupsOperations", - "CapacityReservationsOperations", - "VirtualMachineScaleSetExtensionsOperations", - "VirtualMachineScaleSetRollingUpgradesOperations", - "VirtualMachineScaleSetVMExtensionsOperations", - "VirtualMachineScaleSetVMsOperations", - "LogAnalyticsOperations", - "VirtualMachineRunCommandsOperations", - "VirtualMachineScaleSetVMRunCommandsOperations", - "ResourceSkusOperations", - "GalleriesOperations", - "GalleryImagesOperations", - "GalleryImageVersionsOperations", - "GalleryApplicationsOperations", - "GalleryApplicationVersionsOperations", - "GallerySharingProfileOperations", - "SharedGalleriesOperations", - "SharedGalleryImagesOperations", - "SharedGalleryImageVersionsOperations", - "CommunityGalleriesOperations", - "CommunityGalleryImagesOperations", - "CommunityGalleryImageVersionsOperations", -] -__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/v2021_07_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_operations.py deleted file mode 100644 index db4253503e1a..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_operations.py +++ /dev/null @@ -1,24813 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import ( - build_availability_sets_create_or_update_request, - build_availability_sets_delete_request, - build_availability_sets_get_request, - build_availability_sets_list_available_sizes_request, - build_availability_sets_list_by_subscription_request, - build_availability_sets_list_request, - build_availability_sets_update_request, - build_capacity_reservation_groups_create_or_update_request, - build_capacity_reservation_groups_delete_request, - build_capacity_reservation_groups_get_request, - build_capacity_reservation_groups_list_by_resource_group_request, - build_capacity_reservation_groups_list_by_subscription_request, - build_capacity_reservation_groups_update_request, - build_capacity_reservations_create_or_update_request, - build_capacity_reservations_delete_request, - build_capacity_reservations_get_request, - build_capacity_reservations_list_by_capacity_reservation_group_request, - build_capacity_reservations_update_request, - build_community_galleries_get_request, - build_community_gallery_image_versions_get_request, - build_community_gallery_images_get_request, - build_dedicated_host_groups_create_or_update_request, - build_dedicated_host_groups_delete_request, - build_dedicated_host_groups_get_request, - build_dedicated_host_groups_list_by_resource_group_request, - build_dedicated_host_groups_list_by_subscription_request, - build_dedicated_host_groups_update_request, - build_dedicated_hosts_create_or_update_request, - build_dedicated_hosts_delete_request, - build_dedicated_hosts_get_request, - build_dedicated_hosts_list_by_host_group_request, - build_dedicated_hosts_update_request, - build_galleries_create_or_update_request, - build_galleries_delete_request, - build_galleries_get_request, - build_galleries_list_by_resource_group_request, - build_galleries_list_request, - build_galleries_update_request, - build_gallery_application_versions_create_or_update_request, - build_gallery_application_versions_delete_request, - build_gallery_application_versions_get_request, - build_gallery_application_versions_list_by_gallery_application_request, - build_gallery_application_versions_update_request, - build_gallery_applications_create_or_update_request, - build_gallery_applications_delete_request, - build_gallery_applications_get_request, - build_gallery_applications_list_by_gallery_request, - build_gallery_applications_update_request, - build_gallery_image_versions_create_or_update_request, - build_gallery_image_versions_delete_request, - build_gallery_image_versions_get_request, - build_gallery_image_versions_list_by_gallery_image_request, - build_gallery_image_versions_update_request, - build_gallery_images_create_or_update_request, - build_gallery_images_delete_request, - build_gallery_images_get_request, - build_gallery_images_list_by_gallery_request, - build_gallery_images_update_request, - build_gallery_sharing_profile_update_request, - build_images_create_or_update_request, - build_images_delete_request, - build_images_get_request, - build_images_list_by_resource_group_request, - build_images_list_request, - build_images_update_request, - build_log_analytics_export_request_rate_by_interval_request, - build_log_analytics_export_throttled_requests_request, - build_operations_list_request, - build_proximity_placement_groups_create_or_update_request, - build_proximity_placement_groups_delete_request, - build_proximity_placement_groups_get_request, - build_proximity_placement_groups_list_by_resource_group_request, - build_proximity_placement_groups_list_by_subscription_request, - build_proximity_placement_groups_update_request, - build_resource_skus_list_request, - build_restore_point_collections_create_or_update_request, - build_restore_point_collections_delete_request, - build_restore_point_collections_get_request, - build_restore_point_collections_list_all_request, - build_restore_point_collections_list_request, - build_restore_point_collections_update_request, - build_restore_points_create_request, - build_restore_points_delete_request, - build_restore_points_get_request, - build_shared_galleries_get_request, - build_shared_galleries_list_request, - build_shared_gallery_image_versions_get_request, - build_shared_gallery_image_versions_list_request, - build_shared_gallery_images_get_request, - build_shared_gallery_images_list_request, - build_ssh_public_keys_create_request, - build_ssh_public_keys_delete_request, - build_ssh_public_keys_generate_key_pair_request, - build_ssh_public_keys_get_request, - build_ssh_public_keys_list_by_resource_group_request, - build_ssh_public_keys_list_by_subscription_request, - build_ssh_public_keys_update_request, - build_usage_list_request, - build_virtual_machine_extension_images_get_request, - build_virtual_machine_extension_images_list_types_request, - build_virtual_machine_extension_images_list_versions_request, - build_virtual_machine_extensions_create_or_update_request, - build_virtual_machine_extensions_delete_request, - build_virtual_machine_extensions_get_request, - build_virtual_machine_extensions_list_request, - build_virtual_machine_extensions_update_request, - build_virtual_machine_images_edge_zone_get_request, - build_virtual_machine_images_edge_zone_list_offers_request, - build_virtual_machine_images_edge_zone_list_publishers_request, - build_virtual_machine_images_edge_zone_list_request, - build_virtual_machine_images_edge_zone_list_skus_request, - build_virtual_machine_images_get_request, - build_virtual_machine_images_list_offers_request, - build_virtual_machine_images_list_publishers_request, - build_virtual_machine_images_list_request, - build_virtual_machine_images_list_skus_request, - build_virtual_machine_run_commands_create_or_update_request, - build_virtual_machine_run_commands_delete_request, - build_virtual_machine_run_commands_get_by_virtual_machine_request, - build_virtual_machine_run_commands_get_request, - build_virtual_machine_run_commands_list_by_virtual_machine_request, - build_virtual_machine_run_commands_list_request, - build_virtual_machine_run_commands_update_request, - build_virtual_machine_scale_set_extensions_create_or_update_request, - build_virtual_machine_scale_set_extensions_delete_request, - build_virtual_machine_scale_set_extensions_get_request, - build_virtual_machine_scale_set_extensions_list_request, - build_virtual_machine_scale_set_extensions_update_request, - build_virtual_machine_scale_set_rolling_upgrades_cancel_request, - build_virtual_machine_scale_set_rolling_upgrades_get_latest_request, - build_virtual_machine_scale_set_rolling_upgrades_start_extension_upgrade_request, - build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request, - build_virtual_machine_scale_set_vm_extensions_create_or_update_request, - build_virtual_machine_scale_set_vm_extensions_delete_request, - build_virtual_machine_scale_set_vm_extensions_get_request, - build_virtual_machine_scale_set_vm_extensions_list_request, - build_virtual_machine_scale_set_vm_extensions_update_request, - build_virtual_machine_scale_set_vm_run_commands_create_or_update_request, - build_virtual_machine_scale_set_vm_run_commands_delete_request, - build_virtual_machine_scale_set_vm_run_commands_get_request, - build_virtual_machine_scale_set_vm_run_commands_list_request, - build_virtual_machine_scale_set_vm_run_commands_update_request, - build_virtual_machine_scale_set_vms_deallocate_request, - build_virtual_machine_scale_set_vms_delete_request, - build_virtual_machine_scale_set_vms_get_instance_view_request, - build_virtual_machine_scale_set_vms_get_request, - build_virtual_machine_scale_set_vms_list_request, - build_virtual_machine_scale_set_vms_perform_maintenance_request, - build_virtual_machine_scale_set_vms_power_off_request, - build_virtual_machine_scale_set_vms_redeploy_request, - build_virtual_machine_scale_set_vms_reimage_all_request, - build_virtual_machine_scale_set_vms_reimage_request, - build_virtual_machine_scale_set_vms_restart_request, - build_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data_request, - build_virtual_machine_scale_set_vms_run_command_request, - build_virtual_machine_scale_set_vms_simulate_eviction_request, - build_virtual_machine_scale_set_vms_start_request, - build_virtual_machine_scale_set_vms_update_request, - build_virtual_machine_scale_sets_convert_to_single_placement_group_request, - build_virtual_machine_scale_sets_create_or_update_request, - build_virtual_machine_scale_sets_deallocate_request, - build_virtual_machine_scale_sets_delete_instances_request, - build_virtual_machine_scale_sets_delete_request, - build_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk_request, - build_virtual_machine_scale_sets_get_instance_view_request, - build_virtual_machine_scale_sets_get_os_upgrade_history_request, - build_virtual_machine_scale_sets_get_request, - build_virtual_machine_scale_sets_list_all_request, - build_virtual_machine_scale_sets_list_by_location_request, - build_virtual_machine_scale_sets_list_request, - build_virtual_machine_scale_sets_list_skus_request, - build_virtual_machine_scale_sets_perform_maintenance_request, - build_virtual_machine_scale_sets_power_off_request, - build_virtual_machine_scale_sets_redeploy_request, - build_virtual_machine_scale_sets_reimage_all_request, - build_virtual_machine_scale_sets_reimage_request, - build_virtual_machine_scale_sets_restart_request, - build_virtual_machine_scale_sets_set_orchestration_service_state_request, - build_virtual_machine_scale_sets_start_request, - build_virtual_machine_scale_sets_update_instances_request, - build_virtual_machine_scale_sets_update_request, - build_virtual_machine_sizes_list_request, - build_virtual_machines_assess_patches_request, - build_virtual_machines_capture_request, - build_virtual_machines_convert_to_managed_disks_request, - build_virtual_machines_create_or_update_request, - build_virtual_machines_deallocate_request, - build_virtual_machines_delete_request, - build_virtual_machines_generalize_request, - build_virtual_machines_get_request, - build_virtual_machines_install_patches_request, - build_virtual_machines_instance_view_request, - build_virtual_machines_list_all_request, - build_virtual_machines_list_available_sizes_request, - build_virtual_machines_list_by_location_request, - build_virtual_machines_list_request, - build_virtual_machines_perform_maintenance_request, - build_virtual_machines_power_off_request, - build_virtual_machines_reapply_request, - build_virtual_machines_redeploy_request, - build_virtual_machines_reimage_request, - build_virtual_machines_restart_request, - build_virtual_machines_retrieve_boot_diagnostics_data_request, - build_virtual_machines_run_command_request, - build_virtual_machines_simulate_eviction_request, - build_virtual_machines_start_request, - build_virtual_machines_update_request, -) -from .._configuration import ComputeManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.ComputeOperationValue"]: - """Gets a list of compute operations. - - :return: An iterator like instance of either ComputeOperationValue or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.ComputeOperationValue] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[_models.ComputeOperationListResult] = 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_operations_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async 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, 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 AvailabilitySetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`availability_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2021_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: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySet, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Is either a - AvailabilitySet type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySet") - - _request = build_availability_sets_create_or_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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, - availability_set_name: str, - parameters: _models.AvailabilitySetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2021_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: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Is either a - AvailabilitySetUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySetUpdate or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySetUpdate") - - _request = build_availability_sets_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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: - """ - 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 "2021-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 = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get(self, resource_group_name: str, availability_set_name: str, **kwargs: Any) -> _models.AvailabilitySet: - """Retrieves information about an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", 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) - - _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("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription( - self, *, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. - - :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.v2021_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 "2021-07-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, 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(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets 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 AvailabilitySet or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_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 "2021-07-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, 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_available_sizes( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes that can be used to create a new virtual machine in - an existing availability set. - - :param resource_group_name: The name of the resource group. Required. - :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.v2021_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 "2021-07-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_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 - - if response.status_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 ProximityPlacementGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`proximity_placement_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - 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. 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.v2021_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.v2021_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. 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.v2021_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - 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 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. Is - either a ProximityPlacementGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup or IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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. 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.v2021_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.v2021_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. 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.v2021_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - 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 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. Is - either a ProximityPlacementGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroupUpdate or - IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ProximityPlacementGroupUpdate") - - _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, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete(self, resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any) -> None: - """Delete a proximity placement group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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 "2021-07-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _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, - 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_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. 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.v2021_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - _request = build_proximity_placement_groups_get_request( - resource_group_name=resource_group_name, - proximity_placement_group_name=proximity_placement_group_name, - subscription_id=self._config.subscription_id, - include_colocation_status=include_colocation_status, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a subscription. - - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_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 "2021-07-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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 - ) -> AsyncItemPaged["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a resource group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_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 "2021-07-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) - - -class DedicatedHostGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`dedicated_host_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - host_group_name: str, - parameters: _models.DedicatedHostGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: ~azure.mgmt.compute.v2021_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: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroup, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Is either a - DedicatedHostGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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, "DedicatedHostGroup") - - _request = build_dedicated_host_groups_create_or_update_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DedicatedHostGroup", 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, - host_group_name: str, - parameters: _models.DedicatedHostGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. - :type parameters: ~azure.mgmt.compute.v2021_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: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :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: IO[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.v2021_07_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroupUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Is either - a DedicatedHostGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroupUpdate or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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") - - _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) - - _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("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: - """ - 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 "2021-07-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_dedicated_host_groups_delete_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - 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. 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.v2021_07_01.models.InstanceViewTypes - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-07-01")) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", 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) - - _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("DedicatedHostGroup", 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 - ) -> AsyncItemPaged["_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. - :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.v2021_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 "2021-07-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 - def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_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.v2021_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 "2021-07-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_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 - - if response.status_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 DedicatedHostsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`dedicated_hosts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, 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 "2021-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, "DedicatedHost") - - _request = build_dedicated_hosts_create_or_update_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, - 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) - - 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, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHost, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHost - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. 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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. Is either a DedicatedHost - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHost or IO[bytes] - :return: An instance of AsyncLROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] - :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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, 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 "2021-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, "DedicatedHostUpdate") - - _request = build_dedicated_hosts_update_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, - 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, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHostUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostUpdate - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host 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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Is either a - DedicatedHostUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] - :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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_delete_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 [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, host_group_name: str, host_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete 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 - :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 "2021-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, - 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_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.v2021_07_01.models.InstanceViewTypes - :return: DedicatedHost or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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 - - return deserialized # type: ignore - - @distributed_trace - def list_by_host_group( - self, resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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. - :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.v2021_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 "2021-07-01")) - cls: ClsType[_models.DedicatedHostListResult] = 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_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, - 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("DedicatedHostListResult", 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 SshPublicKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`ssh_public_keys` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_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 "2021-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_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("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) - - 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 - ) -> AsyncItemPaged["_models.SshPublicKeyResource"]: - """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in - the response to get the next page of SSH public keys. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either SshPublicKeyResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_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 "2021-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 - - 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) - - 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) - - @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.v2021_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.v2021_07_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_07_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_07_01.models.SshPublicKeyResource or IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource - :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 "2021-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") - - _request = build_ssh_public_keys_create_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, - 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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # 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. - - :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: ~azure.mgmt.compute.v2021_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.v2021_07_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_07_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_07_01.models.SshPublicKeyUpdateResource or - IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource - :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 "2021-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( - resource_group_name=resource_group_name, - ssh_public_key_name=ssh_public_key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("SshPublicKeyResource", 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, ssh_public_key_name: str, **kwargs: Any) -> None: - """Delete an SSH public key. - - :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: - """ - 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 "2021-07-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_ssh_public_keys_delete_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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, 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. - :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.v2021_07_01.models.SshPublicKeyResource - :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 "2021-07-01")) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - - _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) - - _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("SshPublicKeyResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def generate_key_pair( - self, resource_group_name: str, ssh_public_key_name: str, **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. 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: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyGenerateKeyPairResult - :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 "2021-07-01")) - cls: ClsType[_models.SshPublicKeyGenerateKeyPairResult] = kwargs.pop("cls", None) - - _request = build_ssh_public_keys_generate_key_pair_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) - - _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("SshPublicKeyGenerateKeyPairResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class VirtualMachineExtensionImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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. - - :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.v2021_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 "2021-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 = 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 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 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.v2021_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 "2021-07-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - - _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) - - _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 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 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.v2021_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 "2021-07-01")) - 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 = 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 - - -class VirtualMachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, 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 "2021-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, "VirtualMachineExtension") - - _request = build_virtual_machine_extensions_create_or_update_request( - resource_group_name=resource_group_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, - 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) - - 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, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2021_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 VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_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 create or 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 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] - :keyword content_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.v2021_07_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2021_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.v2021_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2021-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( - resource_group_name=resource_group_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, - 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, - 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. - - :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: - ~azure.mgmt.compute.v2021_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.v2021_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.v2021_07_01.models.VirtualMachineExtension] - :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.v2021_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.v2021_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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) - - _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, vm_name: str, vm_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_name: The name of the virtual machine where the extension should be deleted. - 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, - vm_extension_name=vm_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - 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.v2021_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 "2021-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 = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list( - self, resource_group_name: str, vm_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.VirtualMachineExtensionsListResult: - """The operation to get all extensions of a Virtual Machine. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine containing the extension. Required. - :type vm_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineExtensionsListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionsListResult - :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 "2021-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 VirtualMachineImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.v2021_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 "2021-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.v2021_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 "2021-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.v2021_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 "2021-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. - - :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.v2021_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 "2021-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) - 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. - - :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.v2021_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 "2021-07-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _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) - - _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 - - -class VirtualMachineImagesEdgeZoneOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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. - - :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.v2021_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 "2021-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 = 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, - 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. - - :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.v2021_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 "2021-07-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = 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, - 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, edge_zone: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of virtual machine image offers for the specified location, edge zone and - publisher. - - :param location: The name of 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.v2021_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 "2021-07-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_edge_zone_list_offers_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def 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 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.v2021_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 "2021-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, - 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_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.v2021_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 "2021-07-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_edge_zone_list_skus_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - offer=offer, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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 - - -class UsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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 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.v2021_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 "2021-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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ListUsagesResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class 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.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.VirtualMachine"]: - """Gets all the virtual machines under the specified subscription for the specified location. - - :param location: The location for which virtual machines under the subscription are queried. - Required. - :type location: str - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_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 "2021-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 - - 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) - - 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 _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, - 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 "2021-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, "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 = 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_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. 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.v2021_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.v2021_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. 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.v2021_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. 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.v2021_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.v2021_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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 - ) - 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) - 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.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 _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, 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 "2021-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, - 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) - - 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, - vm_name: str, - parameters: _models.VirtualMachine, - *, - 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. 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.v2021_07_01.models.VirtualMachine - :keyword content_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.v2021_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], - *, - 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. 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 content_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.v2021_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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :param resource_group_name: The name of the resource group. Required. - :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.v2021_07_01.models.VirtualMachine or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_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 "2021-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, - 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, **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]], - **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 "2021-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, - 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, - vm_name: str, - parameters: _models.VirtualMachineUpdate, - *, - 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. 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.v2021_07_01.models.VirtualMachineUpdate - :keyword content_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.v2021_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], - *, - 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. 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 content_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.v2021_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]], - **kwargs: Any - ) -> AsyncLROPoller[_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.v2021_07_01.models.VirtualMachineUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_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 "2021-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, - 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, **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 "2021-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) - - 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, vm_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to delete a virtual machine. - - :param resource_group_name: The name of the resource group. Required. - :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 "2021-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, **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_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.v2021_07_01.models.InstanceViewTypes - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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 - - @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. 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.v2021_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 "2021-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 - - 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, - 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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_convert_to_managed_disks_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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. - - :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 "2021-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 "2021-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. (Feature in Preview). - 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 "2021-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. :code:`
    `For Windows, please refer to - `Create a managed image of a generalized VM in Azure - `_.\\ - :code:`
    `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 "2021-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, **kwargs: Any) -> AsyncItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_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 "2021-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, - 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("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) - - 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, *, status_only: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_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 "2021-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, - 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("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) - - 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_available_sizes( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes to which the specified virtual machine can be - resized. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_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 "2021-07-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_available_sizes_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 - - if response.status_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_name: 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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_power_off_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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_name: str, *, skip_shutdown: bool = False, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with - the same provisioned resources. You are still charged for this virtual machine. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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_name=vm_name, - skip_shutdown=skip_shutdown, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reapply_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - 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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_reapply_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - 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_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. - :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 "2021-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_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 _restart_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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_restart_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - 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_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. - :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 "2021-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._restart_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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_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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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_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 "2021-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]: - 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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_redeploy_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_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. - :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 "2021-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_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 _reimage_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2021-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( - 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) - - 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 the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: ~azure.mgmt.compute.v2021_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 the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. 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.v2021_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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def retrieve_boot_diagnostics_data( - self, - resource_group_name: str, - vm_name: str, - *, - sas_uri_expiration_time_in_minutes: Optional[int] = None, - **kwargs: Any - ) -> _models.RetrieveBootDiagnosticsDataResult: - """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword sas_uri_expiration_time_in_minutes: Expiration duration in minutes for the SAS URIs - with a value between 1 to 1440 minutes. :code:`
    `\\ :code:`
    `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.v2021_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 "2021-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]: - 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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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_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. - :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 "2021-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_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 - - @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 "2021-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]: - 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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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) - - _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_assess_patches( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineAssessPatchesResult]: - """Assess patches on the VM. - - :param resource_group_name: The name of the resource group. Required. - :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.v2021_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 "2021-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 - ) - 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) - 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.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 _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 "2021-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(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, - ) - _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_install_patches( - self, - resource_group_name: str, - vm_name: str, - install_patches_input: _models.VirtualMachineInstallPatchesParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param install_patches_input: Input for InstallPatches as directly received by the API. - Required. - :type install_patches_input: - ~azure.mgmt.compute.v2021_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.v2021_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. 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.v2021_07_01.models.VirtualMachineInstallPatchesResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_install_patches( - self, - resource_group_name: str, - vm_name: str, - install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param install_patches_input: Input for InstallPatches as directly received by the API. Is - either a VirtualMachineInstallPatchesParameters type or a IO[bytes] type. Required. - :type install_patches_input: - ~azure.mgmt.compute.v2021_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.v2021_07_01.models.VirtualMachineInstallPatchesResult] - :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 "2021-07-01")) - 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._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, - **kwargs - ) - 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) - 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.VirtualMachineInstallPatchesResult].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 - ) - - async def _run_command_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, 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 "2021-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, "RunCommandInput") - - _request = build_virtual_machines_run_command_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) - - 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_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2021_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 RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_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.v2021_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._run_command_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -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.v2021_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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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. - 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.v2021_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 "2021-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]], - **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 "2021-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, - 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) - - 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, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. 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.v2021_07_01.models.VirtualMachineScaleSet - :keyword content_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.v2021_07_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. 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: IO[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 VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 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.v2021_07_01.models.VirtualMachineScaleSet or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_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 "2021-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, - 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]], - **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 "2021-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, "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, - 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, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSetUpdate, - *, - 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. 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.v2021_07_01.models.VirtualMachineScaleSetUpdate - :keyword content_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.v2021_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], - *, - 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. 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: IO[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 VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Update 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 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.v2021_07_01.models.VirtualMachineScaleSetUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_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 "2021-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, - 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 _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 "2021-07-01")) - cls: ClsType[AsyncIterator[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 = 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, 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 "2021-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. - - :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 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.v2021_07_01.models.ExpandTypesForGetVMScaleSets - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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 _deallocate_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 "2021-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_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_deallocate( - 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]: - """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. - :type 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.v2021_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_deallocate( - 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]: - """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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_deallocate( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and - releases the compute resources. You are not billed for the compute resources that this virtual - machine scale set deallocates. - - :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.v2021_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 "2021-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, - 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 _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, - 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 "2021-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: - _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, - 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) - - 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_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. Required. - :type 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.v2021_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. Required. - :type 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_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.v2021_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 "2021-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.v2021_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 "2021-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) -> AsyncItemPaged["_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 - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_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 "2021-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_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("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 - def list_all(self, **kwargs: Any) -> AsyncItemPaged["_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.v2021_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 "2021-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = 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_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("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) - - 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_skus( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineScaleSetSku"]: - """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM - instances allowed for each SKU. - - :param resource_group_name: The name of the resource group. Required. - :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.v2021_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 "2021-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 - - 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) - - @distributed_trace - def get_os_upgrade_history( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.UpgradeOperationHistoricalStatusInfo"]: - """Gets list of OS upgrades 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 - :return: An iterator like instance of either UpgradeOperationHistoricalStatusInfo or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_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 "2021-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 _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]: - 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 "2021-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_power_off_request( - resource_group_name=resource_group_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, - 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_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - 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. - - :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.v2021_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 - :keyword content_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_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - 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. - - :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 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 - :keyword content_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_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: bool = False, - **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. - - :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.v2021_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] - :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 "2021-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 "2021-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_restart_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2021_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_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :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.v2021_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 "2021-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, - 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 "2021-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 - 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_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. Required. - :type 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.v2021_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. Required. - :type 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.v2021_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 "2021-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 _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, - 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 "2021-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_redeploy_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_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. - - :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.v2021_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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_redeploy( - self, - resource_group_name: str, - vm_scale_set_name: str, - 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. Required. - :type 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.v2021_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 "2021-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) - - 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 _perform_maintenance_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_perform_maintenance( - 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]: - """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. - :type 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.v2021_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_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 - ) -> 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. - :type 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_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. - - :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.v2021_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 "2021-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._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2021-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: - _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, - 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_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :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.v2021_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 None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2021_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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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._update_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reimage_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which - don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual - machine is reset to initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2021_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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Is either a - VirtualMachineScaleSetReimageParameters type or a IO[bytes] type. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2021_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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_scale_set_reimage_input=vm_scale_set_reimage_input, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reimage_all_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2021_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_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2021_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 "2021-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) - - 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, **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 - :return: RecoveryWalkResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RecoveryWalkResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2021_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. - - :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.v2021_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 "2021-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 _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 "2021-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, - 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_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.v2021_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.v2021_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 "2021-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 VirtualMachineSizesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """This API is deprecated. Use `Resources Skus - `_. - - :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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_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 "2021-07-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_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 - - 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 - - if response.status_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 ImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> 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 "2021-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) - - 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, - image_name: str, - parameters: _models.Image, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Create or update an image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param 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.v2021_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Create or update an image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param 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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.Image] - :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. - - :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 - :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.v2021_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.v2021_07_01.models.Image] - :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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._create_or_update_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Image]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, 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 "2021-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, "ImageUpdate") - - _request = build_images_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) - - 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, - image_name: str, - parameters: _models.ImageUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Update 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 - :param parameters: Parameters supplied to the Update Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2021_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Update 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 - :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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Update 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 - :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.v2021_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.v2021_07_01.models.Image] - :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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Image]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial(self, resource_group_name: str, image_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_images_delete_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, image_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes 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 - :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 "2021-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, - image_name=image_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - 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.v2021_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 "2021-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 = 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("Image", 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) -> AsyncItemPaged["_models.Image"]: - """Gets the list of images 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 Image or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_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 "2021-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 - - 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) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2021_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 "2021-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_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) - - -class RestorePointCollectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`restore_point_collections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - restore_point_collection_name: str, - parameters: _models.RestorePointCollection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to create or update the restore point collection. Please refer to - https://aka.ms/RestorePoints for more details. When updating a restore point collection, only - tags may be modified. - - :param resource_group_name: The name of the resource group. Required. - :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.v2021_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.v2021_07_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to create or update the restore point collection. Please refer to - https://aka.ms/RestorePoints for more details. When updating a restore point collection, only - tags may be modified. - - :param resource_group_name: The name of the resource group. 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.v2021_07_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: Union[_models.RestorePointCollection, IO[bytes]], - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to create or update the restore point collection. Please refer to - https://aka.ms/RestorePoints for more details. When updating a restore point collection, only - tags may be modified. - - :param resource_group_name: The name of the resource group. 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.v2021_07_01.models.RestorePointCollection or IO[bytes] - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, "RestorePointCollection") - - _request = build_restore_point_collections_create_or_update_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RestorePointCollection", 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, - restore_point_collection_name: str, - parameters: _models.RestorePointCollectionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to update the restore point collection. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Update restore point collection operation. - Required. - :type parameters: ~azure.mgmt.compute.v2021_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: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to update the restore point collection. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Update restore point collection operation. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: Union[_models.RestorePointCollectionUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to update the restore point collection. - - :param resource_group_name: The name of the resource group. 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.v2021_07_01.models.RestorePointCollectionUpdate or - IO[bytes] - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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") - - _request = build_restore_point_collections_update_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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 - - async def _delete_initial( - self, resource_group_name: str, restore_point_collection_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_restore_point_collections_delete_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, 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. - :type resource_group_name: str - :param restore_point_collection_name: The name of the Restore Point Collection. Required. - :type restore_point_collection_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, - restore_point_collection_name=restore_point_collection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **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, - 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.v2021_07_01.models.RestorePointCollectionExpandOptions - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) - - _request = build_restore_point_collections_get_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_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.v2021_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 "2021-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) -> AsyncItemPaged["_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.v2021_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 "2021-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) - - _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 RestorePointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`restore_points` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_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, - 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 "2021-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, "RestorePoint") - - _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) - - _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 [201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = 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( - 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. - :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.v2021_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.v2021_07_01.models.RestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - :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 AsyncLROPoller that returns either RestorePoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.RestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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. Is either a - RestorePoint type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_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.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_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 "2021-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, 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): - deserialized = self._deserialize("RestorePoint", 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.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, - 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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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) - - _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, 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. - :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 - :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 "2021-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, - 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) - - 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, restore_point_collection_name: str, restore_point_name: str, **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 - :return: RestorePoint or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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, - 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 - - -class CapacityReservationGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`capacity_reservation_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - async def create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: _models.CapacityReservationGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to create or update a capacity reservation group. When updating a capacity - reservation group, only tags may be modified. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Create capacity reservation Group. Required. - :type parameters: ~azure.mgmt.compute.v2021_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.v2021_07_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to create or update a capacity reservation group. When updating a capacity - reservation group, only tags may be modified. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Create capacity reservation Group. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 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.v2021_07_01.models.CapacityReservationGroup or IO[bytes] - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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") - - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CapacityReservationGroup", 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, - 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 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. - Required. - :type parameters: ~azure.mgmt.compute.v2021_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.v2021_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 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. - 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.v2021_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 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.v2021_07_01.models.CapacityReservationGroupUpdate or - IO[bytes] - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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. 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 "2021-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 - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - *, - expand: Optional[Union[str, _models.CapacityReservationGroupInstanceViewTypes]] = None, - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation that retrieves information about a capacity reservation group. - - :param resource_group_name: The name of the resource group. Required. - :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.v2021_07_01.models.CapacityReservationGroupInstanceViewTypes - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) - - _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) - - _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 - def list_by_resource_group( - self, - resource_group_name: str, - *, - expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, - **kwargs: Any - ) -> AsyncItemPaged["_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 - :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.v2021_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.v2021_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 "2021-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( - self, *, expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, **kwargs: Any - ) -> AsyncItemPaged["_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.v2021_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.v2021_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 "2021-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, - 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) - - -class CapacityReservationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`capacity_reservations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - 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, - 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 "2021-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( - 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) - - _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) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: _models.CapacityReservation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CapacityReservation]: - """The operation to create or update a capacity reservation. Please note some properties can be - set only during capacity reservation creation. Please refer to - https://aka.ms/CapacityReservation for more details. - - :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.v2021_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.v2021_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.v2021_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. - - :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. Is either a - CapacityReservation type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_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.v2021_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 "2021-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, **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, - 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 "2021-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, "CapacityReservationUpdate") - - _request = build_capacity_reservations_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) - - _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( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: _models.CapacityReservationUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CapacityReservation]: - """The operation to update a capacity reservation. - - :param resource_group_name: The name of the resource group. 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.v2021_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: An instance of AsyncLROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CapacityReservation]: - """The operation to update a capacity reservation. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Update capacity reservation operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.CapacityReservation]: - """The operation to update a capacity reservation. - - :param resource_group_name: The name of the resource group. Required. - :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.v2021_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.v2021_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 "2021-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._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, **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 _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, - 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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_capacity_reservations_delete_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, - 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, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to delete a capacity reservation. This operation is allowed only when all the - associated resources are disassociated from the capacity reservation. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. Required. - :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 - :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 "2021-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, - 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) - - 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, - 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. - :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.v2021_07_01.models.CapacityReservationInstanceViewTypes - :return: CapacityReservation or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-07-01")) - 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 - - @distributed_trace - def list_by_capacity_reservation_group( - self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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.v2021_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 "2021-07-01")) - cls: ClsType[_models.CapacityReservationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_capacity_reservations_list_by_capacity_reservation_group_request( - resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) - - 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 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.v2021_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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2021-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") - - _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, - 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) - - 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, - 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. - - :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.v2021_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.v2021_07_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_07_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtension, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to create or update an extension. - - :param resource_group_name: The name of the resource group. Required. - :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.v2021_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.v2021_07_01.models.VirtualMachineScaleSetExtension] - :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 "2021-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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _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]: - 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 "2021-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") - - _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, - 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) - - 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, - 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.v2021_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.v2021_07_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :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.v2021_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.v2021_07_01.models.VirtualMachineScaleSetExtension] - :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 "2021-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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2021-07-01")) - cls: ClsType[AsyncIterator[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, - 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, 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 "2021-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.v2021_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 "2021-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 - ) -> AsyncItemPaged["_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.v2021_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 "2021-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. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> 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 "2021-07-01")) - 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, - 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 - - @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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _start_os_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2021-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, - 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) - - _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_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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _start_extension_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - 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 - - @distributed_trace_async - async def begin_start_extension_upgrade( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Starts a rolling upgrade to move all extensions for all virtual machine scale set instances to - the latest available extension version. Instances which are already running the latest - extension versions are not affected. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get_latest( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> _models.RollingUpgradeStatusInfo: - """Gets the status of the latest virtual machine scale set rolling upgrade. - - :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.v2021_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 "2021-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 = 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("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.v2021_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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2021-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, "VirtualMachineScaleSetVMExtension") - - _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) - - _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) - - 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, - 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.v2021_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.v2021_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.v2021_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.v2021_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.v2021_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, - 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 "2021-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") - - _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, - 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, - 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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2021_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) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to update the VMSS VM extension. - - :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.v2021_07_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to update the VMSS VM extension. - - :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.v2021_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.v2021_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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) - - 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 _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, - 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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_extensions_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - 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, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to delete the VMSS VM extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - 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. - :type 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.v2021_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 "2021-07-01")) - 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 = 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("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list( - self, - resource_group_name: str, - vm_scale_set_name: str, - 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. Required. - :type 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.v2021_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 "2021-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 - ) - - response = pipeline_response.http_response - - if response.status_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 - - -class VirtualMachineScaleSetVMsOperations: # 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.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _reimage_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[ - Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] - ] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - 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 "2021-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( - 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 - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - 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.v2021_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 - ) -> 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. - Is either a VirtualMachineScaleSetVMReimageParameters type or a IO[bytes] type. Default value - is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2021_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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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( - 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, **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, - 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 "2021-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) - - 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_reimage_all( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. - This operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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 - - async def _deallocate_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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. - - :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 "2021-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 - - async def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, 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 "2021-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, "VirtualMachineScaleSetVM") - - _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, - 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( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.VirtualMachineScaleSetVM, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM - :keyword content_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) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - 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 VirtualMachineScaleSetVM or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM] - :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, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. - Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVM or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM] - :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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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, - 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("VirtualMachineScaleSetVM", 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.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 - ) - - async def _delete_initial( - 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, - 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 "2021-07-01")) - 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, - 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, - vm_scale_set_name: str, - instance_id: str, - *, - force_deletion: Optional[bool] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes 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 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, - instance_id=instance_id, - 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, - 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.v2021_07_01.models.InstanceViewTypes - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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 = 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("VirtualMachineScaleSetVM", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_instance_view( - self, resource_group_name: str, vm_scale_set_name: str, 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.v2021_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 "2021-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 - ) -> AsyncItemPaged["_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.v2021_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 "2021-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 "2021-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. - - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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) - - 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, 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 "2021-07-01")) - cls: ClsType[AsyncIterator[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 = 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_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. - :type 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 "2021-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._restart_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _start_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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_start_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - 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 - :param vm_scale_set_name: The name of the VM 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 "2021-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_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _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, - 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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_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, - 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_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. - :type 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 "2021-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) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def retrieve_boot_diagnostics_data( - self, - resource_group_name: str, - vm_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. Required. - :type 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. :code:`
    `\\ :code:`
    `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.v2021_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 "2021-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 = 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_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 "2021-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) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_perform_maintenance( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> 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 "2021-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. - - :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 "2021-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 _run_command_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, 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 "2021-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, "RunCommandInput") - - _request = build_virtual_machine_scale_set_vms_run_command_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 - 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_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - :type 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.v2021_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 RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> 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. - :type 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.v2021_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.v2021_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._run_command_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class LogAnalyticsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`log_analytics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _export_request_rate_by_interval_initial( - self, location: str, parameters: Union[_models.RequestRateByIntervalInput, 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 "2021-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, "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, - ) - _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_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 location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. - Required. - :type parameters: ~azure.mgmt.compute.v2021_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.v2021_07_01.models.LogAnalyticsOperationResult] - :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. - - :param location: The location upon which virtual-machine-sizes is queried. 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.v2021_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 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.v2021_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.v2021_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 "2021-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._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, - **kwargs - ) - 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) - 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LogAnalyticsOperationResult]( - 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 - ) -> 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 "2021-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, - 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_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.v2021_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.v2021_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.v2021_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. - - :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.v2021_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.v2021_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 "2021-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._export_throttled_requests_initial( - location=location, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - 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) - 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LogAnalyticsOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineRunCommandsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.RunCommandDocumentBase"]: - """Lists all available run commands for a subscription in a location. - - :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 - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_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 "2021-07-01")) - cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_run_commands_list_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RunCommandListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, location: str, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: - """Gets specific run command for a subscription in a location. - - :param location: The 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.v2021_07_01.models.RunCommandDocument - :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 "2021-07-01")) - cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) - - _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, - 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("RunCommandDocument", 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, - 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 "2021-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(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_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, - ) - _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) - - 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, - 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. - :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. - :type run_command_name: str - :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. - Required. - :type run_command: ~azure.mgmt.compute.v2021_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.v2021_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. 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. - :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". - :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.v2021_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. 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. - :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.v2021_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.v2021_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 "2021-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._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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommand", 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.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 _update_initial( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommandUpdate, 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 "2021-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(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_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, - ) - _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, - vm_name: 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. - - :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. - Required. - :type vm_name: 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. - Required. - :type run_command: ~azure.mgmt.compute.v2021_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.v2021_07_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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. - Required. - :type vm_name: 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. - 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". - :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.v2021_07_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be updated. - Required. - :type vm_name: 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.v2021_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.v2021_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 "2021-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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommand", 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.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 _delete_initial( - self, resource_group_name: str, vm_name: str, run_command_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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_run_commands_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - run_command_name=run_command_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, vm_name: str, run_command_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to delete the 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. - Required. - :type vm_name: str - :param run_command_name: The name of the virtual machine run command. 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 = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, - run_command_name=run_command_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_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. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine containing the run command. 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.v2021_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 "2021-07-01")) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - - _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) - - _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_by_virtual_machine( - self, resource_group_name: str, vm_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineRunCommand"]: - """The operation to get all run commands 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 run command. Required. - :type vm_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_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 "2021-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_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) - - -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.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vm_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommand, 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 "2021-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(run_command, (IOBase, bytes)): - _content = run_command - else: - _json = self._serialize.body(run_command, "VirtualMachineRunCommand") - - _request = build_virtual_machine_scale_set_vm_run_commands_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, - 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) - - 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, - 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 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 - :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. - Required. - :type run_command: ~azure.mgmt.compute.v2021_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.v2021_07_01.models.VirtualMachineRunCommand] - :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, - 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 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 - :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". - :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.v2021_07_01.models.VirtualMachineRunCommand] - :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, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update 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 - :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.v2021_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.v2021_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 "2021-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._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, - 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("VirtualMachineRunCommand", 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.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 _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]], - **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 "2021-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(run_command, (IOBase, bytes)): - _content = run_command - else: - _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") - - _request = build_virtual_machine_scale_set_vm_run_commands_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, - 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, - 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 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 - :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. - Required. - :type run_command: ~azure.mgmt.compute.v2021_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.v2021_07_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """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_scale_set_name: The name of the VM 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. - 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". - :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.v2021_07_01.models.VirtualMachineRunCommand] - :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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """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_scale_set_name: The name of the VM 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.v2021_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.v2021_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 "2021-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_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, - 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("VirtualMachineRunCommand", 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.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 _delete_initial( - 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, - 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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_run_commands_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, - 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, vm_scale_set_name: str, instance_id: str, run_command_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """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_scale_set_name: The name of the VM 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 - :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 "2021-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, - instance_id=instance_id, - run_command_name=run_command_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, - 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.v2021_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 "2021-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 - ) -> AsyncItemPaged["_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.v2021_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 "2021-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) - - -class ResourceSkusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`resource_skus` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, *, filter: Optional[str] = None, include_extended_locations: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.ResourceSku"]: - """Gets the list of Microsoft.Compute SKUs available for your Subscription. - - :keyword filter: The filter to apply on the operation. Only **location** filter is supported - currently. Default value is None. - :paramtype filter: str - :keyword include_extended_locations: To Include Extended Locations information or not in the - response. Default value is None. - :paramtype include_extended_locations: str - :return: An iterator like instance of either ResourceSku or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.ResourceSku] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[_models.ResourceSkusResult] = 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_resource_skus_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - include_extended_locations=include_extended_locations, - 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("ResourceSkusResult", 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) - - -class GalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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: Union[_models.Gallery, 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 "2021-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(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 = 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: _models.Gallery, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - Required. - :type gallery_name: str - :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. - Required. - :type gallery: ~azure.mgmt.compute.v2021_07_01.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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - 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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, gallery_name: str, gallery: Union[_models.Gallery, IO[bytes]], **kwargs: Any - ) -> 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. - 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.v2021_07_01.models.Gallery or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Gallery] = 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=gallery, - 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("Gallery", 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.Gallery].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Gallery]( - 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: Union[_models.GalleryUpdate, 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 "2021-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(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) - - _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: _models.GalleryUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - Required. - :type gallery_name: str - :param gallery: Parameters supplied to the update Shared Image Gallery operation. Required. - :type gallery: ~azure.mgmt.compute.v2021_07_01.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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - 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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: Union[_models.GalleryUpdate, IO[bytes]], - **kwargs: Any - ) -> 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. - 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.v2021_07_01.models.GalleryUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Gallery] = 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=gallery, - 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("Gallery", 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.Gallery].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Gallery]( - 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, - **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.v2021_07_01.models.SelectPermissions - :return: Gallery or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - 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, - 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, - 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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_galleries_delete_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) - - _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, gallery_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Delete 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 to be deleted. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, - gallery_name=gallery_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) -> AsyncItemPaged["_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.v2021_07_01.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 "2021-07-01")) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2021_07_01.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 "2021-07-01")) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class GalleryImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 "2021-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(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.v2021_07_01.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.v2021_07_01.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.v2021_07_01.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.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - 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 "2021-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(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.v2021_07_01.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.v2021_07_01.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.v2021_07_01.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.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - 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.v2021_07_01.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 "2021-07-01")) - cls: ClsType[_models.GalleryImage] = kwargs.pop("cls", None) - - _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 = 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("GalleryImage", 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]: - 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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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) - - _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, 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, - 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, **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_gallery( - self, resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - cls: ClsType[_models.GalleryImageList] = 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_images_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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryImageList", 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 GalleryImageVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 "2021-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(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.v2021_07_01.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.v2021_07_01.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.v2021_07_01.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.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - 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]: - 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 "2021-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(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) - - _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_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.v2021_07_01.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.v2021_07_01.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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 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.v2021_07_01.models.GalleryImageVersion] - :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_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. 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.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - 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) - - 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 - ) - - @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. - - :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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationStatusTypes - :return: GalleryImageVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - 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) - 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 - - 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, - 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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, - 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) - - 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_gallery_image( - self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.GalleryImageVersion"]: - """List gallery image versions in 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 - resides. 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) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - cls: ClsType[_models.GalleryImageVersionList] = 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_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, - 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("GalleryImageVersionList", 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 GalleryApplicationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`gallery_applications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application: Union[_models.GalleryApplication, 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 "2021-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(gallery_application, (IOBase, bytes)): - _content = gallery_application - else: - _json = self._serialize.body(gallery_application, "GalleryApplication") - - _request = build_gallery_applications_create_or_update_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, - 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_application_name: str, - gallery_application: _models.GalleryApplication, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2021_07_01.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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the create or 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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplication, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2021_07_01.models.GalleryApplication or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryApplication] = 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_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 - ) - await 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: 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.GalleryApplication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GalleryApplication]( - 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_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, 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 "2021-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(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_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, - ) - _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_application_name: str, - gallery_application: _models.GalleryApplicationUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the update gallery Application operation. - Required. - :type gallery_application: ~azure.mgmt.compute.v2021_07_01.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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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 - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :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.v2021_07_01.models.GalleryApplicationUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryApplication] = 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=gallery_application, - 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("GalleryApplication", 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.GalleryApplication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GalleryApplication]( - 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.v2021_07_01.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 "2021-07-01")) - 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]: - 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 "2021-07-01")) - cls: ClsType[AsyncIterator[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 = 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, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete a gallery Application. - - :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 is to be deleted. Required. - :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be deleted. - 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, - 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 - ) - 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_gallery( - self, resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.GalleryApplication"]: - """List gallery Application 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 Application Gallery from which Application - Definitions are to be listed. Required. - :type gallery_name: str - :return: An iterator like instance of either GalleryApplication or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - cls: ClsType[_models.GalleryApplicationList] = 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_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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryApplicationList", 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 GalleryApplicationVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`gallery_application_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: Union[_models.GalleryApplicationVersion, 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 "2021-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(gallery_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersion") - - _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, - 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersion, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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.v2021_07_01.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 AsyncLROPoller that returns either GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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] - :keyword content_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 GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async 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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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.v2021_07_01.models.GalleryApplicationVersion 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.v2021_07_01.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 "2021-07-01")) - 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._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, - 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 - ) - - async 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]], - **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 "2021-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(gallery_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersionUpdate") - - _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, - 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2021_07_01.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 AsyncLROPoller that returns either GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Update 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 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] - :keyword content_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 GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async 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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - 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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationStatusTypes - :return: GalleryApplicationVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - 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) - - deserialized = self._deserialize("GalleryApplicationVersion", 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, - gallery_application_version_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 "2021-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete 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 - deleted. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, - 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, - 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_gallery_application( - self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - 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 - - async 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, 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 GallerySharingProfileOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`gallery_sharing_profile` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _update_initial( - self, - resource_group_name: str, - gallery_name: str, - sharing_update: Union[_models.SharingUpdate, 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 "2021-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(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 = 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( - 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 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.v2021_07_01.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.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.SharingUpdate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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 AsyncLROPoller that returns either SharingUpdate or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.SharingUpdate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - 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) - - 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: 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.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 - ) - - -class SharedGalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`shared_galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_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.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - 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.v2021_07_01.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 "2021-07-01")) - 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 = 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("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.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`shared_gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_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.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - 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 - - async 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, 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, 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.v2021_07_01.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 "2021-07-01")) - 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 = 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("SharedGalleryImage", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class SharedGalleryImageVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`shared_gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.SharedGalleryImageVersion"]: - """List shared gallery image versions 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 - :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.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - 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) - 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, - gallery_image_version_name: str, - **kwargs: Any - ) -> _models.SharedGalleryImageVersion: - """Get a shared gallery image version 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 - :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.v2021_07_01.models.SharedGalleryImageVersion - :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 "2021-07-01")) - cls: ClsType[_models.SharedGalleryImageVersion] = kwargs.pop("cls", None) - - _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, - 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("SharedGalleryImageVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class CommunityGalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`community_galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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: 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.v2021_07_01.models.CommunityGallery - :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 "2021-07-01")) - cls: ClsType[_models.CommunityGallery] = kwargs.pop("cls", 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) - - _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("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.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`community_gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.v2021_07_01.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 "2021-07-01")) - 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 = 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("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.v2021_07_01.aio.ComputeManagementClient`'s - :attr:`community_gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - gallery_image_version_name: str, - **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.v2021_07_01.models.CommunityGalleryImageVersion - :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 "2021-07-01")) - cls: ClsType[_models.CommunityGalleryImageVersion] = 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, - 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("CommunityGalleryImageVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ 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 deleted file mode 100644 index 03e61dff7b9b..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/__init__.py +++ /dev/null @@ -1,812 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - AdditionalCapabilities, - AdditionalUnattendContent, - ApiEntityReference, - ApiError, - ApiErrorBase, - ApplicationProfile, - AutomaticOSUpgradePolicy, - AutomaticOSUpgradeProperties, - AutomaticRepairsPolicy, - AvailabilitySet, - AvailabilitySetListResult, - AvailabilitySetUpdate, - AvailablePatchSummary, - BillingProfile, - BootDiagnostics, - BootDiagnosticsInstanceView, - CapacityReservation, - CapacityReservationGroup, - CapacityReservationGroupInstanceView, - CapacityReservationGroupListResult, - CapacityReservationGroupUpdate, - CapacityReservationInstanceView, - CapacityReservationInstanceViewWithName, - CapacityReservationListResult, - CapacityReservationProfile, - CapacityReservationUpdate, - CapacityReservationUtilization, - CommunityGallery, - CommunityGalleryImage, - CommunityGalleryImageVersion, - ComputeOperationListResult, - ComputeOperationValue, - DataDisk, - DataDiskImage, - DataDiskImageEncryption, - DedicatedHost, - DedicatedHostAllocatableVM, - DedicatedHostAvailableCapacity, - DedicatedHostGroup, - DedicatedHostGroupInstanceView, - DedicatedHostGroupListResult, - DedicatedHostGroupUpdate, - DedicatedHostInstanceView, - DedicatedHostInstanceViewWithName, - DedicatedHostListResult, - DedicatedHostUpdate, - DiagnosticsProfile, - DiffDiskSettings, - Disallowed, - DisallowedConfiguration, - DiskEncryptionSetParameters, - DiskEncryptionSettings, - DiskImageEncryption, - DiskInstanceView, - EncryptionImages, - ErrorAdditionalInfo, - ErrorDetail, - ErrorResponse, - ExtendedLocation, - Gallery, - GalleryApplication, - GalleryApplicationList, - GalleryApplicationUpdate, - GalleryApplicationVersion, - GalleryApplicationVersionList, - GalleryApplicationVersionPublishingProfile, - GalleryApplicationVersionUpdate, - GalleryArtifactPublishingProfileBase, - GalleryArtifactSource, - GalleryArtifactVersionSource, - GalleryDataDiskImage, - GalleryDiskImage, - GalleryIdentifier, - GalleryImage, - GalleryImageFeature, - GalleryImageIdentifier, - GalleryImageList, - GalleryImageUpdate, - GalleryImageVersion, - GalleryImageVersionList, - GalleryImageVersionPublishingProfile, - GalleryImageVersionStorageProfile, - GalleryImageVersionUpdate, - GalleryList, - GalleryOSDiskImage, - GalleryUpdate, - HardwareProfile, - Image, - ImageDataDisk, - ImageDisk, - ImageListResult, - ImageOSDisk, - ImagePurchasePlan, - ImageReference, - ImageStorageProfile, - ImageUpdate, - InnerError, - InstanceViewStatus, - KeyVaultKeyReference, - KeyVaultSecretReference, - LastPatchInstallationSummary, - LinuxConfiguration, - LinuxParameters, - LinuxPatchSettings, - ListUsagesResult, - LogAnalyticsInputBase, - LogAnalyticsOperationResult, - LogAnalyticsOutput, - MaintenanceRedeployStatus, - ManagedArtifact, - ManagedDiskParameters, - NetworkInterfaceReference, - NetworkProfile, - OSDisk, - OSDiskImage, - OSDiskImageEncryption, - OSProfile, - OrchestrationServiceStateInput, - OrchestrationServiceSummary, - PatchInstallationDetail, - PatchSettings, - PirCommunityGalleryResource, - PirResource, - PirSharedGalleryResource, - Plan, - ProximityPlacementGroup, - ProximityPlacementGroupListResult, - ProximityPlacementGroupUpdate, - ProxyResource, - PublicIPAddressSku, - PurchasePlan, - RecommendedMachineConfiguration, - RecoveryWalkResponse, - RegionalReplicationStatus, - ReplicationStatus, - RequestRateByIntervalInput, - Resource, - ResourceRange, - ResourceSku, - ResourceSkuCapabilities, - ResourceSkuCapacity, - ResourceSkuCosts, - ResourceSkuLocationInfo, - ResourceSkuRestrictionInfo, - ResourceSkuRestrictions, - ResourceSkuZoneDetails, - ResourceSkusResult, - RestorePoint, - RestorePointCollection, - RestorePointCollectionListResult, - RestorePointCollectionSourceProperties, - RestorePointCollectionUpdate, - RestorePointSourceMetadata, - RestorePointSourceVMDataDisk, - RestorePointSourceVMOSDisk, - RestorePointSourceVMStorageProfile, - RetrieveBootDiagnosticsDataResult, - RollbackStatusInfo, - RollingUpgradePolicy, - RollingUpgradeProgressInfo, - RollingUpgradeRunningStatus, - RollingUpgradeStatusInfo, - RunCommandDocument, - RunCommandDocumentBase, - RunCommandInput, - RunCommandInputParameter, - RunCommandListResult, - RunCommandParameterDefinition, - RunCommandResult, - ScaleInPolicy, - ScheduledEventsProfile, - SecurityProfile, - SharedGallery, - SharedGalleryImage, - SharedGalleryImageList, - SharedGalleryImageVersion, - SharedGalleryImageVersionList, - SharedGalleryList, - SharingProfile, - SharingProfileGroup, - SharingUpdate, - Sku, - SoftDeletePolicy, - SpotRestorePolicy, - SshConfiguration, - SshPublicKey, - SshPublicKeyGenerateKeyPairResult, - SshPublicKeyResource, - SshPublicKeyUpdateResource, - SshPublicKeysGroupListResult, - StorageProfile, - SubResource, - SubResourceReadOnly, - SubResourceWithColocationStatus, - TargetRegion, - TerminateNotificationProfile, - ThrottledRequestsInput, - UefiSettings, - UpdateResource, - UpdateResourceDefinition, - UpgradeOperationHistoricalStatusInfo, - UpgradeOperationHistoricalStatusInfoProperties, - UpgradeOperationHistoryStatus, - UpgradePolicy, - Usage, - UsageName, - UserArtifactManage, - UserArtifactSource, - UserAssignedIdentitiesValue, - VMGalleryApplication, - VMScaleSetConvertToSinglePlacementGroupInput, - VMSizeProperties, - VaultCertificate, - VaultSecretGroup, - VirtualHardDisk, - VirtualMachine, - VirtualMachineAgentInstanceView, - VirtualMachineAssessPatchesResult, - VirtualMachineCaptureParameters, - VirtualMachineCaptureResult, - VirtualMachineExtension, - VirtualMachineExtensionHandlerInstanceView, - VirtualMachineExtensionImage, - VirtualMachineExtensionInstanceView, - VirtualMachineExtensionUpdate, - VirtualMachineExtensionsListResult, - VirtualMachineHealthStatus, - VirtualMachineIdentity, - VirtualMachineImage, - VirtualMachineImageFeature, - VirtualMachineImageResource, - VirtualMachineInstallPatchesParameters, - VirtualMachineInstallPatchesResult, - VirtualMachineInstanceView, - VirtualMachineIpTag, - VirtualMachineListResult, - VirtualMachineNetworkInterfaceConfiguration, - VirtualMachineNetworkInterfaceDnsSettingsConfiguration, - VirtualMachineNetworkInterfaceIPConfiguration, - VirtualMachinePatchStatus, - VirtualMachinePublicIPAddressConfiguration, - VirtualMachinePublicIPAddressDnsSettingsConfiguration, - VirtualMachineReimageParameters, - VirtualMachineRunCommand, - VirtualMachineRunCommandInstanceView, - VirtualMachineRunCommandScriptSource, - VirtualMachineRunCommandUpdate, - VirtualMachineRunCommandsListResult, - VirtualMachineScaleSet, - VirtualMachineScaleSetDataDisk, - VirtualMachineScaleSetExtension, - VirtualMachineScaleSetExtensionListResult, - VirtualMachineScaleSetExtensionProfile, - VirtualMachineScaleSetExtensionUpdate, - VirtualMachineScaleSetIPConfiguration, - VirtualMachineScaleSetIdentity, - VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue, - VirtualMachineScaleSetInstanceView, - VirtualMachineScaleSetInstanceViewStatusesSummary, - VirtualMachineScaleSetIpTag, - VirtualMachineScaleSetListOSUpgradeHistory, - VirtualMachineScaleSetListResult, - VirtualMachineScaleSetListSkusResult, - VirtualMachineScaleSetListWithLinkResult, - VirtualMachineScaleSetManagedDiskParameters, - VirtualMachineScaleSetNetworkConfiguration, - VirtualMachineScaleSetNetworkConfigurationDnsSettings, - VirtualMachineScaleSetNetworkProfile, - VirtualMachineScaleSetOSDisk, - VirtualMachineScaleSetOSProfile, - VirtualMachineScaleSetPublicIPAddressConfiguration, - VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings, - VirtualMachineScaleSetReimageParameters, - VirtualMachineScaleSetSku, - VirtualMachineScaleSetSkuCapacity, - VirtualMachineScaleSetStorageProfile, - VirtualMachineScaleSetUpdate, - VirtualMachineScaleSetUpdateIPConfiguration, - VirtualMachineScaleSetUpdateNetworkConfiguration, - VirtualMachineScaleSetUpdateNetworkProfile, - VirtualMachineScaleSetUpdateOSDisk, - VirtualMachineScaleSetUpdateOSProfile, - VirtualMachineScaleSetUpdatePublicIPAddressConfiguration, - VirtualMachineScaleSetUpdateStorageProfile, - VirtualMachineScaleSetUpdateVMProfile, - VirtualMachineScaleSetVM, - VirtualMachineScaleSetVMExtension, - VirtualMachineScaleSetVMExtensionUpdate, - VirtualMachineScaleSetVMExtensionsListResult, - VirtualMachineScaleSetVMExtensionsSummary, - VirtualMachineScaleSetVMInstanceIDs, - VirtualMachineScaleSetVMInstanceRequiredIDs, - VirtualMachineScaleSetVMInstanceView, - VirtualMachineScaleSetVMListResult, - VirtualMachineScaleSetVMNetworkProfileConfiguration, - VirtualMachineScaleSetVMProfile, - VirtualMachineScaleSetVMProtectionPolicy, - VirtualMachineScaleSetVMReimageParameters, - VirtualMachineSize, - VirtualMachineSizeListResult, - VirtualMachineSoftwarePatchProperties, - VirtualMachineStatusCodeCount, - VirtualMachineUpdate, - WinRMConfiguration, - WinRMListener, - WindowsConfiguration, - WindowsParameters, -) - -from ._compute_management_client_enums import ( # type: ignore - AggregatedReplicationState, - AvailabilitySetSkuTypes, - CachingTypes, - CapacityReservationGroupInstanceViewTypes, - CapacityReservationInstanceViewTypes, - ConsistencyModeTypes, - DedicatedHostLicenseTypes, - DeleteOptions, - DiffDiskOptions, - DiffDiskPlacement, - DiskCreateOptionTypes, - DiskDeleteOptionTypes, - DiskDetachOptionTypes, - ExecutionState, - ExpandTypesForGetCapacityReservationGroups, - ExpandTypesForGetVMScaleSets, - ExtendedLocationType, - ExtendedLocationTypes, - GalleryApplicationVersionPropertiesProvisioningState, - GalleryImagePropertiesProvisioningState, - GalleryImageVersionPropertiesProvisioningState, - GalleryPropertiesProvisioningState, - GallerySharingPermissionTypes, - HostCaching, - HyperVGeneration, - HyperVGenerationType, - HyperVGenerationTypes, - IPVersion, - IPVersions, - InstanceViewTypes, - IntervalInMins, - LinuxPatchAssessmentMode, - LinuxVMGuestPatchMode, - MaintenanceOperationResultCodeTypes, - NetworkApiVersion, - OperatingSystemStateTypes, - OperatingSystemType, - OperatingSystemTypes, - OrchestrationMode, - OrchestrationServiceNames, - OrchestrationServiceState, - OrchestrationServiceStateAction, - PatchAssessmentState, - PatchInstallationState, - PatchOperationStatus, - ProtocolTypes, - ProximityPlacementGroupType, - PublicIPAddressSkuName, - PublicIPAddressSkuTier, - PublicIPAllocationMethod, - ReplicationMode, - ReplicationState, - ReplicationStatusTypes, - ResourceIdentityType, - ResourceSkuCapacityScaleType, - ResourceSkuRestrictionsReasonCode, - ResourceSkuRestrictionsType, - RestorePointCollectionExpandOptions, - RollingUpgradeActionType, - RollingUpgradeStatusCode, - SecurityTypes, - SelectPermissions, - SettingNames, - SharedToValues, - SharingProfileGroupTypes, - SharingUpdateOperationTypes, - StatusLevelTypes, - StorageAccountType, - StorageAccountTypes, - UpgradeMode, - UpgradeOperationInvoker, - UpgradeState, - VMGuestPatchClassificationLinux, - VMGuestPatchClassificationWindows, - VMGuestPatchRebootBehavior, - VMGuestPatchRebootSetting, - VMGuestPatchRebootStatus, - VirtualMachineEvictionPolicyTypes, - VirtualMachinePriorityTypes, - VirtualMachineScaleSetScaleInRules, - VirtualMachineScaleSetSkuScaleType, - VirtualMachineSizeTypes, - VmDiskTypes, - WindowsPatchAssessmentMode, - WindowsVMGuestPatchMode, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AdditionalCapabilities", - "AdditionalUnattendContent", - "ApiEntityReference", - "ApiError", - "ApiErrorBase", - "ApplicationProfile", - "AutomaticOSUpgradePolicy", - "AutomaticOSUpgradeProperties", - "AutomaticRepairsPolicy", - "AvailabilitySet", - "AvailabilitySetListResult", - "AvailabilitySetUpdate", - "AvailablePatchSummary", - "BillingProfile", - "BootDiagnostics", - "BootDiagnosticsInstanceView", - "CapacityReservation", - "CapacityReservationGroup", - "CapacityReservationGroupInstanceView", - "CapacityReservationGroupListResult", - "CapacityReservationGroupUpdate", - "CapacityReservationInstanceView", - "CapacityReservationInstanceViewWithName", - "CapacityReservationListResult", - "CapacityReservationProfile", - "CapacityReservationUpdate", - "CapacityReservationUtilization", - "CommunityGallery", - "CommunityGalleryImage", - "CommunityGalleryImageVersion", - "ComputeOperationListResult", - "ComputeOperationValue", - "DataDisk", - "DataDiskImage", - "DataDiskImageEncryption", - "DedicatedHost", - "DedicatedHostAllocatableVM", - "DedicatedHostAvailableCapacity", - "DedicatedHostGroup", - "DedicatedHostGroupInstanceView", - "DedicatedHostGroupListResult", - "DedicatedHostGroupUpdate", - "DedicatedHostInstanceView", - "DedicatedHostInstanceViewWithName", - "DedicatedHostListResult", - "DedicatedHostUpdate", - "DiagnosticsProfile", - "DiffDiskSettings", - "Disallowed", - "DisallowedConfiguration", - "DiskEncryptionSetParameters", - "DiskEncryptionSettings", - "DiskImageEncryption", - "DiskInstanceView", - "EncryptionImages", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "ExtendedLocation", - "Gallery", - "GalleryApplication", - "GalleryApplicationList", - "GalleryApplicationUpdate", - "GalleryApplicationVersion", - "GalleryApplicationVersionList", - "GalleryApplicationVersionPublishingProfile", - "GalleryApplicationVersionUpdate", - "GalleryArtifactPublishingProfileBase", - "GalleryArtifactSource", - "GalleryArtifactVersionSource", - "GalleryDataDiskImage", - "GalleryDiskImage", - "GalleryIdentifier", - "GalleryImage", - "GalleryImageFeature", - "GalleryImageIdentifier", - "GalleryImageList", - "GalleryImageUpdate", - "GalleryImageVersion", - "GalleryImageVersionList", - "GalleryImageVersionPublishingProfile", - "GalleryImageVersionStorageProfile", - "GalleryImageVersionUpdate", - "GalleryList", - "GalleryOSDiskImage", - "GalleryUpdate", - "HardwareProfile", - "Image", - "ImageDataDisk", - "ImageDisk", - "ImageListResult", - "ImageOSDisk", - "ImagePurchasePlan", - "ImageReference", - "ImageStorageProfile", - "ImageUpdate", - "InnerError", - "InstanceViewStatus", - "KeyVaultKeyReference", - "KeyVaultSecretReference", - "LastPatchInstallationSummary", - "LinuxConfiguration", - "LinuxParameters", - "LinuxPatchSettings", - "ListUsagesResult", - "LogAnalyticsInputBase", - "LogAnalyticsOperationResult", - "LogAnalyticsOutput", - "MaintenanceRedeployStatus", - "ManagedArtifact", - "ManagedDiskParameters", - "NetworkInterfaceReference", - "NetworkProfile", - "OSDisk", - "OSDiskImage", - "OSDiskImageEncryption", - "OSProfile", - "OrchestrationServiceStateInput", - "OrchestrationServiceSummary", - "PatchInstallationDetail", - "PatchSettings", - "PirCommunityGalleryResource", - "PirResource", - "PirSharedGalleryResource", - "Plan", - "ProximityPlacementGroup", - "ProximityPlacementGroupListResult", - "ProximityPlacementGroupUpdate", - "ProxyResource", - "PublicIPAddressSku", - "PurchasePlan", - "RecommendedMachineConfiguration", - "RecoveryWalkResponse", - "RegionalReplicationStatus", - "ReplicationStatus", - "RequestRateByIntervalInput", - "Resource", - "ResourceRange", - "ResourceSku", - "ResourceSkuCapabilities", - "ResourceSkuCapacity", - "ResourceSkuCosts", - "ResourceSkuLocationInfo", - "ResourceSkuRestrictionInfo", - "ResourceSkuRestrictions", - "ResourceSkuZoneDetails", - "ResourceSkusResult", - "RestorePoint", - "RestorePointCollection", - "RestorePointCollectionListResult", - "RestorePointCollectionSourceProperties", - "RestorePointCollectionUpdate", - "RestorePointSourceMetadata", - "RestorePointSourceVMDataDisk", - "RestorePointSourceVMOSDisk", - "RestorePointSourceVMStorageProfile", - "RetrieveBootDiagnosticsDataResult", - "RollbackStatusInfo", - "RollingUpgradePolicy", - "RollingUpgradeProgressInfo", - "RollingUpgradeRunningStatus", - "RollingUpgradeStatusInfo", - "RunCommandDocument", - "RunCommandDocumentBase", - "RunCommandInput", - "RunCommandInputParameter", - "RunCommandListResult", - "RunCommandParameterDefinition", - "RunCommandResult", - "ScaleInPolicy", - "ScheduledEventsProfile", - "SecurityProfile", - "SharedGallery", - "SharedGalleryImage", - "SharedGalleryImageList", - "SharedGalleryImageVersion", - "SharedGalleryImageVersionList", - "SharedGalleryList", - "SharingProfile", - "SharingProfileGroup", - "SharingUpdate", - "Sku", - "SoftDeletePolicy", - "SpotRestorePolicy", - "SshConfiguration", - "SshPublicKey", - "SshPublicKeyGenerateKeyPairResult", - "SshPublicKeyResource", - "SshPublicKeyUpdateResource", - "SshPublicKeysGroupListResult", - "StorageProfile", - "SubResource", - "SubResourceReadOnly", - "SubResourceWithColocationStatus", - "TargetRegion", - "TerminateNotificationProfile", - "ThrottledRequestsInput", - "UefiSettings", - "UpdateResource", - "UpdateResourceDefinition", - "UpgradeOperationHistoricalStatusInfo", - "UpgradeOperationHistoricalStatusInfoProperties", - "UpgradeOperationHistoryStatus", - "UpgradePolicy", - "Usage", - "UsageName", - "UserArtifactManage", - "UserArtifactSource", - "UserAssignedIdentitiesValue", - "VMGalleryApplication", - "VMScaleSetConvertToSinglePlacementGroupInput", - "VMSizeProperties", - "VaultCertificate", - "VaultSecretGroup", - "VirtualHardDisk", - "VirtualMachine", - "VirtualMachineAgentInstanceView", - "VirtualMachineAssessPatchesResult", - "VirtualMachineCaptureParameters", - "VirtualMachineCaptureResult", - "VirtualMachineExtension", - "VirtualMachineExtensionHandlerInstanceView", - "VirtualMachineExtensionImage", - "VirtualMachineExtensionInstanceView", - "VirtualMachineExtensionUpdate", - "VirtualMachineExtensionsListResult", - "VirtualMachineHealthStatus", - "VirtualMachineIdentity", - "VirtualMachineImage", - "VirtualMachineImageFeature", - "VirtualMachineImageResource", - "VirtualMachineInstallPatchesParameters", - "VirtualMachineInstallPatchesResult", - "VirtualMachineInstanceView", - "VirtualMachineIpTag", - "VirtualMachineListResult", - "VirtualMachineNetworkInterfaceConfiguration", - "VirtualMachineNetworkInterfaceDnsSettingsConfiguration", - "VirtualMachineNetworkInterfaceIPConfiguration", - "VirtualMachinePatchStatus", - "VirtualMachinePublicIPAddressConfiguration", - "VirtualMachinePublicIPAddressDnsSettingsConfiguration", - "VirtualMachineReimageParameters", - "VirtualMachineRunCommand", - "VirtualMachineRunCommandInstanceView", - "VirtualMachineRunCommandScriptSource", - "VirtualMachineRunCommandUpdate", - "VirtualMachineRunCommandsListResult", - "VirtualMachineScaleSet", - "VirtualMachineScaleSetDataDisk", - "VirtualMachineScaleSetExtension", - "VirtualMachineScaleSetExtensionListResult", - "VirtualMachineScaleSetExtensionProfile", - "VirtualMachineScaleSetExtensionUpdate", - "VirtualMachineScaleSetIPConfiguration", - "VirtualMachineScaleSetIdentity", - "VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue", - "VirtualMachineScaleSetInstanceView", - "VirtualMachineScaleSetInstanceViewStatusesSummary", - "VirtualMachineScaleSetIpTag", - "VirtualMachineScaleSetListOSUpgradeHistory", - "VirtualMachineScaleSetListResult", - "VirtualMachineScaleSetListSkusResult", - "VirtualMachineScaleSetListWithLinkResult", - "VirtualMachineScaleSetManagedDiskParameters", - "VirtualMachineScaleSetNetworkConfiguration", - "VirtualMachineScaleSetNetworkConfigurationDnsSettings", - "VirtualMachineScaleSetNetworkProfile", - "VirtualMachineScaleSetOSDisk", - "VirtualMachineScaleSetOSProfile", - "VirtualMachineScaleSetPublicIPAddressConfiguration", - "VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings", - "VirtualMachineScaleSetReimageParameters", - "VirtualMachineScaleSetSku", - "VirtualMachineScaleSetSkuCapacity", - "VirtualMachineScaleSetStorageProfile", - "VirtualMachineScaleSetUpdate", - "VirtualMachineScaleSetUpdateIPConfiguration", - "VirtualMachineScaleSetUpdateNetworkConfiguration", - "VirtualMachineScaleSetUpdateNetworkProfile", - "VirtualMachineScaleSetUpdateOSDisk", - "VirtualMachineScaleSetUpdateOSProfile", - "VirtualMachineScaleSetUpdatePublicIPAddressConfiguration", - "VirtualMachineScaleSetUpdateStorageProfile", - "VirtualMachineScaleSetUpdateVMProfile", - "VirtualMachineScaleSetVM", - "VirtualMachineScaleSetVMExtension", - "VirtualMachineScaleSetVMExtensionUpdate", - "VirtualMachineScaleSetVMExtensionsListResult", - "VirtualMachineScaleSetVMExtensionsSummary", - "VirtualMachineScaleSetVMInstanceIDs", - "VirtualMachineScaleSetVMInstanceRequiredIDs", - "VirtualMachineScaleSetVMInstanceView", - "VirtualMachineScaleSetVMListResult", - "VirtualMachineScaleSetVMNetworkProfileConfiguration", - "VirtualMachineScaleSetVMProfile", - "VirtualMachineScaleSetVMProtectionPolicy", - "VirtualMachineScaleSetVMReimageParameters", - "VirtualMachineSize", - "VirtualMachineSizeListResult", - "VirtualMachineSoftwarePatchProperties", - "VirtualMachineStatusCodeCount", - "VirtualMachineUpdate", - "WinRMConfiguration", - "WinRMListener", - "WindowsConfiguration", - "WindowsParameters", - "AggregatedReplicationState", - "AvailabilitySetSkuTypes", - "CachingTypes", - "CapacityReservationGroupInstanceViewTypes", - "CapacityReservationInstanceViewTypes", - "ConsistencyModeTypes", - "DedicatedHostLicenseTypes", - "DeleteOptions", - "DiffDiskOptions", - "DiffDiskPlacement", - "DiskCreateOptionTypes", - "DiskDeleteOptionTypes", - "DiskDetachOptionTypes", - "ExecutionState", - "ExpandTypesForGetCapacityReservationGroups", - "ExpandTypesForGetVMScaleSets", - "ExtendedLocationType", - "ExtendedLocationTypes", - "GalleryApplicationVersionPropertiesProvisioningState", - "GalleryImagePropertiesProvisioningState", - "GalleryImageVersionPropertiesProvisioningState", - "GalleryPropertiesProvisioningState", - "GallerySharingPermissionTypes", - "HostCaching", - "HyperVGeneration", - "HyperVGenerationType", - "HyperVGenerationTypes", - "IPVersion", - "IPVersions", - "InstanceViewTypes", - "IntervalInMins", - "LinuxPatchAssessmentMode", - "LinuxVMGuestPatchMode", - "MaintenanceOperationResultCodeTypes", - "NetworkApiVersion", - "OperatingSystemStateTypes", - "OperatingSystemType", - "OperatingSystemTypes", - "OrchestrationMode", - "OrchestrationServiceNames", - "OrchestrationServiceState", - "OrchestrationServiceStateAction", - "PatchAssessmentState", - "PatchInstallationState", - "PatchOperationStatus", - "ProtocolTypes", - "ProximityPlacementGroupType", - "PublicIPAddressSkuName", - "PublicIPAddressSkuTier", - "PublicIPAllocationMethod", - "ReplicationMode", - "ReplicationState", - "ReplicationStatusTypes", - "ResourceIdentityType", - "ResourceSkuCapacityScaleType", - "ResourceSkuRestrictionsReasonCode", - "ResourceSkuRestrictionsType", - "RestorePointCollectionExpandOptions", - "RollingUpgradeActionType", - "RollingUpgradeStatusCode", - "SecurityTypes", - "SelectPermissions", - "SettingNames", - "SharedToValues", - "SharingProfileGroupTypes", - "SharingUpdateOperationTypes", - "StatusLevelTypes", - "StorageAccountType", - "StorageAccountTypes", - "UpgradeMode", - "UpgradeOperationInvoker", - "UpgradeState", - "VMGuestPatchClassificationLinux", - "VMGuestPatchClassificationWindows", - "VMGuestPatchRebootBehavior", - "VMGuestPatchRebootSetting", - "VMGuestPatchRebootStatus", - "VirtualMachineEvictionPolicyTypes", - "VirtualMachinePriorityTypes", - "VirtualMachineScaleSetScaleInRules", - "VirtualMachineScaleSetSkuScaleType", - "VirtualMachineSizeTypes", - "VmDiskTypes", - "WindowsPatchAssessmentMode", - "WindowsVMGuestPatchMode", -] -__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/v2021_07_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_compute_management_client_enums.py deleted file mode 100644 index 198bdecff887..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_compute_management_client_enums.py +++ /dev/null @@ -1,964 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AggregatedReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is the aggregated replication status based on all the regional replication status flags.""" - - UNKNOWN = "Unknown" - IN_PROGRESS = "InProgress" - COMPLETED = "Completed" - FAILED = "Failed" - - -class AvailabilitySetSkuTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the sku of an Availability Set. Use 'Aligned' for virtual machines with managed disks - and 'Classic' for virtual machines with unmanaged disks. Default value is 'Classic'. - """ - - CLASSIC = "Classic" - ALIGNED = "Aligned" - - -class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** :code:`
    `\\ - :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for Standard storage. - ReadOnly for Premium storage**. - """ - - NONE = "None" - READ_ONLY = "ReadOnly" - READ_WRITE = "ReadWrite" - - -class CapacityReservationGroupInstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """CapacityReservationGroupInstanceViewTypes.""" - - INSTANCE_VIEW = "instanceView" - - -class CapacityReservationInstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """CapacityReservationInstanceViewTypes.""" - - INSTANCE_VIEW = "instanceView" - - -class ConsistencyModeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the consistency mode for the restore point. Please refer to https://aka.ms/RestorePoints - for more details. - """ - - CRASH_CONSISTENT = "CrashConsistent" - FILE_SYSTEM_CONSISTENT = "FileSystemConsistent" - APPLICATION_CONSISTENT = "ApplicationConsistent" - - -class DedicatedHostLicenseTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the software license type that will be applied to the VMs deployed on the dedicated - host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **None** - :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ :code:`
    ` - **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. - """ - - NONE = "None" - WINDOWS_SERVER_HYBRID = "Windows_Server_Hybrid" - WINDOWS_SERVER_PERPETUAL = "Windows_Server_Perpetual" - - -class DeleteOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specify what happens to the network interface when the VM is deleted.""" - - DELETE = "Delete" - DETACH = "Detach" - - -class DiffDiskOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the ephemeral disk option for operating system disk.""" - - LOCAL = "Local" - - -class DiffDiskPlacement(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the ephemeral disk placement for operating system disk. This property can be used by - user in the request to choose the location i.e, cache disk or resource disk space for Ephemeral - OS disk provisioning. For more information on Ephemeral OS disk size requirements, please refer - Ephemeral OS disk size requirements for Windows VM at - https://docs.microsoft.com/azure/virtual-machines/windows/ephemeral-os-disks#size-requirements - and Linux VM at - https://docs.microsoft.com/azure/virtual-machines/linux/ephemeral-os-disks#size-requirements. - """ - - CACHE_DISK = "CacheDisk" - RESOURCE_DISK = "ResourceDisk" - - -class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies how the virtual machine should be created.\\ :code:`
    `\\ :code:`
    ` Possible - values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value is used when you are - using a specialized disk to create the virtual machine.\\ :code:`
    `\\ :code:`
    ` - **FromImage** \\u2013 This value is used when you are using an image to create the virtual - machine. If you are using a platform image, you also use the imageReference element described - above. If you are using a marketplace image, you also use the plan element previously - described. - """ - - FROM_IMAGE = "FromImage" - EMPTY = "Empty" - ATTACH = "Attach" - - -class DiskDeleteOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the behavior of the managed disk when the VM gets deleted i.e whether the managed - disk is deleted or detached. Supported values:\\ :code:`
    `\\ :code:`
    ` **Delete** If this - value is used, the managed disk is deleted when VM gets deleted.\\ :code:`
    `\\ :code:`
    ` - **Detach** If this value is used, the managed disk is retained after VM gets deleted.\\ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2021-03-01. - """ - - DELETE = "Delete" - DETACH = "Detach" - - -class DiskDetachOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the detach behavior to be used while detaching a disk or which is already in the - process of detachment from the virtual machine. Supported values: **ForceDetach**. - :code:`
    `\\ :code:`
    ` detachOption: **ForceDetach** is applicable only for managed data - disks. If a 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. :code:`
    `\\ :code:`
    ` This feature is still in - preview mode and is not supported for VirtualMachineScaleSet. To force-detach a data disk - update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. - """ - - FORCE_DETACH = "ForceDetach" - - -class ExecutionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Script execution status.""" - - UNKNOWN = "Unknown" - PENDING = "Pending" - RUNNING = "Running" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - TIMED_OUT = "TimedOut" - CANCELED = "Canceled" - - -class ExpandTypesForGetCapacityReservationGroups(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ExpandTypesForGetCapacityReservationGroups.""" - - VIRTUAL_MACHINE_SCALE_SET_VMS_REF = "virtualMachineScaleSetVMs/$ref" - VIRTUAL_MACHINES_REF = "virtualMachines/$ref" - - -class ExpandTypesForGetVMScaleSets(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ExpandTypesForGetVMScaleSets.""" - - USER_DATA = "userData" - - -class ExtendedLocationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the extended location.""" - - EDGE_ZONE = "EdgeZone" - - -class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of extendedLocation.""" - - EDGE_ZONE = "EdgeZone" - - -class GalleryApplicationVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state, which only appears in the response.""" - - CREATING = "Creating" - UPDATING = "Updating" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - MIGRATING = "Migrating" - - -class GalleryImagePropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state, which only appears in the response.""" - - CREATING = "Creating" - UPDATING = "Updating" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - MIGRATING = "Migrating" - - -class GalleryImageVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state, which only appears in the response.""" - - CREATING = "Creating" - UPDATING = "Updating" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - MIGRATING = "Migrating" - - -class GalleryPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state, which only appears in the response.""" - - CREATING = "Creating" - UPDATING = "Updating" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - MIGRATING = "Migrating" - - -class GallerySharingPermissionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows you to specify the permission of sharing gallery. :code:`
    `\\ - :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Private** :code:`
    `\\ - :code:`
    ` **Groups**. - """ - - PRIVATE = "Private" - GROUPS = "Groups" - - -class HostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'.""" - - NONE = "None" - READ_ONLY = "ReadOnly" - READ_WRITE = "ReadWrite" - - -class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The hypervisor generation of the Virtual Machine. Applicable to OS disks only.""" - - V1 = "V1" - V2 = "V2" - - -class HyperVGenerationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the HyperVGeneration Type associated with a resource.""" - - V1 = "V1" - V2 = "V2" - - -class HyperVGenerationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the HyperVGeneration Type.""" - - V1 = "V1" - V2 = "V2" - - -class InstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """InstanceViewTypes.""" - - INSTANCE_VIEW = "instanceView" - USER_DATA = "userData" - - -class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Interval value in minutes used to create LogAnalytics call rate logs.""" - - THREE_MINS = "ThreeMins" - FIVE_MINS = "FiveMins" - THIRTY_MINS = "ThirtyMins" - SIXTY_MINS = "SixtyMins" - - -class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """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'. - """ - - I_PV4 = "IPv4" - I_PV6 = "IPv6" - - -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 - 'IPv6'. - """ - - I_PV4 = "IPv4" - I_PV6 = "IPv6" - - -class LinuxPatchAssessmentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the mode of VM Guest Patch Assessment for the IaaS virtual machine.\\ :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **ImageDefault** - - You control the timing of patch assessments on a virtual machine. :code:`
    `\\ :code:`
    ` **AutomaticByPlatform** - The platform will trigger periodic patch assessments. The - property provisionVMAgent must be true. - """ - - IMAGE_DEFAULT = "ImageDefault" - AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" - - -class LinuxVMGuestPatchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual machines associated - to virtual machine scale set with OrchestrationMode as Flexible.\\ :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **ImageDefault** - The virtual - machine's default patching configuration is used. :code:`
    `\\ :code:`
    ` - **AutomaticByPlatform** - The virtual machine will be automatically updated by the platform. - The property provisionVMAgent must be true. - """ - - IMAGE_DEFAULT = "ImageDefault" - AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" - - -class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The Last Maintenance Operation Result Code.""" - - NONE = "None" - RETRY_LATER = "RetryLater" - MAINTENANCE_ABORTED = "MaintenanceAborted" - MAINTENANCE_COMPLETED = "MaintenanceCompleted" - - -class NetworkApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """specifies the Microsoft.Network API version used when creating networking resources in the - Network Interface Configurations. - """ - - TWO_THOUSAND_TWENTY11_01 = "2020-11-01" - - -class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The OS State.""" - - GENERALIZED = "Generalized" - """Generalized image. Needs to be provisioned during deployment time.""" - SPECIALIZED = "Specialized" - """Specialized image. Contains already provisioned OS Disk.""" - - -class OperatingSystemType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the Operating System type.""" - - WINDOWS = "Windows" - LINUX = "Linux" - - -class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The operating system of the osDiskImage.""" - - WINDOWS = "Windows" - LINUX = "Linux" - - -class OrchestrationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the orchestration mode for the virtual machine scale set.""" - - UNIFORM = "Uniform" - FLEXIBLE = "Flexible" - - -class OrchestrationServiceNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The name of the service.""" - - AUTOMATIC_REPAIRS = "AutomaticRepairs" - - -class OrchestrationServiceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current state of the service.""" - - NOT_RUNNING = "NotRunning" - RUNNING = "Running" - SUSPENDED = "Suspended" - - -class OrchestrationServiceStateAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The action to be performed.""" - - RESUME = "Resume" - SUSPEND = "Suspend" - - -class PatchAssessmentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Describes the availability of a given patch.""" - - UNKNOWN = "Unknown" - AVAILABLE = "Available" - - -class PatchInstallationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The state of the patch after the installation operation completed.""" - - UNKNOWN = "Unknown" - INSTALLED = "Installed" - FAILED = "Failed" - EXCLUDED = "Excluded" - NOT_SELECTED = "NotSelected" - PENDING = "Pending" - - -class PatchOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The overall success or failure status of the operation. It remains "InProgress" until the - operation completes. At that point it will become "Unknown", "Failed", "Succeeded", or - "CompletedWithWarnings.". - """ - - UNKNOWN = "Unknown" - IN_PROGRESS = "InProgress" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - COMPLETED_WITH_WARNINGS = "CompletedWithWarnings" - - -class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the protocol of WinRM listener. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. - """ - - HTTP = "Http" - HTTPS = "Https" - - -class ProximityPlacementGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the type of the proximity placement group. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **Standard** : Co-locate resources within an Azure - region or Availability Zone. :code:`
    `\\ :code:`
    ` **Ultra** : For future use. - """ - - STANDARD = "Standard" - ULTRA = "Ultra" - - -class PublicIPAddressSkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specify public IP sku name.""" - - BASIC = "Basic" - STANDARD = "Standard" - - -class PublicIPAddressSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specify public IP sku tier.""" - - REGIONAL = "Regional" - GLOBAL = "Global" - GLOBAL_ENUM = "Global" - - -class PublicIPAllocationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specify the public IP allocation type.""" - - DYNAMIC = "Dynamic" - STATIC = "Static" - - -class ReplicationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Optional parameter which specifies the mode to be used for replication. This property is not - updatable. - """ - - FULL = "Full" - SHALLOW = "Shallow" - - -class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is the regional replication state.""" - - UNKNOWN = "Unknown" - REPLICATING = "Replicating" - COMPLETED = "Completed" - FAILED = "Failed" - - -class ReplicationStatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ReplicationStatusTypes.""" - - REPLICATION_STATUS = "ReplicationStatus" - - -class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' - includes both an implicitly created identity and a set of user assigned identities. The type - 'None' will remove any identities from the virtual machine. - """ - - SYSTEM_ASSIGNED = "SystemAssigned" - USER_ASSIGNED = "UserAssigned" - SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" - NONE = "None" - - -class ResourceSkuCapacityScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scale type applicable to the sku.""" - - AUTOMATIC = "Automatic" - MANUAL = "Manual" - NONE = "None" - - -class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The reason for restriction.""" - - QUOTA_ID = "QuotaId" - NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" - - -class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of restrictions.""" - - LOCATION = "Location" - ZONE = "Zone" - - -class RestorePointCollectionExpandOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RestorePointCollectionExpandOptions.""" - - RESTORE_POINTS = "restorePoints" - - -class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The last action performed on the rolling upgrade.""" - - START = "Start" - CANCEL = "Cancel" - - -class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Code indicating the current status of the upgrade.""" - - ROLLING_FORWARD = "RollingForward" - CANCELLED = "Cancelled" - COMPLETED = "Completed" - FAULTED = "Faulted" - - -class SecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the SecurityType of the virtual machine. It is set as TrustedLaunch to enable - UefiSettings. :code:`
    `\\ :code:`
    ` Default: UefiSettings will not be enabled unless this - property is set as TrustedLaunch. - """ - - TRUSTED_LAUNCH = "TrustedLaunch" - - -class SelectPermissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SelectPermissions.""" - - PERMISSIONS = "Permissions" - - -class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the name of the setting to which the content applies. Possible values are: - FirstLogonCommands and AutoLogon. - """ - - AUTO_LOGON = "AutoLogon" - FIRST_LOGON_COMMANDS = "FirstLogonCommands" - - -class SharedToValues(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SharedToValues.""" - - TENANT = "tenant" - - -class SharingProfileGroupTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows you to specify the type of sharing group. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Subscriptions** :code:`
    `\\ :code:`
    ` - **AADTenants**. - """ - - SUBSCRIPTIONS = "Subscriptions" - AAD_TENANTS = "AADTenants" - - -class SharingUpdateOperationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows you to specify the operation type of gallery sharing update. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Add** - :code:`
    `\\ :code:`
    ` **Remove** :code:`
    `\\ :code:`
    ` **Reset**. - """ - - ADD = "Add" - REMOVE = "Remove" - RESET = "Reset" - - -class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The level code.""" - - INFO = "Info" - WARNING = "Warning" - ERROR = "Error" - - -class StorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the storage account type to be used to store the image. This property is not - updatable. - """ - - STANDARD_LRS = "Standard_LRS" - STANDARD_ZRS = "Standard_ZRS" - PREMIUM_LRS = "Premium_LRS" - - -class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the storage account type for the managed disk. Managed OS disk storage account type - can only be set when you create the scale set. NOTE: UltraSSD_LRS can only be used with data - disks. It cannot be used with OS Disk. Standard_LRS uses Standard HDD. StandardSSD_LRS uses - Standard SSD. Premium_LRS uses Premium SSD. UltraSSD_LRS uses Ultra disk. Premium_ZRS uses - Premium SSD zone redundant storage. StandardSSD_ZRS uses Standard SSD zone redundant storage. - For more information regarding disks supported for Windows Virtual Machines, refer to - https://docs.microsoft.com/azure/virtual-machines/windows/disks-types and, for Linux Virtual - Machines, refer to https://docs.microsoft.com/azure/virtual-machines/linux/disks-types. - """ - - STANDARD_LRS = "Standard_LRS" - PREMIUM_LRS = "Premium_LRS" - STANDARD_SSD_LRS = "StandardSSD_LRS" - ULTRA_SSD_LRS = "UltraSSD_LRS" - PREMIUM_ZRS = "Premium_ZRS" - STANDARD_SSD_ZRS = "StandardSSD_ZRS" - - -class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the mode of an upgrade to virtual machines in the scale set.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Manual** - You control - the application of updates to virtual machines in the scale set. You do this by using the - manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - All virtual machines in - the scale set are automatically updated at the same time. - """ - - AUTOMATIC = "Automatic" - MANUAL = "Manual" - ROLLING = "Rolling" - - -class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Invoker of the Upgrade Operation.""" - - UNKNOWN = "Unknown" - USER = "User" - PLATFORM = "Platform" - - -class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Code indicating the current status of the upgrade.""" - - ROLLING_FORWARD = "RollingForward" - CANCELLED = "Cancelled" - COMPLETED = "Completed" - FAULTED = "Faulted" - - -class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the eviction policy for the Azure Spot VM/VMSS.""" - - DEALLOCATE = "Deallocate" - DELETE = "Delete" - - -class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the priority for a standalone virtual machine or the virtual machines in the scale - set. :code:`
    `\\ :code:`
    ` 'Low' enum will be deprecated in the future, please use 'Spot' - as the enum to deploy Azure Spot VM/VMSS. - """ - - REGULAR = "Regular" - LOW = "Low" - SPOT = "Spot" - - -class VirtualMachineScaleSetScaleInRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """VirtualMachineScaleSetScaleInRules.""" - - DEFAULT = "Default" - OLDEST_VM = "OldestVM" - NEWEST_VM = "NewestVM" - - -class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The scale type applicable to the sku.""" - - AUTOMATIC = "Automatic" - NONE = "None" - - -class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the size of the virtual machine. :code:`
    `\\ :code:`
    ` The enum data type is - currently deprecated and will be removed by December 23rd 2023. :code:`
    `\\ :code:`
    ` - Recommended way to get the list of available sizes is using these APIs: :code:`
    `\\ - :code:`
    ` `List all available virtual machine sizes in an availability set - `_ - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in a region - `_ :code:`
    `\\ :code:`
    ` - `List all available virtual machine sizes for resizing - `_. For more - information about virtual machine sizes, see `Sizes for virtual machines - `_. :code:`
    `\\ :code:`
    ` The - available VM sizes depend on region and availability set. - """ - - BASIC_A0 = "Basic_A0" - BASIC_A1 = "Basic_A1" - BASIC_A2 = "Basic_A2" - BASIC_A3 = "Basic_A3" - BASIC_A4 = "Basic_A4" - STANDARD_A0 = "Standard_A0" - STANDARD_A1 = "Standard_A1" - STANDARD_A2 = "Standard_A2" - STANDARD_A3 = "Standard_A3" - STANDARD_A4 = "Standard_A4" - STANDARD_A5 = "Standard_A5" - STANDARD_A6 = "Standard_A6" - STANDARD_A7 = "Standard_A7" - STANDARD_A8 = "Standard_A8" - STANDARD_A9 = "Standard_A9" - STANDARD_A10 = "Standard_A10" - STANDARD_A11 = "Standard_A11" - STANDARD_A1_V2 = "Standard_A1_v2" - STANDARD_A2_V2 = "Standard_A2_v2" - STANDARD_A4_V2 = "Standard_A4_v2" - STANDARD_A8_V2 = "Standard_A8_v2" - STANDARD_A2_M_V2 = "Standard_A2m_v2" - STANDARD_A4_M_V2 = "Standard_A4m_v2" - STANDARD_A8_M_V2 = "Standard_A8m_v2" - STANDARD_B1_S = "Standard_B1s" - STANDARD_B1_MS = "Standard_B1ms" - STANDARD_B2_S = "Standard_B2s" - STANDARD_B2_MS = "Standard_B2ms" - STANDARD_B4_MS = "Standard_B4ms" - STANDARD_B8_MS = "Standard_B8ms" - STANDARD_D1 = "Standard_D1" - STANDARD_D2 = "Standard_D2" - STANDARD_D3 = "Standard_D3" - STANDARD_D4 = "Standard_D4" - STANDARD_D11 = "Standard_D11" - STANDARD_D12 = "Standard_D12" - STANDARD_D13 = "Standard_D13" - STANDARD_D14 = "Standard_D14" - STANDARD_D1_V2 = "Standard_D1_v2" - STANDARD_D2_V2 = "Standard_D2_v2" - STANDARD_D3_V2 = "Standard_D3_v2" - STANDARD_D4_V2 = "Standard_D4_v2" - STANDARD_D5_V2 = "Standard_D5_v2" - STANDARD_D2_V3 = "Standard_D2_v3" - STANDARD_D4_V3 = "Standard_D4_v3" - STANDARD_D8_V3 = "Standard_D8_v3" - STANDARD_D16_V3 = "Standard_D16_v3" - STANDARD_D32_V3 = "Standard_D32_v3" - STANDARD_D64_V3 = "Standard_D64_v3" - STANDARD_D2_S_V3 = "Standard_D2s_v3" - STANDARD_D4_S_V3 = "Standard_D4s_v3" - STANDARD_D8_S_V3 = "Standard_D8s_v3" - STANDARD_D16_S_V3 = "Standard_D16s_v3" - STANDARD_D32_S_V3 = "Standard_D32s_v3" - STANDARD_D64_S_V3 = "Standard_D64s_v3" - STANDARD_D11_V2 = "Standard_D11_v2" - STANDARD_D12_V2 = "Standard_D12_v2" - STANDARD_D13_V2 = "Standard_D13_v2" - STANDARD_D14_V2 = "Standard_D14_v2" - STANDARD_D15_V2 = "Standard_D15_v2" - STANDARD_DS1 = "Standard_DS1" - STANDARD_DS2 = "Standard_DS2" - STANDARD_DS3 = "Standard_DS3" - STANDARD_DS4 = "Standard_DS4" - STANDARD_DS11 = "Standard_DS11" - STANDARD_DS12 = "Standard_DS12" - STANDARD_DS13 = "Standard_DS13" - STANDARD_DS14 = "Standard_DS14" - STANDARD_DS1_V2 = "Standard_DS1_v2" - STANDARD_DS2_V2 = "Standard_DS2_v2" - STANDARD_DS3_V2 = "Standard_DS3_v2" - STANDARD_DS4_V2 = "Standard_DS4_v2" - STANDARD_DS5_V2 = "Standard_DS5_v2" - STANDARD_DS11_V2 = "Standard_DS11_v2" - STANDARD_DS12_V2 = "Standard_DS12_v2" - STANDARD_DS13_V2 = "Standard_DS13_v2" - STANDARD_DS14_V2 = "Standard_DS14_v2" - STANDARD_DS15_V2 = "Standard_DS15_v2" - STANDARD_DS13_4_V2 = "Standard_DS13-4_v2" - STANDARD_DS13_2_V2 = "Standard_DS13-2_v2" - STANDARD_DS14_8_V2 = "Standard_DS14-8_v2" - STANDARD_DS14_4_V2 = "Standard_DS14-4_v2" - STANDARD_E2_V3 = "Standard_E2_v3" - STANDARD_E4_V3 = "Standard_E4_v3" - STANDARD_E8_V3 = "Standard_E8_v3" - STANDARD_E16_V3 = "Standard_E16_v3" - STANDARD_E32_V3 = "Standard_E32_v3" - STANDARD_E64_V3 = "Standard_E64_v3" - STANDARD_E2_S_V3 = "Standard_E2s_v3" - STANDARD_E4_S_V3 = "Standard_E4s_v3" - STANDARD_E8_S_V3 = "Standard_E8s_v3" - STANDARD_E16_S_V3 = "Standard_E16s_v3" - STANDARD_E32_S_V3 = "Standard_E32s_v3" - STANDARD_E64_S_V3 = "Standard_E64s_v3" - STANDARD_E32_16_V3 = "Standard_E32-16_v3" - STANDARD_E32_8_S_V3 = "Standard_E32-8s_v3" - STANDARD_E64_32_S_V3 = "Standard_E64-32s_v3" - STANDARD_E64_16_S_V3 = "Standard_E64-16s_v3" - STANDARD_F1 = "Standard_F1" - STANDARD_F2 = "Standard_F2" - STANDARD_F4 = "Standard_F4" - STANDARD_F8 = "Standard_F8" - STANDARD_F16 = "Standard_F16" - STANDARD_F1_S = "Standard_F1s" - STANDARD_F2_S = "Standard_F2s" - STANDARD_F4_S = "Standard_F4s" - STANDARD_F8_S = "Standard_F8s" - STANDARD_F16_S = "Standard_F16s" - STANDARD_F2_S_V2 = "Standard_F2s_v2" - STANDARD_F4_S_V2 = "Standard_F4s_v2" - STANDARD_F8_S_V2 = "Standard_F8s_v2" - STANDARD_F16_S_V2 = "Standard_F16s_v2" - STANDARD_F32_S_V2 = "Standard_F32s_v2" - STANDARD_F64_S_V2 = "Standard_F64s_v2" - STANDARD_F72_S_V2 = "Standard_F72s_v2" - STANDARD_G1 = "Standard_G1" - STANDARD_G2 = "Standard_G2" - STANDARD_G3 = "Standard_G3" - STANDARD_G4 = "Standard_G4" - STANDARD_G5 = "Standard_G5" - STANDARD_GS1 = "Standard_GS1" - STANDARD_GS2 = "Standard_GS2" - STANDARD_GS3 = "Standard_GS3" - STANDARD_GS4 = "Standard_GS4" - STANDARD_GS5 = "Standard_GS5" - STANDARD_GS4_8 = "Standard_GS4-8" - STANDARD_GS4_4 = "Standard_GS4-4" - STANDARD_GS5_16 = "Standard_GS5-16" - STANDARD_GS5_8 = "Standard_GS5-8" - STANDARD_H8 = "Standard_H8" - STANDARD_H16 = "Standard_H16" - STANDARD_H8_M = "Standard_H8m" - STANDARD_H16_M = "Standard_H16m" - STANDARD_H16_R = "Standard_H16r" - STANDARD_H16_MR = "Standard_H16mr" - STANDARD_L4_S = "Standard_L4s" - STANDARD_L8_S = "Standard_L8s" - STANDARD_L16_S = "Standard_L16s" - STANDARD_L32_S = "Standard_L32s" - STANDARD_M64_S = "Standard_M64s" - STANDARD_M64_MS = "Standard_M64ms" - STANDARD_M128_S = "Standard_M128s" - STANDARD_M128_MS = "Standard_M128ms" - STANDARD_M64_32_MS = "Standard_M64-32ms" - STANDARD_M64_16_MS = "Standard_M64-16ms" - STANDARD_M128_64_MS = "Standard_M128-64ms" - STANDARD_M128_32_MS = "Standard_M128-32ms" - STANDARD_NC6 = "Standard_NC6" - STANDARD_NC12 = "Standard_NC12" - STANDARD_NC24 = "Standard_NC24" - STANDARD_NC24_R = "Standard_NC24r" - STANDARD_NC6_S_V2 = "Standard_NC6s_v2" - STANDARD_NC12_S_V2 = "Standard_NC12s_v2" - STANDARD_NC24_S_V2 = "Standard_NC24s_v2" - STANDARD_NC24_RS_V2 = "Standard_NC24rs_v2" - STANDARD_NC6_S_V3 = "Standard_NC6s_v3" - STANDARD_NC12_S_V3 = "Standard_NC12s_v3" - STANDARD_NC24_S_V3 = "Standard_NC24s_v3" - STANDARD_NC24_RS_V3 = "Standard_NC24rs_v3" - STANDARD_ND6_S = "Standard_ND6s" - STANDARD_ND12_S = "Standard_ND12s" - STANDARD_ND24_S = "Standard_ND24s" - STANDARD_ND24_RS = "Standard_ND24rs" - STANDARD_NV6 = "Standard_NV6" - STANDARD_NV12 = "Standard_NV12" - STANDARD_NV24 = "Standard_NV24" - - -class VmDiskTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """VM disk types which are disallowed.""" - - NONE = "None" - UNMANAGED = "Unmanaged" - - -class VMGuestPatchClassificationLinux(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """VMGuestPatchClassificationLinux.""" - - CRITICAL = "Critical" - SECURITY = "Security" - OTHER = "Other" - - -class VMGuestPatchClassificationWindows(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """VMGuestPatchClassificationWindows.""" - - CRITICAL = "Critical" - SECURITY = "Security" - UPDATE_ROLL_UP = "UpdateRollUp" - FEATURE_PACK = "FeaturePack" - SERVICE_PACK = "ServicePack" - DEFINITION = "Definition" - TOOLS = "Tools" - UPDATES = "Updates" - - -class VMGuestPatchRebootBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Describes the reboot requirements of the patch.""" - - UNKNOWN = "Unknown" - NEVER_REBOOTS = "NeverReboots" - ALWAYS_REQUIRES_REBOOT = "AlwaysRequiresReboot" - CAN_REQUEST_REBOOT = "CanRequestReboot" - - -class VMGuestPatchRebootSetting(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Defines when it is acceptable to reboot a VM during a software update operation.""" - - IF_REQUIRED = "IfRequired" - NEVER = "Never" - ALWAYS = "Always" - - -class VMGuestPatchRebootStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The reboot state of the VM following completion of the operation.""" - - UNKNOWN = "Unknown" - NOT_NEEDED = "NotNeeded" - REQUIRED = "Required" - STARTED = "Started" - FAILED = "Failed" - COMPLETED = "Completed" - - -class WindowsPatchAssessmentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the mode of VM Guest patch assessment for the IaaS virtual machine.\\ :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **ImageDefault** - - You control the timing of patch assessments on a virtual machine.\\ :code:`
    `\\ :code:`
    ` **AutomaticByPlatform** - The platform will trigger periodic patch assessments. The - property provisionVMAgent must be true. - """ - - IMAGE_DEFAULT = "ImageDefault" - AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" - - -class WindowsVMGuestPatchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual machines associated - to virtual machine scale set with OrchestrationMode as Flexible.\\ :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Manual** - You control the - application of patches to a virtual machine. You do this by applying patches manually inside - the VM. In this mode, automatic updates are disabled; the property - WindowsConfiguration.enableAutomaticUpdates must be false\\ :code:`
    `\\ :code:`
    ` - **AutomaticByOS** - The virtual machine will automatically be updated by the OS. The property - WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
    `\\ :code:`
    ` - **AutomaticByPlatform** - the virtual machine will automatically updated by the platform. The - properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. - """ - - MANUAL = "Manual" - AUTOMATIC_BY_OS = "AutomaticByOS" - AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" 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 deleted file mode 100644 index 02963560ea13..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_models_py3.py +++ /dev/null @@ -1,17756 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from collections.abc import MutableMapping -import datetime -from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models -JSON = MutableMapping[str, Any] - - -class AdditionalCapabilities(_serialization.Model): - """Enables or disables a capability on the virtual machine or virtual machine scale set. - - :ivar ultra_ssd_enabled: The flag that enables or disables a capability to have one or more - managed data disks with UltraSSD_LRS storage account type on the VM or VMSS. Managed disks with - storage account type UltraSSD_LRS can be added to a virtual machine or virtual machine scale - set only if this property is enabled. - :vartype ultra_ssd_enabled: bool - :ivar hibernation_enabled: The flag that enables or disables hibernation capability on the VM. - :vartype hibernation_enabled: bool - """ - - _attribute_map = { - "ultra_ssd_enabled": {"key": "ultraSSDEnabled", "type": "bool"}, - "hibernation_enabled": {"key": "hibernationEnabled", "type": "bool"}, - } - - def __init__( - self, *, ultra_ssd_enabled: Optional[bool] = None, hibernation_enabled: Optional[bool] = None, **kwargs: Any - ) -> None: - """ - :keyword ultra_ssd_enabled: The flag that enables or disables a capability to have one or more - managed data disks with UltraSSD_LRS storage account type on the VM or VMSS. Managed disks with - storage account type UltraSSD_LRS can be added to a virtual machine or virtual machine scale - set only if this property is enabled. - :paramtype ultra_ssd_enabled: bool - :keyword hibernation_enabled: The flag that enables or disables hibernation capability on the - VM. - :paramtype hibernation_enabled: bool - """ - super().__init__(**kwargs) - self.ultra_ssd_enabled = ultra_ssd_enabled - self.hibernation_enabled = hibernation_enabled - - -class AdditionalUnattendContent(_serialization.Model): - """Specifies additional XML formatted information that can be included in the Unattend.xml file, - which is used by Windows Setup. Contents are defined by setting name, component name, and the - pass in which the content is applied. - - :ivar pass_name: The pass name. Currently, the only allowable value is OobeSystem. Default - value is "OobeSystem". - :vartype pass_name: str - :ivar component_name: The component name. Currently, the only allowable value is - Microsoft-Windows-Shell-Setup. Default value is "Microsoft-Windows-Shell-Setup". - :vartype component_name: str - :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon" and - "FirstLogonCommands". - :vartype setting_name: str or ~azure.mgmt.compute.v2021_07_01.models.SettingNames - :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for - the specified path and component. The XML must be less than 4KB and must include the root - element for the setting or feature that is being inserted. - :vartype content: str - """ - - _attribute_map = { - "pass_name": {"key": "passName", "type": "str"}, - "component_name": {"key": "componentName", "type": "str"}, - "setting_name": {"key": "settingName", "type": "str"}, - "content": {"key": "content", "type": "str"}, - } - - def __init__( - self, - *, - pass_name: Optional[Literal["OobeSystem"]] = None, - component_name: Optional[Literal["Microsoft-Windows-Shell-Setup"]] = None, - setting_name: Optional[Union[str, "_models.SettingNames"]] = None, - content: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword pass_name: The pass name. Currently, the only allowable value is OobeSystem. Default - value is "OobeSystem". - :paramtype pass_name: str - :keyword component_name: The component name. Currently, the only allowable value is - Microsoft-Windows-Shell-Setup. Default value is "Microsoft-Windows-Shell-Setup". - :paramtype component_name: str - :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon" and - "FirstLogonCommands". - :paramtype setting_name: str or ~azure.mgmt.compute.v2021_07_01.models.SettingNames - :keyword content: Specifies the XML formatted content that is added to the unattend.xml file - for the specified path and component. The XML must be less than 4KB and must include the root - element for the setting or feature that is being inserted. - :paramtype content: str - """ - super().__init__(**kwargs) - self.pass_name = pass_name - self.component_name = component_name - self.setting_name = setting_name - self.content = content - - -class ApiEntityReference(_serialization.Model): - """The API entity reference. - - :ivar id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class ApiError(_serialization.Model): - """Api error. - - :ivar details: The Api error details. - :vartype details: list[~azure.mgmt.compute.v2021_07_01.models.ApiErrorBase] - :ivar innererror: The Api inner error. - :vartype innererror: ~azure.mgmt.compute.v2021_07_01.models.InnerError - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "details": {"key": "details", "type": "[ApiErrorBase]"}, - "innererror": {"key": "innererror", "type": "InnerError"}, - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - details: Optional[List["_models.ApiErrorBase"]] = None, - innererror: Optional["_models.InnerError"] = None, - code: Optional[str] = None, - target: Optional[str] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword details: The Api error details. - :paramtype details: list[~azure.mgmt.compute.v2021_07_01.models.ApiErrorBase] - :keyword innererror: The Api inner error. - :paramtype innererror: ~azure.mgmt.compute.v2021_07_01.models.InnerError - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.details = details - self.innererror = innererror - self.code = code - self.target = target - self.message = message - - -class ApiErrorBase(_serialization.Model): - """Api error base. - - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.target = target - self.message = message - - -class ApplicationProfile(_serialization.Model): - """Contains the list of gallery applications that should be made available to the VM/VMSS. - - :ivar gallery_applications: Specifies the gallery applications that should be made available to - the VM/VMSS. - :vartype gallery_applications: - list[~azure.mgmt.compute.v2021_07_01.models.VMGalleryApplication] - """ - - _attribute_map = { - "gallery_applications": {"key": "galleryApplications", "type": "[VMGalleryApplication]"}, - } - - def __init__( - self, *, gallery_applications: Optional[List["_models.VMGalleryApplication"]] = None, **kwargs: Any - ) -> None: - """ - :keyword gallery_applications: Specifies the gallery applications that should be made available - to the VM/VMSS. - :paramtype gallery_applications: - list[~azure.mgmt.compute.v2021_07_01.models.VMGalleryApplication] - """ - super().__init__(**kwargs) - self.gallery_applications = gallery_applications - - -class AutomaticOSUpgradePolicy(_serialization.Model): - """The configuration parameters used for performing automatic OS upgrade. - - :ivar enable_automatic_os_upgrade: Indicates whether OS upgrades should automatically be - applied to scale set instances in a rolling fashion when a newer version of the OS image - becomes available. Default value is false. :code:`
    `\\ :code:`
    ` If this is set to true - for Windows based scale sets, `enableAutomaticUpdates - `_ - is automatically set to false and cannot be set to true. - :vartype enable_automatic_os_upgrade: bool - :ivar disable_automatic_rollback: Whether OS image rollback feature should be disabled. Default - value is false. - :vartype disable_automatic_rollback: bool - """ - - _attribute_map = { - "enable_automatic_os_upgrade": {"key": "enableAutomaticOSUpgrade", "type": "bool"}, - "disable_automatic_rollback": {"key": "disableAutomaticRollback", "type": "bool"}, - } - - def __init__( - self, - *, - enable_automatic_os_upgrade: Optional[bool] = None, - disable_automatic_rollback: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword enable_automatic_os_upgrade: Indicates whether OS upgrades should automatically be - applied to scale set instances in a rolling fashion when a newer version of the OS image - becomes available. Default value is false. :code:`
    `\\ :code:`
    ` If this is set to true - for Windows based scale sets, `enableAutomaticUpdates - `_ - is automatically set to false and cannot be set to true. - :paramtype enable_automatic_os_upgrade: bool - :keyword disable_automatic_rollback: Whether OS image rollback feature should be disabled. - Default value is false. - :paramtype disable_automatic_rollback: bool - """ - super().__init__(**kwargs) - self.enable_automatic_os_upgrade = enable_automatic_os_upgrade - self.disable_automatic_rollback = disable_automatic_rollback - - -class AutomaticOSUpgradeProperties(_serialization.Model): - """Describes automatic OS upgrade properties on the image. - - All required parameters must be populated in order to send to server. - - :ivar automatic_os_upgrade_supported: Specifies whether automatic OS upgrade is supported on - the image. Required. - :vartype automatic_os_upgrade_supported: bool - """ - - _validation = { - "automatic_os_upgrade_supported": {"required": True}, - } - - _attribute_map = { - "automatic_os_upgrade_supported": {"key": "automaticOSUpgradeSupported", "type": "bool"}, - } - - def __init__(self, *, automatic_os_upgrade_supported: bool, **kwargs: Any) -> None: - """ - :keyword automatic_os_upgrade_supported: Specifies whether automatic OS upgrade is supported on - the image. Required. - :paramtype automatic_os_upgrade_supported: bool - """ - super().__init__(**kwargs) - self.automatic_os_upgrade_supported = automatic_os_upgrade_supported - - -class AutomaticRepairsPolicy(_serialization.Model): - """Specifies the configuration parameters for automatic repairs on the virtual machine scale set. - - :ivar enabled: Specifies whether automatic repairs should be enabled on the virtual machine - scale set. The default value is false. - :vartype enabled: bool - :ivar grace_period: The amount of time for which automatic repairs are suspended due to a state - change on VM. The grace time starts after the state change has completed. This helps avoid - premature or accidental repairs. The time duration should be specified in ISO 8601 format. The - minimum allowed grace period is 30 minutes (PT30M), which is also the default value. The - maximum allowed grace period is 90 minutes (PT90M). - :vartype grace_period: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "grace_period": {"key": "gracePeriod", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, grace_period: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Specifies whether automatic repairs should be enabled on the virtual machine - scale set. The default value is false. - :paramtype enabled: bool - :keyword grace_period: The amount of time for which automatic repairs are suspended due to a - state change on VM. The grace time starts after the state change has completed. This helps - avoid premature or accidental repairs. The time duration should be specified in ISO 8601 - format. The minimum allowed grace period is 30 minutes (PT30M), which is also the default - value. The maximum allowed grace period is 90 minutes (PT90M). - :paramtype grace_period: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.grace_period = grace_period - - -class Resource(_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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - - -class AvailabilitySet(Resource): - """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 - overview `_. - :code:`
    `\\ :code:`
    ` For more information on Azure planned maintenance, see `Maintenance - and updates for Virtual Machines in Azure - `_ :code:`
    `\\ - :code:`
    ` Currently, a VM can only be added to availability set at creation time. An - existing VM cannot be added to an availability 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. - :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] - :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 - 'Classic'. - :vartype sku: ~azure.mgmt.compute.v2021_07_01.models.Sku - :ivar platform_update_domain_count: Update Domain count. - :vartype platform_update_domain_count: int - :ivar platform_fault_domain_count: Fault Domain count. - :vartype platform_fault_domain_count: int - :ivar virtual_machines: A list of references to all virtual machines in the availability set. - :vartype virtual_machines: list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the availability set should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "statuses": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "Sku"}, - "platform_update_domain_count": {"key": "properties.platformUpdateDomainCount", "type": "int"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResource]"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "statuses": {"key": "properties.statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - platform_update_domain_count: Optional[int] = None, - platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["_models.SubResource"]] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - 'Classic'. - :paramtype sku: ~azure.mgmt.compute.v2021_07_01.models.Sku - :keyword platform_update_domain_count: Update Domain count. - :paramtype platform_update_domain_count: int - :keyword platform_fault_domain_count: Fault Domain count. - :paramtype platform_fault_domain_count: int - :keyword virtual_machines: A list of references to all virtual machines in the availability - set. - :paramtype virtual_machines: list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the availability set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.platform_update_domain_count = platform_update_domain_count - self.platform_fault_domain_count = platform_fault_domain_count - self.virtual_machines = virtual_machines - self.proximity_placement_group = proximity_placement_group - self.statuses: Optional[List["_models.InstanceViewStatus"]] = None - - -class AvailabilitySetListResult(_serialization.Model): - """The List Availability Set operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of availability sets. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet] - :ivar next_link: The URI to fetch the next page of AvailabilitySets. Call ListNext() with this - URI to fetch the next page of AvailabilitySets. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AvailabilitySet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of availability sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet] - :keyword next_link: The URI to fetch the next page of AvailabilitySets. Call ListNext() with - this URI to fetch the next page of AvailabilitySets. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class UpdateResource(_serialization.Model): - """The Update Resource model definition. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class AvailabilitySetUpdate(UpdateResource): - """Specifies information about the availability set that the virtual machine should be assigned - to. Only tags may be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: Sku of the availability set. - :vartype sku: ~azure.mgmt.compute.v2021_07_01.models.Sku - :ivar platform_update_domain_count: Update Domain count. - :vartype platform_update_domain_count: int - :ivar platform_fault_domain_count: Fault Domain count. - :vartype platform_fault_domain_count: int - :ivar virtual_machines: A list of references to all virtual machines in the availability set. - :vartype virtual_machines: list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the availability set should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - - _validation = { - "statuses": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "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"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResource]"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "statuses": {"key": "properties.statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - platform_update_domain_count: Optional[int] = None, - platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["_models.SubResource"]] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: Sku of the availability set. - :paramtype sku: ~azure.mgmt.compute.v2021_07_01.models.Sku - :keyword platform_update_domain_count: Update Domain count. - :paramtype platform_update_domain_count: int - :keyword platform_fault_domain_count: Fault Domain count. - :paramtype platform_fault_domain_count: int - :keyword virtual_machines: A list of references to all virtual machines in the availability - set. - :paramtype virtual_machines: list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the availability set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - """ - super().__init__(tags=tags, **kwargs) - self.sku = sku - self.platform_update_domain_count = platform_update_domain_count - self.platform_fault_domain_count = platform_fault_domain_count - self.virtual_machines = virtual_machines - self.proximity_placement_group = proximity_placement_group - self.statuses: Optional[List["_models.InstanceViewStatus"]] = None - - -class AvailablePatchSummary(_serialization.Model): - """Describes the properties of an virtual machine instance view for available patch summary. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The overall success or failure status of the operation. It remains "InProgress" - until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", - and "CompletedWithWarnings". - :vartype status: str or ~azure.mgmt.compute.v2021_07_01.models.PatchOperationStatus - :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is - used to correlate across CRP and extension logs. - :vartype assessment_activity_id: str - :ivar reboot_pending: The overall reboot status of the VM. It will be true when partially - installed patches require a reboot to complete installation but the reboot has not yet - occurred. - :vartype reboot_pending: bool - :ivar critical_and_security_patch_count: The number of critical or security patches that have - been detected as available and not yet installed. - :vartype critical_and_security_patch_count: int - :ivar other_patch_count: The number of all available patches excluding critical and security. - :vartype other_patch_count: int - :ivar start_time: The UTC timestamp when the operation began. - :vartype start_time: ~datetime.datetime - :ivar last_modified_time: The UTC timestamp when the operation began. - :vartype last_modified_time: ~datetime.datetime - :ivar error: The errors that were encountered during execution of the operation. The details - array contains the list of them. - :vartype error: ~azure.mgmt.compute.v2021_07_01.models.ApiError - """ - - _validation = { - "status": {"readonly": True}, - "assessment_activity_id": {"readonly": True}, - "reboot_pending": {"readonly": True}, - "critical_and_security_patch_count": {"readonly": True}, - "other_patch_count": {"readonly": True}, - "start_time": {"readonly": True}, - "last_modified_time": {"readonly": True}, - "error": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "assessment_activity_id": {"key": "assessmentActivityId", "type": "str"}, - "reboot_pending": {"key": "rebootPending", "type": "bool"}, - "critical_and_security_patch_count": {"key": "criticalAndSecurityPatchCount", "type": "int"}, - "other_patch_count": {"key": "otherPatchCount", "type": "int"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "last_modified_time": {"key": "lastModifiedTime", "type": "iso-8601"}, - "error": {"key": "error", "type": "ApiError"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional[Union[str, "_models.PatchOperationStatus"]] = None - self.assessment_activity_id: Optional[str] = None - self.reboot_pending: Optional[bool] = None - self.critical_and_security_patch_count: Optional[int] = None - self.other_patch_count: Optional[int] = None - self.start_time: Optional[datetime.datetime] = None - self.last_modified_time: Optional[datetime.datetime] = None - self.error: Optional["_models.ApiError"] = None - - -class BillingProfile(_serialization.Model): - """Specifies the billing related details of a Azure Spot VM or VMSS. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. - - :ivar max_price: Specifies the maximum price you are willing to pay for a Azure Spot VM/VMSS. - This price is in US Dollars. :code:`
    `\\ :code:`
    ` This price will be compared with the - current Azure Spot price for the VM size. Also, the prices are compared at the time of - create/update of Azure Spot VM/VMSS and the operation will only succeed if the maxPrice is - greater than the current Azure Spot price. :code:`
    `\\ :code:`
    ` The maxPrice will also - be used for evicting a Azure Spot VM/VMSS if the current Azure Spot price goes beyond the - maxPrice after creation of VM/VMSS. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` - Any decimal value greater than zero. Example: 0.01538 - :code:`
    `\\ :code:`
    ` -1 – indicates default price to be up-to on-demand. :code:`
    `\\ - :code:`
    ` You can set the maxPrice to -1 to indicate that the Azure Spot VM/VMSS should not - be evicted for price reasons. Also, the default max price is -1 if it is not provided by you. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype max_price: float - """ - - _attribute_map = { - "max_price": {"key": "maxPrice", "type": "float"}, - } - - def __init__(self, *, max_price: Optional[float] = None, **kwargs: Any) -> None: - """ - :keyword max_price: Specifies the maximum price you are willing to pay for a Azure Spot - VM/VMSS. This price is in US Dollars. :code:`
    `\\ :code:`
    ` This price will be compared - with the current Azure Spot price for the VM size. Also, the prices are compared at the time of - create/update of Azure Spot VM/VMSS and the operation will only succeed if the maxPrice is - greater than the current Azure Spot price. :code:`
    `\\ :code:`
    ` The maxPrice will also - be used for evicting a Azure Spot VM/VMSS if the current Azure Spot price goes beyond the - maxPrice after creation of VM/VMSS. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` - Any decimal value greater than zero. Example: 0.01538 - :code:`
    `\\ :code:`
    ` -1 – indicates default price to be up-to on-demand. :code:`
    `\\ - :code:`
    ` You can set the maxPrice to -1 to indicate that the Azure Spot VM/VMSS should not - be evicted for price reasons. Also, the default max price is -1 if it is not provided by you. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype max_price: float - """ - super().__init__(**kwargs) - self.max_price = max_price - - -class BootDiagnostics(_serialization.Model): - """Boot Diagnostics is a debugging feature which allows you to view Console Output and Screenshot - to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily view the output of your - console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see a screenshot of the VM - from the hypervisor. - - :ivar enabled: Whether boot diagnostics should be enabled on the Virtual Machine. - :vartype enabled: bool - :ivar storage_uri: Uri of the storage account to use for placing the console output and - screenshot. :code:`
    `\\ :code:`
    `If storageUri is not specified while enabling boot - diagnostics, managed storage will be used. - :vartype storage_uri: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "storage_uri": {"key": "storageUri", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, storage_uri: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Whether boot diagnostics should be enabled on the Virtual Machine. - :paramtype enabled: bool - :keyword storage_uri: Uri of the storage account to use for placing the console output and - screenshot. :code:`
    `\\ :code:`
    `If storageUri is not specified while enabling boot - diagnostics, managed storage will be used. - :paramtype storage_uri: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.storage_uri = storage_uri - - -class BootDiagnosticsInstanceView(_serialization.Model): - """The instance view of a virtual machine boot diagnostics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar console_screenshot_blob_uri: The console screenshot blob URI. :code:`
    `\\ - :code:`
    `NOTE: This will **not** be set if boot diagnostics is currently enabled with - managed storage. - :vartype console_screenshot_blob_uri: str - :ivar serial_console_log_blob_uri: The serial console log blob Uri. :code:`
    `\\ - :code:`
    `NOTE: This will **not** be set if boot diagnostics is currently enabled with - managed storage. - :vartype serial_console_log_blob_uri: str - :ivar status: The boot diagnostics status information for the VM. :code:`
    `\\ :code:`
    ` - NOTE: It will be set only if there are errors encountered in enabling boot diagnostics. - :vartype status: ~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus - """ - - _validation = { - "console_screenshot_blob_uri": {"readonly": True}, - "serial_console_log_blob_uri": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "console_screenshot_blob_uri": {"key": "consoleScreenshotBlobUri", "type": "str"}, - "serial_console_log_blob_uri": {"key": "serialConsoleLogBlobUri", "type": "str"}, - "status": {"key": "status", "type": "InstanceViewStatus"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.console_screenshot_blob_uri: Optional[str] = None - self.serial_console_log_blob_uri: Optional[str] = None - self.status: Optional["_models.InstanceViewStatus"] = None - - -class CapacityReservation(Resource): - """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. - :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] - :ivar sku: SKU of the resource for which capacity needs be reserved. The SKU name and capacity - is required to be set. Currently VM Skus with the capability called - 'CapacityReservationSupported' set to true are supported. Refer to List Microsoft.Compute SKUs - in a region (https://docs.microsoft.com/rest/api/compute/resourceskus/list) for supported - values. Required. - :vartype sku: ~azure.mgmt.compute.v2021_07_01.models.Sku - :ivar zones: Availability Zone to use for this capacity reservation. The zone has to be single - value and also should be part for the list of zones specified during the capacity reservation - group creation. The zone can be assigned only during creation. If not provided, the reservation - supports only non-zonal deployments. If provided, enforces VM/VMSS using this capacity - reservation to be in same zone. - :vartype zones: list[str] - :ivar reservation_id: A unique id generated and assigned to the capacity reservation by the - platform which does not change throughout the lifetime of the resource. - :vartype reservation_id: str - :ivar virtual_machines_associated: A list of all virtual machine resource ids that are - associated with the capacity reservation. - :vartype virtual_machines_associated: - list[~azure.mgmt.compute.v2021_07_01.models.SubResourceReadOnly] - :ivar provisioning_time: The date time when the capacity reservation was last updated. - :vartype provisioning_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The Capacity reservation instance view. - :vartype instance_view: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationInstanceView - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "sku": {"required": True}, - "reservation_id": {"readonly": True}, - "virtual_machines_associated": {"readonly": True}, - "provisioning_time": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "Sku"}, - "zones": {"key": "zones", "type": "[str]"}, - "reservation_id": {"key": "properties.reservationId", "type": "str"}, - "virtual_machines_associated": {"key": "properties.virtualMachinesAssociated", "type": "[SubResourceReadOnly]"}, - "provisioning_time": {"key": "properties.provisioningTime", "type": "iso-8601"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "CapacityReservationInstanceView"}, - } - - def __init__( - self, - *, - location: str, - sku: "_models.Sku", - tags: Optional[Dict[str, str]] = None, - zones: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: SKU of the resource for which capacity needs be reserved. The SKU name and - capacity is required to be set. Currently VM Skus with the capability called - 'CapacityReservationSupported' set to true are supported. Refer to List Microsoft.Compute SKUs - in a region (https://docs.microsoft.com/rest/api/compute/resourceskus/list) for supported - values. Required. - :paramtype sku: ~azure.mgmt.compute.v2021_07_01.models.Sku - :keyword zones: Availability Zone to use for this capacity reservation. The zone has to be - single value and also should be part for the list of zones specified during the capacity - reservation group creation. The zone can be assigned only during creation. If not provided, the - reservation supports only non-zonal deployments. If provided, enforces VM/VMSS using this - capacity reservation to be in same zone. - :paramtype zones: list[str] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.zones = zones - self.reservation_id: Optional[str] = None - self.virtual_machines_associated: Optional[List["_models.SubResourceReadOnly"]] = None - self.provisioning_time: Optional[datetime.datetime] = None - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.CapacityReservationInstanceView"] = None - - -class CapacityReservationGroup(Resource): - """Specifies information about the capacity reservation group that the capacity reservations - should be assigned to. :code:`
    `\\ :code:`
    ` 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 to another capacity reservation 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. - :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] - :ivar zones: Availability Zones to use for this capacity reservation group. The zones can be - assigned only during creation. If not provided, the group supports only regional resources in - the region. If provided, enforces each capacity reservation in the group to be in one of the - zones. - :vartype zones: list[str] - :ivar capacity_reservations: A list of all capacity reservation resource ids that belong to - capacity reservation group. - :vartype capacity_reservations: - list[~azure.mgmt.compute.v2021_07_01.models.SubResourceReadOnly] - :ivar virtual_machines_associated: A list of references to all virtual machines associated to - the capacity reservation group. - :vartype virtual_machines_associated: - list[~azure.mgmt.compute.v2021_07_01.models.SubResourceReadOnly] - :ivar instance_view: The capacity reservation group instance view which has the list of - instance views for all the capacity reservations that belong to the capacity reservation group. - :vartype instance_view: - ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroupInstanceView - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "capacity_reservations": {"readonly": True}, - "virtual_machines_associated": {"readonly": True}, - "instance_view": {"readonly": 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}"}, - "zones": {"key": "zones", "type": "[str]"}, - "capacity_reservations": {"key": "properties.capacityReservations", "type": "[SubResourceReadOnly]"}, - "virtual_machines_associated": {"key": "properties.virtualMachinesAssociated", "type": "[SubResourceReadOnly]"}, - "instance_view": {"key": "properties.instanceView", "type": "CapacityReservationGroupInstanceView"}, - } - - def __init__( - self, *, location: str, tags: Optional[Dict[str, str]] = None, zones: Optional[List[str]] = None, **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword zones: Availability Zones to use for this capacity reservation group. The zones can be - assigned only during creation. If not provided, the group supports only regional resources in - the region. If provided, enforces each capacity reservation in the group to be in one of the - zones. - :paramtype zones: list[str] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.zones = zones - self.capacity_reservations: Optional[List["_models.SubResourceReadOnly"]] = None - self.virtual_machines_associated: Optional[List["_models.SubResourceReadOnly"]] = None - self.instance_view: Optional["_models.CapacityReservationGroupInstanceView"] = None - - -class CapacityReservationGroupInstanceView(_serialization.Model): - """CapacityReservationGroupInstanceView. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar capacity_reservations: List of instance view of the capacity reservations under the - capacity reservation group. - :vartype capacity_reservations: - list[~azure.mgmt.compute.v2021_07_01.models.CapacityReservationInstanceViewWithName] - """ - - _validation = { - "capacity_reservations": {"readonly": True}, - } - - _attribute_map = { - "capacity_reservations": {"key": "capacityReservations", "type": "[CapacityReservationInstanceViewWithName]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.capacity_reservations: Optional[List["_models.CapacityReservationInstanceViewWithName"]] = None - - -class CapacityReservationGroupListResult(_serialization.Model): - """The List capacity reservation group with resource group response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of capacity reservation groups. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup] - :ivar next_link: The URI to fetch the next page of capacity reservation groups. Call ListNext() - with this URI to fetch the next page of capacity reservation groups. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[CapacityReservationGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.CapacityReservationGroup"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of capacity reservation groups. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup] - :keyword next_link: The URI to fetch the next page of capacity reservation groups. Call - ListNext() with this URI to fetch the next page of capacity reservation groups. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class CapacityReservationGroupUpdate(UpdateResource): - """Specifies information about the capacity reservation group. Only tags can be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar capacity_reservations: A list of all capacity reservation resource ids that belong to - capacity reservation group. - :vartype capacity_reservations: - list[~azure.mgmt.compute.v2021_07_01.models.SubResourceReadOnly] - :ivar virtual_machines_associated: A list of references to all virtual machines associated to - the capacity reservation group. - :vartype virtual_machines_associated: - list[~azure.mgmt.compute.v2021_07_01.models.SubResourceReadOnly] - :ivar instance_view: The capacity reservation group instance view which has the list of - instance views for all the capacity reservations that belong to the capacity reservation group. - :vartype instance_view: - ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroupInstanceView - """ - - _validation = { - "capacity_reservations": {"readonly": True}, - "virtual_machines_associated": {"readonly": True}, - "instance_view": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "capacity_reservations": {"key": "properties.capacityReservations", "type": "[SubResourceReadOnly]"}, - "virtual_machines_associated": {"key": "properties.virtualMachinesAssociated", "type": "[SubResourceReadOnly]"}, - "instance_view": {"key": "properties.instanceView", "type": "CapacityReservationGroupInstanceView"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(tags=tags, **kwargs) - self.capacity_reservations: Optional[List["_models.SubResourceReadOnly"]] = None - self.virtual_machines_associated: Optional[List["_models.SubResourceReadOnly"]] = None - self.instance_view: Optional["_models.CapacityReservationGroupInstanceView"] = None - - -class CapacityReservationInstanceView(_serialization.Model): - """The instance view of a capacity reservation that provides as snapshot of the runtime properties - of the capacity reservation that is managed by the platform and can change outside of control - plane operations. - - :ivar utilization_info: Unutilized capacity of the capacity reservation. - :vartype utilization_info: - ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationUtilization - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "utilization_info": {"key": "utilizationInfo", "type": "CapacityReservationUtilization"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - utilization_info: Optional["_models.CapacityReservationUtilization"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword utilization_info: Unutilized capacity of the capacity reservation. - :paramtype utilization_info: - ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationUtilization - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.utilization_info = utilization_info - self.statuses = statuses - - -class CapacityReservationInstanceViewWithName(CapacityReservationInstanceView): - """The instance view of a capacity reservation that includes the name of the capacity reservation. - It is used for the response to the instance view of a capacity reservation group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar utilization_info: Unutilized capacity of the capacity reservation. - :vartype utilization_info: - ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationUtilization - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - :ivar name: The name of the capacity reservation. - :vartype name: str - """ - - _validation = { - "name": {"readonly": True}, - } - - _attribute_map = { - "utilization_info": {"key": "utilizationInfo", "type": "CapacityReservationUtilization"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - utilization_info: Optional["_models.CapacityReservationUtilization"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword utilization_info: Unutilized capacity of the capacity reservation. - :paramtype utilization_info: - ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationUtilization - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - super().__init__(utilization_info=utilization_info, statuses=statuses, **kwargs) - self.name: Optional[str] = None - - -class CapacityReservationListResult(_serialization.Model): - """The list capacity reservation operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of capacity reservations. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.CapacityReservation] - :ivar next_link: The URI to fetch the next page of capacity reservations. Call ListNext() with - this URI to fetch the next page of capacity reservations. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[CapacityReservation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.CapacityReservation"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of capacity reservations. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.CapacityReservation] - :keyword next_link: The URI to fetch the next page of capacity reservations. Call ListNext() - with this URI to fetch the next page of capacity reservations. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class CapacityReservationProfile(_serialization.Model): - """The parameters of a capacity reservation Profile. - - :ivar capacity_reservation_group: Specifies the capacity reservation group resource id that - should be used for allocating the virtual machine or scaleset vm instances provided enough - capacity has been reserved. Please refer to https://aka.ms/CapacityReservation for more - details. - :vartype capacity_reservation_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - """ - - _attribute_map = { - "capacity_reservation_group": {"key": "capacityReservationGroup", "type": "SubResource"}, - } - - def __init__(self, *, capacity_reservation_group: Optional["_models.SubResource"] = None, **kwargs: Any) -> None: - """ - :keyword capacity_reservation_group: Specifies the capacity reservation group resource id that - should be used for allocating the virtual machine or scaleset vm instances provided enough - capacity has been reserved. Please refer to https://aka.ms/CapacityReservation for more - details. - :paramtype capacity_reservation_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - """ - super().__init__(**kwargs) - self.capacity_reservation_group = capacity_reservation_group - - -class CapacityReservationUpdate(UpdateResource): - """Specifies information about the capacity reservation. Only tags and sku.capacity can be - updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: SKU of the resource for which capacity needs be reserved. The SKU name and capacity - is required to be set. Currently VM Skus with the capability called - 'CapacityReservationSupported' set to true are supported. Refer to List Microsoft.Compute SKUs - in a region (https://docs.microsoft.com/rest/api/compute/resourceskus/list) for supported - values. - :vartype sku: ~azure.mgmt.compute.v2021_07_01.models.Sku - :ivar reservation_id: A unique id generated and assigned to the capacity reservation by the - platform which does not change throughout the lifetime of the resource. - :vartype reservation_id: str - :ivar virtual_machines_associated: A list of all virtual machine resource ids that are - associated with the capacity reservation. - :vartype virtual_machines_associated: - list[~azure.mgmt.compute.v2021_07_01.models.SubResourceReadOnly] - :ivar provisioning_time: The date time when the capacity reservation was last updated. - :vartype provisioning_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The Capacity reservation instance view. - :vartype instance_view: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationInstanceView - """ - - _validation = { - "reservation_id": {"readonly": True}, - "virtual_machines_associated": {"readonly": True}, - "provisioning_time": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "reservation_id": {"key": "properties.reservationId", "type": "str"}, - "virtual_machines_associated": {"key": "properties.virtualMachinesAssociated", "type": "[SubResourceReadOnly]"}, - "provisioning_time": {"key": "properties.provisioningTime", "type": "iso-8601"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "CapacityReservationInstanceView"}, - } - - def __init__( - self, *, tags: Optional[Dict[str, str]] = None, sku: Optional["_models.Sku"] = None, **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: SKU of the resource for which capacity needs be reserved. The SKU name and - capacity is required to be set. Currently VM Skus with the capability called - 'CapacityReservationSupported' set to true are supported. Refer to List Microsoft.Compute SKUs - in a region (https://docs.microsoft.com/rest/api/compute/resourceskus/list) for supported - values. - :paramtype sku: ~azure.mgmt.compute.v2021_07_01.models.Sku - """ - super().__init__(tags=tags, **kwargs) - self.sku = sku - self.reservation_id: Optional[str] = None - self.virtual_machines_associated: Optional[List["_models.SubResourceReadOnly"]] = None - self.provisioning_time: Optional[datetime.datetime] = None - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.CapacityReservationInstanceView"] = None - - -class CapacityReservationUtilization(_serialization.Model): - """Represents the capacity reservation utilization in terms of resources allocated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar virtual_machines_allocated: A list of all virtual machines resource ids allocated against - the capacity reservation. - :vartype virtual_machines_allocated: - list[~azure.mgmt.compute.v2021_07_01.models.SubResourceReadOnly] - """ - - _validation = { - "virtual_machines_allocated": {"readonly": True}, - } - - _attribute_map = { - "virtual_machines_allocated": {"key": "virtualMachinesAllocated", "type": "[SubResourceReadOnly]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.virtual_machines_allocated: Optional[List["_models.SubResourceReadOnly"]] = None - - -class PirCommunityGalleryResource(_serialization.Model): - """Base information about the community gallery resource in pir. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar type: Resource type. - :vartype type: str - :ivar unique_id: The unique id of this community gallery. - :vartype unique_id: str - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - } - - 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 - """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.location: Optional[str] = None - self.type: Optional[str] = None - self.unique_id = unique_id - - -class CommunityGallery(PirCommunityGalleryResource): - """Specifies information about the Community Gallery that you want to create or update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar type: Resource type. - :vartype type: str - :ivar unique_id: The unique id of this community gallery. - :vartype unique_id: str - """ - - -class CommunityGalleryImage(PirCommunityGalleryResource): - """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. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar type: Resource type. - :vartype type: str - :ivar unique_id: The unique id of this community gallery. - :vartype unique_id: str - :ivar 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. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values - are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - :ivar 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". - :vartype os_state: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemStateTypes - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar identifier: This is the gallery image definition identifier. - :vartype identifier: ~azure.mgmt.compute.v2021_07_01.models.GalleryImageIdentifier - :ivar recommended: The properties describe the recommended machine configuration for this Image - Definition. These properties are updatable. - :vartype recommended: ~azure.mgmt.compute.v2021_07_01.models.RecommendedMachineConfiguration - :ivar disallowed: Describes the disallowed disk types. - :vartype disallowed: ~azure.mgmt.compute.v2021_07_01.models.Disallowed - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGeneration - :ivar features: A list of gallery image features. - :vartype features: list[~azure.mgmt.compute.v2021_07_01.models.GalleryImageFeature] - :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :vartype purchase_plan: ~azure.mgmt.compute.v2021_07_01.models.ImagePurchasePlan - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "os_state": {"key": "properties.osState", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, - "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "features": {"key": "properties.features", "type": "[GalleryImageFeature]"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, - } - - 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, - **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. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.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.v2021_07_01.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.v2021_07_01.models.GalleryImageIdentifier - :keyword recommended: The properties describe the recommended machine configuration for this - Image Definition. These properties are updatable. - :paramtype recommended: ~azure.mgmt.compute.v2021_07_01.models.RecommendedMachineConfiguration - :keyword disallowed: Describes the disallowed disk types. - :paramtype disallowed: ~azure.mgmt.compute.v2021_07_01.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.v2021_07_01.models.HyperVGeneration - :keyword features: A list of gallery image features. - :paramtype features: list[~azure.mgmt.compute.v2021_07_01.models.GalleryImageFeature] - :keyword purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :paramtype purchase_plan: ~azure.mgmt.compute.v2021_07_01.models.ImagePurchasePlan - """ - 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.disallowed = disallowed - self.hyper_v_generation = hyper_v_generation - self.features = features - self.purchase_plan = purchase_plan - - -class CommunityGalleryImageVersion(PirCommunityGalleryResource): - """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. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar type: Resource type. - :vartype type: str - :ivar unique_id: The unique id of this community gallery. - :vartype unique_id: str - :ivar published_date: The published date of the gallery image version Definition. This property - can be used for decommissioning purposes. This property is updatable. - :vartype published_date: ~datetime.datetime - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - "published_date": {"key": "properties.publishedDate", "type": "iso-8601"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - } - - def __init__( - self, - *, - unique_id: Optional[str] = None, - published_date: Optional[datetime.datetime] = None, - end_of_life_date: Optional[datetime.datetime] = 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 - """ - super().__init__(unique_id=unique_id, **kwargs) - self.published_date = published_date - self.end_of_life_date = end_of_life_date - - -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.v2021_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: Optional[List["_models.ComputeOperationValue"]] = None - - -class ComputeOperationValue(_serialization.Model): - """Describes the properties of a Compute Operation value. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar origin: The origin of the compute operation. - :vartype origin: str - :ivar name: The name of the compute operation. - :vartype name: str - :ivar operation: The display name of the compute operation. - :vartype operation: str - :ivar resource: The display name of the resource the operation applies to. - :vartype resource: str - :ivar description: The description of the operation. - :vartype description: str - :ivar provider: The resource provider for the operation. - :vartype provider: str - """ - - _validation = { - "origin": {"readonly": True}, - "name": {"readonly": True}, - "operation": {"readonly": True}, - "resource": {"readonly": True}, - "description": {"readonly": True}, - "provider": {"readonly": True}, - } - - _attribute_map = { - "origin": {"key": "origin", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "operation": {"key": "display.operation", "type": "str"}, - "resource": {"key": "display.resource", "type": "str"}, - "description": {"key": "display.description", "type": "str"}, - "provider": {"key": "display.provider", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.origin: Optional[str] = None - self.name: Optional[str] = None - self.operation: Optional[str] = None - self.resource: Optional[str] = None - self.description: Optional[str] = None - self.provider: Optional[str] = None - - -class DataDisk(_serialization.Model): - """Describes a data disk. - - 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 lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - :ivar name: The disk name. - :vartype name: str - :ivar vhd: The virtual hard disk. - :vartype vhd: ~azure.mgmt.compute.v2021_07_01.models.VirtualHardDisk - :ivar image: 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. - :vartype image: ~azure.mgmt.compute.v2021_07_01.models.VirtualHardDisk - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: ~azure.mgmt.compute.v2021_07_01.models.ManagedDiskParameters - :ivar to_be_detached: Specifies whether the data disk is in process of detachment from the - VirtualMachine/VirtualMachineScaleset. - :vartype to_be_detached: bool - :ivar disk_iops_read_write: Specifies the Read-Write IOPS for the managed disk when - StorageAccountType is UltraSSD_LRS. Returned only for VirtualMachine ScaleSet VM disks. Can be - updated only via updates to the VirtualMachine Scale Set. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: Specifies the bandwidth in MB per second for the managed disk when - StorageAccountType is UltraSSD_LRS. Returned only for VirtualMachine ScaleSet VM disks. Can be - updated only via updates to the VirtualMachine Scale Set. - :vartype disk_m_bps_read_write: int - :ivar detach_option: Specifies the detach behavior to be used while detaching a disk or which - is already in the process of detachment from the virtual machine. Supported values: - **ForceDetach**. :code:`
    `\\ :code:`
    ` detachOption: **ForceDetach** is applicable only - for managed data disks. If a 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. :code:`
    `\\ :code:`
    ` This feature - is still in preview mode and is not supported for VirtualMachineScaleSet. To force-detach a - data disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. - "ForceDetach" - :vartype detach_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskDetachOptionTypes - :ivar delete_option: Specifies whether data disk should be deleted or detached upon VM - deletion.\\ :code:`
    `\\ :code:`
    ` Possible values: :code:`
    `\\ :code:`
    ` **Delete** - If this value is used, the data disk is deleted when VM is deleted.\\ :code:`
    `\\ - :code:`
    ` **Detach** If this value is used, the data disk is retained after VM is deleted.\\ - :code:`
    `\\ :code:`
    ` The default value is set to **detach**. Known values are: "Delete" - and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskDeleteOptionTypes - """ - - _validation = { - "lun": {"required": True}, - "create_option": {"required": True}, - "disk_iops_read_write": {"readonly": True}, - "disk_m_bps_read_write": {"readonly": True}, - } - - _attribute_map = { - "lun": {"key": "lun", "type": "int"}, - "name": {"key": "name", "type": "str"}, - "vhd": {"key": "vhd", "type": "VirtualHardDisk"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, - "to_be_detached": {"key": "toBeDetached", "type": "bool"}, - "disk_iops_read_write": {"key": "diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "diskMBpsReadWrite", "type": "int"}, - "detach_option": {"key": "detachOption", "type": "str"}, - "delete_option": {"key": "deleteOption", "type": "str"}, - } - - def __init__( - self, - *, - lun: int, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - vhd: Optional["_models.VirtualHardDisk"] = None, - image: Optional["_models.VirtualHardDisk"] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.ManagedDiskParameters"] = None, - to_be_detached: Optional[bool] = None, - detach_option: Optional[Union[str, "_models.DiskDetachOptionTypes"]] = None, - delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - :keyword name: The disk name. - :paramtype name: str - :keyword vhd: The virtual hard disk. - :paramtype vhd: ~azure.mgmt.compute.v2021_07_01.models.VirtualHardDisk - :keyword image: 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. - :paramtype image: ~azure.mgmt.compute.v2021_07_01.models.VirtualHardDisk - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: ~azure.mgmt.compute.v2021_07_01.models.ManagedDiskParameters - :keyword to_be_detached: Specifies whether the data disk is in process of detachment from the - VirtualMachine/VirtualMachineScaleset. - :paramtype to_be_detached: bool - :keyword detach_option: Specifies the detach behavior to be used while detaching a disk or - which is already in the process of detachment from the virtual machine. Supported values: - **ForceDetach**. :code:`
    `\\ :code:`
    ` detachOption: **ForceDetach** is applicable only - for managed data disks. If a 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. :code:`
    `\\ :code:`
    ` This feature - is still in preview mode and is not supported for VirtualMachineScaleSet. To force-detach a - data disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. - "ForceDetach" - :paramtype detach_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskDetachOptionTypes - :keyword delete_option: Specifies whether data disk should be deleted or detached upon VM - deletion.\\ :code:`
    `\\ :code:`
    ` Possible values: :code:`
    `\\ :code:`
    ` **Delete** - If this value is used, the data disk is deleted when VM is deleted.\\ :code:`
    `\\ - :code:`
    ` **Detach** If this value is used, the data disk is retained after VM is deleted.\\ - :code:`
    `\\ :code:`
    ` The default value is set to **detach**. Known values are: "Delete" - and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskDeleteOptionTypes - """ - super().__init__(**kwargs) - self.lun = lun - self.name = name - self.vhd = vhd - self.image = image - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - self.to_be_detached = to_be_detached - self.disk_iops_read_write: Optional[int] = None - self.disk_m_bps_read_write: Optional[int] = None - self.detach_option = detach_option - self.delete_option = delete_option - - -class DataDiskImage(_serialization.Model): - """Contains the data disk images information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - :vartype lun: int - """ - - _validation = { - "lun": {"readonly": True}, - } - - _attribute_map = { - "lun": {"key": "lun", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.lun: Optional[int] = None - - -class DiskImageEncryption(_serialization.Model): - """This is the disk image encryption base class. - - :ivar disk_encryption_set_id: A relative URI containing the resource ID of the disk encryption - set. - :vartype disk_encryption_set_id: str - """ - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - } - - def __init__(self, *, disk_encryption_set_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword disk_encryption_set_id: A relative URI containing the resource ID of the disk - encryption set. - :paramtype disk_encryption_set_id: str - """ - super().__init__(**kwargs) - self.disk_encryption_set_id = disk_encryption_set_id - - -class DataDiskImageEncryption(DiskImageEncryption): - """Contains encryption settings for a data disk image. - - All required parameters must be populated in order to send to server. - - :ivar disk_encryption_set_id: A relative URI containing the resource ID of the disk encryption - set. - :vartype disk_encryption_set_id: str - :ivar 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. - :vartype lun: int - """ - - _validation = { - "lun": {"required": True}, - } - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__(self, *, lun: int, disk_encryption_set_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword disk_encryption_set_id: A relative URI containing the resource ID of the disk - encryption set. - :paramtype disk_encryption_set_id: str - :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__(disk_encryption_set_id=disk_encryption_set_id, **kwargs) - self.lun = lun - - -class DedicatedHost(Resource): - """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. - :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] - :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.v2021_07_01.models.Sku - :ivar platform_fault_domain: Fault domain of the dedicated host within a dedicated host group. - :vartype platform_fault_domain: int - :ivar auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :vartype auto_replace_on_failure: bool - :ivar host_id: A unique id generated and assigned to the dedicated host by the platform. - :code:`
    `\\ :code:`
    ` Does not change throughout the lifetime of the host. - :vartype host_id: str - :ivar virtual_machines: A list of references to all virtual machines in the Dedicated Host. - :vartype virtual_machines: list[~azure.mgmt.compute.v2021_07_01.models.SubResourceReadOnly] - :ivar license_type: Specifies the software license type that will be applied to the VMs - deployed on the dedicated host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ - :code:`
    ` **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. Known - values are: "None", "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :vartype license_type: str or ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostLicenseTypes - :ivar provisioning_time: The date when the host was first provisioned. - :vartype provisioning_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The dedicated host instance view. - :vartype instance_view: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostInstanceView - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"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}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "Sku"}, - "platform_fault_domain": {"key": "properties.platformFaultDomain", "type": "int"}, - "auto_replace_on_failure": {"key": "properties.autoReplaceOnFailure", "type": "bool"}, - "host_id": {"key": "properties.hostId", "type": "str"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResourceReadOnly]"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "provisioning_time": {"key": "properties.provisioningTime", "type": "iso-8601"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostInstanceView"}, - } - - def __init__( - self, - *, - location: str, - sku: "_models.Sku", - tags: Optional[Dict[str, str]] = None, - platform_fault_domain: Optional[int] = None, - auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2021_07_01.models.Sku - :keyword platform_fault_domain: Fault domain of the dedicated host within a dedicated host - group. - :paramtype platform_fault_domain: int - :keyword auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :paramtype auto_replace_on_failure: bool - :keyword license_type: Specifies the software license type that will be applied to the VMs - deployed on the dedicated host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ - :code:`
    ` **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. Known - values are: "None", "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :paramtype license_type: str or - ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostLicenseTypes - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.platform_fault_domain = platform_fault_domain - self.auto_replace_on_failure = auto_replace_on_failure - self.host_id: Optional[str] = None - self.virtual_machines: Optional[List["_models.SubResourceReadOnly"]] = None - self.license_type = license_type - self.provisioning_time: Optional[datetime.datetime] = None - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.DedicatedHostInstanceView"] = None - - -class DedicatedHostAllocatableVM(_serialization.Model): - """Represents the dedicated host unutilized capacity in terms of a specific VM size. - - :ivar vm_size: VM size in terms of which the unutilized capacity is represented. - :vartype vm_size: str - :ivar count: Maximum number of VMs of size vmSize that can fit in the dedicated host's - remaining capacity. - :vartype count: float - """ - - _attribute_map = { - "vm_size": {"key": "vmSize", "type": "str"}, - "count": {"key": "count", "type": "float"}, - } - - def __init__(self, *, vm_size: Optional[str] = None, count: Optional[float] = None, **kwargs: Any) -> None: - """ - :keyword vm_size: VM size in terms of which the unutilized capacity is represented. - :paramtype vm_size: str - :keyword count: Maximum number of VMs of size vmSize that can fit in the dedicated host's - remaining capacity. - :paramtype count: float - """ - super().__init__(**kwargs) - self.vm_size = vm_size - self.count = count - - -class DedicatedHostAvailableCapacity(_serialization.Model): - """Dedicated host unutilized capacity. - - :ivar allocatable_v_ms: The unutilized capacity of the dedicated host represented in terms of - each VM size that is allowed to be deployed to the dedicated host. - :vartype allocatable_v_ms: - list[~azure.mgmt.compute.v2021_07_01.models.DedicatedHostAllocatableVM] - """ - - _attribute_map = { - "allocatable_v_ms": {"key": "allocatableVMs", "type": "[DedicatedHostAllocatableVM]"}, - } - - def __init__( - self, *, allocatable_v_ms: Optional[List["_models.DedicatedHostAllocatableVM"]] = None, **kwargs: Any - ) -> None: - """ - :keyword allocatable_v_ms: The unutilized capacity of the dedicated host represented in terms - of each VM size that is allowed to be deployed to the dedicated host. - :paramtype allocatable_v_ms: - list[~azure.mgmt.compute.v2021_07_01.models.DedicatedHostAllocatableVM] - """ - super().__init__(**kwargs) - self.allocatable_v_ms = allocatable_v_ms - - -class DedicatedHostGroup(Resource): - """Specifies information about the dedicated host group that the dedicated hosts should be - assigned to. :code:`
    `\\ :code:`
    ` 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. - - 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] - :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. - :vartype zones: list[str] - :ivar platform_fault_domain_count: Number of fault domains that the host group can span. - :vartype platform_fault_domain_count: int - :ivar hosts: A list of references to all dedicated hosts in the dedicated host group. - :vartype hosts: list[~azure.mgmt.compute.v2021_07_01.models.SubResourceReadOnly] - :ivar instance_view: The dedicated host group instance view, which has the list of instance - view of the dedicated hosts under the dedicated host group. - :vartype instance_view: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroupInstanceView - :ivar support_automatic_placement: Specifies whether virtual machines or virtual machine scale - sets can be placed automatically on the dedicated host group. Automatic placement means - resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host - group. The value is defaulted to 'false' when not provided. :code:`
    `\\ :code:`
    `Minimum - api-version: 2020-06-01. - :vartype support_automatic_placement: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "platform_fault_domain_count": {"minimum": 1}, - "hosts": {"readonly": True}, - "instance_view": {"readonly": 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}"}, - "zones": {"key": "zones", "type": "[str]"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "hosts": {"key": "properties.hosts", "type": "[SubResourceReadOnly]"}, - "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostGroupInstanceView"}, - "support_automatic_placement": {"key": "properties.supportAutomaticPlacement", "type": "bool"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - zones: Optional[List[str]] = None, - platform_fault_domain_count: Optional[int] = None, - support_automatic_placement: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword zones: Availability Zone to use for this host group. Only single zone is supported. - The zone can be assigned only during creation. If not provided, the group supports all zones in - the region. If provided, enforces each host in the group to be in the same zone. - :paramtype zones: list[str] - :keyword platform_fault_domain_count: Number of fault domains that the host group can span. - :paramtype platform_fault_domain_count: int - :keyword support_automatic_placement: Specifies whether virtual machines or virtual machine - scale sets can be placed automatically on the dedicated host group. Automatic placement means - resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host - group. The value is defaulted to 'false' when not provided. :code:`
    `\\ :code:`
    `Minimum - api-version: 2020-06-01. - :paramtype support_automatic_placement: bool - """ - super().__init__(location=location, tags=tags, **kwargs) - self.zones = zones - self.platform_fault_domain_count = platform_fault_domain_count - self.hosts: Optional[List["_models.SubResourceReadOnly"]] = None - self.instance_view: Optional["_models.DedicatedHostGroupInstanceView"] = None - self.support_automatic_placement = support_automatic_placement - - -class DedicatedHostGroupInstanceView(_serialization.Model): - """DedicatedHostGroupInstanceView. - - :ivar hosts: List of instance view of the dedicated hosts under the dedicated host group. - :vartype hosts: list[~azure.mgmt.compute.v2021_07_01.models.DedicatedHostInstanceViewWithName] - """ - - _attribute_map = { - "hosts": {"key": "hosts", "type": "[DedicatedHostInstanceViewWithName]"}, - } - - def __init__( - self, *, hosts: Optional[List["_models.DedicatedHostInstanceViewWithName"]] = None, **kwargs: Any - ) -> None: - """ - :keyword hosts: List of instance view of the dedicated hosts under the dedicated host group. - :paramtype hosts: - list[~azure.mgmt.compute.v2021_07_01.models.DedicatedHostInstanceViewWithName] - """ - super().__init__(**kwargs) - self.hosts = hosts - - -class DedicatedHostGroupListResult(_serialization.Model): - """The List Dedicated Host Group with resource group response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of dedicated host groups. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup] - :ivar next_link: The URI to fetch the next page of Dedicated Host Groups. Call ListNext() with - this URI to fetch the next page of Dedicated Host Groups. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DedicatedHostGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DedicatedHostGroup"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of dedicated host groups. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup] - :keyword next_link: The URI to fetch the next page of Dedicated Host Groups. Call ListNext() - with this URI to fetch the next page of Dedicated Host Groups. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DedicatedHostGroupUpdate(UpdateResource): - """Specifies information about the dedicated host group that the dedicated host should be assigned - to. Only tags may be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar zones: Availability Zone to use for this host group. Only single zone is supported. The - zone can be assigned only during creation. If not provided, the group supports all zones in the - region. If provided, enforces each host in the group to be in the same zone. - :vartype zones: list[str] - :ivar platform_fault_domain_count: Number of fault domains that the host group can span. - :vartype platform_fault_domain_count: int - :ivar hosts: A list of references to all dedicated hosts in the dedicated host group. - :vartype hosts: list[~azure.mgmt.compute.v2021_07_01.models.SubResourceReadOnly] - :ivar instance_view: The dedicated host group instance view, which has the list of instance - view of the dedicated hosts under the dedicated host group. - :vartype instance_view: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroupInstanceView - :ivar support_automatic_placement: Specifies whether virtual machines or virtual machine scale - sets can be placed automatically on the dedicated host group. Automatic placement means - resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host - group. The value is defaulted to 'false' when not provided. :code:`
    `\\ :code:`
    `Minimum - api-version: 2020-06-01. - :vartype support_automatic_placement: bool - """ - - _validation = { - "platform_fault_domain_count": {"minimum": 1}, - "hosts": {"readonly": True}, - "instance_view": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "zones": {"key": "zones", "type": "[str]"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "hosts": {"key": "properties.hosts", "type": "[SubResourceReadOnly]"}, - "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostGroupInstanceView"}, - "support_automatic_placement": {"key": "properties.supportAutomaticPlacement", "type": "bool"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - zones: Optional[List[str]] = None, - platform_fault_domain_count: Optional[int] = None, - support_automatic_placement: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword zones: Availability Zone to use for this host group. Only single zone is supported. - The zone can be assigned only during creation. If not provided, the group supports all zones in - the region. If provided, enforces each host in the group to be in the same zone. - :paramtype zones: list[str] - :keyword platform_fault_domain_count: Number of fault domains that the host group can span. - :paramtype platform_fault_domain_count: int - :keyword support_automatic_placement: Specifies whether virtual machines or virtual machine - scale sets can be placed automatically on the dedicated host group. Automatic placement means - resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host - group. The value is defaulted to 'false' when not provided. :code:`
    `\\ :code:`
    `Minimum - api-version: 2020-06-01. - :paramtype support_automatic_placement: bool - """ - super().__init__(tags=tags, **kwargs) - self.zones = zones - self.platform_fault_domain_count = platform_fault_domain_count - self.hosts: Optional[List["_models.SubResourceReadOnly"]] = None - self.instance_view: Optional["_models.DedicatedHostGroupInstanceView"] = None - self.support_automatic_placement = support_automatic_placement - - -class DedicatedHostInstanceView(_serialization.Model): - """The instance view of a dedicated host. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar asset_id: Specifies the unique id of the dedicated physical machine on which the - dedicated host resides. - :vartype asset_id: str - :ivar available_capacity: Unutilized capacity of the dedicated host. - :vartype available_capacity: - ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostAvailableCapacity - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - - _validation = { - "asset_id": {"readonly": True}, - } - - _attribute_map = { - "asset_id": {"key": "assetId", "type": "str"}, - "available_capacity": {"key": "availableCapacity", "type": "DedicatedHostAvailableCapacity"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword available_capacity: Unutilized capacity of the dedicated host. - :paramtype available_capacity: - ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostAvailableCapacity - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.asset_id: Optional[str] = None - self.available_capacity = available_capacity - self.statuses = statuses - - -class DedicatedHostInstanceViewWithName(DedicatedHostInstanceView): - """The instance view of a dedicated host that includes the name of the dedicated host. It is used - for the response to the instance view of a dedicated host group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar asset_id: Specifies the unique id of the dedicated physical machine on which the - dedicated host resides. - :vartype asset_id: str - :ivar available_capacity: Unutilized capacity of the dedicated host. - :vartype available_capacity: - ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostAvailableCapacity - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - :ivar name: The name of the dedicated host. - :vartype name: str - """ - - _validation = { - "asset_id": {"readonly": True}, - "name": {"readonly": True}, - } - - _attribute_map = { - "asset_id": {"key": "assetId", "type": "str"}, - "available_capacity": {"key": "availableCapacity", "type": "DedicatedHostAvailableCapacity"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword available_capacity: Unutilized capacity of the dedicated host. - :paramtype available_capacity: - ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostAvailableCapacity - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - super().__init__(available_capacity=available_capacity, statuses=statuses, **kwargs) - self.name: Optional[str] = None - - -class DedicatedHostListResult(_serialization.Model): - """The list dedicated host operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of dedicated hosts. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] - :ivar next_link: The URI to fetch the next page of dedicated hosts. Call ListNext() with this - URI to fetch the next page of dedicated hosts. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DedicatedHost]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.DedicatedHost"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of dedicated hosts. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] - :keyword next_link: The URI to fetch the next page of dedicated hosts. Call ListNext() with - this URI to fetch the next page of dedicated hosts. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DedicatedHostUpdate(UpdateResource): - """Specifies information about the dedicated host. Only tags, autoReplaceOnFailure and licenseType - may be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar platform_fault_domain: Fault domain of the dedicated host within a dedicated host group. - :vartype platform_fault_domain: int - :ivar auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :vartype auto_replace_on_failure: bool - :ivar host_id: A unique id generated and assigned to the dedicated host by the platform. - :code:`
    `\\ :code:`
    ` Does not change throughout the lifetime of the host. - :vartype host_id: str - :ivar virtual_machines: A list of references to all virtual machines in the Dedicated Host. - :vartype virtual_machines: list[~azure.mgmt.compute.v2021_07_01.models.SubResourceReadOnly] - :ivar license_type: Specifies the software license type that will be applied to the VMs - deployed on the dedicated host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ - :code:`
    ` **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. Known - values are: "None", "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :vartype license_type: str or ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostLicenseTypes - :ivar provisioning_time: The date when the host was first provisioned. - :vartype provisioning_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The dedicated host instance view. - :vartype instance_view: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostInstanceView - """ - - _validation = { - "platform_fault_domain": {"minimum": 0}, - "host_id": {"readonly": True}, - "virtual_machines": {"readonly": True}, - "provisioning_time": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "platform_fault_domain": {"key": "properties.platformFaultDomain", "type": "int"}, - "auto_replace_on_failure": {"key": "properties.autoReplaceOnFailure", "type": "bool"}, - "host_id": {"key": "properties.hostId", "type": "str"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResourceReadOnly]"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "provisioning_time": {"key": "properties.provisioningTime", "type": "iso-8601"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "DedicatedHostInstanceView"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - platform_fault_domain: Optional[int] = None, - auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword platform_fault_domain: Fault domain of the dedicated host within a dedicated host - group. - :paramtype platform_fault_domain: int - :keyword auto_replace_on_failure: Specifies whether the dedicated host should be replaced - automatically in case of a failure. The value is defaulted to 'true' when not provided. - :paramtype auto_replace_on_failure: bool - :keyword license_type: Specifies the software license type that will be applied to the VMs - deployed on the dedicated host. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **Windows_Server_Hybrid** :code:`
    `\\ - :code:`
    ` **Windows_Server_Perpetual** :code:`
    `\\ :code:`
    ` Default: **None**. Known - values are: "None", "Windows_Server_Hybrid", and "Windows_Server_Perpetual". - :paramtype license_type: str or - ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostLicenseTypes - """ - super().__init__(tags=tags, **kwargs) - self.platform_fault_domain = platform_fault_domain - self.auto_replace_on_failure = auto_replace_on_failure - self.host_id: Optional[str] = None - self.virtual_machines: Optional[List["_models.SubResourceReadOnly"]] = None - self.license_type = license_type - self.provisioning_time: Optional[datetime.datetime] = None - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.DedicatedHostInstanceView"] = None - - -class DiagnosticsProfile(_serialization.Model): - """Specifies the boot diagnostic settings state. :code:`
    `\\ :code:`
    `Minimum api-version: - 2015-06-15. - - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ **NOTE**\\ : If storageUri - is being specified then ensure that the storage account is in the same region and subscription - as the VM. :code:`
    `\\ :code:`
    ` You can easily view the output of your console log. - :code:`
    `\\ :code:`
    ` Azure also enables you to see a screenshot of the VM from the - hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2021_07_01.models.BootDiagnostics - """ - - _attribute_map = { - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnostics"}, - } - - def __init__(self, *, boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs: Any) -> None: - """ - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ **NOTE**\\ : If storageUri - is being specified then ensure that the storage account is in the same region and subscription - as the VM. :code:`
    `\\ :code:`
    ` You can easily view the output of your console log. - :code:`
    `\\ :code:`
    ` Azure also enables you to see a screenshot of the VM from the - hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2021_07_01.models.BootDiagnostics - """ - super().__init__(**kwargs) - self.boot_diagnostics = boot_diagnostics - - -class DiffDiskSettings(_serialization.Model): - """Describes the parameters of ephemeral disk settings that can be specified for operating system - disk. :code:`
    `\\ :code:`
    ` NOTE: The ephemeral disk settings can only be specified for - managed disk. - - :ivar option: Specifies the ephemeral disk settings for operating system disk. "Local" - :vartype option: str or ~azure.mgmt.compute.v2021_07_01.models.DiffDiskOptions - :ivar placement: Specifies the ephemeral disk placement for operating system disk.\\ - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **CacheDisk** - :code:`
    `\\ :code:`
    ` **ResourceDisk** :code:`
    `\\ :code:`
    ` Default: **CacheDisk** - if one is configured for the VM size otherwise **ResourceDisk** is used.\\ :code:`
    `\\ - :code:`
    ` Refer to VM size documentation for Windows VM at - https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at - https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM sizes exposes a - cache disk. Known values are: "CacheDisk" and "ResourceDisk". - :vartype placement: str or ~azure.mgmt.compute.v2021_07_01.models.DiffDiskPlacement - """ - - _attribute_map = { - "option": {"key": "option", "type": "str"}, - "placement": {"key": "placement", "type": "str"}, - } - - def __init__( - self, - *, - option: Optional[Union[str, "_models.DiffDiskOptions"]] = None, - placement: Optional[Union[str, "_models.DiffDiskPlacement"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword option: Specifies the ephemeral disk settings for operating system disk. "Local" - :paramtype option: str or ~azure.mgmt.compute.v2021_07_01.models.DiffDiskOptions - :keyword placement: Specifies the ephemeral disk placement for operating system disk.\\ - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **CacheDisk** - :code:`
    `\\ :code:`
    ` **ResourceDisk** :code:`
    `\\ :code:`
    ` Default: **CacheDisk** - if one is configured for the VM size otherwise **ResourceDisk** is used.\\ :code:`
    `\\ - :code:`
    ` Refer to VM size documentation for Windows VM at - https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at - https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM sizes exposes a - cache disk. Known values are: "CacheDisk" and "ResourceDisk". - :paramtype placement: str or ~azure.mgmt.compute.v2021_07_01.models.DiffDiskPlacement - """ - super().__init__(**kwargs) - self.option = option - self.placement = placement - - -class Disallowed(_serialization.Model): - """Describes the disallowed disk types. - - :ivar disk_types: A list of disk types. - :vartype disk_types: list[str] - """ - - _attribute_map = { - "disk_types": {"key": "diskTypes", "type": "[str]"}, - } - - def __init__(self, *, disk_types: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword disk_types: A list of disk types. - :paramtype disk_types: list[str] - """ - super().__init__(**kwargs) - self.disk_types = disk_types - - -class DisallowedConfiguration(_serialization.Model): - """Specifies the disallowed configuration for a virtual machine image. - - :ivar vm_disk_type: VM disk types which are disallowed. Known values are: "None" and - "Unmanaged". - :vartype vm_disk_type: str or ~azure.mgmt.compute.v2021_07_01.models.VmDiskTypes - """ - - _attribute_map = { - "vm_disk_type": {"key": "vmDiskType", "type": "str"}, - } - - def __init__(self, *, vm_disk_type: Optional[Union[str, "_models.VmDiskTypes"]] = None, **kwargs: Any) -> None: - """ - :keyword vm_disk_type: VM disk types which are disallowed. Known values are: "None" and - "Unmanaged". - :paramtype vm_disk_type: str or ~azure.mgmt.compute.v2021_07_01.models.VmDiskTypes - """ - super().__init__(**kwargs) - self.vm_disk_type = vm_disk_type - - -class SubResource(_serialization.Model): - """SubResource. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class DiskEncryptionSetParameters(SubResource): - """Describes the parameter of customer managed disk encryption set resource id that can be - specified for disk. :code:`
    `\\ :code:`
    ` NOTE: The disk encryption set resource id can - only be specified for managed disk. Please refer https://aka.ms/mdssewithcmkoverview for more - details. - - :ivar id: Resource Id. - :vartype id: str - """ - - -class DiskEncryptionSettings(_serialization.Model): - """Describes a Encryption Settings for a Disk. - - :ivar disk_encryption_key: Specifies the location of the disk encryption key, which is a Key - Vault Secret. - :vartype disk_encryption_key: ~azure.mgmt.compute.v2021_07_01.models.KeyVaultSecretReference - :ivar key_encryption_key: Specifies the location of the key encryption key in Key Vault. - :vartype key_encryption_key: ~azure.mgmt.compute.v2021_07_01.models.KeyVaultKeyReference - :ivar enabled: Specifies whether disk encryption should be enabled on the virtual machine. - :vartype enabled: bool - """ - - _attribute_map = { - "disk_encryption_key": {"key": "diskEncryptionKey", "type": "KeyVaultSecretReference"}, - "key_encryption_key": {"key": "keyEncryptionKey", "type": "KeyVaultKeyReference"}, - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__( - self, - *, - disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, - key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, - enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_key: Specifies the location of the disk encryption key, which is a Key - Vault Secret. - :paramtype disk_encryption_key: ~azure.mgmt.compute.v2021_07_01.models.KeyVaultSecretReference - :keyword key_encryption_key: Specifies the location of the key encryption key in Key Vault. - :paramtype key_encryption_key: ~azure.mgmt.compute.v2021_07_01.models.KeyVaultKeyReference - :keyword enabled: Specifies whether disk encryption should be enabled on the virtual machine. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.disk_encryption_key = disk_encryption_key - self.key_encryption_key = key_encryption_key - self.enabled = enabled - - -class DiskInstanceView(_serialization.Model): - """The instance view of the disk. - - :ivar name: The disk name. - :vartype name: str - :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :vartype encryption_settings: - list[~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSettings] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "encryption_settings": {"key": "encryptionSettings", "type": "[DiskEncryptionSettings]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype encryption_settings: - list[~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSettings] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.name = name - self.encryption_settings = encryption_settings - self.statuses = statuses - - -class EncryptionImages(_serialization.Model): - """Optional. Allows users to provide customer managed keys for encrypting the OS and data disks in - the gallery artifact. - - :ivar os_disk_image: Contains encryption settings for an OS disk image. - :vartype os_disk_image: ~azure.mgmt.compute.v2021_07_01.models.OSDiskImageEncryption - :ivar data_disk_images: A list of encryption specifications for data disk images. - :vartype data_disk_images: list[~azure.mgmt.compute.v2021_07_01.models.DataDiskImageEncryption] - """ - - _attribute_map = { - "os_disk_image": {"key": "osDiskImage", "type": "OSDiskImageEncryption"}, - "data_disk_images": {"key": "dataDiskImages", "type": "[DataDiskImageEncryption]"}, - } - - def __init__( - self, - *, - os_disk_image: Optional["_models.OSDiskImageEncryption"] = None, - data_disk_images: Optional[List["_models.DataDiskImageEncryption"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_disk_image: Contains encryption settings for an OS disk image. - :paramtype os_disk_image: ~azure.mgmt.compute.v2021_07_01.models.OSDiskImageEncryption - :keyword data_disk_images: A list of encryption specifications for data disk images. - :paramtype data_disk_images: - list[~azure.mgmt.compute.v2021_07_01.models.DataDiskImageEncryption] - """ - super().__init__(**kwargs) - self.os_disk_image = os_disk_image - 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: Optional[str] = None - self.info: Optional[JSON] = 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: Optional[str] = None - self.message: Optional[str] = None - self.target: Optional[str] = None - self.details: Optional[List["_models.ErrorDetail"]] = None - self.additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = 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. - - :ivar name: The name of the extended location. - :vartype name: str - :ivar type: The type of the extended location. "EdgeZone" - :vartype type: str or ~azure.mgmt.compute.v2021_07_01.models.ExtendedLocationTypes - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the extended location. - :paramtype name: str - :keyword type: The type of the extended location. "EdgeZone" - :paramtype type: str or ~azure.mgmt.compute.v2021_07_01.models.ExtendedLocationTypes - """ - super().__init__(**kwargs) - self.name = name - self.type = type - - -class Gallery(Resource): - """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. - :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] - :ivar description: The description of this Shared Image Gallery resource. This property is - updatable. - :vartype description: str - :ivar identifier: Describes the gallery unique name. - :vartype identifier: ~azure.mgmt.compute.v2021_07_01.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2021_07_01.models.GalleryPropertiesProvisioningState - :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. - :vartype sharing_profile: ~azure.mgmt.compute.v2021_07_01.models.SharingProfile - :ivar soft_delete_policy: Contains information about the soft deletion policy of the gallery. - :vartype soft_delete_policy: ~azure.mgmt.compute.v2021_07_01.models.SoftDeletePolicy - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "identifier": {"key": "properties.identifier", "type": "GalleryIdentifier"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "sharing_profile": {"key": "properties.sharingProfile", "type": "SharingProfile"}, - "soft_delete_policy": {"key": "properties.softDeletePolicy", "type": "SoftDeletePolicy"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - identifier: Optional["_models.GalleryIdentifier"] = None, - sharing_profile: Optional["_models.SharingProfile"] = None, - soft_delete_policy: Optional["_models.SoftDeletePolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this Shared Image Gallery resource. This property is - updatable. - :paramtype description: str - :keyword identifier: Describes the gallery unique name. - :paramtype identifier: ~azure.mgmt.compute.v2021_07_01.models.GalleryIdentifier - :keyword sharing_profile: Profile for gallery sharing to subscription or tenant. - :paramtype sharing_profile: ~azure.mgmt.compute.v2021_07_01.models.SharingProfile - :keyword soft_delete_policy: Contains information about the soft deletion policy of the - gallery. - :paramtype soft_delete_policy: ~azure.mgmt.compute.v2021_07_01.models.SoftDeletePolicy - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.identifier = identifier - self.provisioning_state: Optional[Union[str, "_models.GalleryPropertiesProvisioningState"]] = None - self.sharing_profile = sharing_profile - self.soft_delete_policy = soft_delete_policy - - -class GalleryApplication(Resource): - """Specifies information about the gallery Application 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. - :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] - :ivar description: The description of this gallery Application Definition resource. This - property is updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery Application Definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar supported_os_type: This property allows you to specify the supported type of the OS that - application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :vartype supported_os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - """ - - _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}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "supported_os_type": {"key": "properties.supportedOSType", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery Application Definition resource. This - property is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery Application Definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: str - :keyword end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword supported_os_type: This property allows you to specify the supported type of the OS - that application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :paramtype supported_os_type: str or - ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.end_of_life_date = end_of_life_date - self.supported_os_type = supported_os_type - - -class GalleryApplicationList(_serialization.Model): - """The List Gallery Applications operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of Gallery Applications. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryApplication]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.GalleryApplication"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of Gallery Applications. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class UpdateResourceDefinition(_serialization.Model): - """The Update Resource model definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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 = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.tags = tags - - -class GalleryApplicationUpdate(UpdateResourceDefinition): - """Specifies information about the gallery Application Definition that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar description: The description of this gallery Application Definition resource. This - property is updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery Application Definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar supported_os_type: This property allows you to specify the supported type of the OS that - application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :vartype supported_os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - """ - - _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"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "supported_os_type": {"key": "properties.supportedOSType", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery Application Definition resource. This - property is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery Application Definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: str - :keyword end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword supported_os_type: This property allows you to specify the supported type of the OS - that application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :paramtype supported_os_type: str or - ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - """ - super().__init__(tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.end_of_life_date = end_of_life_date - self.supported_os_type = supported_os_type - - -class GalleryApplicationVersion(Resource): - """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. - :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] - :ivar publishing_profile: The publishing profile of a gallery image version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersionPropertiesProvisioningState - :ivar replication_status: This is the replication status of the gallery image version. - :vartype replication_status: ~azure.mgmt.compute.v2021_07_01.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": 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}"}, - "publishing_profile": { - "key": "properties.publishingProfile", - "type": "GalleryApplicationVersionPublishingProfile", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersionPublishingProfile - """ - super().__init__(location=location, tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[ - Union[str, "_models.GalleryApplicationVersionPropertiesProvisioningState"] - ] = None - self.replication_status: Optional["_models.ReplicationStatus"] = None - - -class GalleryApplicationVersionList(_serialization.Model): - """The List Gallery Application version operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of gallery Application Versions. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion] - :ivar next_link: The uri to fetch the next page of gallery Application Versions. Call - ListNext() with this to fetch the next page of gallery Application Versions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryApplicationVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.GalleryApplicationVersion"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of gallery Application Versions. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion] - :keyword next_link: The uri to fetch the next page of gallery Application Versions. Call - ListNext() with this to fetch the next page of gallery Application Versions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryArtifactPublishingProfileBase(_serialization.Model): - """Describes the basic gallery artifact publishing profile. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar target_regions: The target regions where the Image Version is going to be replicated to. - This property is updatable. - :vartype target_regions: list[~azure.mgmt.compute.v2021_07_01.models.TargetRegion] - :ivar replica_count: The number of replicas of the Image Version to be created per region. This - property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :vartype replica_count: int - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar published_date: The timestamp for when the gallery image version is published. - :vartype published_date: ~datetime.datetime - :ivar end_of_life_date: The end of life date of the gallery image version. This property can be - used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountType - :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Known values are: "Full" and "Shallow". - :vartype replication_mode: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationMode - """ - - _validation = { - "published_date": {"readonly": True}, - } - - _attribute_map = { - "target_regions": {"key": "targetRegions", "type": "[TargetRegion]"}, - "replica_count": {"key": "replicaCount", "type": "int"}, - "exclude_from_latest": {"key": "excludeFromLatest", "type": "bool"}, - "published_date": {"key": "publishedDate", "type": "iso-8601"}, - "end_of_life_date": {"key": "endOfLifeDate", "type": "iso-8601"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "replication_mode": {"key": "replicationMode", "type": "str"}, - } - - def __init__( - self, - *, - target_regions: Optional[List["_models.TargetRegion"]] = None, - replica_count: Optional[int] = None, - exclude_from_latest: Optional[bool] = None, - end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword target_regions: The target regions where the Image Version is going to be replicated - to. This property is updatable. - :paramtype target_regions: list[~azure.mgmt.compute.v2021_07_01.models.TargetRegion] - :keyword replica_count: The number of replicas of the Image Version to be created per region. - This property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :paramtype replica_count: int - :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 end_of_life_date: The end of life date of the gallery image version. This property can - be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2021_07_01.models.StorageAccountType - :keyword replication_mode: Optional parameter which specifies the mode to be used for - replication. This property is not updatable. Known values are: "Full" and "Shallow". - :paramtype replication_mode: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationMode - """ - super().__init__(**kwargs) - self.target_regions = target_regions - self.replica_count = replica_count - self.exclude_from_latest = exclude_from_latest - self.published_date: Optional[datetime.datetime] = None - self.end_of_life_date = end_of_life_date - self.storage_account_type = storage_account_type - self.replication_mode = replication_mode - - -class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfileBase): # pylint: disable=name-too-long - """The publishing profile of a gallery image version. - - 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 target_regions: The target regions where the Image Version is going to be replicated to. - This property is updatable. - :vartype target_regions: list[~azure.mgmt.compute.v2021_07_01.models.TargetRegion] - :ivar replica_count: The number of replicas of the Image Version to be created per region. This - property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :vartype replica_count: int - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar published_date: The timestamp for when the gallery image version is published. - :vartype published_date: ~datetime.datetime - :ivar end_of_life_date: The end of life date of the gallery image version. This property can be - used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountType - :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Known values are: "Full" and "Shallow". - :vartype replication_mode: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationMode - :ivar source: The source image from which the Image Version is going to be created. Required. - :vartype source: ~azure.mgmt.compute.v2021_07_01.models.UserArtifactSource - :ivar manage_actions: - :vartype manage_actions: ~azure.mgmt.compute.v2021_07_01.models.UserArtifactManage - :ivar enable_health_check: Optional. Whether or not this application reports health. - :vartype enable_health_check: bool - """ - - _validation = { - "published_date": {"readonly": True}, - "source": {"required": True}, - } - - _attribute_map = { - "target_regions": {"key": "targetRegions", "type": "[TargetRegion]"}, - "replica_count": {"key": "replicaCount", "type": "int"}, - "exclude_from_latest": {"key": "excludeFromLatest", "type": "bool"}, - "published_date": {"key": "publishedDate", "type": "iso-8601"}, - "end_of_life_date": {"key": "endOfLifeDate", "type": "iso-8601"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "replication_mode": {"key": "replicationMode", "type": "str"}, - "source": {"key": "source", "type": "UserArtifactSource"}, - "manage_actions": {"key": "manageActions", "type": "UserArtifactManage"}, - "enable_health_check": {"key": "enableHealthCheck", "type": "bool"}, - } - - def __init__( - self, - *, - source: "_models.UserArtifactSource", - target_regions: Optional[List["_models.TargetRegion"]] = None, - replica_count: Optional[int] = None, - exclude_from_latest: Optional[bool] = None, - end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, - manage_actions: Optional["_models.UserArtifactManage"] = None, - enable_health_check: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword target_regions: The target regions where the Image Version is going to be replicated - to. This property is updatable. - :paramtype target_regions: list[~azure.mgmt.compute.v2021_07_01.models.TargetRegion] - :keyword replica_count: The number of replicas of the Image Version to be created per region. - This property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :paramtype replica_count: int - :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 end_of_life_date: The end of life date of the gallery image version. This property can - be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2021_07_01.models.StorageAccountType - :keyword replication_mode: Optional parameter which specifies the mode to be used for - replication. This property is not updatable. Known values are: "Full" and "Shallow". - :paramtype replication_mode: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationMode - :keyword source: The source image from which the Image Version is going to be created. - Required. - :paramtype source: ~azure.mgmt.compute.v2021_07_01.models.UserArtifactSource - :keyword manage_actions: - :paramtype manage_actions: ~azure.mgmt.compute.v2021_07_01.models.UserArtifactManage - :keyword enable_health_check: Optional. Whether or not this application reports health. - :paramtype enable_health_check: bool - """ - super().__init__( - target_regions=target_regions, - replica_count=replica_count, - exclude_from_latest=exclude_from_latest, - end_of_life_date=end_of_life_date, - storage_account_type=storage_account_type, - replication_mode=replication_mode, - **kwargs - ) - self.source = source - self.manage_actions = manage_actions - self.enable_health_check = enable_health_check - - -class GalleryApplicationVersionUpdate(UpdateResourceDefinition): - """Specifies information about the gallery Application Version that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar publishing_profile: The publishing profile of a gallery image version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersionPropertiesProvisioningState - :ivar replication_status: This is the replication status of the gallery image version. - :vartype replication_status: ~azure.mgmt.compute.v2021_07_01.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "publishing_profile": { - "key": "properties.publishingProfile", - "type": "GalleryApplicationVersionPublishingProfile", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersionPublishingProfile - """ - super().__init__(tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[ - Union[str, "_models.GalleryApplicationVersionPropertiesProvisioningState"] - ] = None - self.replication_status: Optional["_models.ReplicationStatus"] = 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.v2021_07_01.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.v2021_07_01.models.ManagedArtifact - """ - super().__init__(**kwargs) - self.managed_image = managed_image - - -class GalleryArtifactVersionSource(_serialization.Model): - """The gallery artifact version source. - - :ivar id: The id of the gallery artifact version source. Can specify a disk uri, snapshot uri, - user image or storage account resource. - :vartype id: str - :ivar uri: The uri of the gallery artifact version source. Currently used to specify vhd/blob - source. - :vartype uri: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "uri": {"key": "uri", "type": "str"}, - } - - def __init__( - self, *, id: Optional[str] = None, uri: Optional[str] = None, **kwargs: Any # pylint: disable=redefined-builtin - ) -> None: - """ - :keyword id: The id of the gallery artifact version source. Can specify a disk uri, snapshot - uri, user image or storage account resource. - :paramtype id: str - :keyword uri: The uri of the gallery artifact version source. Currently used to specify - vhd/blob source. - :paramtype uri: str - """ - super().__init__(**kwargs) - self.id = id - self.uri = uri - - -class GalleryDiskImage(_serialization.Model): - """This is the disk image base class. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar size_in_gb: This property indicates the size of the VHD to be created. - :vartype size_in_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2021_07_01.models.HostCaching - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2021_07_01.models.GalleryArtifactVersionSource - """ - - _validation = { - "size_in_gb": {"readonly": True}, - } - - _attribute_map = { - "size_in_gb": {"key": "sizeInGB", "type": "int"}, - "host_caching": {"key": "hostCaching", "type": "str"}, - "source": {"key": "source", "type": "GalleryArtifactVersionSource"}, - } - - def __init__( - self, - *, - host_caching: Optional[Union[str, "_models.HostCaching"]] = None, - source: Optional["_models.GalleryArtifactVersionSource"] = 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.v2021_07_01.models.HostCaching - :keyword source: The gallery artifact version source. - :paramtype source: ~azure.mgmt.compute.v2021_07_01.models.GalleryArtifactVersionSource - """ - super().__init__(**kwargs) - self.size_in_gb: Optional[int] = None - self.host_caching = host_caching - self.source = source - - -class GalleryDataDiskImage(GalleryDiskImage): - """This is the data disk 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 size_in_gb: This property indicates the size of the VHD to be created. - :vartype size_in_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2021_07_01.models.HostCaching - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2021_07_01.models.GalleryArtifactVersionSource - :ivar 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. - :vartype lun: int - """ - - _validation = { - "size_in_gb": {"readonly": True}, - "lun": {"required": True}, - } - - _attribute_map = { - "size_in_gb": {"key": "sizeInGB", "type": "int"}, - "host_caching": {"key": "hostCaching", "type": "str"}, - "source": {"key": "source", "type": "GalleryArtifactVersionSource"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__( - self, - *, - lun: int, - host_caching: Optional[Union[str, "_models.HostCaching"]] = None, - source: Optional["_models.GalleryArtifactVersionSource"] = 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.v2021_07_01.models.HostCaching - :keyword source: The gallery artifact version source. - :paramtype source: ~azure.mgmt.compute.v2021_07_01.models.GalleryArtifactVersionSource - :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, source=source, **kwargs) - self.lun = lun - - -class GalleryIdentifier(_serialization.Model): - """Describes the gallery unique name. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar unique_name: The unique name of the Shared Image Gallery. This name is generated - automatically by Azure. - :vartype unique_name: str - """ - - _validation = { - "unique_name": {"readonly": True}, - } - - _attribute_map = { - "unique_name": {"key": "uniqueName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.unique_name: Optional[str] = None - - -class GalleryImage(Resource): - """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. - :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] - :ivar description: The description of this gallery image definition resource. This property is - updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery image definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar 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. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values - are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - :ivar 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". - :vartype os_state: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemStateTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGeneration - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar identifier: This is the gallery image definition identifier. - :vartype identifier: ~azure.mgmt.compute.v2021_07_01.models.GalleryImageIdentifier - :ivar recommended: The properties describe the recommended machine configuration for this Image - Definition. These properties are updatable. - :vartype recommended: ~azure.mgmt.compute.v2021_07_01.models.RecommendedMachineConfiguration - :ivar disallowed: Describes the disallowed disk types. - :vartype disallowed: ~azure.mgmt.compute.v2021_07_01.models.Disallowed - :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :vartype purchase_plan: ~azure.mgmt.compute.v2021_07_01.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2021_07_01.models.GalleryImagePropertiesProvisioningState - :ivar features: A list of gallery image features. - :vartype features: list[~azure.mgmt.compute.v2021_07_01.models.GalleryImageFeature] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "os_state": {"key": "properties.osState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, - "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "features": {"key": "properties.features", "type": "[GalleryImageFeature]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["_models.GalleryImageIdentifier"] = None, - recommended: Optional["_models.RecommendedMachineConfiguration"] = None, - disallowed: Optional["_models.Disallowed"] = None, - purchase_plan: Optional["_models.ImagePurchasePlan"] = None, - features: Optional[List["_models.GalleryImageFeature"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery image definition resource. This property - is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery image definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: 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. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.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.v2021_07_01.models.OperatingSystemStateTypes - :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.v2021_07_01.models.HyperVGeneration - :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.v2021_07_01.models.GalleryImageIdentifier - :keyword recommended: The properties describe the recommended machine configuration for this - Image Definition. These properties are updatable. - :paramtype recommended: ~azure.mgmt.compute.v2021_07_01.models.RecommendedMachineConfiguration - :keyword disallowed: Describes the disallowed disk types. - :paramtype disallowed: ~azure.mgmt.compute.v2021_07_01.models.Disallowed - :keyword purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :paramtype purchase_plan: ~azure.mgmt.compute.v2021_07_01.models.ImagePurchasePlan - :keyword features: A list of gallery image features. - :paramtype features: list[~azure.mgmt.compute.v2021_07_01.models.GalleryImageFeature] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.os_type = os_type - self.os_state = os_state - self.hyper_v_generation = hyper_v_generation - self.end_of_life_date = end_of_life_date - self.identifier = identifier - self.recommended = recommended - self.disallowed = disallowed - self.purchase_plan = purchase_plan - self.provisioning_state: Optional[Union[str, "_models.GalleryImagePropertiesProvisioningState"]] = None - self.features = features - - -class GalleryImageFeature(_serialization.Model): - """A feature for gallery image. - - :ivar name: The name of the gallery image feature. - :vartype name: str - :ivar value: The value of the gallery image feature. - :vartype value: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: The name of the gallery image feature. - :paramtype name: str - :keyword value: The value of the gallery image feature. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class GalleryImageIdentifier(_serialization.Model): - """This is the gallery image definition identifier. - - All required parameters must be populated in order to send to server. - - :ivar publisher: The name of the gallery image definition publisher. Required. - :vartype publisher: str - :ivar offer: The name of the gallery image definition offer. Required. - :vartype offer: str - :ivar sku: The name of the gallery image definition SKU. Required. - :vartype sku: str - """ - - _validation = { - "publisher": {"required": True}, - "offer": {"required": True}, - "sku": {"required": True}, - } - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "offer": {"key": "offer", "type": "str"}, - "sku": {"key": "sku", "type": "str"}, - } - - def __init__(self, *, publisher: str, offer: str, sku: str, **kwargs: Any) -> None: - """ - :keyword publisher: The name of the gallery image definition publisher. Required. - :paramtype publisher: str - :keyword offer: The name of the gallery image definition offer. Required. - :paramtype offer: str - :keyword sku: The name of the gallery image definition SKU. Required. - :paramtype sku: str - """ - super().__init__(**kwargs) - self.publisher = publisher - self.offer = offer - self.sku = sku - - -class GalleryImageList(_serialization.Model): - """The List Gallery Images operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of Shared Image Gallery images. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.GalleryImage] - :ivar next_link: The uri to fetch the next page of Image Definitions in the Shared Image - Gallery. Call ListNext() with this to fetch the next page of gallery image definitions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryImage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.GalleryImage"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of Shared Image Gallery images. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.GalleryImage] - :keyword next_link: The uri to fetch the next page of Image Definitions in the Shared Image - Gallery. Call ListNext() with this to fetch the next page of gallery image definitions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryImageUpdate(UpdateResourceDefinition): - """Specifies information about the gallery image definition that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar description: The description of this gallery image definition resource. This property is - updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery image definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar 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. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values - are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - :ivar 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". - :vartype os_state: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemStateTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGeneration - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar identifier: This is the gallery image definition identifier. - :vartype identifier: ~azure.mgmt.compute.v2021_07_01.models.GalleryImageIdentifier - :ivar recommended: The properties describe the recommended machine configuration for this Image - Definition. These properties are updatable. - :vartype recommended: ~azure.mgmt.compute.v2021_07_01.models.RecommendedMachineConfiguration - :ivar disallowed: Describes the disallowed disk types. - :vartype disallowed: ~azure.mgmt.compute.v2021_07_01.models.Disallowed - :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :vartype purchase_plan: ~azure.mgmt.compute.v2021_07_01.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2021_07_01.models.GalleryImagePropertiesProvisioningState - :ivar features: A list of gallery image features. - :vartype features: list[~azure.mgmt.compute.v2021_07_01.models.GalleryImageFeature] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "os_state": {"key": "properties.osState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, - "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "features": {"key": "properties.features", "type": "[GalleryImageFeature]"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["_models.GalleryImageIdentifier"] = None, - recommended: Optional["_models.RecommendedMachineConfiguration"] = None, - disallowed: Optional["_models.Disallowed"] = None, - purchase_plan: Optional["_models.ImagePurchasePlan"] = None, - features: Optional[List["_models.GalleryImageFeature"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery image definition resource. This property - is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery image definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: 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. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.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.v2021_07_01.models.OperatingSystemStateTypes - :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.v2021_07_01.models.HyperVGeneration - :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.v2021_07_01.models.GalleryImageIdentifier - :keyword recommended: The properties describe the recommended machine configuration for this - Image Definition. These properties are updatable. - :paramtype recommended: ~azure.mgmt.compute.v2021_07_01.models.RecommendedMachineConfiguration - :keyword disallowed: Describes the disallowed disk types. - :paramtype disallowed: ~azure.mgmt.compute.v2021_07_01.models.Disallowed - :keyword purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :paramtype purchase_plan: ~azure.mgmt.compute.v2021_07_01.models.ImagePurchasePlan - :keyword features: A list of gallery image features. - :paramtype features: list[~azure.mgmt.compute.v2021_07_01.models.GalleryImageFeature] - """ - super().__init__(tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.os_type = os_type - self.os_state = os_state - self.hyper_v_generation = hyper_v_generation - self.end_of_life_date = end_of_life_date - self.identifier = identifier - self.recommended = recommended - self.disallowed = disallowed - self.purchase_plan = purchase_plan - self.provisioning_state: Optional[Union[str, "_models.GalleryImagePropertiesProvisioningState"]] = None - self.features = features - - -class GalleryImageVersion(Resource): - """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. - :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] - :ivar publishing_profile: The publishing profile of a gallery image Version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersionPropertiesProvisioningState - :ivar storage_profile: This is the storage profile of a Gallery Image Version. - :vartype storage_profile: - ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersionStorageProfile - :ivar replication_status: This is the replication status of the gallery image version. - :vartype replication_status: ~azure.mgmt.compute.v2021_07_01.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": 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}"}, - "publishing_profile": {"key": "properties.publishingProfile", "type": "GalleryImageVersionPublishingProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image Version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersionPublishingProfile - :keyword storage_profile: This is the storage profile of a Gallery Image Version. - :paramtype storage_profile: - ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersionStorageProfile - """ - super().__init__(location=location, tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[Union[str, "_models.GalleryImageVersionPropertiesProvisioningState"]] = None - self.storage_profile = storage_profile - self.replication_status: Optional["_models.ReplicationStatus"] = None - - -class GalleryImageVersionList(_serialization.Model): - """The List Gallery Image version operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of gallery image versions. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersion] - :ivar next_link: The uri to fetch the next page of gallery image versions. Call ListNext() with - this to fetch the next page of gallery image versions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryImageVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.GalleryImageVersion"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of gallery image versions. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersion] - :keyword next_link: The uri to fetch the next page of gallery image versions. Call ListNext() - with this to fetch the next page of gallery image versions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase): - """The publishing profile of a gallery image Version. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar target_regions: The target regions where the Image Version is going to be replicated to. - This property is updatable. - :vartype target_regions: list[~azure.mgmt.compute.v2021_07_01.models.TargetRegion] - :ivar replica_count: The number of replicas of the Image Version to be created per region. This - property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :vartype replica_count: int - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar published_date: The timestamp for when the gallery image version is published. - :vartype published_date: ~datetime.datetime - :ivar end_of_life_date: The end of life date of the gallery image version. This property can be - used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountType - :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Known values are: "Full" and "Shallow". - :vartype replication_mode: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationMode - """ - - -class GalleryImageVersionStorageProfile(_serialization.Model): - """This is the storage profile of a Gallery Image Version. - - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2021_07_01.models.GalleryArtifactVersionSource - :ivar os_disk_image: This is the OS disk image. - :vartype os_disk_image: ~azure.mgmt.compute.v2021_07_01.models.GalleryOSDiskImage - :ivar data_disk_images: A list of data disk images. - :vartype data_disk_images: list[~azure.mgmt.compute.v2021_07_01.models.GalleryDataDiskImage] - """ - - _attribute_map = { - "source": {"key": "source", "type": "GalleryArtifactVersionSource"}, - "os_disk_image": {"key": "osDiskImage", "type": "GalleryOSDiskImage"}, - "data_disk_images": {"key": "dataDiskImages", "type": "[GalleryDataDiskImage]"}, - } - - def __init__( - self, - *, - source: Optional["_models.GalleryArtifactVersionSource"] = None, - os_disk_image: Optional["_models.GalleryOSDiskImage"] = None, - data_disk_images: Optional[List["_models.GalleryDataDiskImage"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source: The gallery artifact version source. - :paramtype source: ~azure.mgmt.compute.v2021_07_01.models.GalleryArtifactVersionSource - :keyword os_disk_image: This is the OS disk image. - :paramtype os_disk_image: ~azure.mgmt.compute.v2021_07_01.models.GalleryOSDiskImage - :keyword data_disk_images: A list of data disk images. - :paramtype data_disk_images: list[~azure.mgmt.compute.v2021_07_01.models.GalleryDataDiskImage] - """ - super().__init__(**kwargs) - self.source = source - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - - -class GalleryImageVersionUpdate(UpdateResourceDefinition): - """Specifies information about the gallery image version that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar publishing_profile: The publishing profile of a gallery image Version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersionPropertiesProvisioningState - :ivar storage_profile: This is the storage profile of a Gallery Image Version. - :vartype storage_profile: - ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersionStorageProfile - :ivar replication_status: This is the replication status of the gallery image version. - :vartype replication_status: ~azure.mgmt.compute.v2021_07_01.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "publishing_profile": {"key": "properties.publishingProfile", "type": "GalleryImageVersionPublishingProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image Version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersionPublishingProfile - :keyword storage_profile: This is the storage profile of a Gallery Image Version. - :paramtype storage_profile: - ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersionStorageProfile - """ - super().__init__(tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[Union[str, "_models.GalleryImageVersionPropertiesProvisioningState"]] = None - self.storage_profile = storage_profile - self.replication_status: Optional["_models.ReplicationStatus"] = None - - -class GalleryList(_serialization.Model): - """The List Galleries operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of galleries. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.Gallery] - :ivar next_link: The uri to fetch the next page of galleries. Call ListNext() with this to - fetch the next page of galleries. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Gallery]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Gallery"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of galleries. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.Gallery] - :keyword next_link: The uri to fetch the next page of galleries. Call ListNext() with this to - fetch the next page of galleries. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryOSDiskImage(GalleryDiskImage): - """This is the OS disk image. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar size_in_gb: This property indicates the size of the VHD to be created. - :vartype size_in_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2021_07_01.models.HostCaching - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2021_07_01.models.GalleryArtifactVersionSource - """ - - -class GalleryUpdate(UpdateResourceDefinition): - """Specifies information about the Shared Image Gallery that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar description: The description of this Shared Image Gallery resource. This property is - updatable. - :vartype description: str - :ivar identifier: Describes the gallery unique name. - :vartype identifier: ~azure.mgmt.compute.v2021_07_01.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2021_07_01.models.GalleryPropertiesProvisioningState - :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. - :vartype sharing_profile: ~azure.mgmt.compute.v2021_07_01.models.SharingProfile - :ivar soft_delete_policy: Contains information about the soft deletion policy of the gallery. - :vartype soft_delete_policy: ~azure.mgmt.compute.v2021_07_01.models.SoftDeletePolicy - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "identifier": {"key": "properties.identifier", "type": "GalleryIdentifier"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "sharing_profile": {"key": "properties.sharingProfile", "type": "SharingProfile"}, - "soft_delete_policy": {"key": "properties.softDeletePolicy", "type": "SoftDeletePolicy"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - identifier: Optional["_models.GalleryIdentifier"] = None, - sharing_profile: Optional["_models.SharingProfile"] = None, - soft_delete_policy: Optional["_models.SoftDeletePolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this Shared Image Gallery resource. This property is - updatable. - :paramtype description: str - :keyword identifier: Describes the gallery unique name. - :paramtype identifier: ~azure.mgmt.compute.v2021_07_01.models.GalleryIdentifier - :keyword sharing_profile: Profile for gallery sharing to subscription or tenant. - :paramtype sharing_profile: ~azure.mgmt.compute.v2021_07_01.models.SharingProfile - :keyword soft_delete_policy: Contains information about the soft deletion policy of the - gallery. - :paramtype soft_delete_policy: ~azure.mgmt.compute.v2021_07_01.models.SoftDeletePolicy - """ - super().__init__(tags=tags, **kwargs) - self.description = description - self.identifier = identifier - self.provisioning_state: Optional[Union[str, "_models.GalleryPropertiesProvisioningState"]] = None - self.sharing_profile = sharing_profile - self.soft_delete_policy = soft_delete_policy - - -class HardwareProfile(_serialization.Model): - """Specifies the hardware settings for the virtual machine. - - :ivar vm_size: Specifies the size of the virtual machine. :code:`
    `\\ :code:`
    ` The enum - data type is currently deprecated and will be removed by December 23rd 2023. :code:`
    `\\ - :code:`
    ` Recommended way to get the list of available sizes is using these APIs: - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in an availability set - `_ - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in a region - `_ :code:`
    `\\ :code:`
    ` - `List all available virtual machine sizes for resizing - `_. For more - information about virtual machine sizes, see `Sizes for virtual machines - `_. :code:`
    `\\ :code:`
    ` The - available VM sizes depend on region and availability set. Known values are: "Basic_A0", - "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", - "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", - "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", - "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", "Standard_A8m_v2", - "Standard_B1s", "Standard_B1ms", "Standard_B2s", "Standard_B2ms", "Standard_B4ms", - "Standard_B8ms", "Standard_D1", "Standard_D2", "Standard_D3", "Standard_D4", "Standard_D11", - "Standard_D12", "Standard_D13", "Standard_D14", "Standard_D1_v2", "Standard_D2_v2", - "Standard_D3_v2", "Standard_D4_v2", "Standard_D5_v2", "Standard_D2_v3", "Standard_D4_v3", - "Standard_D8_v3", "Standard_D16_v3", "Standard_D32_v3", "Standard_D64_v3", "Standard_D2s_v3", - "Standard_D4s_v3", "Standard_D8s_v3", "Standard_D16s_v3", "Standard_D32s_v3", - "Standard_D64s_v3", "Standard_D11_v2", "Standard_D12_v2", "Standard_D13_v2", "Standard_D14_v2", - "Standard_D15_v2", "Standard_DS1", "Standard_DS2", "Standard_DS3", "Standard_DS4", - "Standard_DS11", "Standard_DS12", "Standard_DS13", "Standard_DS14", "Standard_DS1_v2", - "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2", "Standard_DS11_v2", - "Standard_DS12_v2", "Standard_DS13_v2", "Standard_DS14_v2", "Standard_DS15_v2", - "Standard_DS13-4_v2", "Standard_DS13-2_v2", "Standard_DS14-8_v2", "Standard_DS14-4_v2", - "Standard_E2_v3", "Standard_E4_v3", "Standard_E8_v3", "Standard_E16_v3", "Standard_E32_v3", - "Standard_E64_v3", "Standard_E2s_v3", "Standard_E4s_v3", "Standard_E8s_v3", "Standard_E16s_v3", - "Standard_E32s_v3", "Standard_E64s_v3", "Standard_E32-16_v3", "Standard_E32-8s_v3", - "Standard_E64-32s_v3", "Standard_E64-16s_v3", "Standard_F1", "Standard_F2", "Standard_F4", - "Standard_F8", "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", - "Standard_F16s", "Standard_F2s_v2", "Standard_F4s_v2", "Standard_F8s_v2", "Standard_F16s_v2", - "Standard_F32s_v2", "Standard_F64s_v2", "Standard_F72s_v2", "Standard_G1", "Standard_G2", - "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", "Standard_GS3", - "Standard_GS4", "Standard_GS5", "Standard_GS4-8", "Standard_GS4-4", "Standard_GS5-16", - "Standard_GS5-8", "Standard_H8", "Standard_H16", "Standard_H8m", "Standard_H16m", - "Standard_H16r", "Standard_H16mr", "Standard_L4s", "Standard_L8s", "Standard_L16s", - "Standard_L32s", "Standard_M64s", "Standard_M64ms", "Standard_M128s", "Standard_M128ms", - "Standard_M64-32ms", "Standard_M64-16ms", "Standard_M128-64ms", "Standard_M128-32ms", - "Standard_NC6", "Standard_NC12", "Standard_NC24", "Standard_NC24r", "Standard_NC6s_v2", - "Standard_NC12s_v2", "Standard_NC24s_v2", "Standard_NC24rs_v2", "Standard_NC6s_v3", - "Standard_NC12s_v3", "Standard_NC24s_v3", "Standard_NC24rs_v3", "Standard_ND6s", - "Standard_ND12s", "Standard_ND24s", "Standard_ND24rs", "Standard_NV6", "Standard_NV12", and - "Standard_NV24". - :vartype vm_size: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineSizeTypes - :ivar vm_size_properties: Specifies the properties for customizing the size of the virtual - machine. Minimum api-version: 2021-07-01. :code:`
    `\\ :code:`
    ` This feature is still in - preview mode and is not supported for VirtualMachineScaleSet. :code:`
    `\\ :code:`
    ` - Please follow the instructions in `VM Customization `_ for more - details. - :vartype vm_size_properties: ~azure.mgmt.compute.v2021_07_01.models.VMSizeProperties - """ - - _attribute_map = { - "vm_size": {"key": "vmSize", "type": "str"}, - "vm_size_properties": {"key": "vmSizeProperties", "type": "VMSizeProperties"}, - } - - def __init__( - self, - *, - vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, - vm_size_properties: Optional["_models.VMSizeProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword vm_size: Specifies the size of the virtual machine. :code:`
    `\\ :code:`
    ` The - enum data type is currently deprecated and will be removed by December 23rd 2023. - :code:`
    `\\ :code:`
    ` Recommended way to get the list of available sizes is using these - APIs: :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in an availability - set `_ - :code:`
    `\\ :code:`
    ` `List all available virtual machine sizes in a region - `_ :code:`
    `\\ :code:`
    ` - `List all available virtual machine sizes for resizing - `_. For more - information about virtual machine sizes, see `Sizes for virtual machines - `_. :code:`
    `\\ :code:`
    ` The - available VM sizes depend on region and availability set. Known values are: "Basic_A0", - "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", - "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", - "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", - "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", "Standard_A8m_v2", - "Standard_B1s", "Standard_B1ms", "Standard_B2s", "Standard_B2ms", "Standard_B4ms", - "Standard_B8ms", "Standard_D1", "Standard_D2", "Standard_D3", "Standard_D4", "Standard_D11", - "Standard_D12", "Standard_D13", "Standard_D14", "Standard_D1_v2", "Standard_D2_v2", - "Standard_D3_v2", "Standard_D4_v2", "Standard_D5_v2", "Standard_D2_v3", "Standard_D4_v3", - "Standard_D8_v3", "Standard_D16_v3", "Standard_D32_v3", "Standard_D64_v3", "Standard_D2s_v3", - "Standard_D4s_v3", "Standard_D8s_v3", "Standard_D16s_v3", "Standard_D32s_v3", - "Standard_D64s_v3", "Standard_D11_v2", "Standard_D12_v2", "Standard_D13_v2", "Standard_D14_v2", - "Standard_D15_v2", "Standard_DS1", "Standard_DS2", "Standard_DS3", "Standard_DS4", - "Standard_DS11", "Standard_DS12", "Standard_DS13", "Standard_DS14", "Standard_DS1_v2", - "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2", "Standard_DS11_v2", - "Standard_DS12_v2", "Standard_DS13_v2", "Standard_DS14_v2", "Standard_DS15_v2", - "Standard_DS13-4_v2", "Standard_DS13-2_v2", "Standard_DS14-8_v2", "Standard_DS14-4_v2", - "Standard_E2_v3", "Standard_E4_v3", "Standard_E8_v3", "Standard_E16_v3", "Standard_E32_v3", - "Standard_E64_v3", "Standard_E2s_v3", "Standard_E4s_v3", "Standard_E8s_v3", "Standard_E16s_v3", - "Standard_E32s_v3", "Standard_E64s_v3", "Standard_E32-16_v3", "Standard_E32-8s_v3", - "Standard_E64-32s_v3", "Standard_E64-16s_v3", "Standard_F1", "Standard_F2", "Standard_F4", - "Standard_F8", "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", - "Standard_F16s", "Standard_F2s_v2", "Standard_F4s_v2", "Standard_F8s_v2", "Standard_F16s_v2", - "Standard_F32s_v2", "Standard_F64s_v2", "Standard_F72s_v2", "Standard_G1", "Standard_G2", - "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", "Standard_GS3", - "Standard_GS4", "Standard_GS5", "Standard_GS4-8", "Standard_GS4-4", "Standard_GS5-16", - "Standard_GS5-8", "Standard_H8", "Standard_H16", "Standard_H8m", "Standard_H16m", - "Standard_H16r", "Standard_H16mr", "Standard_L4s", "Standard_L8s", "Standard_L16s", - "Standard_L32s", "Standard_M64s", "Standard_M64ms", "Standard_M128s", "Standard_M128ms", - "Standard_M64-32ms", "Standard_M64-16ms", "Standard_M128-64ms", "Standard_M128-32ms", - "Standard_NC6", "Standard_NC12", "Standard_NC24", "Standard_NC24r", "Standard_NC6s_v2", - "Standard_NC12s_v2", "Standard_NC24s_v2", "Standard_NC24rs_v2", "Standard_NC6s_v3", - "Standard_NC12s_v3", "Standard_NC24s_v3", "Standard_NC24rs_v3", "Standard_ND6s", - "Standard_ND12s", "Standard_ND24s", "Standard_ND24rs", "Standard_NV6", "Standard_NV12", and - "Standard_NV24". - :paramtype vm_size: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineSizeTypes - :keyword vm_size_properties: Specifies the properties for customizing the size of the virtual - machine. Minimum api-version: 2021-07-01. :code:`
    `\\ :code:`
    ` This feature is still in - preview mode and is not supported for VirtualMachineScaleSet. :code:`
    `\\ :code:`
    ` - Please follow the instructions in `VM Customization `_ for more - details. - :paramtype vm_size_properties: ~azure.mgmt.compute.v2021_07_01.models.VMSizeProperties - """ - super().__init__(**kwargs) - self.vm_size = vm_size - self.vm_size_properties = vm_size_properties - - -class Image(Resource): - """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. - - 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] - :ivar extended_location: The extended location of the Image. - :vartype extended_location: ~azure.mgmt.compute.v2021_07_01.models.ExtendedLocation - :ivar source_virtual_machine: The source virtual machine from which Image is created. - :vartype source_virtual_machine: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2021_07_01.models.ImageStorageProfile - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str - :ivar hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created from - the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to - specify the value, if the source is managed resource like disk or snapshot, we may require the - user to specify the property if we cannot deduce it from the source managed resource. Known - values are: "V1" and "V2". - :vartype hyper_v_generation: str or - ~azure.mgmt.compute.v2021_07_01.models.HyperVGenerationTypes - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - "source_virtual_machine": {"key": "properties.sourceVirtualMachine", "type": "SubResource"}, - "storage_profile": {"key": "properties.storageProfile", "type": "ImageStorageProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - extended_location: Optional["_models.ExtendedLocation"] = None, - source_virtual_machine: Optional["_models.SubResource"] = None, - storage_profile: Optional["_models.ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword extended_location: The extended location of the Image. - :paramtype extended_location: ~azure.mgmt.compute.v2021_07_01.models.ExtendedLocation - :keyword source_virtual_machine: The source virtual machine from which Image is created. - :paramtype source_virtual_machine: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2021_07_01.models.ImageStorageProfile - :keyword hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created - from the image. From API Version 2019-03-01 if the image source is a blob, then we need the - user to specify the value, if the source is managed resource like disk or snapshot, we may - require the user to specify the property if we cannot deduce it from the source managed - resource. Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2021_07_01.models.HyperVGenerationTypes - """ - super().__init__(location=location, tags=tags, **kwargs) - self.extended_location = extended_location - self.source_virtual_machine = source_virtual_machine - self.storage_profile = storage_profile - self.provisioning_state: Optional[str] = None - self.hyper_v_generation = hyper_v_generation - - -class ImageDisk(_serialization.Model): - """Describes a image disk. - - :ivar snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", and - "StandardSSD_ZRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed image disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSetParameters - """ - - _attribute_map = { - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - } - - def __init__( - self, - *, - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", and - "StandardSSD_ZRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed image disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSetParameters - """ - super().__init__(**kwargs) - self.snapshot = snapshot - self.managed_disk = managed_disk - self.blob_uri = blob_uri - self.caching = caching - self.disk_size_gb = disk_size_gb - self.storage_account_type = storage_account_type - self.disk_encryption_set = disk_encryption_set - - -class ImageDataDisk(ImageDisk): - """Describes a data disk. - - All required parameters must be populated in order to send to server. - - :ivar snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", and - "StandardSSD_ZRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed image disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSetParameters - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - """ - - _validation = { - "lun": {"required": True}, - } - - _attribute_map = { - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__( - self, - *, - lun: int, - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", and - "StandardSSD_ZRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed image disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSetParameters - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - """ - super().__init__( - snapshot=snapshot, - managed_disk=managed_disk, - blob_uri=blob_uri, - caching=caching, - disk_size_gb=disk_size_gb, - storage_account_type=storage_account_type, - disk_encryption_set=disk_encryption_set, - **kwargs - ) - self.lun = lun - - -class ImageListResult(_serialization.Model): - """The List Image operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of Images. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.Image] - :ivar next_link: The uri to fetch the next page of Images. Call ListNext() with this to fetch - the next page of Images. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Image]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Image"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of Images. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.Image] - :keyword next_link: The uri to fetch the next page of Images. Call ListNext() with this to - fetch the next page of Images. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ImageOSDisk(ImageDisk): - """Describes an Operating System disk. - - All required parameters must be populated in order to send to server. - - :ivar snapshot: The snapshot. - :vartype snapshot: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar managed_disk: The managedDisk. - :vartype managed_disk: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar blob_uri: The Virtual Hard Disk. - :vartype blob_uri: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", and - "StandardSSD_ZRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed image disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSetParameters - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from a custom image. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Required. Known - values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - :ivar os_state: The OS State. Required. Known values are: "Generalized" and "Specialized". - :vartype os_state: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemStateTypes - """ - - _validation = { - "os_type": {"required": True}, - "os_state": {"required": True}, - } - - _attribute_map = { - "snapshot": {"key": "snapshot", "type": "SubResource"}, - "managed_disk": {"key": "managedDisk", "type": "SubResource"}, - "blob_uri": {"key": "blobUri", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - "os_type": {"key": "osType", "type": "str"}, - "os_state": {"key": "osState", "type": "str"}, - } - - def __init__( - self, - *, - os_type: Union[str, "_models.OperatingSystemTypes"], - os_state: Union[str, "_models.OperatingSystemStateTypes"], - snapshot: Optional["_models.SubResource"] = None, - managed_disk: Optional["_models.SubResource"] = None, - blob_uri: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword snapshot: The snapshot. - :paramtype snapshot: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword managed_disk: The managedDisk. - :paramtype managed_disk: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword blob_uri: The Virtual Hard Disk. - :paramtype blob_uri: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be - used to overwrite the name of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", and - "StandardSSD_ZRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed image disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSetParameters - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from a custom image. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Required. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - :keyword os_state: The OS State. Required. Known values are: "Generalized" and "Specialized". - :paramtype os_state: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemStateTypes - """ - super().__init__( - snapshot=snapshot, - managed_disk=managed_disk, - blob_uri=blob_uri, - caching=caching, - disk_size_gb=disk_size_gb, - storage_account_type=storage_account_type, - disk_encryption_set=disk_encryption_set, - **kwargs - ) - self.os_type = os_type - self.os_state = os_state - - -class ImagePurchasePlan(_serialization.Model): - """Describes the gallery image definition purchase plan. This is used by marketplace images. - - :ivar name: The plan ID. - :vartype name: str - :ivar publisher: The publisher ID. - :vartype publisher: str - :ivar product: The product ID. - :vartype product: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - publisher: Optional[str] = None, - product: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The plan ID. - :paramtype name: str - :keyword publisher: The publisher ID. - :paramtype publisher: str - :keyword product: The product ID. - :paramtype product: str - """ - super().__init__(**kwargs) - self.name = name - self.publisher = publisher - self.product = product - - -class ImageReference(SubResource): - """Specifies information about the image to use. You can specify information about platform - images, marketplace images, or virtual machine images. This element is required when you want - to use a platform image, marketplace image, or virtual machine image, but is not used in other - creation operations. NOTE: Image reference publisher and offer can only be set when you create - the scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar publisher: The image publisher. - :vartype publisher: str - :ivar offer: Specifies the offer of the platform image or marketplace image used to create the - virtual machine. - :vartype offer: str - :ivar sku: The image SKU. - :vartype sku: str - :ivar version: Specifies the version of the platform image or marketplace image used to create - the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and - Build are decimal numbers. Specify 'latest' to use the latest version of an image available at - deploy time. Even if you use 'latest', the VM image will not automatically update after deploy - time even if a new version becomes available. - :vartype version: str - :ivar exact_version: Specifies in decimal numbers, the version of platform image or marketplace - image used to create the virtual machine. This readonly field differs from 'version', only if - the value specified in 'version' field is 'latest'. - :vartype exact_version: str - :ivar shared_gallery_image_id: Specified the shared gallery image unique id for vm deployment. - This can be fetched from shared gallery image GET call. - :vartype shared_gallery_image_id: str - """ - - _validation = { - "exact_version": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "offer": {"key": "offer", "type": "str"}, - "sku": {"key": "sku", "type": "str"}, - "version": {"key": "version", "type": "str"}, - "exact_version": {"key": "exactVersion", "type": "str"}, - "shared_gallery_image_id": {"key": "sharedGalleryImageId", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - publisher: Optional[str] = None, - offer: Optional[str] = None, - sku: Optional[str] = None, - version: Optional[str] = None, - shared_gallery_image_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword publisher: The image publisher. - :paramtype publisher: str - :keyword offer: Specifies the offer of the platform image or marketplace image used to create - the virtual machine. - :paramtype offer: str - :keyword sku: The image SKU. - :paramtype sku: str - :keyword version: Specifies the version of the platform image or marketplace image used to - create the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, - Minor, and Build are decimal numbers. Specify 'latest' to use the latest version of an image - available at deploy time. Even if you use 'latest', the VM image will not automatically update - after deploy time even if a new version becomes available. - :paramtype version: str - :keyword shared_gallery_image_id: Specified the shared gallery image unique id for vm - deployment. This can be fetched from shared gallery image GET call. - :paramtype shared_gallery_image_id: str - """ - super().__init__(id=id, **kwargs) - self.publisher = publisher - self.offer = offer - self.sku = sku - self.version = version - self.exact_version: Optional[str] = None - self.shared_gallery_image_id = shared_gallery_image_id - - -class ImageStorageProfile(_serialization.Model): - """Describes a storage profile. - - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2021_07_01.models.ImageOSDisk - :ivar data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype data_disks: list[~azure.mgmt.compute.v2021_07_01.models.ImageDataDisk] - :ivar zone_resilient: Specifies whether an image is zone resilient or not. Default is false. - Zone resilient images can be created only in regions that provide Zone Redundant Storage (ZRS). - :vartype zone_resilient: bool - """ - - _attribute_map = { - "os_disk": {"key": "osDisk", "type": "ImageOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[ImageDataDisk]"}, - "zone_resilient": {"key": "zoneResilient", "type": "bool"}, - } - - def __init__( - self, - *, - os_disk: Optional["_models.ImageOSDisk"] = None, - data_disks: Optional[List["_models.ImageDataDisk"]] = None, - zone_resilient: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2021_07_01.models.ImageOSDisk - :keyword data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype data_disks: list[~azure.mgmt.compute.v2021_07_01.models.ImageDataDisk] - :keyword zone_resilient: Specifies whether an image is zone resilient or not. Default is false. - Zone resilient images can be created only in regions that provide Zone Redundant Storage (ZRS). - :paramtype zone_resilient: bool - """ - super().__init__(**kwargs) - self.os_disk = os_disk - self.data_disks = data_disks - self.zone_resilient = zone_resilient - - -class ImageUpdate(UpdateResource): - """The source user image virtual hard disk. Only tags may be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar source_virtual_machine: The source virtual machine from which Image is created. - :vartype source_virtual_machine: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2021_07_01.models.ImageStorageProfile - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str - :ivar hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created from - the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to - specify the value, if the source is managed resource like disk or snapshot, we may require the - user to specify the property if we cannot deduce it from the source managed resource. Known - values are: "V1" and "V2". - :vartype hyper_v_generation: str or - ~azure.mgmt.compute.v2021_07_01.models.HyperVGenerationTypes - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "source_virtual_machine": {"key": "properties.sourceVirtualMachine", "type": "SubResource"}, - "storage_profile": {"key": "properties.storageProfile", "type": "ImageStorageProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["_models.SubResource"] = None, - storage_profile: Optional["_models.ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword source_virtual_machine: The source virtual machine from which Image is created. - :paramtype source_virtual_machine: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2021_07_01.models.ImageStorageProfile - :keyword hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created - from the image. From API Version 2019-03-01 if the image source is a blob, then we need the - user to specify the value, if the source is managed resource like disk or snapshot, we may - require the user to specify the property if we cannot deduce it from the source managed - resource. Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2021_07_01.models.HyperVGenerationTypes - """ - super().__init__(tags=tags, **kwargs) - self.source_virtual_machine = source_virtual_machine - self.storage_profile = storage_profile - self.provisioning_state: Optional[str] = None - self.hyper_v_generation = hyper_v_generation - - -class InnerError(_serialization.Model): - """Inner error details. - - :ivar exceptiontype: The exception type. - :vartype exceptiontype: str - :ivar errordetail: The internal error message or exception dump. - :vartype errordetail: str - """ - - _attribute_map = { - "exceptiontype": {"key": "exceptiontype", "type": "str"}, - "errordetail": {"key": "errordetail", "type": "str"}, - } - - def __init__( - self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword exceptiontype: The exception type. - :paramtype exceptiontype: str - :keyword errordetail: The internal error message or exception dump. - :paramtype errordetail: str - """ - super().__init__(**kwargs) - self.exceptiontype = exceptiontype - self.errordetail = errordetail - - -class InstanceViewStatus(_serialization.Model): - """Instance view status. - - :ivar code: The status code. - :vartype code: str - :ivar level: The level code. Known values are: "Info", "Warning", and "Error". - :vartype level: str or ~azure.mgmt.compute.v2021_07_01.models.StatusLevelTypes - :ivar display_status: The short localizable label for the status. - :vartype display_status: str - :ivar message: The detailed status message, including for alerts and error messages. - :vartype message: str - :ivar time: The time of the status. - :vartype time: ~datetime.datetime - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "level": {"key": "level", "type": "str"}, - "display_status": {"key": "displayStatus", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "time": {"key": "time", "type": "iso-8601"}, - } - - def __init__( - self, - *, - code: Optional[str] = None, - level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, - display_status: Optional[str] = None, - message: Optional[str] = None, - time: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword code: The status code. - :paramtype code: str - :keyword level: The level code. Known values are: "Info", "Warning", and "Error". - :paramtype level: str or ~azure.mgmt.compute.v2021_07_01.models.StatusLevelTypes - :keyword display_status: The short localizable label for the status. - :paramtype display_status: str - :keyword message: The detailed status message, including for alerts and error messages. - :paramtype message: str - :keyword time: The time of the status. - :paramtype time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.code = code - self.level = level - self.display_status = display_status - self.message = message - self.time = time - - -class KeyVaultKeyReference(_serialization.Model): - """Describes a reference to Key Vault Key. - - All required parameters must be populated in order to send to server. - - :ivar key_url: The URL referencing a key encryption key in Key Vault. Required. - :vartype key_url: str - :ivar source_vault: The relative URL of the Key Vault containing the key. Required. - :vartype source_vault: ~azure.mgmt.compute.v2021_07_01.models.SubResource - """ - - _validation = { - "key_url": {"required": True}, - "source_vault": {"required": True}, - } - - _attribute_map = { - "key_url": {"key": "keyUrl", "type": "str"}, - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - } - - def __init__(self, *, key_url: str, source_vault: "_models.SubResource", **kwargs: Any) -> None: - """ - :keyword key_url: The URL referencing a key encryption key in Key Vault. Required. - :paramtype key_url: str - :keyword source_vault: The relative URL of the Key Vault containing the key. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2021_07_01.models.SubResource - """ - super().__init__(**kwargs) - self.key_url = key_url - self.source_vault = source_vault - - -class KeyVaultSecretReference(_serialization.Model): - """Describes a reference to Key Vault Secret. - - All required parameters must be populated in order to send to server. - - :ivar secret_url: The URL referencing a secret in a Key Vault. Required. - :vartype secret_url: str - :ivar source_vault: The relative URL of the Key Vault containing the secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2021_07_01.models.SubResource - """ - - _validation = { - "secret_url": {"required": True}, - "source_vault": {"required": True}, - } - - _attribute_map = { - "secret_url": {"key": "secretUrl", "type": "str"}, - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - } - - def __init__(self, *, secret_url: str, source_vault: "_models.SubResource", **kwargs: Any) -> None: - """ - :keyword secret_url: The URL referencing a secret in a Key Vault. Required. - :paramtype secret_url: str - :keyword source_vault: The relative URL of the Key Vault containing the secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2021_07_01.models.SubResource - """ - super().__init__(**kwargs) - self.secret_url = secret_url - self.source_vault = source_vault - - -class LastPatchInstallationSummary(_serialization.Model): - """Describes the properties of the last installed patch summary. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The overall success or failure status of the operation. It remains "InProgress" - until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", - and "CompletedWithWarnings". - :vartype status: str or ~azure.mgmt.compute.v2021_07_01.models.PatchOperationStatus - :ivar installation_activity_id: The activity ID of the operation that produced this result. It - is used to correlate across CRP and extension logs. - :vartype installation_activity_id: str - :ivar maintenance_window_exceeded: Describes whether the operation ran out of time before it - completed all its intended actions. - :vartype maintenance_window_exceeded: bool - :ivar not_selected_patch_count: The number of all available patches but not going to be - installed because it didn't match a classification or inclusion list entry. - :vartype not_selected_patch_count: int - :ivar excluded_patch_count: The number of all available patches but excluded explicitly by a - customer-specified exclusion list match. - :vartype excluded_patch_count: int - :ivar pending_patch_count: The number of all available patches expected to be installed over - the course of the patch installation operation. - :vartype pending_patch_count: int - :ivar installed_patch_count: The count of patches that successfully installed. - :vartype installed_patch_count: int - :ivar failed_patch_count: The count of patches that failed installation. - :vartype failed_patch_count: int - :ivar start_time: The UTC timestamp when the operation began. - :vartype start_time: ~datetime.datetime - :ivar last_modified_time: The UTC timestamp when the operation began. - :vartype last_modified_time: ~datetime.datetime - :ivar error: The errors that were encountered during execution of the operation. The details - array contains the list of them. - :vartype error: ~azure.mgmt.compute.v2021_07_01.models.ApiError - """ - - _validation = { - "status": {"readonly": True}, - "installation_activity_id": {"readonly": True}, - "maintenance_window_exceeded": {"readonly": True}, - "not_selected_patch_count": {"readonly": True}, - "excluded_patch_count": {"readonly": True}, - "pending_patch_count": {"readonly": True}, - "installed_patch_count": {"readonly": True}, - "failed_patch_count": {"readonly": True}, - "start_time": {"readonly": True}, - "last_modified_time": {"readonly": True}, - "error": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "installation_activity_id": {"key": "installationActivityId", "type": "str"}, - "maintenance_window_exceeded": {"key": "maintenanceWindowExceeded", "type": "bool"}, - "not_selected_patch_count": {"key": "notSelectedPatchCount", "type": "int"}, - "excluded_patch_count": {"key": "excludedPatchCount", "type": "int"}, - "pending_patch_count": {"key": "pendingPatchCount", "type": "int"}, - "installed_patch_count": {"key": "installedPatchCount", "type": "int"}, - "failed_patch_count": {"key": "failedPatchCount", "type": "int"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "last_modified_time": {"key": "lastModifiedTime", "type": "iso-8601"}, - "error": {"key": "error", "type": "ApiError"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional[Union[str, "_models.PatchOperationStatus"]] = None - self.installation_activity_id: Optional[str] = None - self.maintenance_window_exceeded: Optional[bool] = None - self.not_selected_patch_count: Optional[int] = None - self.excluded_patch_count: Optional[int] = None - self.pending_patch_count: Optional[int] = None - self.installed_patch_count: Optional[int] = None - self.failed_patch_count: Optional[int] = None - self.start_time: Optional[datetime.datetime] = None - self.last_modified_time: Optional[datetime.datetime] = None - self.error: Optional["_models.ApiError"] = None - - -class LinuxConfiguration(_serialization.Model): - """Specifies the Linux operating system settings on the virtual machine. :code:`
    `\\ - :code:`
    `For a list of supported Linux distributions, see `Linux on Azure-Endorsed - Distributions `_. - - :ivar disable_password_authentication: Specifies whether password authentication should be - disabled. - :vartype disable_password_authentication: bool - :ivar ssh: Specifies the ssh key configuration for a Linux OS. - :vartype ssh: ~azure.mgmt.compute.v2021_07_01.models.SshConfiguration - :ivar provision_vm_agent: Indicates whether virtual machine agent should be provisioned on the - virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the request - body, default behavior is to set it to true. This will ensure that VM Agent is installed on - the VM so that extensions can be added to the VM later. - :vartype provision_vm_agent: bool - :ivar patch_settings: [Preview Feature] Specifies settings related to VM Guest Patching on - Linux. - :vartype patch_settings: ~azure.mgmt.compute.v2021_07_01.models.LinuxPatchSettings - """ - - _attribute_map = { - "disable_password_authentication": {"key": "disablePasswordAuthentication", "type": "bool"}, - "ssh": {"key": "ssh", "type": "SshConfiguration"}, - "provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"}, - "patch_settings": {"key": "patchSettings", "type": "LinuxPatchSettings"}, - } - - def __init__( - self, - *, - disable_password_authentication: Optional[bool] = None, - ssh: Optional["_models.SshConfiguration"] = None, - provision_vm_agent: Optional[bool] = None, - patch_settings: Optional["_models.LinuxPatchSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword disable_password_authentication: Specifies whether password authentication should be - disabled. - :paramtype disable_password_authentication: bool - :keyword ssh: Specifies the ssh key configuration for a Linux OS. - :paramtype ssh: ~azure.mgmt.compute.v2021_07_01.models.SshConfiguration - :keyword provision_vm_agent: Indicates whether virtual machine agent should be provisioned on - the virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the - request body, default behavior is to set it to true. This will ensure that VM Agent is - installed on the VM so that extensions can be added to the VM later. - :paramtype provision_vm_agent: bool - :keyword patch_settings: [Preview Feature] Specifies settings related to VM Guest Patching on - Linux. - :paramtype patch_settings: ~azure.mgmt.compute.v2021_07_01.models.LinuxPatchSettings - """ - super().__init__(**kwargs) - self.disable_password_authentication = disable_password_authentication - self.ssh = ssh - self.provision_vm_agent = provision_vm_agent - self.patch_settings = patch_settings - - -class LinuxParameters(_serialization.Model): - """Input for InstallPatches on a Linux VM, as directly received by the API. - - :ivar classifications_to_include: The update classifications to select when installing patches - for Linux. - :vartype classifications_to_include: list[str or - ~azure.mgmt.compute.v2021_07_01.models.VMGuestPatchClassificationLinux] - :ivar package_name_masks_to_include: packages to include in the patch operation. Format: - packageName_packageVersion. - :vartype package_name_masks_to_include: list[str] - :ivar package_name_masks_to_exclude: packages to exclude in the patch operation. Format: - packageName_packageVersion. - :vartype package_name_masks_to_exclude: list[str] - :ivar maintenance_run_id: This is used as a maintenance run identifier for Auto VM Guest - Patching in Linux. - :vartype maintenance_run_id: str - """ - - _attribute_map = { - "classifications_to_include": {"key": "classificationsToInclude", "type": "[str]"}, - "package_name_masks_to_include": {"key": "packageNameMasksToInclude", "type": "[str]"}, - "package_name_masks_to_exclude": {"key": "packageNameMasksToExclude", "type": "[str]"}, - "maintenance_run_id": {"key": "maintenanceRunId", "type": "str"}, - } - - def __init__( - self, - *, - classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationLinux"]]] = None, - package_name_masks_to_include: Optional[List[str]] = None, - package_name_masks_to_exclude: Optional[List[str]] = None, - maintenance_run_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword classifications_to_include: The update classifications to select when installing - patches for Linux. - :paramtype classifications_to_include: list[str or - ~azure.mgmt.compute.v2021_07_01.models.VMGuestPatchClassificationLinux] - :keyword package_name_masks_to_include: packages to include in the patch operation. Format: - packageName_packageVersion. - :paramtype package_name_masks_to_include: list[str] - :keyword package_name_masks_to_exclude: packages to exclude in the patch operation. Format: - packageName_packageVersion. - :paramtype package_name_masks_to_exclude: list[str] - :keyword maintenance_run_id: This is used as a maintenance run identifier for Auto VM Guest - Patching in Linux. - :paramtype maintenance_run_id: str - """ - super().__init__(**kwargs) - self.classifications_to_include = classifications_to_include - self.package_name_masks_to_include = package_name_masks_to_include - self.package_name_masks_to_exclude = package_name_masks_to_exclude - self.maintenance_run_id = maintenance_run_id - - -class LinuxPatchSettings(_serialization.Model): - """Specifies settings related to VM Guest Patching on Linux. - - :ivar patch_mode: Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual - machines associated to virtual machine scale set with OrchestrationMode as Flexible.\\ - :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` - **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
    `\\ :code:`
    ` **AutomaticByPlatform** - The virtual machine will be automatically - updated by the platform. The property provisionVMAgent must be true. Known values are: - "ImageDefault" and "AutomaticByPlatform". - :vartype patch_mode: str or ~azure.mgmt.compute.v2021_07_01.models.LinuxVMGuestPatchMode - :ivar assessment_mode: Specifies the mode of VM Guest Patch Assessment for the IaaS virtual - machine.\\ :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **ImageDefault** - You control the timing of patch assessments on a virtual machine. - :code:`
    `\\ :code:`
    ` **AutomaticByPlatform** - The platform will trigger periodic - patch assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault" - and "AutomaticByPlatform". - :vartype assessment_mode: str or - ~azure.mgmt.compute.v2021_07_01.models.LinuxPatchAssessmentMode - """ - - _attribute_map = { - "patch_mode": {"key": "patchMode", "type": "str"}, - "assessment_mode": {"key": "assessmentMode", "type": "str"}, - } - - def __init__( - self, - *, - patch_mode: Optional[Union[str, "_models.LinuxVMGuestPatchMode"]] = None, - assessment_mode: Optional[Union[str, "_models.LinuxPatchAssessmentMode"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword patch_mode: Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual - machines associated to virtual machine scale set with OrchestrationMode as Flexible.\\ - :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` - **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
    `\\ :code:`
    ` **AutomaticByPlatform** - The virtual machine will be automatically - updated by the platform. The property provisionVMAgent must be true. Known values are: - "ImageDefault" and "AutomaticByPlatform". - :paramtype patch_mode: str or ~azure.mgmt.compute.v2021_07_01.models.LinuxVMGuestPatchMode - :keyword assessment_mode: Specifies the mode of VM Guest Patch Assessment for the IaaS virtual - machine.\\ :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **ImageDefault** - You control the timing of patch assessments on a virtual machine. - :code:`
    `\\ :code:`
    ` **AutomaticByPlatform** - The platform will trigger periodic - patch assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault" - and "AutomaticByPlatform". - :paramtype assessment_mode: str or - ~azure.mgmt.compute.v2021_07_01.models.LinuxPatchAssessmentMode - """ - super().__init__(**kwargs) - self.patch_mode = patch_mode - self.assessment_mode = assessment_mode - - -class ListUsagesResult(_serialization.Model): - """The List Usages operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of compute resource usages. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.Usage] - :ivar next_link: The URI to fetch the next page of compute resource usage information. Call - ListNext() with this to fetch the next page of compute resource usage information. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Usage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of compute resource usages. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.Usage] - :keyword next_link: The URI to fetch the next page of compute resource usage information. Call - ListNext() with this to fetch the next page of compute resource usage information. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class LogAnalyticsInputBase(_serialization.Model): - """Api input base class for LogAnalytics Api. - - All required parameters must be populated in order to send to server. - - :ivar blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api - writes output logs to. Required. - :vartype blob_container_sas_uri: str - :ivar from_time: From time of the query. Required. - :vartype from_time: ~datetime.datetime - :ivar to_time: To time of the query. Required. - :vartype to_time: ~datetime.datetime - :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. - :vartype group_by_throttle_policy: bool - :ivar group_by_operation_name: Group query result by Operation Name. - :vartype group_by_operation_name: bool - :ivar group_by_resource_name: Group query result by Resource Name. - :vartype group_by_resource_name: bool - :ivar group_by_client_application_id: Group query result by Client Application ID. - :vartype group_by_client_application_id: bool - :ivar group_by_user_agent: Group query result by User Agent. - :vartype group_by_user_agent: bool - """ - - _validation = { - "blob_container_sas_uri": {"required": True}, - "from_time": {"required": True}, - "to_time": {"required": True}, - } - - _attribute_map = { - "blob_container_sas_uri": {"key": "blobContainerSasUri", "type": "str"}, - "from_time": {"key": "fromTime", "type": "iso-8601"}, - "to_time": {"key": "toTime", "type": "iso-8601"}, - "group_by_throttle_policy": {"key": "groupByThrottlePolicy", "type": "bool"}, - "group_by_operation_name": {"key": "groupByOperationName", "type": "bool"}, - "group_by_resource_name": {"key": "groupByResourceName", "type": "bool"}, - "group_by_client_application_id": {"key": "groupByClientApplicationId", "type": "bool"}, - "group_by_user_agent": {"key": "groupByUserAgent", "type": "bool"}, - } - - def __init__( - self, - *, - blob_container_sas_uri: str, - from_time: datetime.datetime, - to_time: datetime.datetime, - group_by_throttle_policy: Optional[bool] = None, - group_by_operation_name: Optional[bool] = None, - group_by_resource_name: Optional[bool] = None, - group_by_client_application_id: Optional[bool] = None, - group_by_user_agent: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics - Api writes output logs to. Required. - :paramtype blob_container_sas_uri: str - :keyword from_time: From time of the query. Required. - :paramtype from_time: ~datetime.datetime - :keyword to_time: To time of the query. Required. - :paramtype to_time: ~datetime.datetime - :keyword group_by_throttle_policy: Group query result by Throttle Policy applied. - :paramtype group_by_throttle_policy: bool - :keyword group_by_operation_name: Group query result by Operation Name. - :paramtype group_by_operation_name: bool - :keyword group_by_resource_name: Group query result by Resource Name. - :paramtype group_by_resource_name: bool - :keyword group_by_client_application_id: Group query result by Client Application ID. - :paramtype group_by_client_application_id: bool - :keyword group_by_user_agent: Group query result by User Agent. - :paramtype group_by_user_agent: bool - """ - super().__init__(**kwargs) - self.blob_container_sas_uri = blob_container_sas_uri - self.from_time = from_time - self.to_time = to_time - self.group_by_throttle_policy = group_by_throttle_policy - self.group_by_operation_name = group_by_operation_name - self.group_by_resource_name = group_by_resource_name - self.group_by_client_application_id = group_by_client_application_id - self.group_by_user_agent = group_by_user_agent - - -class LogAnalyticsOperationResult(_serialization.Model): - """LogAnalytics operation status response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar properties: LogAnalyticsOutput. - :vartype properties: ~azure.mgmt.compute.v2021_07_01.models.LogAnalyticsOutput - """ - - _validation = { - "properties": {"readonly": True}, - } - - _attribute_map = { - "properties": {"key": "properties", "type": "LogAnalyticsOutput"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.properties: Optional["_models.LogAnalyticsOutput"] = None - - -class LogAnalyticsOutput(_serialization.Model): - """LogAnalytics output properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar output: Output file Uri path to blob container. - :vartype output: str - """ - - _validation = { - "output": {"readonly": True}, - } - - _attribute_map = { - "output": {"key": "output", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.output: Optional[str] = None - - -class MaintenanceRedeployStatus(_serialization.Model): - """Maintenance Operation Status. - - :ivar is_customer_initiated_maintenance_allowed: True, if customer is allowed to perform - Maintenance. - :vartype is_customer_initiated_maintenance_allowed: bool - :ivar pre_maintenance_window_start_time: Start Time for the Pre Maintenance Window. - :vartype pre_maintenance_window_start_time: ~datetime.datetime - :ivar pre_maintenance_window_end_time: End Time for the Pre Maintenance Window. - :vartype pre_maintenance_window_end_time: ~datetime.datetime - :ivar maintenance_window_start_time: Start Time for the Maintenance Window. - :vartype maintenance_window_start_time: ~datetime.datetime - :ivar maintenance_window_end_time: End Time for the Maintenance Window. - :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: - "None", "RetryLater", "MaintenanceAborted", and "MaintenanceCompleted". - :vartype last_operation_result_code: str or - ~azure.mgmt.compute.v2021_07_01.models.MaintenanceOperationResultCodeTypes - :ivar last_operation_message: Message returned for the last Maintenance Operation. - :vartype last_operation_message: str - """ - - _attribute_map = { - "is_customer_initiated_maintenance_allowed": {"key": "isCustomerInitiatedMaintenanceAllowed", "type": "bool"}, - "pre_maintenance_window_start_time": {"key": "preMaintenanceWindowStartTime", "type": "iso-8601"}, - "pre_maintenance_window_end_time": {"key": "preMaintenanceWindowEndTime", "type": "iso-8601"}, - "maintenance_window_start_time": {"key": "maintenanceWindowStartTime", "type": "iso-8601"}, - "maintenance_window_end_time": {"key": "maintenanceWindowEndTime", "type": "iso-8601"}, - "last_operation_result_code": {"key": "lastOperationResultCode", "type": "str"}, - "last_operation_message": {"key": "lastOperationMessage", "type": "str"}, - } - - def __init__( - self, - *, - is_customer_initiated_maintenance_allowed: Optional[bool] = None, - pre_maintenance_window_start_time: Optional[datetime.datetime] = None, - pre_maintenance_window_end_time: Optional[datetime.datetime] = None, - maintenance_window_start_time: Optional[datetime.datetime] = None, - maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, - last_operation_message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_customer_initiated_maintenance_allowed: True, if customer is allowed to perform - Maintenance. - :paramtype is_customer_initiated_maintenance_allowed: bool - :keyword pre_maintenance_window_start_time: Start Time for the Pre Maintenance Window. - :paramtype pre_maintenance_window_start_time: ~datetime.datetime - :keyword pre_maintenance_window_end_time: End Time for the Pre Maintenance Window. - :paramtype pre_maintenance_window_end_time: ~datetime.datetime - :keyword maintenance_window_start_time: Start Time for the Maintenance Window. - :paramtype maintenance_window_start_time: ~datetime.datetime - :keyword maintenance_window_end_time: End Time for the Maintenance Window. - :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values - are: "None", "RetryLater", "MaintenanceAborted", and "MaintenanceCompleted". - :paramtype last_operation_result_code: str or - ~azure.mgmt.compute.v2021_07_01.models.MaintenanceOperationResultCodeTypes - :keyword last_operation_message: Message returned for the last Maintenance Operation. - :paramtype last_operation_message: str - """ - super().__init__(**kwargs) - self.is_customer_initiated_maintenance_allowed = is_customer_initiated_maintenance_allowed - self.pre_maintenance_window_start_time = pre_maintenance_window_start_time - self.pre_maintenance_window_end_time = pre_maintenance_window_end_time - self.maintenance_window_start_time = maintenance_window_start_time - self.maintenance_window_end_time = maintenance_window_end_time - self.last_operation_result_code = last_operation_result_code - self.last_operation_message = last_operation_message - - -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 ManagedDiskParameters(SubResource): - """The parameters of a managed disk. - - :ivar id: Resource Id. - :vartype id: str - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", and - "StandardSSD_ZRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSetParameters - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", and - "StandardSSD_ZRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSetParameters - """ - super().__init__(id=id, **kwargs) - self.storage_account_type = storage_account_type - self.disk_encryption_set = disk_encryption_set - - -class NetworkInterfaceReference(SubResource): - """Describes a network interface reference. - - :ivar id: Resource Id. - :vartype id: str - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Known values are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "delete_option": {"key": "properties.deleteOption", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - primary: Optional[bool] = None, - delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Known values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions - """ - super().__init__(id=id, **kwargs) - self.primary = primary - self.delete_option = delete_option - - -class NetworkProfile(_serialization.Model): - """Specifies the network interfaces or the networking configuration of the virtual machine. - - :ivar network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the virtual machine. - :vartype network_interfaces: - list[~azure.mgmt.compute.v2021_07_01.models.NetworkInterfaceReference] - :ivar network_api_version: specifies the Microsoft.Network API version used when creating - networking resources in the Network Interface Configurations. "2020-11-01" - :vartype network_api_version: str or ~azure.mgmt.compute.v2021_07_01.models.NetworkApiVersion - :ivar network_interface_configurations: Specifies the networking configurations that will be - used to create the virtual machine networking resources. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineNetworkInterfaceConfiguration] - """ - - _attribute_map = { - "network_interfaces": {"key": "networkInterfaces", "type": "[NetworkInterfaceReference]"}, - "network_api_version": {"key": "networkApiVersion", "type": "str"}, - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineNetworkInterfaceConfiguration]", - }, - } - - def __init__( - self, - *, - network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, - network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, - network_interface_configurations: Optional[List["_models.VirtualMachineNetworkInterfaceConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the virtual machine. - :paramtype network_interfaces: - list[~azure.mgmt.compute.v2021_07_01.models.NetworkInterfaceReference] - :keyword network_api_version: specifies the Microsoft.Network API version used when creating - networking resources in the Network Interface Configurations. "2020-11-01" - :paramtype network_api_version: str or ~azure.mgmt.compute.v2021_07_01.models.NetworkApiVersion - :keyword network_interface_configurations: Specifies the networking configurations that will be - used to create the virtual machine networking resources. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineNetworkInterfaceConfiguration] - """ - super().__init__(**kwargs) - self.network_interfaces = network_interfaces - self.network_api_version = network_api_version - self.network_interface_configurations = network_interface_configurations - - -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. "AutomaticRepairs" - :vartype service_name: str or ~azure.mgmt.compute.v2021_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.v2021_07_01.models.OrchestrationServiceStateAction - """ - - _validation = { - "service_name": {"required": True}, - "action": {"required": True}, - } - - _attribute_map = { - "service_name": {"key": "serviceName", "type": "str"}, - "action": {"key": "action", "type": "str"}, - } - - def __init__( - self, - *, - service_name: Union[str, "_models.OrchestrationServiceNames"], - action: Union[str, "_models.OrchestrationServiceStateAction"], - **kwargs: Any - ) -> None: - """ - :keyword service_name: The name of the service. Required. "AutomaticRepairs" - :paramtype service_name: str or - ~azure.mgmt.compute.v2021_07_01.models.OrchestrationServiceNames - :keyword action: The action to be performed. Required. Known values are: "Resume" and - "Suspend". - :paramtype action: str or - ~azure.mgmt.compute.v2021_07_01.models.OrchestrationServiceStateAction - """ - super().__init__(**kwargs) - self.service_name = service_name - self.action = action - - -class OrchestrationServiceSummary(_serialization.Model): - """Summary for an orchestration service of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar service_name: The name of the service. "AutomaticRepairs" - :vartype service_name: str or ~azure.mgmt.compute.v2021_07_01.models.OrchestrationServiceNames - :ivar service_state: The current state of the service. Known values are: "NotRunning", - "Running", and "Suspended". - :vartype service_state: str or ~azure.mgmt.compute.v2021_07_01.models.OrchestrationServiceState - """ - - _validation = { - "service_name": {"readonly": True}, - "service_state": {"readonly": True}, - } - - _attribute_map = { - "service_name": {"key": "serviceName", "type": "str"}, - "service_state": {"key": "serviceState", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.service_name: Optional[Union[str, "_models.OrchestrationServiceNames"]] = None - self.service_state: Optional[Union[str, "_models.OrchestrationServiceState"]] = None - - -class OSDisk(_serialization.Model): - """Specifies information about the operating system disk used by the virtual machine. - :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and VHDs for - Azure virtual machines - `_. - - All required parameters must be populated in order to send to server. - - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :vartype encryption_settings: ~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSettings - :ivar name: The disk name. - :vartype name: str - :ivar vhd: The virtual hard disk. - :vartype vhd: ~azure.mgmt.compute.v2021_07_01.models.VirtualHardDisk - :ivar image: 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. - :vartype image: ~azure.mgmt.compute.v2021_07_01.models.VirtualHardDisk - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None** for - Standard storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar diff_disk_settings: Specifies the ephemeral Disk Settings for the operating system disk - used by the virtual machine. - :vartype diff_disk_settings: ~azure.mgmt.compute.v2021_07_01.models.DiffDiskSettings - :ivar create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: ~azure.mgmt.compute.v2021_07_01.models.ManagedDiskParameters - :ivar delete_option: Specifies whether OS Disk should be deleted or detached upon VM deletion. - :code:`
    `\\ :code:`
    ` Possible values: :code:`
    `\\ :code:`
    ` **Delete** If this - value is used, the OS disk is deleted when VM is deleted.\\ :code:`
    `\\ :code:`
    ` - **Detach** If this value is used, the os disk is retained after VM is deleted. :code:`
    `\\ - :code:`
    ` The default value is set to **detach**. For an ephemeral OS Disk, the default - value is set to **Delete**. User cannot change the delete option for ephemeral OS Disk. Known - values are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskDeleteOptionTypes - """ - - _validation = { - "create_option": {"required": True}, - } - - _attribute_map = { - "os_type": {"key": "osType", "type": "str"}, - "encryption_settings": {"key": "encryptionSettings", "type": "DiskEncryptionSettings"}, - "name": {"key": "name", "type": "str"}, - "vhd": {"key": "vhd", "type": "VirtualHardDisk"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "diff_disk_settings": {"key": "diffDiskSettings", "type": "DiffDiskSettings"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, - "delete_option": {"key": "deleteOption", "type": "str"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, - name: Optional[str] = None, - vhd: Optional["_models.VirtualHardDisk"] = None, - image: Optional["_models.VirtualHardDisk"] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.ManagedDiskParameters"] = None, - delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
    `\\ - :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype encryption_settings: ~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSettings - :keyword name: The disk name. - :paramtype name: str - :keyword vhd: The virtual hard disk. - :paramtype vhd: ~azure.mgmt.compute.v2021_07_01.models.VirtualHardDisk - :keyword image: 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. - :paramtype image: ~azure.mgmt.compute.v2021_07_01.models.VirtualHardDisk - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None** for - Standard storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword diff_disk_settings: Specifies the ephemeral Disk Settings for the operating system - disk used by the virtual machine. - :paramtype diff_disk_settings: ~azure.mgmt.compute.v2021_07_01.models.DiffDiskSettings - :keyword create_option: Specifies how the virtual machine should be created.\\ :code:`
    `\\ - :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Attach** \\u2013 This value - is used when you are using a specialized disk to create the virtual machine.\\ :code:`
    `\\ - :code:`
    ` **FromImage** \\u2013 This value is used when you are using an image to create the - virtual machine. If you are using a platform image, you also use the imageReference element - described above. If you are using a marketplace image, you also use the plan element - previously described. Required. Known values are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: ~azure.mgmt.compute.v2021_07_01.models.ManagedDiskParameters - :keyword delete_option: Specifies whether OS Disk should be deleted or detached upon VM - deletion. :code:`
    `\\ :code:`
    ` Possible values: :code:`
    `\\ :code:`
    ` **Delete** - If this value is used, the OS disk is deleted when VM is deleted.\\ :code:`
    `\\ :code:`
    ` - **Detach** If this value is used, the os disk is retained after VM is deleted. :code:`
    `\\ - :code:`
    ` The default value is set to **detach**. For an ephemeral OS Disk, the default - value is set to **Delete**. User cannot change the delete option for ephemeral OS Disk. Known - values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskDeleteOptionTypes - """ - super().__init__(**kwargs) - self.os_type = os_type - self.encryption_settings = encryption_settings - self.name = name - self.vhd = vhd - self.image = image - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.diff_disk_settings = diff_disk_settings - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - self.delete_option = delete_option - - -class OSDiskImage(_serialization.Model): - """Contains the os disk image information. - - All required parameters must be populated in order to send to server. - - :ivar operating_system: The operating system of the osDiskImage. Required. Known values are: - "Windows" and "Linux". - :vartype operating_system: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - """ - - _validation = { - "operating_system": {"required": True}, - } - - _attribute_map = { - "operating_system": {"key": "operatingSystem", "type": "str"}, - } - - def __init__(self, *, operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs: Any) -> None: - """ - :keyword operating_system: The operating system of the osDiskImage. Required. Known values are: - "Windows" and "Linux". - :paramtype operating_system: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - """ - super().__init__(**kwargs) - self.operating_system = operating_system - - -class OSDiskImageEncryption(DiskImageEncryption): - """Contains encryption settings for an OS disk image. - - :ivar disk_encryption_set_id: A relative URI containing the resource ID of the disk encryption - set. - :vartype disk_encryption_set_id: str - """ - - -class OSProfile(_serialization.Model): - """Specifies the operating system settings for the virtual machine. Some of the settings cannot be - changed once VM is provisioned. - - :ivar computer_name: Specifies the host OS name of the virtual machine. :code:`
    `\\ - :code:`
    ` This name cannot be updated after the VM is created. :code:`
    `\\ :code:`
    ` - **Max-length (Windows):** 15 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 - characters. :code:`
    `\\ :code:`
    ` For naming conventions and restrictions see `Azure - infrastructure services implementation guidelines - `_. - :vartype computer_name: str - :ivar admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` This property cannot be updated after the VM is created. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters. - :vartype admin_username: str - :ivar admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :vartype admin_password: str - :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` **Note: Do not pass any - secrets or passwords in customData property** :code:`
    `\\ :code:`
    ` This property cannot - be updated after the VM is created. :code:`
    `\\ :code:`
    ` customData is passed to the VM - to be saved as a file, for more information see `Custom Data on Azure VMs - `_ - :code:`
    `\\ :code:`
    ` For using cloud-init for your Linux VM, see `Using cloud-init to - customize a Linux VM during creation - `_. - :vartype custom_data: str - :ivar windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :vartype windows_configuration: ~azure.mgmt.compute.v2021_07_01.models.WindowsConfiguration - :ivar linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_. - :vartype linux_configuration: ~azure.mgmt.compute.v2021_07_01.models.LinuxConfiguration - :ivar secrets: Specifies set of certificates that should be installed onto the virtual machine. - To install certificates on a virtual machine it is recommended to use the `Azure Key Vault - virtual machine extension for Linux - `_ or the `Azure - Key Vault virtual machine extension for Windows - `_. - :vartype secrets: list[~azure.mgmt.compute.v2021_07_01.models.VaultSecretGroup] - :ivar allow_extension_operations: Specifies whether extension operations should be allowed on - the virtual machine. :code:`
    `\\ :code:`
    `This may only be set to False when no - extensions are present on the virtual machine. - :vartype allow_extension_operations: bool - :ivar require_guest_provision_signal: Specifies whether the guest provision signal is required - to infer provision success of the virtual machine. **Note: This property is for private - testing only, and all customers must not set the property to false.**. - :vartype require_guest_provision_signal: bool - """ - - _attribute_map = { - "computer_name": {"key": "computerName", "type": "str"}, - "admin_username": {"key": "adminUsername", "type": "str"}, - "admin_password": {"key": "adminPassword", "type": "str"}, - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - "allow_extension_operations": {"key": "allowExtensionOperations", "type": "bool"}, - "require_guest_provision_signal": {"key": "requireGuestProvisionSignal", "type": "bool"}, - } - - def __init__( - self, - *, - computer_name: Optional[str] = None, - admin_username: Optional[str] = None, - admin_password: Optional[str] = None, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - allow_extension_operations: Optional[bool] = None, - require_guest_provision_signal: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword computer_name: Specifies the host OS name of the virtual machine. :code:`
    `\\ - :code:`
    ` This name cannot be updated after the VM is created. :code:`
    `\\ :code:`
    ` - **Max-length (Windows):** 15 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 - characters. :code:`
    `\\ :code:`
    ` For naming conventions and restrictions see `Azure - infrastructure services implementation guidelines - `_. - :paramtype computer_name: str - :keyword admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` This property cannot be updated after the VM is created. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters. - :paramtype admin_username: str - :keyword admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :paramtype admin_password: str - :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` **Note: Do not pass any - secrets or passwords in customData property** :code:`
    `\\ :code:`
    ` This property cannot - be updated after the VM is created. :code:`
    `\\ :code:`
    ` customData is passed to the VM - to be saved as a file, for more information see `Custom Data on Azure VMs - `_ - :code:`
    `\\ :code:`
    ` For using cloud-init for your Linux VM, see `Using cloud-init to - customize a Linux VM during creation - `_. - :paramtype custom_data: str - :keyword windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :paramtype windows_configuration: ~azure.mgmt.compute.v2021_07_01.models.WindowsConfiguration - :keyword linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_. - :paramtype linux_configuration: ~azure.mgmt.compute.v2021_07_01.models.LinuxConfiguration - :keyword secrets: Specifies set of certificates that should be installed onto the virtual - machine. To install certificates on a virtual machine it is recommended to use the `Azure Key - Vault virtual machine extension for Linux - `_ or the `Azure - Key Vault virtual machine extension for Windows - `_. - :paramtype secrets: list[~azure.mgmt.compute.v2021_07_01.models.VaultSecretGroup] - :keyword allow_extension_operations: Specifies whether extension operations should be allowed - on the virtual machine. :code:`
    `\\ :code:`
    `This may only be set to False when no - extensions are present on the virtual machine. - :paramtype allow_extension_operations: bool - :keyword require_guest_provision_signal: Specifies whether the guest provision signal is - required to infer provision success of the virtual machine. **Note: This property is for - private testing only, and all customers must not set the property to false.**. - :paramtype require_guest_provision_signal: bool - """ - super().__init__(**kwargs) - self.computer_name = computer_name - self.admin_username = admin_username - self.admin_password = admin_password - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - self.allow_extension_operations = allow_extension_operations - self.require_guest_provision_signal = require_guest_provision_signal - - -class PatchInstallationDetail(_serialization.Model): - """Information about a specific patch that was encountered during an installation action. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar patch_id: A unique identifier for the patch. - :vartype patch_id: str - :ivar name: The friendly name of the patch. - :vartype name: str - :ivar version: The version string of the package. It may conform to Semantic Versioning. Only - applies to Linux. - :vartype version: str - :ivar kb_id: The KBID of the patch. Only applies to Windows patches. - :vartype kb_id: str - :ivar classifications: The classification(s) of the patch as provided by the patch publisher. - :vartype classifications: list[str] - :ivar installation_state: The state of the patch after the installation operation completed. - Known values are: "Unknown", "Installed", "Failed", "Excluded", "NotSelected", and "Pending". - :vartype installation_state: str or - ~azure.mgmt.compute.v2021_07_01.models.PatchInstallationState - """ - - _validation = { - "patch_id": {"readonly": True}, - "name": {"readonly": True}, - "version": {"readonly": True}, - "kb_id": {"readonly": True}, - "classifications": {"readonly": True}, - "installation_state": {"readonly": True}, - } - - _attribute_map = { - "patch_id": {"key": "patchId", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "version": {"key": "version", "type": "str"}, - "kb_id": {"key": "kbId", "type": "str"}, - "classifications": {"key": "classifications", "type": "[str]"}, - "installation_state": {"key": "installationState", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.patch_id: Optional[str] = None - self.name: Optional[str] = None - self.version: Optional[str] = None - self.kb_id: Optional[str] = None - self.classifications: Optional[List[str]] = None - self.installation_state: Optional[Union[str, "_models.PatchInstallationState"]] = None - - -class PatchSettings(_serialization.Model): - """Specifies settings related to VM Guest Patching on Windows. - - :ivar patch_mode: Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual - machines associated to virtual machine scale set with OrchestrationMode as Flexible.\\ - :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` - **Manual** - You control the application of patches to a virtual machine. You do this by - applying patches manually inside the VM. In this mode, automatic updates are disabled; the - property WindowsConfiguration.enableAutomaticUpdates must be false\\ :code:`
    `\\ - :code:`
    ` **AutomaticByOS** - The virtual machine will automatically be updated by the OS. - The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
    `\\ - :code:`
    ` **AutomaticByPlatform** - the virtual machine will automatically updated by the - platform. The properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must - be true. Known values are: "Manual", "AutomaticByOS", and "AutomaticByPlatform". - :vartype patch_mode: str or ~azure.mgmt.compute.v2021_07_01.models.WindowsVMGuestPatchMode - :ivar enable_hotpatching: Enables customers to patch their Azure VMs without requiring a - reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must - be set to 'AutomaticByPlatform'. - :vartype enable_hotpatching: bool - :ivar assessment_mode: Specifies the mode of VM Guest patch assessment for the IaaS virtual - machine.\\ :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **ImageDefault** - You control the timing of patch assessments on a virtual machine.\\ - :code:`
    `\\ :code:`
    ` **AutomaticByPlatform** - The platform will trigger periodic - patch assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault" - and "AutomaticByPlatform". - :vartype assessment_mode: str or - ~azure.mgmt.compute.v2021_07_01.models.WindowsPatchAssessmentMode - """ - - _attribute_map = { - "patch_mode": {"key": "patchMode", "type": "str"}, - "enable_hotpatching": {"key": "enableHotpatching", "type": "bool"}, - "assessment_mode": {"key": "assessmentMode", "type": "str"}, - } - - def __init__( - self, - *, - patch_mode: Optional[Union[str, "_models.WindowsVMGuestPatchMode"]] = None, - enable_hotpatching: Optional[bool] = None, - assessment_mode: Optional[Union[str, "_models.WindowsPatchAssessmentMode"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword patch_mode: Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual - machines associated to virtual machine scale set with OrchestrationMode as Flexible.\\ - :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` - **Manual** - You control the application of patches to a virtual machine. You do this by - applying patches manually inside the VM. In this mode, automatic updates are disabled; the - property WindowsConfiguration.enableAutomaticUpdates must be false\\ :code:`
    `\\ - :code:`
    ` **AutomaticByOS** - The virtual machine will automatically be updated by the OS. - The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
    `\\ - :code:`
    ` **AutomaticByPlatform** - the virtual machine will automatically updated by the - platform. The properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must - be true. Known values are: "Manual", "AutomaticByOS", and "AutomaticByPlatform". - :paramtype patch_mode: str or ~azure.mgmt.compute.v2021_07_01.models.WindowsVMGuestPatchMode - :keyword enable_hotpatching: Enables customers to patch their Azure VMs without requiring a - reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must - be set to 'AutomaticByPlatform'. - :paramtype enable_hotpatching: bool - :keyword assessment_mode: Specifies the mode of VM Guest patch assessment for the IaaS virtual - machine.\\ :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **ImageDefault** - You control the timing of patch assessments on a virtual machine.\\ - :code:`
    `\\ :code:`
    ` **AutomaticByPlatform** - The platform will trigger periodic - patch assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault" - and "AutomaticByPlatform". - :paramtype assessment_mode: str or - ~azure.mgmt.compute.v2021_07_01.models.WindowsPatchAssessmentMode - """ - super().__init__(**kwargs) - self.patch_mode = patch_mode - self.enable_hotpatching = enable_hotpatching - self.assessment_mode = assessment_mode - - -class PirResource(_serialization.Model): - """The Resource model definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.location: Optional[str] = None - - -class PirSharedGalleryResource(PirResource): - """Base information about the shared gallery resource in pir. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar unique_id: The unique id of this shared gallery. - :vartype unique_id: str - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - } - - 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 - """ - super().__init__(**kwargs) - self.unique_id = unique_id - - -class Plan(_serialization.Model): - """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 the marketplace - image that you want to use and then click **Want to deploy programmatically, Get Started ->**. - Enter any required information and then click **Save**. - - :ivar name: The plan ID. - :vartype name: str - :ivar publisher: The publisher ID. - :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. - :vartype product: str - :ivar promotion_code: The promotion code. - :vartype promotion_code: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - "promotion_code": {"key": "promotionCode", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - publisher: Optional[str] = None, - product: Optional[str] = None, - promotion_code: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The plan ID. - :paramtype name: str - :keyword publisher: The publisher ID. - :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. - :paramtype product: str - :keyword promotion_code: The promotion code. - :paramtype promotion_code: str - """ - super().__init__(**kwargs) - self.name = name - self.publisher = publisher - self.product = product - self.promotion_code = promotion_code - - -class ProximityPlacementGroup(Resource): - """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. - :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] - :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Standard** : - Co-locate resources within an Azure region or Availability Zone. :code:`
    `\\ :code:`
    ` - **Ultra** : For future use. Known values are: "Standard" and "Ultra". - :vartype proximity_placement_group_type: str or - ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroupType - :ivar virtual_machines: A list of references to all virtual machines in the proximity placement - group. - :vartype virtual_machines: - list[~azure.mgmt.compute.v2021_07_01.models.SubResourceWithColocationStatus] - :ivar virtual_machine_scale_sets: A list of references to all virtual machine scale sets in the - proximity placement group. - :vartype virtual_machine_scale_sets: - list[~azure.mgmt.compute.v2021_07_01.models.SubResourceWithColocationStatus] - :ivar availability_sets: A list of references to all availability sets in the proximity - placement group. - :vartype availability_sets: - list[~azure.mgmt.compute.v2021_07_01.models.SubResourceWithColocationStatus] - :ivar colocation_status: Describes colocation status of the Proximity Placement Group. - :vartype colocation_status: ~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "virtual_machines": {"readonly": True}, - "virtual_machine_scale_sets": {"readonly": True}, - "availability_sets": {"readonly": 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}"}, - "proximity_placement_group_type": {"key": "properties.proximityPlacementGroupType", "type": "str"}, - "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResourceWithColocationStatus]"}, - "virtual_machine_scale_sets": { - "key": "properties.virtualMachineScaleSets", - "type": "[SubResourceWithColocationStatus]", - }, - "availability_sets": {"key": "properties.availabilitySets", "type": "[SubResourceWithColocationStatus]"}, - "colocation_status": {"key": "properties.colocationStatus", "type": "InstanceViewStatus"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, - colocation_status: Optional["_models.InstanceViewStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Standard** : - Co-locate resources within an Azure region or Availability Zone. :code:`
    `\\ :code:`
    ` - **Ultra** : For future use. Known values are: "Standard" and "Ultra". - :paramtype proximity_placement_group_type: str or - ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroupType - :keyword colocation_status: Describes colocation status of the Proximity Placement Group. - :paramtype colocation_status: ~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus - """ - super().__init__(location=location, tags=tags, **kwargs) - self.proximity_placement_group_type = proximity_placement_group_type - self.virtual_machines: Optional[List["_models.SubResourceWithColocationStatus"]] = None - self.virtual_machine_scale_sets: Optional[List["_models.SubResourceWithColocationStatus"]] = None - self.availability_sets: Optional[List["_models.SubResourceWithColocationStatus"]] = None - self.colocation_status = colocation_status - - -class ProximityPlacementGroupListResult(_serialization.Model): - """The List Proximity Placement Group operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of proximity placement groups. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup] - :ivar next_link: The URI to fetch the next page of proximity placement groups. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ProximityPlacementGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of proximity placement groups. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup] - :keyword next_link: The URI to fetch the next page of proximity placement groups. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ProximityPlacementGroupUpdate(UpdateResource): - """Specifies information about the proximity placement group. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - -class ProxyResource(_serialization.Model): - """The resource model definition for an 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. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - - -class PublicIPAddressSku(_serialization.Model): - """Describes the public IP Sku. - - :ivar name: Specify public IP sku name. Known values are: "Basic" and "Standard". - :vartype name: str or ~azure.mgmt.compute.v2021_07_01.models.PublicIPAddressSkuName - :ivar tier: Specify public IP sku tier. Known values are: "Regional", "Global", and "Global". - :vartype tier: str or ~azure.mgmt.compute.v2021_07_01.models.PublicIPAddressSkuTier - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[Union[str, "_models.PublicIPAddressSkuName"]] = None, - tier: Optional[Union[str, "_models.PublicIPAddressSkuTier"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Specify public IP sku name. Known values are: "Basic" and "Standard". - :paramtype name: str or ~azure.mgmt.compute.v2021_07_01.models.PublicIPAddressSkuName - :keyword tier: Specify public IP sku tier. Known values are: "Regional", "Global", and - "Global". - :paramtype tier: str or ~azure.mgmt.compute.v2021_07_01.models.PublicIPAddressSkuTier - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - - -class PurchasePlan(_serialization.Model): - """Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. - - All required parameters must be populated in order to send to server. - - :ivar publisher: The publisher ID. Required. - :vartype publisher: str - :ivar name: The plan ID. Required. - :vartype name: 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 - """ - - _validation = { - "publisher": {"required": True}, - "name": {"required": True}, - "product": {"required": True}, - } - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "product": {"key": "product", "type": "str"}, - } - - def __init__(self, *, publisher: str, name: str, product: str, **kwargs: Any) -> None: - """ - :keyword publisher: The publisher ID. Required. - :paramtype publisher: str - :keyword name: The plan ID. Required. - :paramtype name: 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 - """ - super().__init__(**kwargs) - self.publisher = publisher - self.name = name - self.product = product - - -class RecommendedMachineConfiguration(_serialization.Model): - """The properties describe the recommended machine configuration for this Image Definition. These - properties are updatable. - - :ivar v_cp_us: Describes the resource range. - :vartype v_cp_us: ~azure.mgmt.compute.v2021_07_01.models.ResourceRange - :ivar memory: Describes the resource range. - :vartype memory: ~azure.mgmt.compute.v2021_07_01.models.ResourceRange - """ - - _attribute_map = { - "v_cp_us": {"key": "vCPUs", "type": "ResourceRange"}, - "memory": {"key": "memory", "type": "ResourceRange"}, - } - - def __init__( - self, - *, - v_cp_us: Optional["_models.ResourceRange"] = None, - memory: Optional["_models.ResourceRange"] = None, - **kwargs: Any - ) -> None: - """ - :keyword v_cp_us: Describes the resource range. - :paramtype v_cp_us: ~azure.mgmt.compute.v2021_07_01.models.ResourceRange - :keyword memory: Describes the resource range. - :paramtype memory: ~azure.mgmt.compute.v2021_07_01.models.ResourceRange - """ - super().__init__(**kwargs) - self.v_cp_us = v_cp_us - self.memory = memory - - -class RecoveryWalkResponse(_serialization.Model): - """Response after calling a manual recovery walk. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar walk_performed: Whether the recovery walk was performed. - :vartype walk_performed: bool - :ivar next_platform_update_domain: The next update domain that needs to be walked. Null means - walk spanning all update domains has been completed. - :vartype next_platform_update_domain: int - """ - - _validation = { - "walk_performed": {"readonly": True}, - "next_platform_update_domain": {"readonly": True}, - } - - _attribute_map = { - "walk_performed": {"key": "walkPerformed", "type": "bool"}, - "next_platform_update_domain": {"key": "nextPlatformUpdateDomain", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.walk_performed: Optional[bool] = None - self.next_platform_update_domain: Optional[int] = None - - -class RegionalReplicationStatus(_serialization.Model): - """This is the regional replication status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar region: The region to which the gallery image version is being replicated to. - :vartype region: str - :ivar state: This is the regional replication state. Known values are: "Unknown", - "Replicating", "Completed", and "Failed". - :vartype state: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationState - :ivar details: The details of the replication status. - :vartype details: str - :ivar progress: It indicates progress of the replication job. - :vartype progress: int - """ - - _validation = { - "region": {"readonly": True}, - "state": {"readonly": True}, - "details": {"readonly": True}, - "progress": {"readonly": True}, - } - - _attribute_map = { - "region": {"key": "region", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "details": {"key": "details", "type": "str"}, - "progress": {"key": "progress", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.region: Optional[str] = None - self.state: Optional[Union[str, "_models.ReplicationState"]] = None - self.details: Optional[str] = None - self.progress: Optional[int] = None - - -class ReplicationStatus(_serialization.Model): - """This is the replication status of the gallery image version. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar aggregated_state: This is the aggregated replication status based on all the regional - replication status flags. Known values are: "Unknown", "InProgress", "Completed", and "Failed". - :vartype aggregated_state: str or - ~azure.mgmt.compute.v2021_07_01.models.AggregatedReplicationState - :ivar summary: This is a summary of replication status for each region. - :vartype summary: list[~azure.mgmt.compute.v2021_07_01.models.RegionalReplicationStatus] - """ - - _validation = { - "aggregated_state": {"readonly": True}, - "summary": {"readonly": True}, - } - - _attribute_map = { - "aggregated_state": {"key": "aggregatedState", "type": "str"}, - "summary": {"key": "summary", "type": "[RegionalReplicationStatus]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.aggregated_state: Optional[Union[str, "_models.AggregatedReplicationState"]] = None - self.summary: Optional[List["_models.RegionalReplicationStatus"]] = None - - -class RequestRateByIntervalInput(LogAnalyticsInputBase): - """Api request input for LogAnalytics getRequestRateByInterval Api. - - All required parameters must be populated in order to send to server. - - :ivar blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api - writes output logs to. Required. - :vartype blob_container_sas_uri: str - :ivar from_time: From time of the query. Required. - :vartype from_time: ~datetime.datetime - :ivar to_time: To time of the query. Required. - :vartype to_time: ~datetime.datetime - :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. - :vartype group_by_throttle_policy: bool - :ivar group_by_operation_name: Group query result by Operation Name. - :vartype group_by_operation_name: bool - :ivar group_by_resource_name: Group query result by Resource Name. - :vartype group_by_resource_name: bool - :ivar group_by_client_application_id: Group query result by Client Application ID. - :vartype group_by_client_application_id: bool - :ivar group_by_user_agent: Group query result by User Agent. - :vartype group_by_user_agent: bool - :ivar interval_length: Interval value in minutes used to create LogAnalytics call rate logs. - Required. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", and "SixtyMins". - :vartype interval_length: str or ~azure.mgmt.compute.v2021_07_01.models.IntervalInMins - """ - - _validation = { - "blob_container_sas_uri": {"required": True}, - "from_time": {"required": True}, - "to_time": {"required": True}, - "interval_length": {"required": True}, - } - - _attribute_map = { - "blob_container_sas_uri": {"key": "blobContainerSasUri", "type": "str"}, - "from_time": {"key": "fromTime", "type": "iso-8601"}, - "to_time": {"key": "toTime", "type": "iso-8601"}, - "group_by_throttle_policy": {"key": "groupByThrottlePolicy", "type": "bool"}, - "group_by_operation_name": {"key": "groupByOperationName", "type": "bool"}, - "group_by_resource_name": {"key": "groupByResourceName", "type": "bool"}, - "group_by_client_application_id": {"key": "groupByClientApplicationId", "type": "bool"}, - "group_by_user_agent": {"key": "groupByUserAgent", "type": "bool"}, - "interval_length": {"key": "intervalLength", "type": "str"}, - } - - def __init__( - self, - *, - blob_container_sas_uri: str, - from_time: datetime.datetime, - to_time: datetime.datetime, - interval_length: Union[str, "_models.IntervalInMins"], - group_by_throttle_policy: Optional[bool] = None, - group_by_operation_name: Optional[bool] = None, - group_by_resource_name: Optional[bool] = None, - group_by_client_application_id: Optional[bool] = None, - group_by_user_agent: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics - Api writes output logs to. Required. - :paramtype blob_container_sas_uri: str - :keyword from_time: From time of the query. Required. - :paramtype from_time: ~datetime.datetime - :keyword to_time: To time of the query. Required. - :paramtype to_time: ~datetime.datetime - :keyword group_by_throttle_policy: Group query result by Throttle Policy applied. - :paramtype group_by_throttle_policy: bool - :keyword group_by_operation_name: Group query result by Operation Name. - :paramtype group_by_operation_name: bool - :keyword group_by_resource_name: Group query result by Resource Name. - :paramtype group_by_resource_name: bool - :keyword group_by_client_application_id: Group query result by Client Application ID. - :paramtype group_by_client_application_id: bool - :keyword group_by_user_agent: Group query result by User Agent. - :paramtype group_by_user_agent: bool - :keyword interval_length: Interval value in minutes used to create LogAnalytics call rate logs. - Required. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", and "SixtyMins". - :paramtype interval_length: str or ~azure.mgmt.compute.v2021_07_01.models.IntervalInMins - """ - super().__init__( - blob_container_sas_uri=blob_container_sas_uri, - from_time=from_time, - to_time=to_time, - group_by_throttle_policy=group_by_throttle_policy, - group_by_operation_name=group_by_operation_name, - group_by_resource_name=group_by_resource_name, - group_by_client_application_id=group_by_client_application_id, - group_by_user_agent=group_by_user_agent, - **kwargs - ) - self.interval_length = interval_length - - -class ResourceRange(_serialization.Model): - """Describes the resource range. - - :ivar min: The minimum number of the resource. - :vartype min: int - :ivar max: The maximum number of the resource. - :vartype max: int - """ - - _attribute_map = { - "min": {"key": "min", "type": "int"}, - "max": {"key": "max", "type": "int"}, - } - - def __init__( - self, - *, - min: Optional[int] = None, # pylint: disable=redefined-builtin - max: Optional[int] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword min: The minimum number of the resource. - :paramtype min: int - :keyword max: The maximum number of the resource. - :paramtype max: int - """ - super().__init__(**kwargs) - self.min = min - self.max = max - - -class ResourceSku(_serialization.Model): - """Describes an available Compute SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of resource the SKU applies to. - :vartype resource_type: str - :ivar name: The name of SKU. - :vartype name: str - :ivar tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
    `\\ - :code:`
    ` Possible Values:\\ :code:`
    `\\ :code:`
    ` **Standard**\\ :code:`
    `\\ :code:`
    ` **Basic**. - :vartype tier: str - :ivar size: The Size of the SKU. - :vartype size: str - :ivar family: The Family of this particular SKU. - :vartype family: str - :ivar kind: The Kind of resources that are supported in this SKU. - :vartype kind: str - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: ~azure.mgmt.compute.v2021_07_01.models.ResourceSkuCapacity - :ivar locations: The set of locations that the SKU is available. - :vartype locations: list[str] - :ivar location_info: A list of locations and availability zones in those locations where the - SKU is available. - :vartype location_info: list[~azure.mgmt.compute.v2021_07_01.models.ResourceSkuLocationInfo] - :ivar api_versions: The api versions that support this SKU. - :vartype api_versions: list[str] - :ivar costs: Metadata for retrieving price info. - :vartype costs: list[~azure.mgmt.compute.v2021_07_01.models.ResourceSkuCosts] - :ivar capabilities: A name value pair to describe the capability. - :vartype capabilities: list[~azure.mgmt.compute.v2021_07_01.models.ResourceSkuCapabilities] - :ivar restrictions: The restrictions because of which SKU cannot be used. This is empty if - there are no restrictions. - :vartype restrictions: list[~azure.mgmt.compute.v2021_07_01.models.ResourceSkuRestrictions] - """ - - _validation = { - "resource_type": {"readonly": True}, - "name": {"readonly": True}, - "tier": {"readonly": True}, - "size": {"readonly": True}, - "family": {"readonly": True}, - "kind": {"readonly": True}, - "capacity": {"readonly": True}, - "locations": {"readonly": True}, - "location_info": {"readonly": True}, - "api_versions": {"readonly": True}, - "costs": {"readonly": True}, - "capabilities": {"readonly": True}, - "restrictions": {"readonly": True}, - } - - _attribute_map = { - "resource_type": {"key": "resourceType", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "size": {"key": "size", "type": "str"}, - "family": {"key": "family", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "capacity": {"key": "capacity", "type": "ResourceSkuCapacity"}, - "locations": {"key": "locations", "type": "[str]"}, - "location_info": {"key": "locationInfo", "type": "[ResourceSkuLocationInfo]"}, - "api_versions": {"key": "apiVersions", "type": "[str]"}, - "costs": {"key": "costs", "type": "[ResourceSkuCosts]"}, - "capabilities": {"key": "capabilities", "type": "[ResourceSkuCapabilities]"}, - "restrictions": {"key": "restrictions", "type": "[ResourceSkuRestrictions]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_type: Optional[str] = None - self.name: Optional[str] = None - self.tier: Optional[str] = None - self.size: Optional[str] = None - self.family: Optional[str] = None - self.kind: Optional[str] = None - self.capacity: Optional["_models.ResourceSkuCapacity"] = None - self.locations: Optional[List[str]] = None - self.location_info: Optional[List["_models.ResourceSkuLocationInfo"]] = None - self.api_versions: Optional[List[str]] = None - self.costs: Optional[List["_models.ResourceSkuCosts"]] = None - self.capabilities: Optional[List["_models.ResourceSkuCapabilities"]] = None - self.restrictions: Optional[List["_models.ResourceSkuRestrictions"]] = None - - -class ResourceSkuCapabilities(_serialization.Model): - """Describes The SKU capabilities object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: An invariant to describe the feature. - :vartype name: str - :ivar value: An invariant if the feature is measured by quantity. - :vartype value: str - """ - - _validation = { - "name": {"readonly": True}, - "value": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.value: Optional[str] = None - - -class ResourceSkuCapacity(_serialization.Model): - """Describes scaling information of a SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar minimum: The minimum capacity. - :vartype minimum: int - :ivar maximum: The maximum capacity that can be set. - :vartype maximum: int - :ivar default: The default capacity. - :vartype default: int - :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", - "Manual", and "None". - :vartype scale_type: str or ~azure.mgmt.compute.v2021_07_01.models.ResourceSkuCapacityScaleType - """ - - _validation = { - "minimum": {"readonly": True}, - "maximum": {"readonly": True}, - "default": {"readonly": True}, - "scale_type": {"readonly": True}, - } - - _attribute_map = { - "minimum": {"key": "minimum", "type": "int"}, - "maximum": {"key": "maximum", "type": "int"}, - "default": {"key": "default", "type": "int"}, - "scale_type": {"key": "scaleType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.minimum: Optional[int] = None - self.maximum: Optional[int] = None - self.default: Optional[int] = None - self.scale_type: Optional[Union[str, "_models.ResourceSkuCapacityScaleType"]] = None - - -class ResourceSkuCosts(_serialization.Model): - """Describes metadata for retrieving price info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar meter_id: Used for querying price from commerce. - :vartype meter_id: str - :ivar quantity: The multiplier is needed to extend the base metered cost. - :vartype quantity: int - :ivar extended_unit: An invariant to show the extended unit. - :vartype extended_unit: str - """ - - _validation = { - "meter_id": {"readonly": True}, - "quantity": {"readonly": True}, - "extended_unit": {"readonly": True}, - } - - _attribute_map = { - "meter_id": {"key": "meterID", "type": "str"}, - "quantity": {"key": "quantity", "type": "int"}, - "extended_unit": {"key": "extendedUnit", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.meter_id: Optional[str] = None - self.quantity: Optional[int] = None - self.extended_unit: Optional[str] = None - - -class ResourceSkuLocationInfo(_serialization.Model): - """Describes an available Compute SKU Location Information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: Location of the SKU. - :vartype location: str - :ivar zones: List of availability zones where the SKU is supported. - :vartype zones: list[str] - :ivar zone_details: Details of capabilities available to a SKU in specific zones. - :vartype zone_details: list[~azure.mgmt.compute.v2021_07_01.models.ResourceSkuZoneDetails] - :ivar extended_locations: The names of extended locations. - :vartype extended_locations: list[str] - :ivar type: The type of the extended location. "EdgeZone" - :vartype type: str or ~azure.mgmt.compute.v2021_07_01.models.ExtendedLocationType - """ - - _validation = { - "location": {"readonly": True}, - "zones": {"readonly": True}, - "zone_details": {"readonly": True}, - "extended_locations": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "zones": {"key": "zones", "type": "[str]"}, - "zone_details": {"key": "zoneDetails", "type": "[ResourceSkuZoneDetails]"}, - "extended_locations": {"key": "extendedLocations", "type": "[str]"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.location: Optional[str] = None - self.zones: Optional[List[str]] = None - self.zone_details: Optional[List["_models.ResourceSkuZoneDetails"]] = None - self.extended_locations: Optional[List[str]] = None - self.type: Optional[Union[str, "_models.ExtendedLocationType"]] = None - - -class ResourceSkuRestrictionInfo(_serialization.Model): - """Describes an available Compute SKU Restriction Information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar locations: Locations where the SKU is restricted. - :vartype locations: list[str] - :ivar zones: List of availability zones where the SKU is restricted. - :vartype zones: list[str] - """ - - _validation = { - "locations": {"readonly": True}, - "zones": {"readonly": True}, - } - - _attribute_map = { - "locations": {"key": "locations", "type": "[str]"}, - "zones": {"key": "zones", "type": "[str]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.locations: Optional[List[str]] = None - self.zones: Optional[List[str]] = None - - -class ResourceSkuRestrictions(_serialization.Model): - """Describes scaling information of a SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of restrictions. Known values are: "Location" and "Zone". - :vartype type: str or ~azure.mgmt.compute.v2021_07_01.models.ResourceSkuRestrictionsType - :ivar values: The value of restrictions. If the restriction type is set to location. This would - be different locations where the SKU is restricted. - :vartype values: list[str] - :ivar restriction_info: The information about the restriction where the SKU cannot be used. - :vartype restriction_info: ~azure.mgmt.compute.v2021_07_01.models.ResourceSkuRestrictionInfo - :ivar reason_code: The reason for restriction. Known values are: "QuotaId" and - "NotAvailableForSubscription". - :vartype reason_code: str or - ~azure.mgmt.compute.v2021_07_01.models.ResourceSkuRestrictionsReasonCode - """ - - _validation = { - "type": {"readonly": True}, - "values": {"readonly": True}, - "restriction_info": {"readonly": True}, - "reason_code": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "values": {"key": "values", "type": "[str]"}, - "restriction_info": {"key": "restrictionInfo", "type": "ResourceSkuRestrictionInfo"}, - "reason_code": {"key": "reasonCode", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[Union[str, "_models.ResourceSkuRestrictionsType"]] = None - self.values: Optional[List[str]] = None - self.restriction_info: Optional["_models.ResourceSkuRestrictionInfo"] = None - self.reason_code: Optional[Union[str, "_models.ResourceSkuRestrictionsReasonCode"]] = None - - -class ResourceSkusResult(_serialization.Model): - """The List Resource Skus operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The ResourceSku items on this page. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.ResourceSku] - :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": "[ResourceSku]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.ResourceSku"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The ResourceSku items on this page. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.ResourceSku] - :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 ResourceSkuZoneDetails(_serialization.Model): - """Describes The zonal capabilities of a SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The set of zones that the SKU is available in with the specified capabilities. - :vartype name: list[str] - :ivar capabilities: A list of capabilities that are available for the SKU in the specified list - of zones. - :vartype capabilities: list[~azure.mgmt.compute.v2021_07_01.models.ResourceSkuCapabilities] - """ - - _validation = { - "name": {"readonly": True}, - "capabilities": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "[str]"}, - "capabilities": {"key": "capabilities", "type": "[ResourceSkuCapabilities]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[List[str]] = None - self.capabilities: Optional[List["_models.ResourceSkuCapabilities"]] = None - - -class RestorePoint(ProxyResource): - """Restore Point details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :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.v2021_07_01.models.ApiEntityReference] - :ivar source_metadata: Gets the details of the VM captured at the time of the restore point - creation. - :vartype source_metadata: ~azure.mgmt.compute.v2021_07_01.models.RestorePointSourceMetadata - :ivar provisioning_state: Gets the provisioning state of the restore point. - :vartype provisioning_state: str - :ivar consistency_mode: Gets the consistency mode for the restore point. Please refer to - https://aka.ms/RestorePoints for more details. Known values are: "CrashConsistent", - "FileSystemConsistent", and "ApplicationConsistent". - :vartype consistency_mode: str or ~azure.mgmt.compute.v2021_07_01.models.ConsistencyModeTypes - :ivar time_created: Gets the creation time of the restore point. - :vartype time_created: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "source_metadata": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "consistency_mode": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "exclude_disks": {"key": "properties.excludeDisks", "type": "[ApiEntityReference]"}, - "source_metadata": {"key": "properties.sourceMetadata", "type": "RestorePointSourceMetadata"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "consistency_mode": {"key": "properties.consistencyMode", "type": "str"}, - "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, - } - - def __init__( - self, - *, - exclude_disks: Optional[List["_models.ApiEntityReference"]] = None, - time_created: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword 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. - :paramtype exclude_disks: list[~azure.mgmt.compute.v2021_07_01.models.ApiEntityReference] - :keyword time_created: Gets the creation time of the restore point. - :paramtype time_created: ~datetime.datetime - """ - super().__init__(**kwargs) - self.exclude_disks = exclude_disks - self.source_metadata: Optional["_models.RestorePointSourceMetadata"] = None - self.provisioning_state: Optional[str] = None - self.consistency_mode: Optional[Union[str, "_models.ConsistencyModeTypes"]] = None - self.time_created = time_created - - -class RestorePointCollection(Resource): - """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. - :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] - :ivar source: The properties of the source resource that this restore point collection is - created from. - :vartype source: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollectionSourceProperties - :ivar provisioning_state: The provisioning state of the restore point collection. - :vartype provisioning_state: str - :ivar restore_point_collection_id: The unique id of the restore point collection. - :vartype restore_point_collection_id: str - :ivar restore_points: A list containing all restore points created under this restore point - collection. - :vartype restore_points: list[~azure.mgmt.compute.v2021_07_01.models.RestorePoint] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "restore_point_collection_id": {"readonly": True}, - "restore_points": {"readonly": 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}"}, - "source": {"key": "properties.source", "type": "RestorePointCollectionSourceProperties"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "restore_point_collection_id": {"key": "properties.restorePointCollectionId", "type": "str"}, - "restore_points": {"key": "properties.restorePoints", "type": "[RestorePoint]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - source: Optional["_models.RestorePointCollectionSourceProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword source: The properties of the source resource that this restore point collection is - created from. - :paramtype source: - ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollectionSourceProperties - """ - super().__init__(location=location, tags=tags, **kwargs) - self.source = source - self.provisioning_state: Optional[str] = None - self.restore_point_collection_id: Optional[str] = None - self.restore_points: Optional[List["_models.RestorePoint"]] = None - - -class RestorePointCollectionListResult(_serialization.Model): - """The List restore point collection operation response. - - :ivar value: Gets the list of restore point collections. - :vartype value: list[~azure.mgmt.compute.v2021_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 - """ - - _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 - ) -> None: - """ - :keyword value: Gets the list of restore point collections. - :paramtype value: list[~azure.mgmt.compute.v2021_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RestorePointCollectionSourceProperties(_serialization.Model): - """The properties of the source resource that this restore point collection is created from. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: Location of the source resource used to create this restore point collection. - :vartype location: str - :ivar id: Resource Id of the source resource used to create this restore point collection. - :vartype id: str - """ - - _validation = { - "location": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id of the source resource used to create this restore point collection. - :paramtype id: str - """ - super().__init__(**kwargs) - self.location: Optional[str] = None - self.id = id - - -class RestorePointCollectionUpdate(UpdateResource): - """Update Restore Point collection parameters. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar source: The properties of the source resource that this restore point collection is - created from. - :vartype source: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollectionSourceProperties - :ivar provisioning_state: The provisioning state of the restore point collection. - :vartype provisioning_state: str - :ivar restore_point_collection_id: The unique id of the restore point collection. - :vartype restore_point_collection_id: str - :ivar restore_points: A list containing all restore points created under this restore point - collection. - :vartype restore_points: list[~azure.mgmt.compute.v2021_07_01.models.RestorePoint] - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "restore_point_collection_id": {"readonly": True}, - "restore_points": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "source": {"key": "properties.source", "type": "RestorePointCollectionSourceProperties"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "restore_point_collection_id": {"key": "properties.restorePointCollectionId", "type": "str"}, - "restore_points": {"key": "properties.restorePoints", "type": "[RestorePoint]"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - source: Optional["_models.RestorePointCollectionSourceProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword source: The properties of the source resource that this restore point collection is - created from. - :paramtype source: - ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollectionSourceProperties - """ - super().__init__(tags=tags, **kwargs) - self.source = source - self.provisioning_state: Optional[str] = None - self.restore_point_collection_id: Optional[str] = None - self.restore_points: Optional[List["_models.RestorePoint"]] = None - - -class RestorePointSourceMetadata(_serialization.Model): - """Describes the properties of the Virtual Machine for which the restore point was created. The - properties provided are a subset and the snapshot of the overall Virtual Machine properties - captured at the time of the restore point creation. - - :ivar hardware_profile: Gets the hardware profile. - :vartype hardware_profile: ~azure.mgmt.compute.v2021_07_01.models.HardwareProfile - :ivar storage_profile: Gets the storage profile. - :vartype storage_profile: - ~azure.mgmt.compute.v2021_07_01.models.RestorePointSourceVMStorageProfile - :ivar os_profile: Gets the OS profile. - :vartype os_profile: ~azure.mgmt.compute.v2021_07_01.models.OSProfile - :ivar diagnostics_profile: Gets the diagnostics profile. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2021_07_01.models.DiagnosticsProfile - :ivar license_type: Gets the license type, which is for bring your own license scenario. - :vartype license_type: str - :ivar vm_id: Gets the virtual machine unique id. - :vartype vm_id: str - :ivar security_profile: Gets the security profile. - :vartype security_profile: ~azure.mgmt.compute.v2021_07_01.models.SecurityProfile - :ivar location: Location of the VM from which the restore point was created. - :vartype location: str - """ - - _attribute_map = { - "hardware_profile": {"key": "hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "storageProfile", "type": "RestorePointSourceVMStorageProfile"}, - "os_profile": {"key": "osProfile", "type": "OSProfile"}, - "diagnostics_profile": {"key": "diagnosticsProfile", "type": "DiagnosticsProfile"}, - "license_type": {"key": "licenseType", "type": "str"}, - "vm_id": {"key": "vmId", "type": "str"}, - "security_profile": {"key": "securityProfile", "type": "SecurityProfile"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__( - self, - *, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.RestorePointSourceVMStorageProfile"] = None, - os_profile: Optional["_models.OSProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - license_type: Optional[str] = None, - vm_id: Optional[str] = None, - security_profile: Optional["_models.SecurityProfile"] = None, - location: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword hardware_profile: Gets the hardware profile. - :paramtype hardware_profile: ~azure.mgmt.compute.v2021_07_01.models.HardwareProfile - :keyword storage_profile: Gets the storage profile. - :paramtype storage_profile: - ~azure.mgmt.compute.v2021_07_01.models.RestorePointSourceVMStorageProfile - :keyword os_profile: Gets the OS profile. - :paramtype os_profile: ~azure.mgmt.compute.v2021_07_01.models.OSProfile - :keyword diagnostics_profile: Gets the diagnostics profile. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2021_07_01.models.DiagnosticsProfile - :keyword license_type: Gets the license type, which is for bring your own license scenario. - :paramtype license_type: str - :keyword vm_id: Gets the virtual machine unique id. - :paramtype vm_id: str - :keyword security_profile: Gets the security profile. - :paramtype security_profile: ~azure.mgmt.compute.v2021_07_01.models.SecurityProfile - :keyword location: Location of the VM from which the restore point was created. - :paramtype location: str - """ - super().__init__(**kwargs) - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.os_profile = os_profile - self.diagnostics_profile = diagnostics_profile - self.license_type = license_type - self.vm_id = vm_id - self.security_profile = security_profile - self.location = location - - -class RestorePointSourceVMDataDisk(_serialization.Model): - """Describes a data disk. - - :ivar lun: Gets the logical unit number. - :vartype lun: int - :ivar name: Gets the disk name. - :vartype name: str - :ivar caching: Gets the caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :ivar disk_size_gb: Gets the initial disk size in GB for blank data disks, and the new desired - size for existing OS and Data disks. - :vartype disk_size_gb: int - :ivar managed_disk: Gets the managed disk details. - :vartype managed_disk: ~azure.mgmt.compute.v2021_07_01.models.ManagedDiskParameters - :ivar disk_restore_point: Gets the disk restore point Id. - :vartype disk_restore_point: ~azure.mgmt.compute.v2021_07_01.models.ApiEntityReference - """ - - _attribute_map = { - "lun": {"key": "lun", "type": "int"}, - "name": {"key": "name", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, - "disk_restore_point": {"key": "diskRestorePoint", "type": "ApiEntityReference"}, - } - - def __init__( - self, - *, - lun: Optional[int] = None, - name: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.ManagedDiskParameters"] = None, - disk_restore_point: Optional["_models.ApiEntityReference"] = None, - **kwargs: Any - ) -> None: - """ - :keyword lun: Gets the logical unit number. - :paramtype lun: int - :keyword name: Gets the disk name. - :paramtype name: str - :keyword caching: Gets the caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :keyword disk_size_gb: Gets the initial disk size in GB for blank data disks, and the new - desired size for existing OS and Data disks. - :paramtype disk_size_gb: int - :keyword managed_disk: Gets the managed disk details. - :paramtype managed_disk: ~azure.mgmt.compute.v2021_07_01.models.ManagedDiskParameters - :keyword disk_restore_point: Gets the disk restore point Id. - :paramtype disk_restore_point: ~azure.mgmt.compute.v2021_07_01.models.ApiEntityReference - """ - super().__init__(**kwargs) - self.lun = lun - self.name = name - self.caching = caching - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - self.disk_restore_point = disk_restore_point - - -class RestorePointSourceVMOSDisk(_serialization.Model): - """Describes an Operating System disk. - - :ivar os_type: Gets the Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemType - :ivar encryption_settings: Gets the disk encryption settings. - :vartype encryption_settings: ~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSettings - :ivar name: Gets the disk name. - :vartype name: str - :ivar caching: Gets the caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :ivar disk_size_gb: Gets the disk size in GB. - :vartype disk_size_gb: int - :ivar managed_disk: Gets the managed disk details. - :vartype managed_disk: ~azure.mgmt.compute.v2021_07_01.models.ManagedDiskParameters - :ivar disk_restore_point: Gets the disk restore point Id. - :vartype disk_restore_point: ~azure.mgmt.compute.v2021_07_01.models.ApiEntityReference - """ - - _attribute_map = { - "os_type": {"key": "osType", "type": "str"}, - "encryption_settings": {"key": "encryptionSettings", "type": "DiskEncryptionSettings"}, - "name": {"key": "name", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "ManagedDiskParameters"}, - "disk_restore_point": {"key": "diskRestorePoint", "type": "ApiEntityReference"}, - } - - def __init__( - self, - *, - os_type: Optional[Union[str, "_models.OperatingSystemType"]] = None, - encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, - name: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.ManagedDiskParameters"] = None, - disk_restore_point: Optional["_models.ApiEntityReference"] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_type: Gets the Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemType - :keyword encryption_settings: Gets the disk encryption settings. - :paramtype encryption_settings: ~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSettings - :keyword name: Gets the disk name. - :paramtype name: str - :keyword caching: Gets the caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :keyword disk_size_gb: Gets the disk size in GB. - :paramtype disk_size_gb: int - :keyword managed_disk: Gets the managed disk details. - :paramtype managed_disk: ~azure.mgmt.compute.v2021_07_01.models.ManagedDiskParameters - :keyword disk_restore_point: Gets the disk restore point Id. - :paramtype disk_restore_point: ~azure.mgmt.compute.v2021_07_01.models.ApiEntityReference - """ - super().__init__(**kwargs) - self.os_type = os_type - self.encryption_settings = encryption_settings - self.name = name - self.caching = caching - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - self.disk_restore_point = disk_restore_point - - -class RestorePointSourceVMStorageProfile(_serialization.Model): - """Describes the storage profile. - - :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.v2021_07_01.models.RestorePointSourceVMOSDisk - :ivar data_disks: Gets the data disks of the VM captured at the time of the restore point - creation. - :vartype data_disks: list[~azure.mgmt.compute.v2021_07_01.models.RestorePointSourceVMDataDisk] - """ - - _attribute_map = { - "os_disk": {"key": "osDisk", "type": "RestorePointSourceVMOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[RestorePointSourceVMDataDisk]"}, - } - - def __init__( - self, - *, - os_disk: Optional["_models.RestorePointSourceVMOSDisk"] = None, - data_disks: 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.v2021_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: - list[~azure.mgmt.compute.v2021_07_01.models.RestorePointSourceVMDataDisk] - """ - super().__init__(**kwargs) - self.os_disk = os_disk - self.data_disks = data_disks - - -class RetrieveBootDiagnosticsDataResult(_serialization.Model): - """The SAS URIs of the console screenshot and serial log blobs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar console_screenshot_blob_uri: The console screenshot blob URI. - :vartype console_screenshot_blob_uri: str - :ivar serial_console_log_blob_uri: The serial console log blob URI. - :vartype serial_console_log_blob_uri: str - """ - - _validation = { - "console_screenshot_blob_uri": {"readonly": True}, - "serial_console_log_blob_uri": {"readonly": True}, - } - - _attribute_map = { - "console_screenshot_blob_uri": {"key": "consoleScreenshotBlobUri", "type": "str"}, - "serial_console_log_blob_uri": {"key": "serialConsoleLogBlobUri", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.console_screenshot_blob_uri: Optional[str] = None - self.serial_console_log_blob_uri: Optional[str] = None - - -class RollbackStatusInfo(_serialization.Model): - """Information about rollback on failed VM instances after a OS Upgrade operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar successfully_rolledback_instance_count: The number of instances which have been - successfully rolled back. - :vartype successfully_rolledback_instance_count: int - :ivar failed_rolledback_instance_count: The number of instances which failed to rollback. - :vartype failed_rolledback_instance_count: int - :ivar rollback_error: Error details if OS rollback failed. - :vartype rollback_error: ~azure.mgmt.compute.v2021_07_01.models.ApiError - """ - - _validation = { - "successfully_rolledback_instance_count": {"readonly": True}, - "failed_rolledback_instance_count": {"readonly": True}, - "rollback_error": {"readonly": True}, - } - - _attribute_map = { - "successfully_rolledback_instance_count": {"key": "successfullyRolledbackInstanceCount", "type": "int"}, - "failed_rolledback_instance_count": {"key": "failedRolledbackInstanceCount", "type": "int"}, - "rollback_error": {"key": "rollbackError", "type": "ApiError"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.successfully_rolledback_instance_count: Optional[int] = None - self.failed_rolledback_instance_count: Optional[int] = None - self.rollback_error: Optional["_models.ApiError"] = None - - -class RollingUpgradePolicy(_serialization.Model): - """The configuration parameters used while performing a rolling upgrade. - - :ivar max_batch_instance_percent: The maximum percent of total virtual machine instances that - will be upgraded simultaneously by the rolling upgrade in one batch. As this is a maximum, - unhealthy instances in previous or future batches can cause the percentage of instances in a - batch to decrease to ensure higher reliability. The default value for this parameter is 20%. - :vartype max_batch_instance_percent: int - :ivar max_unhealthy_instance_percent: The maximum percentage of the total virtual machine - instances in the scale set that can be simultaneously unhealthy, either as a result of being - upgraded, or by being found in an unhealthy state by the virtual machine health checks before - the rolling upgrade aborts. This constraint will be checked prior to starting any batch. The - default value for this parameter is 20%. - :vartype max_unhealthy_instance_percent: int - :ivar max_unhealthy_upgraded_instance_percent: The maximum percentage of upgraded virtual - machine instances that can be found to be in an unhealthy state. This check will happen after - each batch is upgraded. If this percentage is ever exceeded, the rolling update aborts. The - default value for this parameter is 20%. - :vartype max_unhealthy_upgraded_instance_percent: int - :ivar pause_time_between_batches: The wait time between completing the update for all virtual - machines in one batch and starting the next batch. The time duration should be specified in ISO - 8601 format. The default value is 0 seconds (PT0S). - :vartype pause_time_between_batches: str - :ivar enable_cross_zone_upgrade: Allow VMSS to ignore AZ boundaries when constructing upgrade - batches. Take into consideration the Update Domain and maxBatchInstancePercent to determine the - batch size. - :vartype enable_cross_zone_upgrade: bool - :ivar prioritize_unhealthy_instances: Upgrade all unhealthy instances in a scale set before any - healthy instances. - :vartype prioritize_unhealthy_instances: bool - """ - - _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}, - } - - _attribute_map = { - "max_batch_instance_percent": {"key": "maxBatchInstancePercent", "type": "int"}, - "max_unhealthy_instance_percent": {"key": "maxUnhealthyInstancePercent", "type": "int"}, - "max_unhealthy_upgraded_instance_percent": {"key": "maxUnhealthyUpgradedInstancePercent", "type": "int"}, - "pause_time_between_batches": {"key": "pauseTimeBetweenBatches", "type": "str"}, - "enable_cross_zone_upgrade": {"key": "enableCrossZoneUpgrade", "type": "bool"}, - "prioritize_unhealthy_instances": {"key": "prioritizeUnhealthyInstances", "type": "bool"}, - } - - def __init__( - self, - *, - max_batch_instance_percent: Optional[int] = None, - max_unhealthy_instance_percent: Optional[int] = None, - max_unhealthy_upgraded_instance_percent: Optional[int] = None, - pause_time_between_batches: Optional[str] = None, - enable_cross_zone_upgrade: Optional[bool] = None, - prioritize_unhealthy_instances: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword max_batch_instance_percent: The maximum percent of total virtual machine instances - that will be upgraded simultaneously by the rolling upgrade in one batch. As this is a maximum, - unhealthy instances in previous or future batches can cause the percentage of instances in a - batch to decrease to ensure higher reliability. The default value for this parameter is 20%. - :paramtype max_batch_instance_percent: int - :keyword max_unhealthy_instance_percent: The maximum percentage of the total virtual machine - instances in the scale set that can be simultaneously unhealthy, either as a result of being - upgraded, or by being found in an unhealthy state by the virtual machine health checks before - the rolling upgrade aborts. This constraint will be checked prior to starting any batch. The - default value for this parameter is 20%. - :paramtype max_unhealthy_instance_percent: int - :keyword max_unhealthy_upgraded_instance_percent: The maximum percentage of upgraded virtual - machine instances that can be found to be in an unhealthy state. This check will happen after - each batch is upgraded. If this percentage is ever exceeded, the rolling update aborts. The - default value for this parameter is 20%. - :paramtype max_unhealthy_upgraded_instance_percent: int - :keyword pause_time_between_batches: The wait time between completing the update for all - virtual machines in one batch and starting the next batch. The time duration should be - specified in ISO 8601 format. The default value is 0 seconds (PT0S). - :paramtype pause_time_between_batches: str - :keyword enable_cross_zone_upgrade: Allow VMSS to ignore AZ boundaries when constructing - upgrade batches. Take into consideration the Update Domain and maxBatchInstancePercent to - determine the batch size. - :paramtype enable_cross_zone_upgrade: bool - :keyword prioritize_unhealthy_instances: Upgrade all unhealthy instances in a scale set before - any healthy instances. - :paramtype prioritize_unhealthy_instances: bool - """ - super().__init__(**kwargs) - self.max_batch_instance_percent = max_batch_instance_percent - self.max_unhealthy_instance_percent = max_unhealthy_instance_percent - self.max_unhealthy_upgraded_instance_percent = max_unhealthy_upgraded_instance_percent - self.pause_time_between_batches = pause_time_between_batches - self.enable_cross_zone_upgrade = enable_cross_zone_upgrade - self.prioritize_unhealthy_instances = prioritize_unhealthy_instances - - -class RollingUpgradeProgressInfo(_serialization.Model): - """Information about the number of virtual machine instances in each upgrade state. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar successful_instance_count: The number of instances that have been successfully upgraded. - :vartype successful_instance_count: int - :ivar failed_instance_count: The number of instances that have failed to be upgraded - successfully. - :vartype failed_instance_count: int - :ivar in_progress_instance_count: The number of instances that are currently being upgraded. - :vartype in_progress_instance_count: int - :ivar pending_instance_count: The number of instances that have not yet begun to be upgraded. - :vartype pending_instance_count: int - """ - - _validation = { - "successful_instance_count": {"readonly": True}, - "failed_instance_count": {"readonly": True}, - "in_progress_instance_count": {"readonly": True}, - "pending_instance_count": {"readonly": True}, - } - - _attribute_map = { - "successful_instance_count": {"key": "successfulInstanceCount", "type": "int"}, - "failed_instance_count": {"key": "failedInstanceCount", "type": "int"}, - "in_progress_instance_count": {"key": "inProgressInstanceCount", "type": "int"}, - "pending_instance_count": {"key": "pendingInstanceCount", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.successful_instance_count: Optional[int] = None - self.failed_instance_count: Optional[int] = None - self.in_progress_instance_count: Optional[int] = None - self.pending_instance_count: Optional[int] = None - - -class RollingUpgradeRunningStatus(_serialization.Model): - """Information about the current running state of the overall upgrade. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Code indicating the current status of the upgrade. Known values are: - "RollingForward", "Cancelled", "Completed", and "Faulted". - :vartype code: str or ~azure.mgmt.compute.v2021_07_01.models.RollingUpgradeStatusCode - :ivar start_time: Start time of the upgrade. - :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start" - and "Cancel". - :vartype last_action: str or ~azure.mgmt.compute.v2021_07_01.models.RollingUpgradeActionType - :ivar last_action_time: Last action time of the upgrade. - :vartype last_action_time: ~datetime.datetime - """ - - _validation = { - "code": {"readonly": True}, - "start_time": {"readonly": True}, - "last_action": {"readonly": True}, - "last_action_time": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "last_action": {"key": "lastAction", "type": "str"}, - "last_action_time": {"key": "lastActionTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[Union[str, "_models.RollingUpgradeStatusCode"]] = None - self.start_time: Optional[datetime.datetime] = None - self.last_action: Optional[Union[str, "_models.RollingUpgradeActionType"]] = None - self.last_action_time: Optional[datetime.datetime] = None - - -class RollingUpgradeStatusInfo(Resource): - """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. - :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] - :ivar policy: The rolling upgrade policies applied for this upgrade. - :vartype policy: ~azure.mgmt.compute.v2021_07_01.models.RollingUpgradePolicy - :ivar running_status: Information about the current running state of the overall upgrade. - :vartype running_status: ~azure.mgmt.compute.v2021_07_01.models.RollingUpgradeRunningStatus - :ivar progress: Information about the number of virtual machine instances in each upgrade - state. - :vartype progress: ~azure.mgmt.compute.v2021_07_01.models.RollingUpgradeProgressInfo - :ivar error: Error details for this upgrade, if there are any. - :vartype error: ~azure.mgmt.compute.v2021_07_01.models.ApiError - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "policy": {"readonly": True}, - "running_status": {"readonly": True}, - "progress": {"readonly": True}, - "error": {"readonly": 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}"}, - "policy": {"key": "properties.policy", "type": "RollingUpgradePolicy"}, - "running_status": {"key": "properties.runningStatus", "type": "RollingUpgradeRunningStatus"}, - "progress": {"key": "properties.progress", "type": "RollingUpgradeProgressInfo"}, - "error": {"key": "properties.error", "type": "ApiError"}, - } - - 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__(location=location, tags=tags, **kwargs) - self.policy: Optional["_models.RollingUpgradePolicy"] = None - self.running_status: Optional["_models.RollingUpgradeRunningStatus"] = None - self.progress: Optional["_models.RollingUpgradeProgressInfo"] = None - self.error: Optional["_models.ApiError"] = None - - -class RunCommandDocumentBase(_serialization.Model): - """Describes the properties of a Run Command metadata. - - All required parameters must be populated in order to send to server. - - :ivar schema: The VM run command schema. Required. - :vartype schema: str - :ivar id: The VM run command id. Required. - :vartype id: str - :ivar os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - :ivar label: The VM run command label. Required. - :vartype label: str - :ivar description: The VM run command description. Required. - :vartype description: str - """ - - _validation = { - "schema": {"required": True}, - "id": {"required": True}, - "os_type": {"required": True}, - "label": {"required": True}, - "description": {"required": True}, - } - - _attribute_map = { - "schema": {"key": "$schema", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "os_type": {"key": "osType", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - schema: str, - id: str, # pylint: disable=redefined-builtin - os_type: Union[str, "_models.OperatingSystemTypes"], - label: str, - description: str, - **kwargs: Any - ) -> None: - """ - :keyword schema: The VM run command schema. Required. - :paramtype schema: str - :keyword id: The VM run command id. Required. - :paramtype id: str - :keyword os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - :keyword label: The VM run command label. Required. - :paramtype label: str - :keyword description: The VM run command description. Required. - :paramtype description: str - """ - super().__init__(**kwargs) - self.schema = schema - self.id = id - self.os_type = os_type - self.label = label - self.description = description - - -class RunCommandDocument(RunCommandDocumentBase): - """Describes the properties of a Run Command. - - All required parameters must be populated in order to send to server. - - :ivar schema: The VM run command schema. Required. - :vartype schema: str - :ivar id: The VM run command id. Required. - :vartype id: str - :ivar os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - :ivar label: The VM run command label. Required. - :vartype label: str - :ivar description: The VM run command description. Required. - :vartype description: str - :ivar script: The script to be executed. Required. - :vartype script: list[str] - :ivar parameters: The parameters used by the script. - :vartype parameters: list[~azure.mgmt.compute.v2021_07_01.models.RunCommandParameterDefinition] - """ - - _validation = { - "schema": {"required": True}, - "id": {"required": True}, - "os_type": {"required": True}, - "label": {"required": True}, - "description": {"required": True}, - "script": {"required": True}, - } - - _attribute_map = { - "schema": {"key": "$schema", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "os_type": {"key": "osType", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "script": {"key": "script", "type": "[str]"}, - "parameters": {"key": "parameters", "type": "[RunCommandParameterDefinition]"}, - } - - def __init__( - self, - *, - schema: str, - id: str, # pylint: disable=redefined-builtin - os_type: Union[str, "_models.OperatingSystemTypes"], - label: str, - description: str, - script: List[str], - parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword schema: The VM run command schema. Required. - :paramtype schema: str - :keyword id: The VM run command id. Required. - :paramtype id: str - :keyword os_type: The Operating System type. Required. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - :keyword label: The VM run command label. Required. - :paramtype label: str - :keyword description: The VM run command description. Required. - :paramtype description: str - :keyword script: The script to be executed. Required. - :paramtype script: list[str] - :keyword parameters: The parameters used by the script. - :paramtype parameters: - list[~azure.mgmt.compute.v2021_07_01.models.RunCommandParameterDefinition] - """ - super().__init__(schema=schema, id=id, os_type=os_type, label=label, description=description, **kwargs) - self.script = script - self.parameters = parameters - - -class RunCommandInput(_serialization.Model): - """Capture Virtual Machine parameters. - - All required parameters must be populated in order to send to server. - - :ivar command_id: The run command id. Required. - :vartype command_id: str - :ivar script: Optional. The script to be executed. When this value is given, the given script - will override the default script of the command. - :vartype script: list[str] - :ivar parameters: The run command parameters. - :vartype parameters: list[~azure.mgmt.compute.v2021_07_01.models.RunCommandInputParameter] - """ - - _validation = { - "command_id": {"required": True}, - } - - _attribute_map = { - "command_id": {"key": "commandId", "type": "str"}, - "script": {"key": "script", "type": "[str]"}, - "parameters": {"key": "parameters", "type": "[RunCommandInputParameter]"}, - } - - def __init__( - self, - *, - command_id: str, - script: Optional[List[str]] = None, - parameters: Optional[List["_models.RunCommandInputParameter"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword command_id: The run command id. Required. - :paramtype command_id: str - :keyword script: Optional. The script to be executed. When this value is given, the given - script will override the default script of the command. - :paramtype script: list[str] - :keyword parameters: The run command parameters. - :paramtype parameters: list[~azure.mgmt.compute.v2021_07_01.models.RunCommandInputParameter] - """ - super().__init__(**kwargs) - self.command_id = command_id - self.script = script - self.parameters = parameters - - -class RunCommandInputParameter(_serialization.Model): - """Describes the properties of a run command parameter. - - All required parameters must be populated in order to send to server. - - :ivar name: The run command parameter name. Required. - :vartype name: str - :ivar value: The run command parameter value. Required. - :vartype value: str - """ - - _validation = { - "name": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: - """ - :keyword name: The run command parameter name. Required. - :paramtype name: str - :keyword value: The run command parameter value. Required. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class RunCommandListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine run commands. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.RunCommandDocumentBase] - :ivar next_link: The uri to fetch the next page of run commands. Call ListNext() with this to - fetch the next page of run commands. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RunCommandDocumentBase]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine run commands. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.RunCommandDocumentBase] - :keyword next_link: The uri to fetch the next page of run commands. Call ListNext() with this - to fetch the next page of run commands. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RunCommandParameterDefinition(_serialization.Model): - """Describes the properties of a run command parameter. - - All required parameters must be populated in order to send to server. - - :ivar name: The run command parameter name. Required. - :vartype name: str - :ivar type: The run command parameter type. Required. - :vartype type: str - :ivar default_value: The run command parameter default value. - :vartype default_value: str - :ivar required: The run command parameter required. - :vartype required: bool - """ - - _validation = { - "name": {"required": True}, - "type": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "default_value": {"key": "defaultValue", "type": "str"}, - "required": {"key": "required", "type": "bool"}, - } - - def __init__( - self, *, name: str, type: str, default_value: Optional[str] = None, required: bool = False, **kwargs: Any - ) -> None: - """ - :keyword name: The run command parameter name. Required. - :paramtype name: str - :keyword type: The run command parameter type. Required. - :paramtype type: str - :keyword default_value: The run command parameter default value. - :paramtype default_value: str - :keyword required: The run command parameter required. - :paramtype required: bool - """ - super().__init__(**kwargs) - self.name = name - self.type = type - self.default_value = default_value - self.required = required - - -class RunCommandResult(_serialization.Model): - """RunCommandResult. - - :ivar value: Run command operation response. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[InstanceViewStatus]"}, - } - - def __init__(self, *, value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Run command operation response. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.value = value - - -class ScaleInPolicy(_serialization.Model): - """Describes a scale-in policy for a virtual machine scale set. - - :ivar rules: The rules to be followed when scaling-in a virtual machine scale set. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Default** When a - virtual machine scale set is scaled in, the scale set will first be balanced across zones if it - is a zonal scale set. Then, it will be balanced across Fault Domains as far as possible. Within - each Fault Domain, the virtual machines chosen for removal will be the newest ones that are not - protected from scale-in. :code:`
    `\\ :code:`
    ` **OldestVM** When a virtual machine scale - set is being scaled-in, the oldest virtual machines that are not protected from scale-in will - be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the oldest virtual machines that are not protected - will be chosen for removal. :code:`
    `\\ :code:`
    ` **NewestVM** When a virtual machine - scale set is being scaled-in, the newest virtual machines that are not protected from scale-in - will be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the newest virtual machines that are not protected - will be chosen for removal. :code:`
    `\\ :code:`
    `. - :vartype rules: list[str or - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetScaleInRules] - :ivar force_deletion: This property allows you to specify if virtual machines chosen for - removal have to be force deleted when a virtual machine scale set is being scaled-in.(Feature - in Preview). - :vartype force_deletion: bool - """ - - _attribute_map = { - "rules": {"key": "rules", "type": "[str]"}, - "force_deletion": {"key": "forceDeletion", "type": "bool"}, - } - - def __init__( - self, - *, - rules: Optional[List[Union[str, "_models.VirtualMachineScaleSetScaleInRules"]]] = None, - force_deletion: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword rules: The rules to be followed when scaling-in a virtual machine scale set. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Default** When a - virtual machine scale set is scaled in, the scale set will first be balanced across zones if it - is a zonal scale set. Then, it will be balanced across Fault Domains as far as possible. Within - each Fault Domain, the virtual machines chosen for removal will be the newest ones that are not - protected from scale-in. :code:`
    `\\ :code:`
    ` **OldestVM** When a virtual machine scale - set is being scaled-in, the oldest virtual machines that are not protected from scale-in will - be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the oldest virtual machines that are not protected - will be chosen for removal. :code:`
    `\\ :code:`
    ` **NewestVM** When a virtual machine - scale set is being scaled-in, the newest virtual machines that are not protected from scale-in - will be chosen for removal. For zonal virtual machine scale sets, the scale set will first be - balanced across zones. Within each zone, the newest virtual machines that are not protected - will be chosen for removal. :code:`
    `\\ :code:`
    `. - :paramtype rules: list[str or - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetScaleInRules] - :keyword force_deletion: This property allows you to specify if virtual machines chosen for - removal have to be force deleted when a virtual machine scale set is being scaled-in.(Feature - in Preview). - :paramtype force_deletion: bool - """ - super().__init__(**kwargs) - self.rules = rules - self.force_deletion = force_deletion - - -class ScheduledEventsProfile(_serialization.Model): - """ScheduledEventsProfile. - - :ivar terminate_notification_profile: Specifies Terminate Scheduled Event related - configurations. - :vartype terminate_notification_profile: - ~azure.mgmt.compute.v2021_07_01.models.TerminateNotificationProfile - """ - - _attribute_map = { - "terminate_notification_profile": { - "key": "terminateNotificationProfile", - "type": "TerminateNotificationProfile", - }, - } - - def __init__( - self, *, terminate_notification_profile: Optional["_models.TerminateNotificationProfile"] = None, **kwargs: Any - ) -> None: - """ - :keyword terminate_notification_profile: Specifies Terminate Scheduled Event related - configurations. - :paramtype terminate_notification_profile: - ~azure.mgmt.compute.v2021_07_01.models.TerminateNotificationProfile - """ - super().__init__(**kwargs) - self.terminate_notification_profile = terminate_notification_profile - - -class SecurityProfile(_serialization.Model): - """Specifies the Security profile settings for the virtual machine or virtual machine scale set. - - :ivar uefi_settings: Specifies the security settings like secure boot and vTPM used while - creating the virtual machine. :code:`
    `\\ :code:`
    `Minimum api-version: 2020-12-01. - :vartype uefi_settings: ~azure.mgmt.compute.v2021_07_01.models.UefiSettings - :ivar encryption_at_host: This property can be used by user in the request to enable or disable - the Host Encryption for the virtual machine or virtual machine scale set. This will enable the - encryption for all the disks including Resource/Temp disk at host itself. :code:`
    `\\ - :code:`
    ` Default: The Encryption at host will be disabled unless this property is set to - true for the resource. - :vartype encryption_at_host: bool - :ivar security_type: Specifies the SecurityType of the virtual machine. It is set as - TrustedLaunch to enable UefiSettings. :code:`
    `\\ :code:`
    ` Default: UefiSettings will - not be enabled unless this property is set as TrustedLaunch. "TrustedLaunch" - :vartype security_type: str or ~azure.mgmt.compute.v2021_07_01.models.SecurityTypes - """ - - _attribute_map = { - "uefi_settings": {"key": "uefiSettings", "type": "UefiSettings"}, - "encryption_at_host": {"key": "encryptionAtHost", "type": "bool"}, - "security_type": {"key": "securityType", "type": "str"}, - } - - def __init__( - self, - *, - uefi_settings: Optional["_models.UefiSettings"] = None, - encryption_at_host: Optional[bool] = None, - security_type: Optional[Union[str, "_models.SecurityTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword uefi_settings: Specifies the security settings like secure boot and vTPM used while - creating the virtual machine. :code:`
    `\\ :code:`
    `Minimum api-version: 2020-12-01. - :paramtype uefi_settings: ~azure.mgmt.compute.v2021_07_01.models.UefiSettings - :keyword encryption_at_host: This property can be used by user in the request to enable or - disable the Host Encryption for the virtual machine or virtual machine scale set. This will - enable the encryption for all the disks including Resource/Temp disk at host itself. - :code:`
    `\\ :code:`
    ` Default: The Encryption at host will be disabled unless this - property is set to true for the resource. - :paramtype encryption_at_host: bool - :keyword security_type: Specifies the SecurityType of the virtual machine. It is set as - TrustedLaunch to enable UefiSettings. :code:`
    `\\ :code:`
    ` Default: UefiSettings will - not be enabled unless this property is set as TrustedLaunch. "TrustedLaunch" - :paramtype security_type: str or ~azure.mgmt.compute.v2021_07_01.models.SecurityTypes - """ - super().__init__(**kwargs) - self.uefi_settings = uefi_settings - self.encryption_at_host = encryption_at_host - self.security_type = security_type - - -class SharedGallery(PirSharedGalleryResource): - """Specifies information about the Shared Gallery that you want to create or update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar unique_id: The unique id of this shared gallery. - :vartype unique_id: str - """ - - -class SharedGalleryImage(PirSharedGalleryResource): - """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. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar unique_id: The unique id of this shared gallery. - :vartype unique_id: str - :ivar 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. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values - are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - :ivar 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". - :vartype os_state: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemStateTypes - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar identifier: This is the gallery image definition identifier. - :vartype identifier: ~azure.mgmt.compute.v2021_07_01.models.GalleryImageIdentifier - :ivar recommended: The properties describe the recommended machine configuration for this Image - Definition. These properties are updatable. - :vartype recommended: ~azure.mgmt.compute.v2021_07_01.models.RecommendedMachineConfiguration - :ivar disallowed: Describes the disallowed disk types. - :vartype disallowed: ~azure.mgmt.compute.v2021_07_01.models.Disallowed - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGeneration - :ivar features: A list of gallery image features. - :vartype features: list[~azure.mgmt.compute.v2021_07_01.models.GalleryImageFeature] - :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :vartype purchase_plan: ~azure.mgmt.compute.v2021_07_01.models.ImagePurchasePlan - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "os_state": {"key": "properties.osState", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, - "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "features": {"key": "properties.features", "type": "[GalleryImageFeature]"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, - } - - 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, - **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. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.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.v2021_07_01.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.v2021_07_01.models.GalleryImageIdentifier - :keyword recommended: The properties describe the recommended machine configuration for this - Image Definition. These properties are updatable. - :paramtype recommended: ~azure.mgmt.compute.v2021_07_01.models.RecommendedMachineConfiguration - :keyword disallowed: Describes the disallowed disk types. - :paramtype disallowed: ~azure.mgmt.compute.v2021_07_01.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.v2021_07_01.models.HyperVGeneration - :keyword features: A list of gallery image features. - :paramtype features: list[~azure.mgmt.compute.v2021_07_01.models.GalleryImageFeature] - :keyword purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :paramtype purchase_plan: ~azure.mgmt.compute.v2021_07_01.models.ImagePurchasePlan - """ - 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.disallowed = disallowed - self.hyper_v_generation = hyper_v_generation - self.features = features - self.purchase_plan = purchase_plan - - -class SharedGalleryImageList(_serialization.Model): - """The List Shared Gallery Images operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of shared gallery images. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.SharedGalleryImage] - :ivar next_link: The uri to fetch the next page of shared gallery images. Call ListNext() with - this to fetch the next page of shared gallery images. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SharedGalleryImage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.SharedGalleryImage"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of shared gallery images. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.SharedGalleryImage] - :keyword next_link: The uri to fetch the next page of shared gallery images. Call ListNext() - with this to fetch the next page of shared gallery images. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SharedGalleryImageVersion(PirSharedGalleryResource): - """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. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar unique_id: The unique id of this shared gallery. - :vartype unique_id: str - :ivar published_date: The published date of the gallery image version Definition. This property - can be used for decommissioning purposes. This property is updatable. - :vartype published_date: ~datetime.datetime - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - "published_date": {"key": "properties.publishedDate", "type": "iso-8601"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - } - - def __init__( - self, - *, - unique_id: Optional[str] = None, - published_date: Optional[datetime.datetime] = None, - end_of_life_date: Optional[datetime.datetime] = 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 - """ - super().__init__(unique_id=unique_id, **kwargs) - self.published_date = published_date - self.end_of_life_date = end_of_life_date - - -class SharedGalleryImageVersionList(_serialization.Model): - """The List Shared Gallery Image versions operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of shared gallery images versions. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SharedGalleryImageVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - 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. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SharedGalleryList(_serialization.Model): - """The List Shared Galleries operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of shared galleries. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.SharedGallery] - :ivar next_link: The uri to fetch the next page of shared galleries. Call ListNext() with this - to fetch the next page of shared galleries. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SharedGallery]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.SharedGallery"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of shared galleries. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.SharedGallery] - :keyword next_link: The uri to fetch the next page of shared galleries. Call ListNext() with - this to fetch the next page of shared galleries. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SharingProfile(_serialization.Model): - """Profile for gallery sharing to subscription or tenant. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar permissions: This property allows you to specify the permission of sharing gallery. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Private** - :code:`
    `\\ :code:`
    ` **Groups**. Known values are: "Private" and "Groups". - :vartype permissions: str or - ~azure.mgmt.compute.v2021_07_01.models.GallerySharingPermissionTypes - :ivar groups: A list of sharing profile groups. - :vartype groups: list[~azure.mgmt.compute.v2021_07_01.models.SharingProfileGroup] - """ - - _validation = { - "groups": {"readonly": True}, - } - - _attribute_map = { - "permissions": {"key": "permissions", "type": "str"}, - "groups": {"key": "groups", "type": "[SharingProfileGroup]"}, - } - - def __init__( - self, *, permissions: Optional[Union[str, "_models.GallerySharingPermissionTypes"]] = None, **kwargs: Any - ) -> None: - """ - :keyword permissions: This property allows you to specify the permission of sharing gallery. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Private** - :code:`
    `\\ :code:`
    ` **Groups**. Known values are: "Private" and "Groups". - :paramtype permissions: str or - ~azure.mgmt.compute.v2021_07_01.models.GallerySharingPermissionTypes - """ - super().__init__(**kwargs) - self.permissions = permissions - self.groups: Optional[List["_models.SharingProfileGroup"]] = None - - -class SharingProfileGroup(_serialization.Model): - """Group of the gallery sharing profile. - - :ivar type: This property allows you to specify the type of sharing group. :code:`
    `\\ - :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Subscriptions** :code:`
    `\\ - :code:`
    ` **AADTenants**. Known values are: "Subscriptions" and "AADTenants". - :vartype type: str or ~azure.mgmt.compute.v2021_07_01.models.SharingProfileGroupTypes - :ivar ids: A list of subscription/tenant ids the gallery is aimed to be shared to. - :vartype ids: list[str] - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "ids": {"key": "ids", "type": "[str]"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.SharingProfileGroupTypes"]] = None, - ids: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: This property allows you to specify the type of sharing group. :code:`
    `\\ - :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Subscriptions** :code:`
    `\\ - :code:`
    ` **AADTenants**. Known values are: "Subscriptions" and "AADTenants". - :paramtype type: str or ~azure.mgmt.compute.v2021_07_01.models.SharingProfileGroupTypes - :keyword ids: A list of subscription/tenant ids the gallery is aimed to be shared to. - :paramtype ids: list[str] - """ - super().__init__(**kwargs) - self.type = type - self.ids = ids - - -class SharingUpdate(_serialization.Model): - """Specifies information about the gallery sharing profile update. - - All required parameters must be populated in order to send to server. - - :ivar operation_type: This property allows you to specify the operation type of gallery sharing - update. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Add** - :code:`
    `\\ :code:`
    ` **Remove** :code:`
    `\\ :code:`
    ` **Reset**. Required. Known - values are: "Add", "Remove", and "Reset". - :vartype operation_type: str or - ~azure.mgmt.compute.v2021_07_01.models.SharingUpdateOperationTypes - :ivar groups: A list of sharing profile groups. - :vartype groups: list[~azure.mgmt.compute.v2021_07_01.models.SharingProfileGroup] - """ - - _validation = { - "operation_type": {"required": True}, - } - - _attribute_map = { - "operation_type": {"key": "operationType", "type": "str"}, - "groups": {"key": "groups", "type": "[SharingProfileGroup]"}, - } - - def __init__( - self, - *, - operation_type: Union[str, "_models.SharingUpdateOperationTypes"], - groups: Optional[List["_models.SharingProfileGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword operation_type: This property allows you to specify the operation type of gallery - sharing update. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - **Add** :code:`
    `\\ :code:`
    ` **Remove** :code:`
    `\\ :code:`
    ` **Reset**. Required. - Known values are: "Add", "Remove", and "Reset". - :paramtype operation_type: str or - ~azure.mgmt.compute.v2021_07_01.models.SharingUpdateOperationTypes - :keyword groups: A list of sharing profile groups. - :paramtype groups: list[~azure.mgmt.compute.v2021_07_01.models.SharingProfileGroup] - """ - super().__init__(**kwargs) - self.operation_type = operation_type - self.groups = groups - - -class Sku(_serialization.Model): - """Describes a virtual machine scale set sku. NOTE: If the new VM SKU is not supported on the - hardware the scale set is currently on, you need to deallocate the VMs in the scale set before - you modify the SKU name. - - :ivar name: The sku name. - :vartype name: str - :ivar tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
    `\\ - :code:`
    ` Possible Values:\\ :code:`
    `\\ :code:`
    ` **Standard**\\ :code:`
    `\\ :code:`
    ` **Basic**. - :vartype tier: str - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: int - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "capacity": {"key": "capacity", "type": "int"}, - } - - def __init__( - self, *, name: Optional[str] = None, tier: Optional[str] = None, capacity: Optional[int] = None, **kwargs: Any - ) -> None: - """ - :keyword name: The sku name. - :paramtype name: str - :keyword tier: Specifies the tier of virtual machines in a scale set.\\ :code:`
    `\\ - :code:`
    ` Possible Values:\\ :code:`
    `\\ :code:`
    ` **Standard**\\ :code:`
    `\\ :code:`
    ` **Basic**. - :paramtype tier: str - :keyword capacity: Specifies the number of virtual machines in the scale set. - :paramtype capacity: int - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - self.capacity = capacity - - -class SoftDeletePolicy(_serialization.Model): - """Contains information about the soft deletion policy of the gallery. - - :ivar is_soft_delete_enabled: Enables soft-deletion for resources in this gallery, allowing - them to be recovered within retention time. - :vartype is_soft_delete_enabled: bool - """ - - _attribute_map = { - "is_soft_delete_enabled": {"key": "isSoftDeleteEnabled", "type": "bool"}, - } - - def __init__(self, *, is_soft_delete_enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword is_soft_delete_enabled: Enables soft-deletion for resources in this gallery, allowing - them to be recovered within retention time. - :paramtype is_soft_delete_enabled: bool - """ - super().__init__(**kwargs) - self.is_soft_delete_enabled = is_soft_delete_enabled - - -class SpotRestorePolicy(_serialization.Model): - """Specifies the Spot-Try-Restore properties for the virtual machine scale set. :code:`
    `\\ - :code:`
    ` With this property customer can enable or disable automatic restore of the evicted - Spot VMSS VM instances opportunistically based on capacity availability and pricing constraint. - - :ivar enabled: Enables the Spot-Try-Restore feature where evicted VMSS SPOT instances will be - tried to be restored opportunistically based on capacity availability and pricing constraints. - :vartype enabled: bool - :ivar restore_timeout: Timeout value expressed as an ISO 8601 time duration after which the - platform will not try to restore the VMSS SPOT instances. - :vartype restore_timeout: str - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "restore_timeout": {"key": "restoreTimeout", "type": "str"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, restore_timeout: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Enables the Spot-Try-Restore feature where evicted VMSS SPOT instances will - be tried to be restored opportunistically based on capacity availability and pricing - constraints. - :paramtype enabled: bool - :keyword restore_timeout: Timeout value expressed as an ISO 8601 time duration after which the - platform will not try to restore the VMSS SPOT instances. - :paramtype restore_timeout: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.restore_timeout = restore_timeout - - -class SshConfiguration(_serialization.Model): - """SSH configuration for Linux based VMs running on Azure. - - :ivar public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :vartype public_keys: list[~azure.mgmt.compute.v2021_07_01.models.SshPublicKey] - """ - - _attribute_map = { - "public_keys": {"key": "publicKeys", "type": "[SshPublicKey]"}, - } - - def __init__(self, *, public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs: Any) -> None: - """ - :keyword public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :paramtype public_keys: list[~azure.mgmt.compute.v2021_07_01.models.SshPublicKey] - """ - super().__init__(**kwargs) - self.public_keys = public_keys - - -class SshPublicKey(_serialization.Model): - """Contains information about SSH certificate public key and the path on the Linux VM where the - public key is placed. - - :ivar path: Specifies the full path on the created VM where ssh public key is stored. If the - file already exists, the specified key is appended to the file. Example: - /home/user/.ssh/authorized_keys. - :vartype path: str - :ivar key_data: SSH public key certificate used to authenticate with the VM through ssh. The - key needs to be at least 2048-bit and in ssh-rsa format. :code:`
    `\\ :code:`
    ` For - creating ssh keys, see [Create SSH keys on Linux and Mac for Linux VMs in - Azure]https://docs.microsoft.com/azure/virtual-machines/linux/create-ssh-keys-detailed). - :vartype key_data: str - """ - - _attribute_map = { - "path": {"key": "path", "type": "str"}, - "key_data": {"key": "keyData", "type": "str"}, - } - - def __init__(self, *, path: Optional[str] = None, key_data: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword path: Specifies the full path on the created VM where ssh public key is stored. If the - file already exists, the specified key is appended to the file. Example: - /home/user/.ssh/authorized_keys. - :paramtype path: str - :keyword key_data: SSH public key certificate used to authenticate with the VM through ssh. The - key needs to be at least 2048-bit and in ssh-rsa format. :code:`
    `\\ :code:`
    ` For - creating ssh keys, see [Create SSH keys on Linux and Mac for Linux VMs in - Azure]https://docs.microsoft.com/azure/virtual-machines/linux/create-ssh-keys-detailed). - :paramtype key_data: str - """ - super().__init__(**kwargs) - self.path = path - self.key_data = key_data - - -class SshPublicKeyGenerateKeyPairResult(_serialization.Model): - """Response from generation of an SSH key pair. - - All required parameters must be populated in order to send to server. - - :ivar private_key: Private key portion of the key pair used to authenticate to a virtual - machine through ssh. The private key is returned in RFC3447 format and should be treated as a - secret. Required. - :vartype private_key: str - :ivar public_key: Public key portion of the key pair used to authenticate to a virtual machine - through ssh. The public key is in ssh-rsa format. Required. - :vartype public_key: str - :ivar id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{SshPublicKeyName}. - Required. - :vartype id: str - """ - - _validation = { - "private_key": {"required": True}, - "public_key": {"required": True}, - "id": {"required": True}, - } - - _attribute_map = { - "private_key": {"key": "privateKey", "type": "str"}, - "public_key": {"key": "publicKey", "type": "str"}, - "id": {"key": "id", "type": "str"}, - } - - def __init__( - self, *, private_key: str, public_key: str, id: str, **kwargs: Any # pylint: disable=redefined-builtin - ) -> None: - """ - :keyword private_key: Private key portion of the key pair used to authenticate to a virtual - machine through ssh. The private key is returned in RFC3447 format and should be treated as a - secret. Required. - :paramtype private_key: str - :keyword public_key: Public key portion of the key pair used to authenticate to a virtual - machine through ssh. The public key is in ssh-rsa format. Required. - :paramtype public_key: str - :keyword id: The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{SshPublicKeyName}. - Required. - :paramtype id: str - """ - super().__init__(**kwargs) - self.private_key = private_key - self.public_key = public_key - self.id = id - - -class SshPublicKeyResource(Resource): - """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. - :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] - :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, - the provided public key needs to be at least 2048-bit and in ssh-rsa format. - :vartype public_key: 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}"}, - "public_key": {"key": "properties.publicKey", "type": "str"}, - } - - 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 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) - self.public_key = public_key - - -class SshPublicKeysGroupListResult(_serialization.Model): - """The list SSH public keys operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of SSH public keys. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource] - :ivar next_link: The URI to fetch the next page of SSH public keys. Call ListNext() with this - URI to fetch the next page of SSH public keys. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SshPublicKeyResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.SshPublicKeyResource"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of SSH public keys. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource] - :keyword next_link: The URI to fetch the next page of SSH public keys. Call ListNext() with - this URI to fetch the next page of SSH public keys. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SshPublicKeyUpdateResource(UpdateResource): - """Specifies information about the SSH public key. - - :ivar tags: Resource tags. - :vartype tags: dict[str, 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, - the provided public key needs to be at least 2048-bit and in ssh-rsa format. - :vartype public_key: str - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "public_key": {"key": "properties.publicKey", "type": "str"}, - } - - def __init__( - self, *, tags: Optional[Dict[str, str]] = None, public_key: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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__(tags=tags, **kwargs) - self.public_key = public_key - - -class StorageProfile(_serialization.Model): - """Specifies the storage settings for the virtual machine disks. - - :ivar image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :vartype image_reference: ~azure.mgmt.compute.v2021_07_01.models.ImageReference - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2021_07_01.models.OSDisk - :ivar data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :vartype data_disks: list[~azure.mgmt.compute.v2021_07_01.models.DataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "OSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[DataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.OSDisk"] = None, - data_disks: Optional[List["_models.DataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :paramtype image_reference: ~azure.mgmt.compute.v2021_07_01.models.ImageReference - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2021_07_01.models.OSDisk - :keyword data_disks: Specifies the parameters that are used to add a data disk to a virtual - machine. :code:`
    `\\ :code:`
    ` For more information about disks, see `About disks and - VHDs for Azure virtual machines - `_. - :paramtype data_disks: list[~azure.mgmt.compute.v2021_07_01.models.DataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class SubResourceReadOnly(_serialization.Model): - """SubResourceReadOnly. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class SubResourceWithColocationStatus(SubResource): - """SubResourceWithColocationStatus. - - :ivar id: Resource Id. - :vartype id: str - :ivar colocation_status: Describes colocation status of a resource in the Proximity Placement - Group. - :vartype colocation_status: ~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "colocation_status": {"key": "colocationStatus", "type": "InstanceViewStatus"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - colocation_status: Optional["_models.InstanceViewStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword colocation_status: Describes colocation status of a resource in the Proximity - Placement Group. - :paramtype colocation_status: ~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus - """ - super().__init__(id=id, **kwargs) - self.colocation_status = colocation_status - - -class TargetRegion(_serialization.Model): - """Describes the target region information. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the region. Required. - :vartype name: str - :ivar regional_replica_count: The number of replicas of the Image Version to be created per - region. This property is updatable. - :vartype regional_replica_count: int - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountType - :ivar encryption: Optional. Allows users to provide customer managed keys for encrypting the OS - and data disks in the gallery artifact. - :vartype encryption: ~azure.mgmt.compute.v2021_07_01.models.EncryptionImages - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "regional_replica_count": {"key": "regionalReplicaCount", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "encryption": {"key": "encryption", "type": "EncryptionImages"}, - } - - def __init__( - self, - *, - name: str, - regional_replica_count: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - encryption: Optional["_models.EncryptionImages"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the region. Required. - :paramtype name: str - :keyword regional_replica_count: The number of replicas of the Image Version to be created per - region. This property is updatable. - :paramtype regional_replica_count: int - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2021_07_01.models.StorageAccountType - :keyword encryption: Optional. Allows users to provide customer managed keys for encrypting the - OS and data disks in the gallery artifact. - :paramtype encryption: ~azure.mgmt.compute.v2021_07_01.models.EncryptionImages - """ - super().__init__(**kwargs) - self.name = name - self.regional_replica_count = regional_replica_count - self.storage_account_type = storage_account_type - self.encryption = encryption - - -class TerminateNotificationProfile(_serialization.Model): - """TerminateNotificationProfile. - - :ivar not_before_timeout: Configurable length of time a Virtual Machine being deleted will have - to potentially approve the Terminate Scheduled Event before the event is auto approved (timed - out). The configuration must be specified in ISO 8601 format, the default value is 5 minutes - (PT5M). - :vartype not_before_timeout: str - :ivar enable: Specifies whether the Terminate Scheduled event is enabled or disabled. - :vartype enable: bool - """ - - _attribute_map = { - "not_before_timeout": {"key": "notBeforeTimeout", "type": "str"}, - "enable": {"key": "enable", "type": "bool"}, - } - - def __init__( - self, *, not_before_timeout: Optional[str] = None, enable: Optional[bool] = None, **kwargs: Any - ) -> None: - """ - :keyword not_before_timeout: Configurable length of time a Virtual Machine being deleted will - have to potentially approve the Terminate Scheduled Event before the event is auto approved - (timed out). The configuration must be specified in ISO 8601 format, the default value is 5 - minutes (PT5M). - :paramtype not_before_timeout: str - :keyword enable: Specifies whether the Terminate Scheduled event is enabled or disabled. - :paramtype enable: bool - """ - super().__init__(**kwargs) - self.not_before_timeout = not_before_timeout - self.enable = enable - - -class ThrottledRequestsInput(LogAnalyticsInputBase): - """Api request input for LogAnalytics getThrottledRequests Api. - - All required parameters must be populated in order to send to server. - - :ivar blob_container_sas_uri: SAS Uri of the logging blob container to which LogAnalytics Api - writes output logs to. Required. - :vartype blob_container_sas_uri: str - :ivar from_time: From time of the query. Required. - :vartype from_time: ~datetime.datetime - :ivar to_time: To time of the query. Required. - :vartype to_time: ~datetime.datetime - :ivar group_by_throttle_policy: Group query result by Throttle Policy applied. - :vartype group_by_throttle_policy: bool - :ivar group_by_operation_name: Group query result by Operation Name. - :vartype group_by_operation_name: bool - :ivar group_by_resource_name: Group query result by Resource Name. - :vartype group_by_resource_name: bool - :ivar group_by_client_application_id: Group query result by Client Application ID. - :vartype group_by_client_application_id: bool - :ivar group_by_user_agent: Group query result by User Agent. - :vartype group_by_user_agent: bool - """ - - -class UefiSettings(_serialization.Model): - """Specifies the security settings like secure boot and vTPM used while creating the virtual - machine. :code:`
    `\\ :code:`
    `Minimum api-version: 2020-12-01. - - :ivar secure_boot_enabled: Specifies whether secure boot should be enabled on the virtual - machine. :code:`
    `\\ :code:`
    `Minimum api-version: 2020-12-01. - :vartype secure_boot_enabled: bool - :ivar v_tpm_enabled: Specifies whether vTPM should be enabled on the virtual machine. - :code:`
    `\\ :code:`
    `Minimum api-version: 2020-12-01. - :vartype v_tpm_enabled: bool - """ - - _attribute_map = { - "secure_boot_enabled": {"key": "secureBootEnabled", "type": "bool"}, - "v_tpm_enabled": {"key": "vTpmEnabled", "type": "bool"}, - } - - def __init__( - self, *, secure_boot_enabled: Optional[bool] = None, v_tpm_enabled: Optional[bool] = None, **kwargs: Any - ) -> None: - """ - :keyword secure_boot_enabled: Specifies whether secure boot should be enabled on the virtual - machine. :code:`
    `\\ :code:`
    `Minimum api-version: 2020-12-01. - :paramtype secure_boot_enabled: bool - :keyword v_tpm_enabled: Specifies whether vTPM should be enabled on the virtual machine. - :code:`
    `\\ :code:`
    `Minimum api-version: 2020-12-01. - :paramtype v_tpm_enabled: bool - """ - super().__init__(**kwargs) - self.secure_boot_enabled = secure_boot_enabled - self.v_tpm_enabled = v_tpm_enabled - - -class UpgradeOperationHistoricalStatusInfo(_serialization.Model): - """Virtual Machine Scale Set OS Upgrade History operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar properties: Information about the properties of the upgrade operation. - :vartype properties: - ~azure.mgmt.compute.v2021_07_01.models.UpgradeOperationHistoricalStatusInfoProperties - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - """ - - _validation = { - "properties": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "properties": {"key": "properties", "type": "UpgradeOperationHistoricalStatusInfoProperties"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.properties: Optional["_models.UpgradeOperationHistoricalStatusInfoProperties"] = None - self.type: Optional[str] = None - self.location: Optional[str] = None - - -class UpgradeOperationHistoricalStatusInfoProperties(_serialization.Model): # pylint: disable=name-too-long - """Describes each OS upgrade on the Virtual Machine Scale Set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar running_status: Information about the overall status of the upgrade operation. - :vartype running_status: ~azure.mgmt.compute.v2021_07_01.models.UpgradeOperationHistoryStatus - :ivar progress: Counts of the VMs in each state. - :vartype progress: ~azure.mgmt.compute.v2021_07_01.models.RollingUpgradeProgressInfo - :ivar error: Error Details for this upgrade if there are any. - :vartype error: ~azure.mgmt.compute.v2021_07_01.models.ApiError - :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", and - "Platform". - :vartype started_by: str or ~azure.mgmt.compute.v2021_07_01.models.UpgradeOperationInvoker - :ivar target_image_reference: Image Reference details. - :vartype target_image_reference: ~azure.mgmt.compute.v2021_07_01.models.ImageReference - :ivar rollback_info: Information about OS rollback if performed. - :vartype rollback_info: ~azure.mgmt.compute.v2021_07_01.models.RollbackStatusInfo - """ - - _validation = { - "running_status": {"readonly": True}, - "progress": {"readonly": True}, - "error": {"readonly": True}, - "started_by": {"readonly": True}, - "target_image_reference": {"readonly": True}, - "rollback_info": {"readonly": True}, - } - - _attribute_map = { - "running_status": {"key": "runningStatus", "type": "UpgradeOperationHistoryStatus"}, - "progress": {"key": "progress", "type": "RollingUpgradeProgressInfo"}, - "error": {"key": "error", "type": "ApiError"}, - "started_by": {"key": "startedBy", "type": "str"}, - "target_image_reference": {"key": "targetImageReference", "type": "ImageReference"}, - "rollback_info": {"key": "rollbackInfo", "type": "RollbackStatusInfo"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.running_status: Optional["_models.UpgradeOperationHistoryStatus"] = None - self.progress: Optional["_models.RollingUpgradeProgressInfo"] = None - self.error: Optional["_models.ApiError"] = None - self.started_by: Optional[Union[str, "_models.UpgradeOperationInvoker"]] = None - self.target_image_reference: Optional["_models.ImageReference"] = None - self.rollback_info: Optional["_models.RollbackStatusInfo"] = None - - -class UpgradeOperationHistoryStatus(_serialization.Model): - """Information about the current running state of the overall upgrade. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Code indicating the current status of the upgrade. Known values are: - "RollingForward", "Cancelled", "Completed", and "Faulted". - :vartype code: str or ~azure.mgmt.compute.v2021_07_01.models.UpgradeState - :ivar start_time: Start time of the upgrade. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the upgrade. - :vartype end_time: ~datetime.datetime - """ - - _validation = { - "code": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[Union[str, "_models.UpgradeState"]] = None - self.start_time: Optional[datetime.datetime] = None - self.end_time: Optional[datetime.datetime] = None - - -class UpgradePolicy(_serialization.Model): - """Describes an upgrade policy - automatic, manual, or rolling. - - :ivar mode: Specifies the mode of an upgrade to virtual machines in the scale set.\\ :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` **Manual** - You - control the application of updates to virtual machines in the scale set. You do this by using - the manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - All virtual - machines in the scale set are automatically updated at the same time. Known values are: - "Automatic", "Manual", and "Rolling". - :vartype mode: str or ~azure.mgmt.compute.v2021_07_01.models.UpgradeMode - :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling - upgrade. - :vartype rolling_upgrade_policy: ~azure.mgmt.compute.v2021_07_01.models.RollingUpgradePolicy - :ivar automatic_os_upgrade_policy: Configuration parameters used for performing automatic OS - Upgrade. - :vartype automatic_os_upgrade_policy: - ~azure.mgmt.compute.v2021_07_01.models.AutomaticOSUpgradePolicy - """ - - _attribute_map = { - "mode": {"key": "mode", "type": "str"}, - "rolling_upgrade_policy": {"key": "rollingUpgradePolicy", "type": "RollingUpgradePolicy"}, - "automatic_os_upgrade_policy": {"key": "automaticOSUpgradePolicy", "type": "AutomaticOSUpgradePolicy"}, - } - - def __init__( - self, - *, - mode: Optional[Union[str, "_models.UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, - automatic_os_upgrade_policy: Optional["_models.AutomaticOSUpgradePolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword mode: Specifies the mode of an upgrade to virtual machines in the scale set.\\ - :code:`
    `\\ :code:`
    ` Possible values are:\\ :code:`
    `\\ :code:`
    ` - **Manual** - You control the application of updates to virtual machines in the scale set. You - do this by using the manualUpgrade action.\\ :code:`
    `\\ :code:`
    ` **Automatic** - - All virtual machines in the scale set are automatically updated at the same time. Known values - are: "Automatic", "Manual", and "Rolling". - :paramtype mode: str or ~azure.mgmt.compute.v2021_07_01.models.UpgradeMode - :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling - upgrade. - :paramtype rolling_upgrade_policy: ~azure.mgmt.compute.v2021_07_01.models.RollingUpgradePolicy - :keyword automatic_os_upgrade_policy: Configuration parameters used for performing automatic OS - Upgrade. - :paramtype automatic_os_upgrade_policy: - ~azure.mgmt.compute.v2021_07_01.models.AutomaticOSUpgradePolicy - """ - super().__init__(**kwargs) - self.mode = mode - self.rolling_upgrade_policy = rolling_upgrade_policy - self.automatic_os_upgrade_policy = automatic_os_upgrade_policy - - -class Usage(_serialization.Model): - """Describes Compute Resource Usage. - - 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 unit: An enum describing the unit of usage measurement. Required. Default value is - "Count". - :vartype unit: str - :ivar current_value: The current usage of the resource. Required. - :vartype current_value: int - :ivar limit: The maximum permitted usage of the resource. Required. - :vartype limit: int - :ivar name: The name of the type of usage. Required. - :vartype name: ~azure.mgmt.compute.v2021_07_01.models.UsageName - """ - - _validation = { - "unit": {"required": True, "constant": True}, - "current_value": {"required": True}, - "limit": {"required": True}, - "name": {"required": True}, - } - - _attribute_map = { - "unit": {"key": "unit", "type": "str"}, - "current_value": {"key": "currentValue", "type": "int"}, - "limit": {"key": "limit", "type": "int"}, - "name": {"key": "name", "type": "UsageName"}, - } - - unit = "Count" - - def __init__(self, *, current_value: int, limit: int, name: "_models.UsageName", **kwargs: Any) -> None: - """ - :keyword current_value: The current usage of the resource. Required. - :paramtype current_value: int - :keyword limit: The maximum permitted usage of the resource. Required. - :paramtype limit: int - :keyword name: The name of the type of usage. Required. - :paramtype name: ~azure.mgmt.compute.v2021_07_01.models.UsageName - """ - super().__init__(**kwargs) - self.current_value = current_value - self.limit = limit - self.name = name - - -class UsageName(_serialization.Model): - """The Usage Names. - - :ivar value: The name of the resource. - :vartype value: str - :ivar localized_value: The localized name of the resource. - :vartype localized_value: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, - } - - def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The name of the resource. - :paramtype value: str - :keyword localized_value: The localized name of the resource. - :paramtype localized_value: str - """ - super().__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - -class UserArtifactManage(_serialization.Model): - """UserArtifactManage. - - All required parameters must be populated in order to send to server. - - :ivar install: Required. The path and arguments to install the gallery application. This is - limited to 4096 characters. Required. - :vartype install: str - :ivar remove: Required. The path and arguments to remove the gallery application. This is - limited to 4096 characters. Required. - :vartype remove: str - :ivar update: Optional. The path and arguments to update the gallery application. If not - present, then update operation will invoke remove command on the previous version and install - command on the current version of the gallery application. This is limited to 4096 characters. - :vartype update: str - """ - - _validation = { - "install": {"required": True}, - "remove": {"required": True}, - } - - _attribute_map = { - "install": {"key": "install", "type": "str"}, - "remove": {"key": "remove", "type": "str"}, - "update": {"key": "update", "type": "str"}, - } - - def __init__(self, *, install: str, remove: str, update: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword install: Required. The path and arguments to install the gallery application. This is - limited to 4096 characters. Required. - :paramtype install: str - :keyword remove: Required. The path and arguments to remove the gallery application. This is - limited to 4096 characters. Required. - :paramtype remove: str - :keyword update: Optional. The path and arguments to update the gallery application. If not - present, then update operation will invoke remove command on the previous version and install - command on the current version of the gallery application. This is limited to 4096 characters. - :paramtype update: str - """ - super().__init__(**kwargs) - self.install = install - self.remove = remove - self.update = update - - -class UserArtifactSource(_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 media_link: Required. The mediaLink of the artifact, must be a readable storage page - blob. Required. - :vartype media_link: str - :ivar default_configuration_link: Optional. The defaultConfigurationLink of the artifact, must - be a readable storage page blob. - :vartype default_configuration_link: str - """ - - _validation = { - "media_link": {"required": True}, - } - - _attribute_map = { - "media_link": {"key": "mediaLink", "type": "str"}, - "default_configuration_link": {"key": "defaultConfigurationLink", "type": "str"}, - } - - def __init__(self, *, media_link: str, default_configuration_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword media_link: Required. The mediaLink of the artifact, must be a readable storage page - blob. Required. - :paramtype media_link: str - :keyword default_configuration_link: Optional. The defaultConfigurationLink of the artifact, - must be a readable storage page blob. - :paramtype default_configuration_link: str - """ - super().__init__(**kwargs) - self.media_link = media_link - self.default_configuration_link = default_configuration_link - - -class UserAssignedIdentitiesValue(_serialization.Model): - """UserAssignedIdentitiesValue. - - 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: Optional[str] = None - self.client_id: Optional[str] = None - - -class VaultCertificate(_serialization.Model): - """Describes a single certificate reference in a Key Vault, and where the certificate should - reside on the VM. - - :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as - a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `} :code:`
    ` To install - certificates on a virtual machine it is recommended to use the `Azure Key Vault virtual machine - extension for Linux - `_ or the `Azure - Key Vault virtual machine extension for Windows - `_. - :vartype certificate_url: str - :ivar certificate_store: For Windows VMs, specifies the certificate store on the Virtual - Machine to which the certificate should be added. The specified certificate store is implicitly - in the LocalMachine account. :code:`
    `\\ :code:`
    `For Linux VMs, the certificate file is - placed under the /var/lib/waagent directory, with the file name <UppercaseThumbprint>.crt - for the X509 certificate file and <UppercaseThumbprint>.prv for private key. Both of - these files are .pem formatted. - :vartype certificate_store: str - """ - - _attribute_map = { - "certificate_url": {"key": "certificateUrl", "type": "str"}, - "certificate_store": {"key": "certificateStore", "type": "str"}, - } - - def __init__( - self, *, certificate_url: Optional[str] = None, certificate_store: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault - as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `} :code:`
    ` To install - certificates on a virtual machine it is recommended to use the `Azure Key Vault virtual machine - extension for Linux - `_ or the `Azure - Key Vault virtual machine extension for Windows - `_. - :paramtype certificate_url: str - :keyword certificate_store: For Windows VMs, specifies the certificate store on the Virtual - Machine to which the certificate should be added. The specified certificate store is implicitly - in the LocalMachine account. :code:`
    `\\ :code:`
    `For Linux VMs, the certificate file is - placed under the /var/lib/waagent directory, with the file name <UppercaseThumbprint>.crt - for the X509 certificate file and <UppercaseThumbprint>.prv for private key. Both of - these files are .pem formatted. - :paramtype certificate_store: str - """ - super().__init__(**kwargs) - self.certificate_url = certificate_url - self.certificate_store = certificate_store - - -class VaultSecretGroup(_serialization.Model): - """Describes a set of certificates which are all in the same Key Vault. - - :ivar source_vault: The relative URL of the Key Vault containing all of the certificates in - VaultCertificates. - :vartype source_vault: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar vault_certificates: The list of key vault references in SourceVault which contain - certificates. - :vartype vault_certificates: list[~azure.mgmt.compute.v2021_07_01.models.VaultCertificate] - """ - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - "vault_certificates": {"key": "vaultCertificates", "type": "[VaultCertificate]"}, - } - - def __init__( - self, - *, - source_vault: Optional["_models.SubResource"] = None, - vault_certificates: Optional[List["_models.VaultCertificate"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source_vault: The relative URL of the Key Vault containing all of the certificates in - VaultCertificates. - :paramtype source_vault: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword vault_certificates: The list of key vault references in SourceVault which contain - certificates. - :paramtype vault_certificates: list[~azure.mgmt.compute.v2021_07_01.models.VaultCertificate] - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.vault_certificates = vault_certificates - - -class VirtualHardDisk(_serialization.Model): - """Describes the uri of a disk. - - :ivar uri: Specifies the virtual hard disk's uri. - :vartype uri: str - """ - - _attribute_map = { - "uri": {"key": "uri", "type": "str"}, - } - - def __init__(self, *, uri: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword uri: Specifies the virtual hard disk's uri. - :paramtype uri: str - """ - super().__init__(**kwargs) - self.uri = uri - - -class VirtualMachine(Resource): - """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. - :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] - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2021_07_01.models.Plan - :ivar resources: The virtual machine child extension resources. - :vartype resources: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension] - :ivar identity: The identity of the virtual machine, if configured. - :vartype identity: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineIdentity - :ivar zones: The virtual machine zones. - :vartype zones: list[str] - :ivar extended_location: The extended location of the Virtual Machine. - :vartype extended_location: ~azure.mgmt.compute.v2021_07_01.models.ExtendedLocation - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2021_07_01.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2021_07_01.models.StorageProfile - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine. - :vartype additional_capabilities: ~azure.mgmt.compute.v2021_07_01.models.AdditionalCapabilities - :ivar os_profile: Specifies the operating system settings used while creating the virtual - machine. Some of the settings cannot be changed once VM is provisioned. - :vartype os_profile: ~azure.mgmt.compute.v2021_07_01.models.OSProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2021_07_01.models.NetworkProfile - :ivar security_profile: Specifies the Security related profile settings for the virtual - machine. - :vartype security_profile: ~azure.mgmt.compute.v2021_07_01.models.SecurityProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2021_07_01.models.DiagnosticsProfile - :ivar availability_set: 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 overview - `_. :code:`
    `\\ - :code:`
    ` For more information on Azure planned maintenance, see `Maintenance and updates - for Virtual Machines in Azure - `_ :code:`
    `\\ - :code:`
    ` Currently, a VM can only be added to availability set at creation time. The - availability set to which the VM is being added should be under the same resource group as the - availability set resource. An existing VM cannot be added to an availability set. - :code:`
    `\\ :code:`
    `This property cannot exist along with a non-null - properties.virtualMachineScaleSet reference. - :vartype availability_set: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar virtual_machine_scale_set: Specifies information about the virtual machine scale set that - the virtual machine should be assigned to. Virtual machines specified in the same virtual - machine scale set are allocated to different nodes to maximize availability. Currently, a VM - can only be added to virtual machine scale set at creation time. An existing VM cannot be added - to a virtual machine scale set. :code:`
    `\\ :code:`
    `This property cannot exist along - with a non-null properties.availabilitySet reference. :code:`
    `\\ :code:`
    `Minimum - api‐version: 2019‐03‐01. - :vartype virtual_machine_scale_set: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the virtual machine should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar priority: Specifies the priority for the virtual machine. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :vartype priority: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePriorityTypes - :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, both - 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. - :code:`
    `\\ :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are - supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and - "Delete". - :vartype eviction_policy: str or - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineEvictionPolicyTypes - :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2021_07_01.models.BillingProfile - :ivar host: Specifies information about the dedicated host that the virtual machine resides in. - :code:`
    `\\ :code:`
    `Minimum api-version: 2018-10-01. - :vartype host: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar host_group: Specifies information about the dedicated host group that the virtual machine - resides in. :code:`
    `\\ :code:`
    `Minimum api-version: 2020-06-01. :code:`
    `\\ - :code:`
    `NOTE: User cannot specify both host and hostGroup properties. - :vartype host_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineInstanceView - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. :code:`
    `\\ :code:`
    ` Possible values for Windows Server operating system - are: :code:`
    `\\ :code:`
    ` Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server - :code:`
    `\\ :code:`
    ` Possible values for Linux Server operating system are: - :code:`
    `\\ :code:`
    ` RHEL_BYOS (for RHEL) :code:`
    `\\ :code:`
    ` SLES_BYOS (for - SUSE) :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid Use Benefit for - Windows Server - `_ - :code:`
    `\\ :code:`
    ` `Azure Hybrid Use Benefit for Linux Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar vm_id: Specifies the VM unique ID which is a 128-bits identifier that is encoded and - stored in all Azure IaaS VMs SMBIOS and can be read using platform BIOS commands. - :vartype vm_id: str - :ivar extensions_time_budget: Specifies the time alloted for all extensions to start. The time - duration should be between 15 minutes and 120 minutes (inclusive) and should be specified in - ISO 8601 format. The default value is 90 minutes (PT1H30M). :code:`
    `\\ :code:`
    ` Minimum - api-version: 2020-06-01. - :vartype extensions_time_budget: str - :ivar platform_fault_domain: Specifies the scale set logical fault domain into which the - Virtual Machine will be created. By default, the Virtual Machine will by automatically assigned - to a fault domain that best maintains balance across available fault domains.\\ :code:`
    `\\ - :code:`
  • `This is applicable only if the 'virtualMachineScaleSet' property of this Virtual - Machine is set.\\ :code:`
  • `The Virtual Machine Scale Set that is referenced, must have - 'platformFaultDomainCount' > 1.\\ :code:`
  • `This property cannot be updated once the - Virtual Machine is created.\\ :code:`
  • `Fault domain assignment can be viewed in the Virtual - Machine Instance View.\\ :code:`
    `\\ :code:`
    `Minimum api‐version: 2020‐12‐01. - :vartype platform_fault_domain: int - :ivar scheduled_events_profile: Specifies Scheduled Event related configurations. - :vartype scheduled_events_profile: - ~azure.mgmt.compute.v2021_07_01.models.ScheduledEventsProfile - :ivar user_data: UserData for the VM, which must be base-64 encoded. Customer should not pass - any secrets in here. :code:`
    `\\ :code:`
    `Minimum api-version: 2021-03-01. - :vartype user_data: str - :ivar capacity_reservation: Specifies information about the capacity reservation that is used - to allocate virtual machine. :code:`
    `\\ :code:`
    `Minimum api-version: 2021-04-01. - :vartype capacity_reservation: - ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationProfile - :ivar application_profile: Specifies the gallery applications that should be made available to - the VM/VMSS. - :vartype application_profile: ~azure.mgmt.compute.v2021_07_01.models.ApplicationProfile - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "resources": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - "vm_id": {"readonly": 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}"}, - "plan": {"key": "plan", "type": "Plan"}, - "resources": {"key": "resources", "type": "[VirtualMachineExtension]"}, - "identity": {"key": "identity", "type": "VirtualMachineIdentity"}, - "zones": {"key": "zones", "type": "[str]"}, - "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "security_profile": {"key": "properties.securityProfile", "type": "SecurityProfile"}, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "virtual_machine_scale_set": {"key": "properties.virtualMachineScaleSet", "type": "SubResource"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "priority": {"key": "properties.priority", "type": "str"}, - "eviction_policy": {"key": "properties.evictionPolicy", "type": "str"}, - "billing_profile": {"key": "properties.billingProfile", "type": "BillingProfile"}, - "host": {"key": "properties.host", "type": "SubResource"}, - "host_group": {"key": "properties.hostGroup", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineInstanceView"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - "extensions_time_budget": {"key": "properties.extensionsTimeBudget", "type": "str"}, - "platform_fault_domain": {"key": "properties.platformFaultDomain", "type": "int"}, - "scheduled_events_profile": {"key": "properties.scheduledEventsProfile", "type": "ScheduledEventsProfile"}, - "user_data": {"key": "properties.userData", "type": "str"}, - "capacity_reservation": {"key": "properties.capacityReservation", "type": "CapacityReservationProfile"}, - "application_profile": {"key": "properties.applicationProfile", "type": "ApplicationProfile"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineIdentity"] = None, - zones: Optional[List[str]] = None, - extended_location: Optional["_models.ExtendedLocation"] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - os_profile: Optional["_models.OSProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - security_profile: Optional["_models.SecurityProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - virtual_machine_scale_set: Optional["_models.SubResource"] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["_models.BillingProfile"] = None, - host: Optional["_models.SubResource"] = None, - host_group: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - extensions_time_budget: Optional[str] = None, - platform_fault_domain: Optional[int] = None, - scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, - user_data: Optional[str] = None, - capacity_reservation: Optional["_models.CapacityReservationProfile"] = None, - application_profile: Optional["_models.ApplicationProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2021_07_01.models.Plan - :keyword identity: The identity of the virtual machine, if configured. - :paramtype identity: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineIdentity - :keyword zones: The virtual machine zones. - :paramtype zones: list[str] - :keyword extended_location: The extended location of the Virtual Machine. - :paramtype extended_location: ~azure.mgmt.compute.v2021_07_01.models.ExtendedLocation - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2021_07_01.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2021_07_01.models.StorageProfile - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2021_07_01.models.AdditionalCapabilities - :keyword os_profile: Specifies the operating system settings used while creating the virtual - machine. Some of the settings cannot be changed once VM is provisioned. - :paramtype os_profile: ~azure.mgmt.compute.v2021_07_01.models.OSProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2021_07_01.models.NetworkProfile - :keyword security_profile: Specifies the Security related profile settings for the virtual - machine. - :paramtype security_profile: ~azure.mgmt.compute.v2021_07_01.models.SecurityProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2021_07_01.models.DiagnosticsProfile - :keyword availability_set: 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 overview - `_. :code:`
    `\\ - :code:`
    ` For more information on Azure planned maintenance, see `Maintenance and updates - for Virtual Machines in Azure - `_ :code:`
    `\\ - :code:`
    ` Currently, a VM can only be added to availability set at creation time. The - availability set to which the VM is being added should be under the same resource group as the - availability set resource. An existing VM cannot be added to an availability set. - :code:`
    `\\ :code:`
    `This property cannot exist along with a non-null - properties.virtualMachineScaleSet reference. - :paramtype availability_set: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword virtual_machine_scale_set: Specifies information about the virtual machine scale set - that the virtual machine should be assigned to. Virtual machines specified in the same virtual - machine scale set are allocated to different nodes to maximize availability. Currently, a VM - can only be added to virtual machine scale set at creation time. An existing VM cannot be added - to a virtual machine scale set. :code:`
    `\\ :code:`
    `This property cannot exist along - with a non-null properties.availabilitySet reference. :code:`
    `\\ :code:`
    `Minimum - api‐version: 2019‐03‐01. - :paramtype virtual_machine_scale_set: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the virtual machine should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword priority: Specifies the priority for the virtual machine. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :paramtype priority: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePriorityTypes - :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, both - 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. - :code:`
    `\\ :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are - supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and - "Delete". - :paramtype eviction_policy: str or - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineEvictionPolicyTypes - :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual - machine. :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2021_07_01.models.BillingProfile - :keyword host: Specifies information about the dedicated host that the virtual machine resides - in. :code:`
    `\\ :code:`
    `Minimum api-version: 2018-10-01. - :paramtype host: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword host_group: Specifies information about the dedicated host group that the virtual - machine resides in. :code:`
    `\\ :code:`
    `Minimum api-version: 2020-06-01. :code:`
    `\\ - :code:`
    `NOTE: User cannot specify both host and hostGroup properties. - :paramtype host_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. :code:`
    `\\ :code:`
    ` Possible values for Windows Server operating system - are: :code:`
    `\\ :code:`
    ` Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server - :code:`
    `\\ :code:`
    ` Possible values for Linux Server operating system are: - :code:`
    `\\ :code:`
    ` RHEL_BYOS (for RHEL) :code:`
    `\\ :code:`
    ` SLES_BYOS (for - SUSE) :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid Use Benefit for - Windows Server - `_ - :code:`
    `\\ :code:`
    ` `Azure Hybrid Use Benefit for Linux Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - :keyword extensions_time_budget: Specifies the time alloted for all extensions to start. The - time duration should be between 15 minutes and 120 minutes (inclusive) and should be specified - in ISO 8601 format. The default value is 90 minutes (PT1H30M). :code:`
    `\\ :code:`
    ` - Minimum api-version: 2020-06-01. - :paramtype extensions_time_budget: str - :keyword platform_fault_domain: Specifies the scale set logical fault domain into which the - Virtual Machine will be created. By default, the Virtual Machine will by automatically assigned - to a fault domain that best maintains balance across available fault domains.\\ :code:`
    `\\ - :code:`
  • `This is applicable only if the 'virtualMachineScaleSet' property of this Virtual - Machine is set.\\ :code:`
  • `The Virtual Machine Scale Set that is referenced, must have - 'platformFaultDomainCount' > 1.\\ :code:`
  • `This property cannot be updated once the - Virtual Machine is created.\\ :code:`
  • `Fault domain assignment can be viewed in the Virtual - Machine Instance View.\\ :code:`
    `\\ :code:`
    `Minimum api‐version: 2020‐12‐01. - :paramtype platform_fault_domain: int - :keyword scheduled_events_profile: Specifies Scheduled Event related configurations. - :paramtype scheduled_events_profile: - ~azure.mgmt.compute.v2021_07_01.models.ScheduledEventsProfile - :keyword user_data: UserData for the VM, which must be base-64 encoded. Customer should not - pass any secrets in here. :code:`
    `\\ :code:`
    `Minimum api-version: 2021-03-01. - :paramtype user_data: str - :keyword capacity_reservation: Specifies information about the capacity reservation that is - used to allocate virtual machine. :code:`
    `\\ :code:`
    `Minimum api-version: 2021-04-01. - :paramtype capacity_reservation: - ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationProfile - :keyword application_profile: Specifies the gallery applications that should be made available - to the VM/VMSS. - :paramtype application_profile: ~azure.mgmt.compute.v2021_07_01.models.ApplicationProfile - """ - super().__init__(location=location, tags=tags, **kwargs) - self.plan = plan - self.resources: Optional[List["_models.VirtualMachineExtension"]] = None - self.identity = identity - self.zones = zones - self.extended_location = extended_location - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.additional_capabilities = additional_capabilities - self.os_profile = os_profile - self.network_profile = network_profile - self.security_profile = security_profile - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.virtual_machine_scale_set = virtual_machine_scale_set - self.proximity_placement_group = proximity_placement_group - self.priority = priority - self.eviction_policy = eviction_policy - self.billing_profile = billing_profile - self.host = host - self.host_group = host_group - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineInstanceView"] = None - self.license_type = license_type - self.vm_id: Optional[str] = None - self.extensions_time_budget = extensions_time_budget - self.platform_fault_domain = platform_fault_domain - self.scheduled_events_profile = scheduled_events_profile - self.user_data = user_data - self.capacity_reservation = capacity_reservation - self.application_profile = application_profile - - -class VirtualMachineAgentInstanceView(_serialization.Model): - """The instance view of the VM Agent running on the virtual machine. - - :ivar vm_agent_version: The VM Agent full version. - :vartype vm_agent_version: str - :ivar extension_handlers: The virtual machine extension handler instance view. - :vartype extension_handlers: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionHandlerInstanceView] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "vm_agent_version": {"key": "vmAgentVersion", "type": "str"}, - "extension_handlers": {"key": "extensionHandlers", "type": "[VirtualMachineExtensionHandlerInstanceView]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword vm_agent_version: The VM Agent full version. - :paramtype vm_agent_version: str - :keyword extension_handlers: The virtual machine extension handler instance view. - :paramtype extension_handlers: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionHandlerInstanceView] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.vm_agent_version = vm_agent_version - self.extension_handlers = extension_handlers - self.statuses = statuses - - -class VirtualMachineAssessPatchesResult(_serialization.Model): - """Describes the properties of an AssessPatches result. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The overall success or failure status of the operation. It remains "InProgress" - until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", - and "CompletedWithWarnings". - :vartype status: str or ~azure.mgmt.compute.v2021_07_01.models.PatchOperationStatus - :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is - used to correlate across CRP and extension logs. - :vartype assessment_activity_id: str - :ivar reboot_pending: The overall reboot status of the VM. It will be true when partially - installed patches require a reboot to complete installation but the reboot has not yet - occurred. - :vartype reboot_pending: bool - :ivar critical_and_security_patch_count: The number of critical or security patches that have - been detected as available and not yet installed. - :vartype critical_and_security_patch_count: int - :ivar other_patch_count: The number of all available patches excluding critical and security. - :vartype other_patch_count: int - :ivar start_date_time: The UTC timestamp when the operation began. - :vartype start_date_time: ~datetime.datetime - :ivar available_patches: The list of patches that have been detected as available for - installation. - :vartype available_patches: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineSoftwarePatchProperties] - :ivar error: The errors that were encountered during execution of the operation. The details - array contains the list of them. - :vartype error: ~azure.mgmt.compute.v2021_07_01.models.ApiError - """ - - _validation = { - "status": {"readonly": True}, - "assessment_activity_id": {"readonly": True}, - "reboot_pending": {"readonly": True}, - "critical_and_security_patch_count": {"readonly": True}, - "other_patch_count": {"readonly": True}, - "start_date_time": {"readonly": True}, - "available_patches": {"readonly": True}, - "error": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "assessment_activity_id": {"key": "assessmentActivityId", "type": "str"}, - "reboot_pending": {"key": "rebootPending", "type": "bool"}, - "critical_and_security_patch_count": {"key": "criticalAndSecurityPatchCount", "type": "int"}, - "other_patch_count": {"key": "otherPatchCount", "type": "int"}, - "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, - "available_patches": {"key": "availablePatches", "type": "[VirtualMachineSoftwarePatchProperties]"}, - "error": {"key": "error", "type": "ApiError"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional[Union[str, "_models.PatchOperationStatus"]] = None - self.assessment_activity_id: Optional[str] = None - self.reboot_pending: Optional[bool] = None - self.critical_and_security_patch_count: Optional[int] = None - self.other_patch_count: Optional[int] = None - self.start_date_time: Optional[datetime.datetime] = None - self.available_patches: Optional[List["_models.VirtualMachineSoftwarePatchProperties"]] = None - self.error: Optional["_models.ApiError"] = None - - -class VirtualMachineCaptureParameters(_serialization.Model): - """Capture Virtual Machine parameters. - - All required parameters must be populated in order to send to server. - - :ivar vhd_prefix: The captured virtual hard disk's name prefix. Required. - :vartype vhd_prefix: str - :ivar destination_container_name: The destination container name. Required. - :vartype destination_container_name: str - :ivar overwrite_vhds: Specifies whether to overwrite the destination virtual hard disk, in case - of conflict. Required. - :vartype overwrite_vhds: bool - """ - - _validation = { - "vhd_prefix": {"required": True}, - "destination_container_name": {"required": True}, - "overwrite_vhds": {"required": True}, - } - - _attribute_map = { - "vhd_prefix": {"key": "vhdPrefix", "type": "str"}, - "destination_container_name": {"key": "destinationContainerName", "type": "str"}, - "overwrite_vhds": {"key": "overwriteVhds", "type": "bool"}, - } - - def __init__( - self, *, vhd_prefix: str, destination_container_name: str, overwrite_vhds: bool, **kwargs: Any - ) -> None: - """ - :keyword vhd_prefix: The captured virtual hard disk's name prefix. Required. - :paramtype vhd_prefix: str - :keyword destination_container_name: The destination container name. Required. - :paramtype destination_container_name: str - :keyword overwrite_vhds: Specifies whether to overwrite the destination virtual hard disk, in - case of conflict. Required. - :paramtype overwrite_vhds: bool - """ - super().__init__(**kwargs) - self.vhd_prefix = vhd_prefix - self.destination_container_name = destination_container_name - self.overwrite_vhds = overwrite_vhds - - -class VirtualMachineCaptureResult(SubResource): - """Output of virtual machine capture operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar schema: the schema of the captured virtual machine. - :vartype schema: str - :ivar content_version: the version of the content. - :vartype content_version: str - :ivar parameters: parameters of the captured virtual machine. - :vartype parameters: JSON - :ivar resources: a list of resource items of the captured virtual machine. - :vartype resources: list[JSON] - """ - - _validation = { - "schema": {"readonly": True}, - "content_version": {"readonly": True}, - "parameters": {"readonly": True}, - "resources": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "schema": {"key": "$schema", "type": "str"}, - "content_version": {"key": "contentVersion", "type": "str"}, - "parameters": {"key": "parameters", "type": "object"}, - "resources": {"key": "resources", "type": "[object]"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(id=id, **kwargs) - self.schema: Optional[str] = None - self.content_version: Optional[str] = None - self.parameters: Optional[JSON] = None - self.resources: Optional[List[JSON]] = None - - -class VirtualMachineExtension(Resource): - """Describes a Virtual Machine Extension. - - 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] - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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. - :vartype instance_view: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionInstanceView - :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. - :vartype suppress_failures: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "enable_automatic_upgrade": {"key": "properties.enableAutomaticUpgrade", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineExtensionInstanceView"}, - "suppress_failures": {"key": "properties.suppressFailures", "type": "bool"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, 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, - instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, - suppress_failures: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :keyword instance_view: The virtual machine extension instance view. - :paramtype instance_view: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionInstanceView - :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. - :paramtype suppress_failures: bool - """ - super().__init__(location=location, tags=tags, **kwargs) - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.enable_automatic_upgrade = enable_automatic_upgrade - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - self.instance_view = instance_view - self.suppress_failures = suppress_failures - - -class VirtualMachineExtensionHandlerInstanceView(_serialization.Model): # pylint: disable=name-too-long - """The instance view of a virtual machine extension handler. - - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar status: The extension handler status. - :vartype status: ~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "status": {"key": "status", "type": "InstanceViewStatus"}, - } - - def __init__( - self, - *, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - status: Optional["_models.InstanceViewStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword status: The extension handler status. - :paramtype status: ~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus - """ - super().__init__(**kwargs) - self.type = type - self.type_handler_version = type_handler_version - self.status = status - - -class VirtualMachineExtensionImage(Resource): - """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. - :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] - :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. - :vartype compute_role: str - :ivar handler_schema: The schema defined by publisher, where extension consumers should provide - settings in a matching schema. - :vartype handler_schema: str - :ivar vm_scale_set_enabled: Whether the extension can be used on xRP VMScaleSets. By default - existing extensions are usable on scalesets, but there might be cases where a publisher wants - to explicitly indicate the extension is only enabled for CRP VMs but not VMSS. - :vartype vm_scale_set_enabled: bool - :ivar supports_multiple_extensions: Whether the handler can support multiple extensions. - :vartype supports_multiple_extensions: bool - """ - - _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}"}, - "operating_system": {"key": "properties.operatingSystem", "type": "str"}, - "compute_role": {"key": "properties.computeRole", "type": "str"}, - "handler_schema": {"key": "properties.handlerSchema", "type": "str"}, - "vm_scale_set_enabled": {"key": "properties.vmScaleSetEnabled", "type": "bool"}, - "supports_multiple_extensions": {"key": "properties.supportsMultipleExtensions", "type": "bool"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - operating_system: Optional[str] = None, - compute_role: Optional[str] = None, - handler_schema: Optional[str] = None, - vm_scale_set_enabled: Optional[bool] = None, - supports_multiple_extensions: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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. - :paramtype compute_role: str - :keyword handler_schema: The schema defined by publisher, where extension consumers should - provide settings in a matching schema. - :paramtype handler_schema: str - :keyword vm_scale_set_enabled: Whether the extension can be used on xRP VMScaleSets. By default - existing extensions are usable on scalesets, but there might be cases where a publisher wants - to explicitly indicate the extension is only enabled for CRP VMs but not VMSS. - :paramtype vm_scale_set_enabled: bool - :keyword supports_multiple_extensions: Whether the handler can support multiple extensions. - :paramtype supports_multiple_extensions: bool - """ - super().__init__(location=location, tags=tags, **kwargs) - self.operating_system = operating_system - self.compute_role = compute_role - self.handler_schema = handler_schema - self.vm_scale_set_enabled = vm_scale_set_enabled - self.supports_multiple_extensions = supports_multiple_extensions - - -class VirtualMachineExtensionInstanceView(_serialization.Model): - """The instance view of a virtual machine extension. - - :ivar name: The virtual machine extension name. - :vartype name: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar substatuses: The resource status information. - :vartype substatuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "substatuses": {"key": "substatuses", "type": "[InstanceViewStatus]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - substatuses: Optional[List["_models.InstanceViewStatus"]] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The virtual machine extension name. - :paramtype name: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword substatuses: The resource status information. - :paramtype substatuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.name = name - self.type = type - self.type_handler_version = type_handler_version - self.substatuses = substatuses - self.statuses = statuses - - -class VirtualMachineExtensionsListResult(_serialization.Model): - """The List Extension operation response. - - :ivar value: The list of extensions. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineExtension]"}, - } - - def __init__(self, *, value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of extensions. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension] - """ - super().__init__(**kwargs) - self.value = value - - -class VirtualMachineExtensionUpdate(UpdateResource): - """Describes a Virtual Machine Extension. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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. - :vartype suppress_failures: bool - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "enable_automatic_upgrade": {"key": "properties.enableAutomaticUpgrade", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "suppress_failures": {"key": "properties.suppressFailures", "type": "bool"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - force_update_tag: Optional[str] = None, - publisher: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - auto_upgrade_minor_version: Optional[bool] = None, - enable_automatic_upgrade: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - suppress_failures: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". - :paramtype type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :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. - :paramtype suppress_failures: bool - """ - super().__init__(tags=tags, **kwargs) - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type = type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.enable_automatic_upgrade = enable_automatic_upgrade - self.settings = settings - self.protected_settings = protected_settings - self.suppress_failures = suppress_failures - - -class VirtualMachineHealthStatus(_serialization.Model): - """The health status of the VM. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The health status information for the VM. - :vartype status: ~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus - """ - - _validation = { - "status": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "InstanceViewStatus"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional["_models.InstanceViewStatus"] = None - - -class VirtualMachineIdentity(_serialization.Model): - """Identity for the virtual machine. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of virtual machine identity. This property will only be - provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the virtual machine. This property will only be - provided for a system assigned identity. - :vartype tenant_id: str - :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, - UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Known values - are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :vartype type: str or ~azure.mgmt.compute.v2021_07_01.models.ResourceIdentityType - :ivar user_assigned_identities: The list of user identities associated with the Virtual - Machine. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2021_07_01.models.UserAssignedIdentitiesValue] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentitiesValue}"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, - UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Known values - are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :paramtype type: str or ~azure.mgmt.compute.v2021_07_01.models.ResourceIdentityType - :keyword user_assigned_identities: The list of user identities associated with the Virtual - Machine. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2021_07_01.models.UserAssignedIdentitiesValue] - """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.type = type - self.user_assigned_identities = user_assigned_identities - - -class VirtualMachineImageResource(SubResource): - """Virtual machine image resource information. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar location: The supported Azure location of the resource. Required. - :vartype location: str - :ivar tags: Specifies the tags that are assigned to the virtual machine. For more information - about using tags, see `Using tags to organize your Azure resources - `_. - :vartype tags: dict[str, str] - :ivar extended_location: The extended location of the Virtual Machine. - :vartype extended_location: ~azure.mgmt.compute.v2021_07_01.models.ExtendedLocation - """ - - _validation = { - "name": {"required": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - } - - def __init__( - self, - *, - name: str, - location: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - tags: Optional[Dict[str, str]] = None, - extended_location: Optional["_models.ExtendedLocation"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The name of the resource. Required. - :paramtype name: str - :keyword location: The supported Azure location of the resource. Required. - :paramtype location: str - :keyword tags: Specifies the tags that are assigned to the virtual machine. For more - information about using tags, see `Using tags to organize your Azure resources - `_. - :paramtype tags: dict[str, str] - :keyword extended_location: The extended location of the Virtual Machine. - :paramtype extended_location: ~azure.mgmt.compute.v2021_07_01.models.ExtendedLocation - """ - super().__init__(id=id, **kwargs) - self.name = name - self.location = location - self.tags = tags - self.extended_location = extended_location - - -class VirtualMachineImage(VirtualMachineImageResource): - """Describes a Virtual Machine Image. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the resource. Required. - :vartype name: str - :ivar location: The supported Azure location of the resource. Required. - :vartype location: str - :ivar tags: Specifies the tags that are assigned to the virtual machine. For more information - about using tags, see `Using tags to organize your Azure resources - `_. - :vartype tags: dict[str, str] - :ivar extended_location: The extended location of the Virtual Machine. - :vartype extended_location: ~azure.mgmt.compute.v2021_07_01.models.ExtendedLocation - :ivar plan: Used for establishing the purchase context of any 3rd Party artifact through - MarketPlace. - :vartype plan: ~azure.mgmt.compute.v2021_07_01.models.PurchasePlan - :ivar os_disk_image: Contains the os disk image information. - :vartype os_disk_image: ~azure.mgmt.compute.v2021_07_01.models.OSDiskImage - :ivar data_disk_images: - :vartype data_disk_images: list[~azure.mgmt.compute.v2021_07_01.models.DataDiskImage] - :ivar automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. - :vartype automatic_os_upgrade_properties: - ~azure.mgmt.compute.v2021_07_01.models.AutomaticOSUpgradeProperties - :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or - ~azure.mgmt.compute.v2021_07_01.models.HyperVGenerationTypes - :ivar disallowed: Specifies disallowed configuration for the VirtualMachine created from the - image. - :vartype disallowed: ~azure.mgmt.compute.v2021_07_01.models.DisallowedConfiguration - :ivar features: - :vartype features: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageFeature] - """ - - _validation = { - "name": {"required": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - "plan": {"key": "properties.plan", "type": "PurchasePlan"}, - "os_disk_image": {"key": "properties.osDiskImage", "type": "OSDiskImage"}, - "data_disk_images": {"key": "properties.dataDiskImages", "type": "[DataDiskImage]"}, - "automatic_os_upgrade_properties": { - "key": "properties.automaticOSUpgradeProperties", - "type": "AutomaticOSUpgradeProperties", - }, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "disallowed": {"key": "properties.disallowed", "type": "DisallowedConfiguration"}, - "features": {"key": "properties.features", "type": "[VirtualMachineImageFeature]"}, - } - - def __init__( - self, - *, - name: str, - location: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - tags: Optional[Dict[str, str]] = None, - extended_location: Optional["_models.ExtendedLocation"] = None, - plan: Optional["_models.PurchasePlan"] = None, - os_disk_image: Optional["_models.OSDiskImage"] = None, - data_disk_images: Optional[List["_models.DataDiskImage"]] = None, - automatic_os_upgrade_properties: Optional["_models.AutomaticOSUpgradeProperties"] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, - disallowed: Optional["_models.DisallowedConfiguration"] = None, - features: Optional[List["_models.VirtualMachineImageFeature"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The name of the resource. Required. - :paramtype name: str - :keyword location: The supported Azure location of the resource. Required. - :paramtype location: str - :keyword tags: Specifies the tags that are assigned to the virtual machine. For more - information about using tags, see `Using tags to organize your Azure resources - `_. - :paramtype tags: dict[str, str] - :keyword extended_location: The extended location of the Virtual Machine. - :paramtype extended_location: ~azure.mgmt.compute.v2021_07_01.models.ExtendedLocation - :keyword plan: Used for establishing the purchase context of any 3rd Party artifact through - MarketPlace. - :paramtype plan: ~azure.mgmt.compute.v2021_07_01.models.PurchasePlan - :keyword os_disk_image: Contains the os disk image information. - :paramtype os_disk_image: ~azure.mgmt.compute.v2021_07_01.models.OSDiskImage - :keyword data_disk_images: - :paramtype data_disk_images: list[~azure.mgmt.compute.v2021_07_01.models.DataDiskImage] - :keyword automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the - image. - :paramtype automatic_os_upgrade_properties: - ~azure.mgmt.compute.v2021_07_01.models.AutomaticOSUpgradeProperties - :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1" and - "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2021_07_01.models.HyperVGenerationTypes - :keyword disallowed: Specifies disallowed configuration for the VirtualMachine created from the - image. - :paramtype disallowed: ~azure.mgmt.compute.v2021_07_01.models.DisallowedConfiguration - :keyword features: - :paramtype features: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageFeature] - """ - super().__init__(id=id, name=name, location=location, tags=tags, extended_location=extended_location, **kwargs) - self.plan = plan - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - self.automatic_os_upgrade_properties = automatic_os_upgrade_properties - self.hyper_v_generation = hyper_v_generation - self.disallowed = disallowed - self.features = features - - -class VirtualMachineImageFeature(_serialization.Model): - """Specifies additional capabilities supported by the image. - - :ivar name: The name of the feature. - :vartype name: str - :ivar value: The corresponding value for the feature. - :vartype value: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: The name of the feature. - :paramtype name: str - :keyword value: The corresponding value for the feature. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class VirtualMachineInstallPatchesParameters(_serialization.Model): - """Input for InstallPatches as directly received by the API. - - All required parameters must be populated in order to send to server. - - :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 - :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 - ~azure.mgmt.compute.v2021_07_01.models.VMGuestPatchRebootSetting - :ivar windows_parameters: Input for InstallPatches on a Windows VM, as directly received by the - API. - :vartype windows_parameters: ~azure.mgmt.compute.v2021_07_01.models.WindowsParameters - :ivar linux_parameters: Input for InstallPatches on a Linux VM, as directly received by the - API. - :vartype linux_parameters: ~azure.mgmt.compute.v2021_07_01.models.LinuxParameters - """ - - _validation = { - "reboot_setting": {"required": True}, - } - - _attribute_map = { - "maximum_duration": {"key": "maximumDuration", "type": "str"}, - "reboot_setting": {"key": "rebootSetting", "type": "str"}, - "windows_parameters": {"key": "windowsParameters", "type": "WindowsParameters"}, - "linux_parameters": {"key": "linuxParameters", "type": "LinuxParameters"}, - } - - def __init__( - self, - *, - reboot_setting: Union[str, "_models.VMGuestPatchRebootSetting"], - maximum_duration: Optional[str] = None, - windows_parameters: Optional["_models.WindowsParameters"] = None, - linux_parameters: Optional["_models.LinuxParameters"] = None, - **kwargs: Any - ) -> None: - """ - :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 - :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 - ~azure.mgmt.compute.v2021_07_01.models.VMGuestPatchRebootSetting - :keyword windows_parameters: Input for InstallPatches on a Windows VM, as directly received by - the API. - :paramtype windows_parameters: ~azure.mgmt.compute.v2021_07_01.models.WindowsParameters - :keyword linux_parameters: Input for InstallPatches on a Linux VM, as directly received by the - API. - :paramtype linux_parameters: ~azure.mgmt.compute.v2021_07_01.models.LinuxParameters - """ - super().__init__(**kwargs) - self.maximum_duration = maximum_duration - self.reboot_setting = reboot_setting - self.windows_parameters = windows_parameters - self.linux_parameters = linux_parameters - - -class VirtualMachineInstallPatchesResult(_serialization.Model): - """The result summary of an installation operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The overall success or failure status of the operation. It remains "InProgress" - until the operation completes. At that point it will become "Failed", "Succeeded", "Unknown" or - "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", and - "CompletedWithWarnings". - :vartype status: str or ~azure.mgmt.compute.v2021_07_01.models.PatchOperationStatus - :ivar installation_activity_id: The activity ID of the operation that produced this result. It - is used to correlate across CRP and extension logs. - :vartype installation_activity_id: str - :ivar reboot_status: The reboot state of the VM following completion of the operation. Known - values are: "Unknown", "NotNeeded", "Required", "Started", "Failed", and "Completed". - :vartype reboot_status: str or ~azure.mgmt.compute.v2021_07_01.models.VMGuestPatchRebootStatus - :ivar maintenance_window_exceeded: Whether the operation ran out of time before it completed - all its intended actions. - :vartype maintenance_window_exceeded: bool - :ivar excluded_patch_count: The number of patches that were not installed due to the user - blocking their installation. - :vartype excluded_patch_count: int - :ivar not_selected_patch_count: The number of patches that were detected as available for - install, but did not meet the operation's criteria. - :vartype not_selected_patch_count: int - :ivar pending_patch_count: The number of patches that were identified as meeting the - installation criteria, but were not able to be installed. Typically this happens when - maintenanceWindowExceeded == true. - :vartype pending_patch_count: int - :ivar installed_patch_count: The number of patches successfully installed. - :vartype installed_patch_count: int - :ivar failed_patch_count: The number of patches that could not be installed due to some issue. - See errors for details. - :vartype failed_patch_count: int - :ivar patches: The patches that were installed during the operation. - :vartype patches: list[~azure.mgmt.compute.v2021_07_01.models.PatchInstallationDetail] - :ivar start_date_time: The UTC timestamp when the operation began. - :vartype start_date_time: ~datetime.datetime - :ivar error: The errors that were encountered during execution of the operation. The details - array contains the list of them. - :vartype error: ~azure.mgmt.compute.v2021_07_01.models.ApiError - """ - - _validation = { - "status": {"readonly": True}, - "installation_activity_id": {"readonly": True}, - "reboot_status": {"readonly": True}, - "maintenance_window_exceeded": {"readonly": True}, - "excluded_patch_count": {"readonly": True}, - "not_selected_patch_count": {"readonly": True}, - "pending_patch_count": {"readonly": True}, - "installed_patch_count": {"readonly": True}, - "failed_patch_count": {"readonly": True}, - "patches": {"readonly": True}, - "start_date_time": {"readonly": True}, - "error": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "installation_activity_id": {"key": "installationActivityId", "type": "str"}, - "reboot_status": {"key": "rebootStatus", "type": "str"}, - "maintenance_window_exceeded": {"key": "maintenanceWindowExceeded", "type": "bool"}, - "excluded_patch_count": {"key": "excludedPatchCount", "type": "int"}, - "not_selected_patch_count": {"key": "notSelectedPatchCount", "type": "int"}, - "pending_patch_count": {"key": "pendingPatchCount", "type": "int"}, - "installed_patch_count": {"key": "installedPatchCount", "type": "int"}, - "failed_patch_count": {"key": "failedPatchCount", "type": "int"}, - "patches": {"key": "patches", "type": "[PatchInstallationDetail]"}, - "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, - "error": {"key": "error", "type": "ApiError"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional[Union[str, "_models.PatchOperationStatus"]] = None - self.installation_activity_id: Optional[str] = None - self.reboot_status: Optional[Union[str, "_models.VMGuestPatchRebootStatus"]] = None - self.maintenance_window_exceeded: Optional[bool] = None - self.excluded_patch_count: Optional[int] = None - self.not_selected_patch_count: Optional[int] = None - self.pending_patch_count: Optional[int] = None - self.installed_patch_count: Optional[int] = None - self.failed_patch_count: Optional[int] = None - self.patches: Optional[List["_models.PatchInstallationDetail"]] = None - self.start_date_time: Optional[datetime.datetime] = None - self.error: Optional["_models.ApiError"] = None - - -class VirtualMachineInstanceView(_serialization.Model): - """The instance view of a virtual machine. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar platform_update_domain: Specifies the update domain of the virtual machine. - :vartype platform_update_domain: int - :ivar platform_fault_domain: Specifies the fault domain of the virtual machine. - :vartype platform_fault_domain: int - :ivar computer_name: The computer name assigned to the virtual machine. - :vartype computer_name: str - :ivar os_name: The Operating System running on the virtual machine. - :vartype os_name: str - :ivar os_version: The version of Operating System running on the virtual machine. - :vartype os_version: str - :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. Known - values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGenerationType - :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. - :vartype rdp_thumb_print: str - :ivar vm_agent: The VM Agent running on the virtual machine. - :vartype vm_agent: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineAgentInstanceView - :ivar maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :vartype maintenance_redeploy_status: - ~azure.mgmt.compute.v2021_07_01.models.MaintenanceRedeployStatus - :ivar disks: The virtual machine disk information. - :vartype disks: list[~azure.mgmt.compute.v2021_07_01.models.DiskInstanceView] - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionInstanceView] - :ivar vm_health: The health status for the VM. - :vartype vm_health: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineHealthStatus - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2021_07_01.models.BootDiagnosticsInstanceView - :ivar assigned_host: Resource id of the dedicated host, on which the virtual machine is - allocated through automatic placement, when the virtual machine is associated with a dedicated - host group that has automatic placement enabled. :code:`
    `\\ :code:`
    `Minimum - api-version: 2020-06-01. - :vartype assigned_host: str - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - :ivar patch_status: [Preview Feature] The status of virtual machine patch operations. - :vartype patch_status: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePatchStatus - """ - - _validation = { - "vm_health": {"readonly": True}, - "assigned_host": {"readonly": True}, - } - - _attribute_map = { - "platform_update_domain": {"key": "platformUpdateDomain", "type": "int"}, - "platform_fault_domain": {"key": "platformFaultDomain", "type": "int"}, - "computer_name": {"key": "computerName", "type": "str"}, - "os_name": {"key": "osName", "type": "str"}, - "os_version": {"key": "osVersion", "type": "str"}, - "hyper_v_generation": {"key": "hyperVGeneration", "type": "str"}, - "rdp_thumb_print": {"key": "rdpThumbPrint", "type": "str"}, - "vm_agent": {"key": "vmAgent", "type": "VirtualMachineAgentInstanceView"}, - "maintenance_redeploy_status": {"key": "maintenanceRedeployStatus", "type": "MaintenanceRedeployStatus"}, - "disks": {"key": "disks", "type": "[DiskInstanceView]"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineExtensionInstanceView]"}, - "vm_health": {"key": "vmHealth", "type": "VirtualMachineHealthStatus"}, - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnosticsInstanceView"}, - "assigned_host": {"key": "assignedHost", "type": "str"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - "patch_status": {"key": "patchStatus", "type": "VirtualMachinePatchStatus"}, - } - - def __init__( - self, - *, - platform_update_domain: Optional[int] = None, - platform_fault_domain: Optional[int] = None, - computer_name: Optional[str] = None, - os_name: Optional[str] = None, - os_version: Optional[str] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationType"]] = None, - rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, - disks: Optional[List["_models.DiskInstanceView"]] = None, - extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - patch_status: Optional["_models.VirtualMachinePatchStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword platform_update_domain: Specifies the update domain of the virtual machine. - :paramtype platform_update_domain: int - :keyword platform_fault_domain: Specifies the fault domain of the virtual machine. - :paramtype platform_fault_domain: int - :keyword computer_name: The computer name assigned to the virtual machine. - :paramtype computer_name: str - :keyword os_name: The Operating System running on the virtual machine. - :paramtype os_name: str - :keyword os_version: The version of Operating System running on the virtual machine. - :paramtype os_version: str - :keyword hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or - ~azure.mgmt.compute.v2021_07_01.models.HyperVGenerationType - :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. - :paramtype rdp_thumb_print: str - :keyword vm_agent: The VM Agent running on the virtual machine. - :paramtype vm_agent: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineAgentInstanceView - :keyword maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :paramtype maintenance_redeploy_status: - ~azure.mgmt.compute.v2021_07_01.models.MaintenanceRedeployStatus - :keyword disks: The virtual machine disk information. - :paramtype disks: list[~azure.mgmt.compute.v2021_07_01.models.DiskInstanceView] - :keyword extensions: The extensions information. - :paramtype extensions: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionInstanceView] - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2021_07_01.models.BootDiagnosticsInstanceView - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - :keyword patch_status: [Preview Feature] The status of virtual machine patch operations. - :paramtype patch_status: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePatchStatus - """ - super().__init__(**kwargs) - self.platform_update_domain = platform_update_domain - self.platform_fault_domain = platform_fault_domain - self.computer_name = computer_name - self.os_name = os_name - self.os_version = os_version - self.hyper_v_generation = hyper_v_generation - self.rdp_thumb_print = rdp_thumb_print - self.vm_agent = vm_agent - self.maintenance_redeploy_status = maintenance_redeploy_status - self.disks = disks - self.extensions = extensions - self.vm_health: Optional["_models.VirtualMachineHealthStatus"] = None - self.boot_diagnostics = boot_diagnostics - self.assigned_host: Optional[str] = None - self.statuses = statuses - self.patch_status = patch_status - - -class VirtualMachineIpTag(_serialization.Model): - """Contains the IP tag associated with the public IP address. - - :ivar ip_tag_type: IP tag type. Example: FirstPartyUsage. - :vartype ip_tag_type: str - :ivar tag: IP tag associated with the public IP. Example: SQL, Storage etc. - :vartype tag: str - """ - - _attribute_map = { - "ip_tag_type": {"key": "ipTagType", "type": "str"}, - "tag": {"key": "tag", "type": "str"}, - } - - def __init__(self, *, ip_tag_type: Optional[str] = None, tag: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword ip_tag_type: IP tag type. Example: FirstPartyUsage. - :paramtype ip_tag_type: str - :keyword tag: IP tag associated with the public IP. Example: SQL, Storage etc. - :paramtype tag: str - """ - super().__init__(**kwargs) - self.ip_tag_type = ip_tag_type - self.tag = tag - - -class VirtualMachineListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machines. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachine] - :ivar next_link: The URI to fetch the next page of VMs. Call ListNext() with this URI to fetch - the next page of Virtual Machines. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachine]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machines. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachine] - :keyword next_link: The URI to fetch the next page of VMs. Call ListNext() with this URI to - fetch the next page of Virtual Machines. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineNetworkInterfaceConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machine network interface configurations. - - All required parameters must be populated in order to send to server. - - :ivar name: The network interface configuration name. Required. - :vartype name: str - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Known values are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions - :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :vartype enable_accelerated_networking: bool - :ivar enable_fpga: Specifies whether the network interface is FPGA networking-enabled. - :vartype enable_fpga: bool - :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :vartype enable_ip_forwarding: bool - :ivar network_security_group: The network security group. - :vartype network_security_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar dns_settings: The dns settings to be applied on the network interfaces. - :vartype dns_settings: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineNetworkInterfaceDnsSettingsConfiguration - :ivar ip_configurations: Specifies the IP configurations of the network interface. - :vartype ip_configurations: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineNetworkInterfaceIPConfiguration] - :ivar dscp_configuration: - :vartype dscp_configuration: ~azure.mgmt.compute.v2021_07_01.models.SubResource - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "delete_option": {"key": "properties.deleteOption", "type": "str"}, - "enable_accelerated_networking": {"key": "properties.enableAcceleratedNetworking", "type": "bool"}, - "enable_fpga": {"key": "properties.enableFpga", "type": "bool"}, - "enable_ip_forwarding": {"key": "properties.enableIPForwarding", "type": "bool"}, - "network_security_group": {"key": "properties.networkSecurityGroup", "type": "SubResource"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineNetworkInterfaceDnsSettingsConfiguration", - }, - "ip_configurations": { - "key": "properties.ipConfigurations", - "type": "[VirtualMachineNetworkInterfaceIPConfiguration]", - }, - "dscp_configuration": {"key": "properties.dscpConfiguration", "type": "SubResource"}, - } - - def __init__( - self, - *, - name: str, - primary: Optional[bool] = None, - delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, - enable_accelerated_networking: Optional[bool] = None, - enable_fpga: Optional[bool] = None, - enable_ip_forwarding: Optional[bool] = None, - network_security_group: Optional["_models.SubResource"] = None, - dns_settings: Optional["_models.VirtualMachineNetworkInterfaceDnsSettingsConfiguration"] = None, - ip_configurations: Optional[List["_models.VirtualMachineNetworkInterfaceIPConfiguration"]] = None, - dscp_configuration: Optional["_models.SubResource"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The network interface configuration name. Required. - :paramtype name: str - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Known values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions - :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :paramtype enable_accelerated_networking: bool - :keyword enable_fpga: Specifies whether the network interface is FPGA networking-enabled. - :paramtype enable_fpga: bool - :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :paramtype enable_ip_forwarding: bool - :keyword network_security_group: The network security group. - :paramtype network_security_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword dns_settings: The dns settings to be applied on the network interfaces. - :paramtype dns_settings: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineNetworkInterfaceDnsSettingsConfiguration - :keyword ip_configurations: Specifies the IP configurations of the network interface. - :paramtype ip_configurations: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineNetworkInterfaceIPConfiguration] - :keyword dscp_configuration: - :paramtype dscp_configuration: ~azure.mgmt.compute.v2021_07_01.models.SubResource - """ - super().__init__(**kwargs) - self.name = name - self.primary = primary - self.delete_option = delete_option - self.enable_accelerated_networking = enable_accelerated_networking - self.enable_fpga = enable_fpga - self.enable_ip_forwarding = enable_ip_forwarding - self.network_security_group = network_security_group - self.dns_settings = dns_settings - self.ip_configurations = ip_configurations - self.dscp_configuration = dscp_configuration - - -class VirtualMachineNetworkInterfaceDnsSettingsConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines network configuration's DNS settings. - - :ivar dns_servers: List of DNS servers IP addresses. - :vartype dns_servers: list[str] - """ - - _attribute_map = { - "dns_servers": {"key": "dnsServers", "type": "[str]"}, - } - - def __init__(self, *, dns_servers: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword dns_servers: List of DNS servers IP addresses. - :paramtype dns_servers: list[str] - """ - super().__init__(**kwargs) - self.dns_servers = dns_servers - - -class VirtualMachineNetworkInterfaceIPConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machine network profile's IP configuration. - - All required parameters must be populated in order to send to server. - - :ivar name: The IP configuration name. Required. - :vartype name: str - :ivar subnet: Specifies the identifier of the subnet. - :vartype subnet: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - :ivar public_ip_address_configuration: The publicIPAddressConfiguration. - :vartype public_ip_address_configuration: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePublicIPAddressConfiguration - :ivar private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersions - :ivar application_security_groups: Specifies an array of references to application security - group. - :vartype application_security_groups: list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :ivar application_gateway_backend_address_pools: Specifies an array of references to backend - address pools of application gateways. A virtual machine can reference backend address pools of - multiple application gateways. Multiple virtual machines cannot use the same application - gateway. - :vartype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :ivar load_balancer_backend_address_pools: Specifies an array of references to backend address - pools of load balancers. A virtual machine can reference backend address pools of one public - and one internal load balancer. [Multiple virtual machines cannot use the same basic sku load - balancer]. - :vartype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "subnet": {"key": "properties.subnet", "type": "SubResource"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "public_ip_address_configuration": { - "key": "properties.publicIPAddressConfiguration", - "type": "VirtualMachinePublicIPAddressConfiguration", - }, - "private_ip_address_version": {"key": "properties.privateIPAddressVersion", "type": "str"}, - "application_security_groups": {"key": "properties.applicationSecurityGroups", "type": "[SubResource]"}, - "application_gateway_backend_address_pools": { - "key": "properties.applicationGatewayBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_backend_address_pools": { - "key": "properties.loadBalancerBackendAddressPools", - "type": "[SubResource]", - }, - } - - def __init__( - self, - *, - name: str, - subnet: Optional["_models.SubResource"] = None, - primary: Optional[bool] = None, - public_ip_address_configuration: Optional["_models.VirtualMachinePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "_models.IPVersions"]] = None, - application_security_groups: Optional[List["_models.SubResource"]] = None, - application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The IP configuration name. Required. - :paramtype name: str - :keyword subnet: Specifies the identifier of the subnet. - :paramtype subnet: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - :keyword public_ip_address_configuration: The publicIPAddressConfiguration. - :paramtype public_ip_address_configuration: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePublicIPAddressConfiguration - :keyword private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersions - :keyword application_security_groups: Specifies an array of references to application security - group. - :paramtype application_security_groups: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :keyword application_gateway_backend_address_pools: Specifies an array of references to backend - address pools of application gateways. A virtual machine can reference backend address pools of - multiple application gateways. Multiple virtual machines cannot use the same application - gateway. - :paramtype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :keyword load_balancer_backend_address_pools: Specifies an array of references to backend - address pools of load balancers. A virtual machine can reference backend address pools of one - public and one internal load balancer. [Multiple virtual machines cannot use the same basic sku - load balancer]. - :paramtype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - """ - super().__init__(**kwargs) - self.name = name - self.subnet = subnet - self.primary = primary - self.public_ip_address_configuration = public_ip_address_configuration - self.private_ip_address_version = private_ip_address_version - self.application_security_groups = application_security_groups - self.application_gateway_backend_address_pools = application_gateway_backend_address_pools - self.load_balancer_backend_address_pools = load_balancer_backend_address_pools - - -class VirtualMachinePatchStatus(_serialization.Model): - """The status of virtual machine patch operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar available_patch_summary: The available patch summary of the latest assessment operation - for the virtual machine. - :vartype available_patch_summary: ~azure.mgmt.compute.v2021_07_01.models.AvailablePatchSummary - :ivar last_patch_installation_summary: The installation summary of the latest installation - operation for the virtual machine. - :vartype last_patch_installation_summary: - ~azure.mgmt.compute.v2021_07_01.models.LastPatchInstallationSummary - :ivar configuration_statuses: The enablement status of the specified patchMode. - :vartype configuration_statuses: - list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - - _validation = { - "configuration_statuses": {"readonly": True}, - } - - _attribute_map = { - "available_patch_summary": {"key": "availablePatchSummary", "type": "AvailablePatchSummary"}, - "last_patch_installation_summary": { - "key": "lastPatchInstallationSummary", - "type": "LastPatchInstallationSummary", - }, - "configuration_statuses": {"key": "configurationStatuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - available_patch_summary: Optional["_models.AvailablePatchSummary"] = None, - last_patch_installation_summary: Optional["_models.LastPatchInstallationSummary"] = None, - **kwargs: Any - ) -> None: - """ - :keyword available_patch_summary: The available patch summary of the latest assessment - operation for the virtual machine. - :paramtype available_patch_summary: - ~azure.mgmt.compute.v2021_07_01.models.AvailablePatchSummary - :keyword last_patch_installation_summary: The installation summary of the latest installation - operation for the virtual machine. - :paramtype last_patch_installation_summary: - ~azure.mgmt.compute.v2021_07_01.models.LastPatchInstallationSummary - """ - super().__init__(**kwargs) - self.available_patch_summary = available_patch_summary - self.last_patch_installation_summary = last_patch_installation_summary - self.configuration_statuses: Optional[List["_models.InstanceViewStatus"]] = None - - -class VirtualMachinePublicIPAddressConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines IP Configuration's PublicIPAddress configuration. - - All required parameters must be populated in order to send to server. - - :ivar name: The publicIP address configuration name. Required. - :vartype name: str - :ivar sku: Describes the public IP Sku. - :vartype sku: ~azure.mgmt.compute.v2021_07_01.models.PublicIPAddressSku - :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. - :vartype idle_timeout_in_minutes: int - :ivar delete_option: Specify what happens to the public IP address when the VM is deleted. - Known values are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions - :ivar dns_settings: The dns settings to be applied on the publicIP addresses . - :vartype dns_settings: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePublicIPAddressDnsSettingsConfiguration - :ivar ip_tags: The list of IP tags associated with the public IP address. - :vartype ip_tags: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineIpTag] - :ivar public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. - :vartype public_ip_prefix: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar public_ip_address_version: 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 'IPv6'. Known values are: "IPv4" and "IPv6". - :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersions - :ivar public_ip_allocation_method: Specify the public IP allocation type. Known values are: - "Dynamic" and "Static". - :vartype public_ip_allocation_method: str or - ~azure.mgmt.compute.v2021_07_01.models.PublicIPAllocationMethod - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "sku": {"key": "sku", "type": "PublicIPAddressSku"}, - "idle_timeout_in_minutes": {"key": "properties.idleTimeoutInMinutes", "type": "int"}, - "delete_option": {"key": "properties.deleteOption", "type": "str"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachinePublicIPAddressDnsSettingsConfiguration", - }, - "ip_tags": {"key": "properties.ipTags", "type": "[VirtualMachineIpTag]"}, - "public_ip_prefix": {"key": "properties.publicIPPrefix", "type": "SubResource"}, - "public_ip_address_version": {"key": "properties.publicIPAddressVersion", "type": "str"}, - "public_ip_allocation_method": {"key": "properties.publicIPAllocationMethod", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - sku: Optional["_models.PublicIPAddressSku"] = None, - idle_timeout_in_minutes: Optional[int] = None, - delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, - dns_settings: Optional["_models.VirtualMachinePublicIPAddressDnsSettingsConfiguration"] = None, - ip_tags: Optional[List["_models.VirtualMachineIpTag"]] = None, - public_ip_prefix: Optional["_models.SubResource"] = None, - public_ip_address_version: Optional[Union[str, "_models.IPVersions"]] = None, - public_ip_allocation_method: Optional[Union[str, "_models.PublicIPAllocationMethod"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The publicIP address configuration name. Required. - :paramtype name: str - :keyword sku: Describes the public IP Sku. - :paramtype sku: ~azure.mgmt.compute.v2021_07_01.models.PublicIPAddressSku - :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. - :paramtype idle_timeout_in_minutes: int - :keyword delete_option: Specify what happens to the public IP address when the VM is deleted. - Known values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions - :keyword dns_settings: The dns settings to be applied on the publicIP addresses . - :paramtype dns_settings: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePublicIPAddressDnsSettingsConfiguration - :keyword ip_tags: The list of IP tags associated with the public IP address. - :paramtype ip_tags: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineIpTag] - :keyword public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. - :paramtype public_ip_prefix: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword public_ip_address_version: 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 'IPv6'. Known values are: "IPv4" and "IPv6". - :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersions - :keyword public_ip_allocation_method: Specify the public IP allocation type. Known values are: - "Dynamic" and "Static". - :paramtype public_ip_allocation_method: str or - ~azure.mgmt.compute.v2021_07_01.models.PublicIPAllocationMethod - """ - super().__init__(**kwargs) - self.name = name - self.sku = sku - self.idle_timeout_in_minutes = idle_timeout_in_minutes - self.delete_option = delete_option - self.dns_settings = dns_settings - self.ip_tags = ip_tags - self.public_ip_prefix = public_ip_prefix - self.public_ip_address_version = public_ip_address_version - self.public_ip_allocation_method = public_ip_allocation_method - - -class VirtualMachinePublicIPAddressDnsSettingsConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines network configuration's DNS settings. - - All required parameters must be populated in order to send to server. - - :ivar domain_name_label: The Domain name label prefix of the PublicIPAddress resources that - will be created. The generated name label is the concatenation of the domain name label and vm - network profile unique ID. Required. - :vartype domain_name_label: str - """ - - _validation = { - "domain_name_label": {"required": True}, - } - - _attribute_map = { - "domain_name_label": {"key": "domainNameLabel", "type": "str"}, - } - - def __init__(self, *, domain_name_label: str, **kwargs: Any) -> None: - """ - :keyword domain_name_label: The Domain name label prefix of the PublicIPAddress resources that - will be created. The generated name label is the concatenation of the domain name label and vm - network profile unique ID. Required. - :paramtype domain_name_label: str - """ - super().__init__(**kwargs) - self.domain_name_label = domain_name_label - - -class VirtualMachineReimageParameters(_serialization.Model): - """Parameters for Reimaging Virtual Machine. NOTE: Virtual Machine OS disk will always be - reimaged. - - :ivar temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This temp - disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :vartype temp_disk: bool - """ - - _attribute_map = { - "temp_disk": {"key": "tempDisk", "type": "bool"}, - } - - def __init__(self, *, temp_disk: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This - temp disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :paramtype temp_disk: bool - """ - super().__init__(**kwargs) - self.temp_disk = temp_disk - - -class VirtualMachineRunCommand(Resource): - """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. - :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] - :ivar source: The source of the run command script. - :vartype source: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommandScriptSource - :ivar parameters: The parameters used by the script. - :vartype parameters: list[~azure.mgmt.compute.v2021_07_01.models.RunCommandInputParameter] - :ivar protected_parameters: The parameters used by the script. - :vartype protected_parameters: - list[~azure.mgmt.compute.v2021_07_01.models.RunCommandInputParameter] - :ivar async_execution: Optional. If set to true, provisioning will complete as soon as the - script starts and will not wait for script to complete. - :vartype async_execution: bool - :ivar run_as_user: Specifies the user account on the VM when executing the run command. - :vartype run_as_user: str - :ivar run_as_password: Specifies the user account password on the VM when executing the run - command. - :vartype run_as_password: str - :ivar timeout_in_seconds: The timeout in seconds to execute the run command. - :vartype timeout_in_seconds: int - :ivar output_blob_uri: Specifies the Azure storage blob where script output stream will be - uploaded. - :vartype output_blob_uri: str - :ivar error_blob_uri: Specifies the Azure storage blob where script error stream will be - uploaded. - :vartype error_blob_uri: str - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The virtual machine run command instance view. - :vartype instance_view: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommandInstanceView - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": 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}"}, - "source": {"key": "properties.source", "type": "VirtualMachineRunCommandScriptSource"}, - "parameters": {"key": "properties.parameters", "type": "[RunCommandInputParameter]"}, - "protected_parameters": {"key": "properties.protectedParameters", "type": "[RunCommandInputParameter]"}, - "async_execution": {"key": "properties.asyncExecution", "type": "bool"}, - "run_as_user": {"key": "properties.runAsUser", "type": "str"}, - "run_as_password": {"key": "properties.runAsPassword", "type": "str"}, - "timeout_in_seconds": {"key": "properties.timeoutInSeconds", "type": "int"}, - "output_blob_uri": {"key": "properties.outputBlobUri", "type": "str"}, - "error_blob_uri": {"key": "properties.errorBlobUri", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineRunCommandInstanceView"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, - parameters: Optional[List["_models.RunCommandInputParameter"]] = None, - protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, - async_execution: bool = False, - run_as_user: Optional[str] = None, - run_as_password: Optional[str] = None, - timeout_in_seconds: Optional[int] = None, - output_blob_uri: Optional[str] = None, - error_blob_uri: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword source: The source of the run command script. - :paramtype source: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommandScriptSource - :keyword parameters: The parameters used by the script. - :paramtype parameters: list[~azure.mgmt.compute.v2021_07_01.models.RunCommandInputParameter] - :keyword protected_parameters: The parameters used by the script. - :paramtype protected_parameters: - list[~azure.mgmt.compute.v2021_07_01.models.RunCommandInputParameter] - :keyword async_execution: Optional. If set to true, provisioning will complete as soon as the - script starts and will not wait for script to complete. - :paramtype async_execution: bool - :keyword run_as_user: Specifies the user account on the VM when executing the run command. - :paramtype run_as_user: str - :keyword run_as_password: Specifies the user account password on the VM when executing the run - command. - :paramtype run_as_password: str - :keyword timeout_in_seconds: The timeout in seconds to execute the run command. - :paramtype timeout_in_seconds: int - :keyword output_blob_uri: Specifies the Azure storage blob where script output stream will be - uploaded. - :paramtype output_blob_uri: str - :keyword error_blob_uri: Specifies the Azure storage blob where script error stream will be - uploaded. - :paramtype error_blob_uri: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.source = source - self.parameters = parameters - self.protected_parameters = protected_parameters - self.async_execution = async_execution - self.run_as_user = run_as_user - self.run_as_password = run_as_password - self.timeout_in_seconds = timeout_in_seconds - self.output_blob_uri = output_blob_uri - self.error_blob_uri = error_blob_uri - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineRunCommandInstanceView"] = None - - -class VirtualMachineRunCommandInstanceView(_serialization.Model): - """The instance view of a virtual machine run command. - - :ivar execution_state: Script execution status. Known values are: "Unknown", "Pending", - "Running", "Failed", "Succeeded", "TimedOut", and "Canceled". - :vartype execution_state: str or ~azure.mgmt.compute.v2021_07_01.models.ExecutionState - :ivar execution_message: Communicate script configuration errors or execution messages. - :vartype execution_message: str - :ivar exit_code: Exit code returned from script execution. - :vartype exit_code: int - :ivar output: Script output stream. - :vartype output: str - :ivar error: Script error stream. - :vartype error: str - :ivar start_time: Script start time. - :vartype start_time: ~datetime.datetime - :ivar end_time: Script end time. - :vartype end_time: ~datetime.datetime - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - - _attribute_map = { - "execution_state": {"key": "executionState", "type": "str"}, - "execution_message": {"key": "executionMessage", "type": "str"}, - "exit_code": {"key": "exitCode", "type": "int"}, - "output": {"key": "output", "type": "str"}, - "error": {"key": "error", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - } - - def __init__( - self, - *, - execution_state: Optional[Union[str, "_models.ExecutionState"]] = None, - execution_message: Optional[str] = None, - exit_code: Optional[int] = None, - output: Optional[str] = None, - error: Optional[str] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword execution_state: Script execution status. Known values are: "Unknown", "Pending", - "Running", "Failed", "Succeeded", "TimedOut", and "Canceled". - :paramtype execution_state: str or ~azure.mgmt.compute.v2021_07_01.models.ExecutionState - :keyword execution_message: Communicate script configuration errors or execution messages. - :paramtype execution_message: str - :keyword exit_code: Exit code returned from script execution. - :paramtype exit_code: int - :keyword output: Script output stream. - :paramtype output: str - :keyword error: Script error stream. - :paramtype error: str - :keyword start_time: Script start time. - :paramtype start_time: ~datetime.datetime - :keyword end_time: Script end time. - :paramtype end_time: ~datetime.datetime - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.execution_state = execution_state - self.execution_message = execution_message - self.exit_code = exit_code - self.output = output - self.error = error - self.start_time = start_time - self.end_time = end_time - self.statuses = statuses - - -class VirtualMachineRunCommandScriptSource(_serialization.Model): - """Describes the script sources for run command. - - :ivar script: Specifies the script content to be executed on the VM. - :vartype script: str - :ivar script_uri: Specifies the script download location. - :vartype script_uri: str - :ivar command_id: Specifies a commandId of predefined built-in script. - :vartype command_id: str - """ - - _attribute_map = { - "script": {"key": "script", "type": "str"}, - "script_uri": {"key": "scriptUri", "type": "str"}, - "command_id": {"key": "commandId", "type": "str"}, - } - - def __init__( - self, - *, - script: Optional[str] = None, - script_uri: Optional[str] = None, - command_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword script: Specifies the script content to be executed on the VM. - :paramtype script: str - :keyword script_uri: Specifies the script download location. - :paramtype script_uri: str - :keyword command_id: Specifies a commandId of predefined built-in script. - :paramtype command_id: str - """ - super().__init__(**kwargs) - self.script = script - self.script_uri = script_uri - self.command_id = command_id - - -class VirtualMachineRunCommandsListResult(_serialization.Model): - """The List run command operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of run commands. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] - :ivar next_link: The uri to fetch the next page of run commands. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineRunCommand]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineRunCommand"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of run commands. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] - :keyword next_link: The uri to fetch the next page of run commands. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineRunCommandUpdate(UpdateResource): - """Describes a Virtual Machine run command. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar source: The source of the run command script. - :vartype source: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommandScriptSource - :ivar parameters: The parameters used by the script. - :vartype parameters: list[~azure.mgmt.compute.v2021_07_01.models.RunCommandInputParameter] - :ivar protected_parameters: The parameters used by the script. - :vartype protected_parameters: - list[~azure.mgmt.compute.v2021_07_01.models.RunCommandInputParameter] - :ivar async_execution: Optional. If set to true, provisioning will complete as soon as the - script starts and will not wait for script to complete. - :vartype async_execution: bool - :ivar run_as_user: Specifies the user account on the VM when executing the run command. - :vartype run_as_user: str - :ivar run_as_password: Specifies the user account password on the VM when executing the run - command. - :vartype run_as_password: str - :ivar timeout_in_seconds: The timeout in seconds to execute the run command. - :vartype timeout_in_seconds: int - :ivar output_blob_uri: Specifies the Azure storage blob where script output stream will be - uploaded. - :vartype output_blob_uri: str - :ivar error_blob_uri: Specifies the Azure storage blob where script error stream will be - uploaded. - :vartype error_blob_uri: str - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The virtual machine run command instance view. - :vartype instance_view: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommandInstanceView - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "source": {"key": "properties.source", "type": "VirtualMachineRunCommandScriptSource"}, - "parameters": {"key": "properties.parameters", "type": "[RunCommandInputParameter]"}, - "protected_parameters": {"key": "properties.protectedParameters", "type": "[RunCommandInputParameter]"}, - "async_execution": {"key": "properties.asyncExecution", "type": "bool"}, - "run_as_user": {"key": "properties.runAsUser", "type": "str"}, - "run_as_password": {"key": "properties.runAsPassword", "type": "str"}, - "timeout_in_seconds": {"key": "properties.timeoutInSeconds", "type": "int"}, - "output_blob_uri": {"key": "properties.outputBlobUri", "type": "str"}, - "error_blob_uri": {"key": "properties.errorBlobUri", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineRunCommandInstanceView"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, - parameters: Optional[List["_models.RunCommandInputParameter"]] = None, - protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, - async_execution: bool = False, - run_as_user: Optional[str] = None, - run_as_password: Optional[str] = None, - timeout_in_seconds: Optional[int] = None, - output_blob_uri: Optional[str] = None, - error_blob_uri: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword source: The source of the run command script. - :paramtype source: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommandScriptSource - :keyword parameters: The parameters used by the script. - :paramtype parameters: list[~azure.mgmt.compute.v2021_07_01.models.RunCommandInputParameter] - :keyword protected_parameters: The parameters used by the script. - :paramtype protected_parameters: - list[~azure.mgmt.compute.v2021_07_01.models.RunCommandInputParameter] - :keyword async_execution: Optional. If set to true, provisioning will complete as soon as the - script starts and will not wait for script to complete. - :paramtype async_execution: bool - :keyword run_as_user: Specifies the user account on the VM when executing the run command. - :paramtype run_as_user: str - :keyword run_as_password: Specifies the user account password on the VM when executing the run - command. - :paramtype run_as_password: str - :keyword timeout_in_seconds: The timeout in seconds to execute the run command. - :paramtype timeout_in_seconds: int - :keyword output_blob_uri: Specifies the Azure storage blob where script output stream will be - uploaded. - :paramtype output_blob_uri: str - :keyword error_blob_uri: Specifies the Azure storage blob where script error stream will be - uploaded. - :paramtype error_blob_uri: str - """ - super().__init__(tags=tags, **kwargs) - self.source = source - self.parameters = parameters - self.protected_parameters = protected_parameters - self.async_execution = async_execution - self.run_as_user = run_as_user - self.run_as_password = run_as_password - self.timeout_in_seconds = timeout_in_seconds - self.output_blob_uri = output_blob_uri - self.error_blob_uri = error_blob_uri - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineRunCommandInstanceView"] = None - - -class VirtualMachineScaleSet(Resource): - """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. - :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] - :ivar sku: The virtual machine scale set sku. - :vartype sku: ~azure.mgmt.compute.v2021_07_01.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2021_07_01.models.Plan - :ivar identity: The identity of the virtual machine scale set, if configured. - :vartype identity: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetIdentity - :ivar zones: The virtual machine scale set zones. NOTE: Availability zones can only be set when - you create the scale set. - :vartype zones: list[str] - :ivar extended_location: The extended location of the Virtual Machine Scale Set. - :vartype extended_location: ~azure.mgmt.compute.v2021_07_01.models.ExtendedLocation - :ivar upgrade_policy: The upgrade policy. - :vartype upgrade_policy: ~azure.mgmt.compute.v2021_07_01.models.UpgradePolicy - :ivar automatic_repairs_policy: Policy for automatic repairs. - :vartype automatic_repairs_policy: - ~azure.mgmt.compute.v2021_07_01.models.AutomaticRepairsPolicy - :ivar virtual_machine_profile: The virtual machine profile. - :vartype virtual_machine_profile: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar overprovision: Specifies whether the Virtual Machine Scale Set should be overprovisioned. - :vartype overprovision: bool - :ivar do_not_run_extensions_on_overprovisioned_v_ms: When Overprovision is enabled, extensions - are launched only on the requested number of VMs which are finally kept. This property will - hence ensure that the extensions do not run on the extra overprovisioned VMs. - :vartype do_not_run_extensions_on_overprovisioned_v_ms: bool - :ivar unique_id: Specifies the ID which uniquely identifies a Virtual Machine Scale Set. - :vartype unique_id: str - :ivar single_placement_group: When true this limits the scale set to a single placement group, - of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be modified to - false. However, if singlePlacementGroup is false, it may not be modified to true. - :vartype single_placement_group: bool - :ivar zone_balance: Whether to force strictly even Virtual Machine distribution cross x-zones - in case there is zone outage. zoneBalance property can only be set if the zones property of the - scale set contains more than one zone. If there are no zones or only one zone specified, then - zoneBalance property should not be set. - :vartype zone_balance: bool - :ivar platform_fault_domain_count: Fault Domain count for each placement group. - :vartype platform_fault_domain_count: int - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the virtual machine scale set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar host_group: Specifies information about the dedicated host group that the virtual machine - scale set resides in. :code:`
    `\\ :code:`
    `Minimum api-version: 2020-06-01. - :vartype host_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines - have the capability to support attaching managed data disks with UltraSSD_LRS storage account - type. - :vartype additional_capabilities: ~azure.mgmt.compute.v2021_07_01.models.AdditionalCapabilities - :ivar scale_in_policy: Specifies the policies applied when scaling in Virtual Machines in the - Virtual Machine Scale Set. - :vartype scale_in_policy: ~azure.mgmt.compute.v2021_07_01.models.ScaleInPolicy - :ivar orchestration_mode: Specifies the orchestration mode for the virtual machine scale set. - Known values are: "Uniform" and "Flexible". - :vartype orchestration_mode: str or ~azure.mgmt.compute.v2021_07_01.models.OrchestrationMode - :ivar spot_restore_policy: Specifies the Spot Restore properties for the virtual machine scale - set. - :vartype spot_restore_policy: ~azure.mgmt.compute.v2021_07_01.models.SpotRestorePolicy - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "unique_id": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "identity": {"key": "identity", "type": "VirtualMachineScaleSetIdentity"}, - "zones": {"key": "zones", "type": "[str]"}, - "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - "upgrade_policy": {"key": "properties.upgradePolicy", "type": "UpgradePolicy"}, - "automatic_repairs_policy": {"key": "properties.automaticRepairsPolicy", "type": "AutomaticRepairsPolicy"}, - "virtual_machine_profile": { - "key": "properties.virtualMachineProfile", - "type": "VirtualMachineScaleSetVMProfile", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "overprovision": {"key": "properties.overprovision", "type": "bool"}, - "do_not_run_extensions_on_overprovisioned_v_ms": { - "key": "properties.doNotRunExtensionsOnOverprovisionedVMs", - "type": "bool", - }, - "unique_id": {"key": "properties.uniqueId", "type": "str"}, - "single_placement_group": {"key": "properties.singlePlacementGroup", "type": "bool"}, - "zone_balance": {"key": "properties.zoneBalance", "type": "bool"}, - "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "host_group": {"key": "properties.hostGroup", "type": "SubResource"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "scale_in_policy": {"key": "properties.scaleInPolicy", "type": "ScaleInPolicy"}, - "orchestration_mode": {"key": "properties.orchestrationMode", "type": "str"}, - "spot_restore_policy": {"key": "properties.spotRestorePolicy", "type": "SpotRestorePolicy"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, - zones: Optional[List[str]] = None, - extended_location: Optional["_models.ExtendedLocation"] = None, - upgrade_policy: Optional["_models.UpgradePolicy"] = None, - automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, - overprovision: Optional[bool] = None, - do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, - single_placement_group: Optional[bool] = None, - zone_balance: Optional[bool] = None, - platform_fault_domain_count: Optional[int] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - host_group: Optional["_models.SubResource"] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - scale_in_policy: Optional["_models.ScaleInPolicy"] = None, - orchestration_mode: Optional[Union[str, "_models.OrchestrationMode"]] = None, - spot_restore_policy: Optional["_models.SpotRestorePolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The virtual machine scale set sku. - :paramtype sku: ~azure.mgmt.compute.v2021_07_01.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2021_07_01.models.Plan - :keyword identity: The identity of the virtual machine scale set, if configured. - :paramtype identity: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetIdentity - :keyword zones: The virtual machine scale set zones. NOTE: Availability zones can only be set - when you create the scale set. - :paramtype zones: list[str] - :keyword extended_location: The extended location of the Virtual Machine Scale Set. - :paramtype extended_location: ~azure.mgmt.compute.v2021_07_01.models.ExtendedLocation - :keyword upgrade_policy: The upgrade policy. - :paramtype upgrade_policy: ~azure.mgmt.compute.v2021_07_01.models.UpgradePolicy - :keyword automatic_repairs_policy: Policy for automatic repairs. - :paramtype automatic_repairs_policy: - ~azure.mgmt.compute.v2021_07_01.models.AutomaticRepairsPolicy - :keyword virtual_machine_profile: The virtual machine profile. - :paramtype virtual_machine_profile: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMProfile - :keyword overprovision: Specifies whether the Virtual Machine Scale Set should be - overprovisioned. - :paramtype overprovision: bool - :keyword do_not_run_extensions_on_overprovisioned_v_ms: When Overprovision is enabled, - extensions are launched only on the requested number of VMs which are finally kept. This - property will hence ensure that the extensions do not run on the extra overprovisioned VMs. - :paramtype do_not_run_extensions_on_overprovisioned_v_ms: bool - :keyword single_placement_group: When true this limits the scale set to a single placement - group, of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be - modified to false. However, if singlePlacementGroup is false, it may not be modified to true. - :paramtype single_placement_group: bool - :keyword zone_balance: Whether to force strictly even Virtual Machine distribution cross - x-zones in case there is zone outage. zoneBalance property can only be set if the zones - property of the scale set contains more than one zone. If there are no zones or only one zone - specified, then zoneBalance property should not be set. - :paramtype zone_balance: bool - :keyword platform_fault_domain_count: Fault Domain count for each placement group. - :paramtype platform_fault_domain_count: int - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the virtual machine scale set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword host_group: Specifies information about the dedicated host group that the virtual - machine scale set resides in. :code:`
    `\\ :code:`
    `Minimum api-version: 2020-06-01. - :paramtype host_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines - have the capability to support attaching managed data disks with UltraSSD_LRS storage account - type. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2021_07_01.models.AdditionalCapabilities - :keyword scale_in_policy: Specifies the policies applied when scaling in Virtual Machines in - the Virtual Machine Scale Set. - :paramtype scale_in_policy: ~azure.mgmt.compute.v2021_07_01.models.ScaleInPolicy - :keyword orchestration_mode: Specifies the orchestration mode for the virtual machine scale - set. Known values are: "Uniform" and "Flexible". - :paramtype orchestration_mode: str or ~azure.mgmt.compute.v2021_07_01.models.OrchestrationMode - :keyword spot_restore_policy: Specifies the Spot Restore properties for the virtual machine - scale set. - :paramtype spot_restore_policy: ~azure.mgmt.compute.v2021_07_01.models.SpotRestorePolicy - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.plan = plan - self.identity = identity - self.zones = zones - self.extended_location = extended_location - self.upgrade_policy = upgrade_policy - self.automatic_repairs_policy = automatic_repairs_policy - self.virtual_machine_profile = virtual_machine_profile - self.provisioning_state: Optional[str] = None - self.overprovision = overprovision - self.do_not_run_extensions_on_overprovisioned_v_ms = do_not_run_extensions_on_overprovisioned_v_ms - self.unique_id: Optional[str] = None - self.single_placement_group = single_placement_group - self.zone_balance = zone_balance - self.platform_fault_domain_count = platform_fault_domain_count - self.proximity_placement_group = proximity_placement_group - self.host_group = host_group - self.additional_capabilities = additional_capabilities - self.scale_in_policy = scale_in_policy - self.orchestration_mode = orchestration_mode - self.spot_restore_policy = spot_restore_policy - - -class VirtualMachineScaleSetDataDisk(_serialization.Model): - """Describes a virtual machine scale set data disk. - - All required parameters must be populated in order to send to server. - - :ivar name: The disk name. - :vartype name: str - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - Required. - :vartype lun: int - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar create_option: The create option. Required. Known values are: "FromImage", "Empty", and - "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskCreateOptionTypes - :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be - used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ :code:`
    ` - This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetManagedDiskParameters - :ivar disk_iops_read_write: Specifies the Read-Write IOPS for the managed disk. Should be used - only when StorageAccountType is UltraSSD_LRS. If not specified, a default value would be - assigned based on diskSizeGB. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: Specifies the bandwidth in MB per second for the managed disk. - Should be used only when StorageAccountType is UltraSSD_LRS. If not specified, a default value - would be assigned based on diskSizeGB. - :vartype disk_m_bps_read_write: int - """ - - _validation = { - "lun": {"required": True}, - "create_option": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "create_option": {"key": "createOption", "type": "str"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "managed_disk": {"key": "managedDisk", "type": "VirtualMachineScaleSetManagedDiskParameters"}, - "disk_iops_read_write": {"key": "diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "diskMBpsReadWrite", "type": "int"}, - } - - def __init__( - self, - *, - lun: int, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - disk_size_gb: Optional[int] = None, - managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, - disk_iops_read_write: Optional[int] = None, - disk_m_bps_read_write: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword lun: Specifies the logical unit number of the data disk. This value is used to - identify data disks within the VM and therefore must be unique for each data disk attached to a - VM. Required. - :paramtype lun: int - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword create_option: The create option. Required. Known values are: "FromImage", "Empty", - and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskCreateOptionTypes - :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can - be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetManagedDiskParameters - :keyword disk_iops_read_write: Specifies the Read-Write IOPS for the managed disk. Should be - used only when StorageAccountType is UltraSSD_LRS. If not specified, a default value would be - assigned based on diskSizeGB. - :paramtype disk_iops_read_write: int - :keyword disk_m_bps_read_write: Specifies the bandwidth in MB per second for the managed disk. - Should be used only when StorageAccountType is UltraSSD_LRS. If not specified, a default value - would be assigned based on diskSizeGB. - :paramtype disk_m_bps_read_write: int - """ - super().__init__(**kwargs) - self.name = name - self.lun = lun - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.create_option = create_option - self.disk_size_gb = disk_size_gb - self.managed_disk = managed_disk - self.disk_iops_read_write = disk_iops_read_write - self.disk_m_bps_read_write = disk_m_bps_read_write - - -class VirtualMachineScaleSetExtension(SubResourceReadOnly): - """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. - :vartype id: str - :ivar name: The name of the extension. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar force_update_tag: If a value is provided and is different from the previous value, the - extension handler will be forced to update even if the extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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 - needs to be provisioned. - :vartype provision_after_extensions: list[str] - :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. - :vartype suppress_failures: bool - """ - - _validation = { - "id": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "enable_automatic_upgrade": {"key": "properties.enableAutomaticUpgrade", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "provision_after_extensions": {"key": "properties.provisionAfterExtensions", "type": "[str]"}, - "suppress_failures": {"key": "properties.suppressFailures", "type": "bool"}, - } - - 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, - provision_after_extensions: Optional[List[str]] = None, - suppress_failures: Optional[bool] = 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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :keyword provision_after_extensions: Collection of extension names after which this extension - needs to be provisioned. - :paramtype provision_after_extensions: list[str] - :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. - :paramtype suppress_failures: bool - """ - super().__init__(**kwargs) - self.name = name - self.type: Optional[str] = None - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.enable_automatic_upgrade = enable_automatic_upgrade - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - self.provision_after_extensions = provision_after_extensions - self.suppress_failures = suppress_failures - - -class VirtualMachineScaleSetExtensionListResult(_serialization.Model): # pylint: disable=name-too-long - """The List VM scale set extension operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of VM scale set extensions. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension] - :ivar next_link: The uri to fetch the next page of VM scale set extensions. Call ListNext() - with this to fetch the next page of VM scale set extensions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetExtension]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of VM scale set extensions. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension] - :keyword next_link: The uri to fetch the next page of VM scale set extensions. Call ListNext() - with this to fetch the next page of VM scale set extensions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetExtensionProfile(_serialization.Model): - """Describes a virtual machine scale set extension profile. - - :ivar extensions: The virtual machine scale set child extension resources. - :vartype extensions: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension] - :ivar extensions_time_budget: Specifies the time alloted for all extensions to start. The time - duration should be between 15 minutes and 120 minutes (inclusive) and should be specified in - ISO 8601 format. The default value is 90 minutes (PT1H30M). :code:`
    `\\ :code:`
    ` Minimum - api-version: 2020-06-01. - :vartype extensions_time_budget: str - """ - - _attribute_map = { - "extensions": {"key": "extensions", "type": "[VirtualMachineScaleSetExtension]"}, - "extensions_time_budget": {"key": "extensionsTimeBudget", "type": "str"}, - } - - def __init__( - self, - *, - extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, - extensions_time_budget: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword extensions: The virtual machine scale set child extension resources. - :paramtype extensions: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension] - :keyword extensions_time_budget: Specifies the time alloted for all extensions to start. The - time duration should be between 15 minutes and 120 minutes (inclusive) and should be specified - in ISO 8601 format. The default value is 90 minutes (PT1H30M). :code:`
    `\\ :code:`
    ` - Minimum api-version: 2020-06-01. - :paramtype extensions_time_budget: str - """ - super().__init__(**kwargs) - self.extensions = extensions - self.extensions_time_budget = extensions_time_budget - - -class VirtualMachineScaleSetExtensionUpdate(SubResourceReadOnly): - """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. - :vartype id: str - :ivar name: The name of the extension. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar force_update_tag: If a value is provided and is different from the previous value, the - extension handler will be forced to update even if the extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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 - needs to be provisioned. - :vartype provision_after_extensions: list[str] - :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. - :vartype suppress_failures: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "enable_automatic_upgrade": {"key": "properties.enableAutomaticUpgrade", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "provision_after_extensions": {"key": "properties.provisionAfterExtensions", "type": "[str]"}, - "suppress_failures": {"key": "properties.suppressFailures", "type": "bool"}, - } - - def __init__( - self, - *, - 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, - provision_after_extensions: Optional[List[str]] = None, - suppress_failures: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword force_update_tag: If a value is provided and is different from the previous value, the - extension handler will be forced to update even if the extension configuration has not changed. - :paramtype force_update_tag: str - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :keyword provision_after_extensions: Collection of extension names after which this extension - needs to be provisioned. - :paramtype provision_after_extensions: list[str] - :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. - :paramtype suppress_failures: bool - """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.type: Optional[str] = None - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.enable_automatic_upgrade = enable_automatic_upgrade - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - self.provision_after_extensions = provision_after_extensions - self.suppress_failures = suppress_failures - - -class VirtualMachineScaleSetIdentity(_serialization.Model): - """Identity for the virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of virtual machine scale set identity. This property will - only be provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the virtual machine scale set. This property - will only be provided for a system assigned identity. - :vartype tenant_id: str - :ivar type: The type of identity used for the virtual machine scale set. The type - 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user - assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and - "None". - :vartype type: str or ~azure.mgmt.compute.v2021_07_01.models.ResourceIdentityType - :ivar user_assigned_identities: The list of user identities associated with the virtual machine - scale set. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": { - "key": "userAssignedIdentities", - "type": "{VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue}", - }, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, - user_assigned_identities: Optional[ - Dict[str, "_models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of identity used for the virtual machine scale set. The type - 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user - assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and - "None". - :paramtype type: str or ~azure.mgmt.compute.v2021_07_01.models.ResourceIdentityType - :keyword user_assigned_identities: The list of user identities associated with the virtual - machine scale set. The user identity dictionary key references will be ARM resource ids in the - form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue] - """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.type = type - self.user_assigned_identities = user_assigned_identities - - -class VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue(_serialization.Model): # pylint: disable=name-too-long - """VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue. - - 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: Optional[str] = None - self.client_id: Optional[str] = None - - -class VirtualMachineScaleSetInstanceView(_serialization.Model): - """The instance view of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar virtual_machine: The instance view status summary for the virtual machine scale set. - :vartype virtual_machine: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetInstanceViewStatusesSummary - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtensionsSummary] - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - :ivar orchestration_services: The orchestration services information. - :vartype orchestration_services: - list[~azure.mgmt.compute.v2021_07_01.models.OrchestrationServiceSummary] - """ - - _validation = { - "virtual_machine": {"readonly": True}, - "extensions": {"readonly": True}, - "orchestration_services": {"readonly": True}, - } - - _attribute_map = { - "virtual_machine": {"key": "virtualMachine", "type": "VirtualMachineScaleSetInstanceViewStatusesSummary"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineScaleSetVMExtensionsSummary]"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - "orchestration_services": {"key": "orchestrationServices", "type": "[OrchestrationServiceSummary]"}, - } - - def __init__(self, *, statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs: Any) -> None: - """ - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - """ - super().__init__(**kwargs) - self.virtual_machine: Optional["_models.VirtualMachineScaleSetInstanceViewStatusesSummary"] = None - self.extensions: Optional[List["_models.VirtualMachineScaleSetVMExtensionsSummary"]] = None - self.statuses = statuses - self.orchestration_services: Optional[List["_models.OrchestrationServiceSummary"]] = None - - -class VirtualMachineScaleSetInstanceViewStatusesSummary(_serialization.Model): # pylint: disable=name-too-long - """Instance view statuses summary for virtual machines of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar statuses_summary: The extensions information. - :vartype statuses_summary: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineStatusCodeCount] - """ - - _validation = { - "statuses_summary": {"readonly": True}, - } - - _attribute_map = { - "statuses_summary": {"key": "statusesSummary", "type": "[VirtualMachineStatusCodeCount]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.statuses_summary: Optional[List["_models.VirtualMachineStatusCodeCount"]] = None - - -class VirtualMachineScaleSetIPConfiguration(SubResource): - """Describes a virtual machine scale set network profile's IP configuration. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The IP configuration name. Required. - :vartype name: str - :ivar subnet: Specifies the identifier of the subnet. - :vartype subnet: ~azure.mgmt.compute.v2021_07_01.models.ApiEntityReference - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - :ivar public_ip_address_configuration: The publicIPAddressConfiguration. - :vartype public_ip_address_configuration: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration - :ivar private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersion - :ivar application_gateway_backend_address_pools: Specifies an array of references to backend - address pools of application gateways. A scale set can reference backend address pools of - multiple application gateways. Multiple scale sets cannot use the same application gateway. - :vartype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :ivar application_security_groups: Specifies an array of references to application security - group. - :vartype application_security_groups: list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :ivar load_balancer_backend_address_pools: Specifies an array of references to backend address - pools of load balancers. A scale set can reference backend address pools of one public and one - internal load balancer. Multiple scale sets cannot use the same basic sku load balancer. - :vartype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :ivar load_balancer_inbound_nat_pools: Specifies an array of references to inbound Nat pools of - the load balancers. A scale set can reference inbound nat pools of one public and one internal - load balancer. Multiple scale sets cannot use the same basic sku load balancer. - :vartype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subnet": {"key": "properties.subnet", "type": "ApiEntityReference"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "public_ip_address_configuration": { - "key": "properties.publicIPAddressConfiguration", - "type": "VirtualMachineScaleSetPublicIPAddressConfiguration", - }, - "private_ip_address_version": {"key": "properties.privateIPAddressVersion", "type": "str"}, - "application_gateway_backend_address_pools": { - "key": "properties.applicationGatewayBackendAddressPools", - "type": "[SubResource]", - }, - "application_security_groups": {"key": "properties.applicationSecurityGroups", "type": "[SubResource]"}, - "load_balancer_backend_address_pools": { - "key": "properties.loadBalancerBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_inbound_nat_pools": {"key": "properties.loadBalancerInboundNatPools", "type": "[SubResource]"}, - } - - def __init__( - self, - *, - name: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - subnet: Optional["_models.ApiEntityReference"] = None, - primary: Optional[bool] = None, - public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, - application_security_groups: Optional[List["_models.SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The IP configuration name. Required. - :paramtype name: str - :keyword subnet: Specifies the identifier of the subnet. - :paramtype subnet: ~azure.mgmt.compute.v2021_07_01.models.ApiEntityReference - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - :keyword public_ip_address_configuration: The publicIPAddressConfiguration. - :paramtype public_ip_address_configuration: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration - :keyword private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersion - :keyword application_gateway_backend_address_pools: Specifies an array of references to backend - address pools of application gateways. A scale set can reference backend address pools of - multiple application gateways. Multiple scale sets cannot use the same application gateway. - :paramtype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :keyword application_security_groups: Specifies an array of references to application security - group. - :paramtype application_security_groups: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :keyword load_balancer_backend_address_pools: Specifies an array of references to backend - address pools of load balancers. A scale set can reference backend address pools of one public - and one internal load balancer. Multiple scale sets cannot use the same basic sku load - balancer. - :paramtype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :keyword load_balancer_inbound_nat_pools: Specifies an array of references to inbound Nat pools - of the load balancers. A scale set can reference inbound nat pools of one public and one - internal load balancer. Multiple scale sets cannot use the same basic sku load balancer. - :paramtype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.subnet = subnet - self.primary = primary - self.public_ip_address_configuration = public_ip_address_configuration - self.private_ip_address_version = private_ip_address_version - self.application_gateway_backend_address_pools = application_gateway_backend_address_pools - self.application_security_groups = application_security_groups - self.load_balancer_backend_address_pools = load_balancer_backend_address_pools - self.load_balancer_inbound_nat_pools = load_balancer_inbound_nat_pools - - -class VirtualMachineScaleSetIpTag(_serialization.Model): - """Contains the IP tag associated with the public IP address. - - :ivar ip_tag_type: IP tag type. Example: FirstPartyUsage. - :vartype ip_tag_type: str - :ivar tag: IP tag associated with the public IP. Example: SQL, Storage etc. - :vartype tag: str - """ - - _attribute_map = { - "ip_tag_type": {"key": "ipTagType", "type": "str"}, - "tag": {"key": "tag", "type": "str"}, - } - - def __init__(self, *, ip_tag_type: Optional[str] = None, tag: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword ip_tag_type: IP tag type. Example: FirstPartyUsage. - :paramtype ip_tag_type: str - :keyword tag: IP tag associated with the public IP. Example: SQL, Storage etc. - :paramtype tag: str - """ - super().__init__(**kwargs) - self.ip_tag_type = ip_tag_type - self.tag = tag - - -class VirtualMachineScaleSetListOSUpgradeHistory(_serialization.Model): # pylint: disable=name-too-long - """List of Virtual Machine Scale Set OS Upgrade History operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of OS upgrades performed on the virtual machine scale set. Required. - :vartype value: - list[~azure.mgmt.compute.v2021_07_01.models.UpgradeOperationHistoricalStatusInfo] - :ivar next_link: The uri to fetch the next page of OS Upgrade History. Call ListNext() with - this to fetch the next page of history of upgrades. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[UpgradeOperationHistoricalStatusInfo]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: List["_models.UpgradeOperationHistoricalStatusInfo"], - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of OS upgrades performed on the virtual machine scale set. Required. - :paramtype value: - list[~azure.mgmt.compute.v2021_07_01.models.UpgradeOperationHistoricalStatusInfo] - :keyword next_link: The uri to fetch the next page of OS Upgrade History. Call ListNext() with - this to fetch the next page of history of upgrades. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call ListNext() - with this to fetch the next page of VMSS. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call - ListNext() with this to fetch the next page of VMSS. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListSkusResult(_serialization.Model): - """The Virtual Machine Scale Set List Skus operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of skus available for the virtual machine scale set. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetSku] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Set Skus. Call - ListNext() with this to fetch the next page of VMSS Skus. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetSku]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of skus available for the virtual machine scale set. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetSku] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Set Skus. Call - ListNext() with this to fetch the next page of VMSS Skus. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetListWithLinkResult(_serialization.Model): - """The List Virtual Machine operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call ListNext() - with this to fetch the next page of Virtual Machine Scale Sets. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Sets. Call - ListNext() with this to fetch the next page of Virtual Machine Scale Sets. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetManagedDiskParameters(_serialization.Model): # pylint: disable=name-too-long - """Describes the parameters of a ScaleSet managed disk. - - :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", and - "StandardSSD_ZRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes - :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for - the managed disk. - :vartype disk_encryption_set: - ~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSetParameters - """ - - _attribute_map = { - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "disk_encryption_set": {"key": "diskEncryptionSet", "type": "DiskEncryptionSetParameters"}, - } - - def __init__( - self, - *, - storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, - disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values - are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", and - "StandardSSD_ZRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes - :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id - for the managed disk. - :paramtype disk_encryption_set: - ~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSetParameters - """ - super().__init__(**kwargs) - self.storage_account_type = storage_account_type - self.disk_encryption_set = disk_encryption_set - - -class VirtualMachineScaleSetNetworkConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's network configurations. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The network configuration name. Required. - :vartype name: str - :ivar primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :vartype primary: bool - :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :vartype enable_accelerated_networking: bool - :ivar enable_fpga: Specifies whether the network interface is FPGA networking-enabled. - :vartype enable_fpga: bool - :ivar network_security_group: The network security group. - :vartype network_security_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar dns_settings: The dns settings to be applied on the network interfaces. - :vartype dns_settings: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :ivar ip_configurations: Specifies the IP configurations of the network interface. - :vartype ip_configurations: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetIPConfiguration] - :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :vartype enable_ip_forwarding: bool - :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Known values are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "enable_accelerated_networking": {"key": "properties.enableAcceleratedNetworking", "type": "bool"}, - "enable_fpga": {"key": "properties.enableFpga", "type": "bool"}, - "network_security_group": {"key": "properties.networkSecurityGroup", "type": "SubResource"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetNetworkConfigurationDnsSettings", - }, - "ip_configurations": {"key": "properties.ipConfigurations", "type": "[VirtualMachineScaleSetIPConfiguration]"}, - "enable_ip_forwarding": {"key": "properties.enableIPForwarding", "type": "bool"}, - "delete_option": {"key": "properties.deleteOption", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - primary: Optional[bool] = None, - enable_accelerated_networking: Optional[bool] = None, - enable_fpga: Optional[bool] = None, - network_security_group: Optional["_models.SubResource"] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, - enable_ip_forwarding: Optional[bool] = None, - delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The network configuration name. Required. - :paramtype name: str - :keyword primary: Specifies the primary network interface in case the virtual machine has more - than 1 network interface. - :paramtype primary: bool - :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :paramtype enable_accelerated_networking: bool - :keyword enable_fpga: Specifies whether the network interface is FPGA networking-enabled. - :paramtype enable_fpga: bool - :keyword network_security_group: The network security group. - :paramtype network_security_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword dns_settings: The dns settings to be applied on the network interfaces. - :paramtype dns_settings: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :keyword ip_configurations: Specifies the IP configurations of the network interface. - :paramtype ip_configurations: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetIPConfiguration] - :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :paramtype enable_ip_forwarding: bool - :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Known values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions - """ - super().__init__(id=id, **kwargs) - self.name = name - self.primary = primary - self.enable_accelerated_networking = enable_accelerated_networking - self.enable_fpga = enable_fpga - self.network_security_group = network_security_group - self.dns_settings = dns_settings - self.ip_configurations = ip_configurations - self.enable_ip_forwarding = enable_ip_forwarding - self.delete_option = delete_option - - -class VirtualMachineScaleSetNetworkConfigurationDnsSettings(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines scale sets network configuration's DNS settings. - - :ivar dns_servers: List of DNS servers IP addresses. - :vartype dns_servers: list[str] - """ - - _attribute_map = { - "dns_servers": {"key": "dnsServers", "type": "[str]"}, - } - - def __init__(self, *, dns_servers: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword dns_servers: List of DNS servers IP addresses. - :paramtype dns_servers: list[str] - """ - super().__init__(**kwargs) - self.dns_servers = dns_servers - - -class VirtualMachineScaleSetNetworkProfile(_serialization.Model): - """Describes a virtual machine scale set network profile. - - :ivar health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :vartype health_probe: ~azure.mgmt.compute.v2021_07_01.models.ApiEntityReference - :ivar network_interface_configurations: The list of network configurations. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetNetworkConfiguration] - :ivar network_api_version: specifies the Microsoft.Network API version used when creating - networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. "2020-11-01" - :vartype network_api_version: str or ~azure.mgmt.compute.v2021_07_01.models.NetworkApiVersion - """ - - _attribute_map = { - "health_probe": {"key": "healthProbe", "type": "ApiEntityReference"}, - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineScaleSetNetworkConfiguration]", - }, - "network_api_version": {"key": "networkApiVersion", "type": "str"}, - } - - def __init__( - self, - *, - health_probe: Optional["_models.ApiEntityReference"] = None, - network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, - network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :paramtype health_probe: ~azure.mgmt.compute.v2021_07_01.models.ApiEntityReference - :keyword network_interface_configurations: The list of network configurations. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetNetworkConfiguration] - :keyword network_api_version: specifies the Microsoft.Network API version used when creating - networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. "2020-11-01" - :paramtype network_api_version: str or ~azure.mgmt.compute.v2021_07_01.models.NetworkApiVersion - """ - super().__init__(**kwargs) - self.health_probe = health_probe - self.network_interface_configurations = network_interface_configurations - self.network_api_version = network_api_version - - -class VirtualMachineScaleSetOSDisk(_serialization.Model): - """Describes a virtual machine scale set operating system disk. - - All required parameters must be populated in order to send to server. - - :ivar name: The disk name. - :vartype name: str - :ivar caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar create_option: Specifies how the virtual machines in the scale set should be created.\\ - :code:`
    `\\ :code:`
    ` The only allowed value is: **FromImage** \\u2013 This value is used - when you are using an image to create the virtual machine. If you are using a platform image, - you also use the imageReference element described above. If you are using a marketplace image, - you also use the plan element previously described. Required. Known values are: "FromImage", - "Empty", and "Attach". - :vartype create_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskCreateOptionTypes - :ivar diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk - used by the virtual machine scale set. - :vartype diff_disk_settings: ~azure.mgmt.compute.v2021_07_01.models.DiffDiskSettings - :ivar disk_size_gb: Specifies the size of the operating system disk in gigabytes. This element - can be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar os_type: This property allows you to specify the type of the OS that is included in the - disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - :ivar image: Specifies information about the unmanaged user image to base the scale set on. - :vartype image: ~azure.mgmt.compute.v2021_07_01.models.VirtualHardDisk - :ivar vhd_containers: Specifies the container urls that are used to store operating system - disks for the scale set. - :vartype vhd_containers: list[str] - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - - _validation = { - "create_option": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "create_option": {"key": "createOption", "type": "str"}, - "diff_disk_settings": {"key": "diffDiskSettings", "type": "DiffDiskSettings"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "os_type": {"key": "osType", "type": "str"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "vhd_containers": {"key": "vhdContainers", "type": "[str]"}, - "managed_disk": {"key": "managedDisk", "type": "VirtualMachineScaleSetManagedDiskParameters"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOptionTypes"], - name: Optional[str] = None, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, - disk_size_gb: Optional[int] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - image: Optional["_models.VirtualHardDisk"] = None, - vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The disk name. - :paramtype name: str - :keyword caching: Specifies the caching requirements. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ :code:`
    ` **None** :code:`
    `\\ :code:`
    ` **ReadOnly** - :code:`
    `\\ :code:`
    ` **ReadWrite** :code:`
    `\\ :code:`
    ` Default: **None for - Standard storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", and - "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword create_option: Specifies how the virtual machines in the scale set should be - created.\\ :code:`
    `\\ :code:`
    ` The only allowed value is: **FromImage** \\u2013 This - value is used when you are using an image to create the virtual machine. If you are using a - platform image, you also use the imageReference element described above. If you are using a - marketplace image, you also use the plan element previously described. Required. Known values - are: "FromImage", "Empty", and "Attach". - :paramtype create_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskCreateOptionTypes - :keyword diff_disk_settings: Specifies the ephemeral disk Settings for the operating system - disk used by the virtual machine scale set. - :paramtype diff_disk_settings: ~azure.mgmt.compute.v2021_07_01.models.DiffDiskSettings - :keyword disk_size_gb: Specifies the size of the operating system disk in gigabytes. This - element can be used to overwrite the size of the disk in a virtual machine image. - :code:`
    `\\ :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk if creating a VM from user-image or a specialized VHD. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` - **Linux**. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - :keyword image: Specifies information about the unmanaged user image to base the scale set on. - :paramtype image: ~azure.mgmt.compute.v2021_07_01.models.VirtualHardDisk - :keyword vhd_containers: Specifies the container urls that are used to store operating system - disks for the scale set. - :paramtype vhd_containers: list[str] - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - super().__init__(**kwargs) - self.name = name - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.create_option = create_option - self.diff_disk_settings = diff_disk_settings - self.disk_size_gb = disk_size_gb - self.os_type = os_type - self.image = image - self.vhd_containers = vhd_containers - self.managed_disk = managed_disk - - -class VirtualMachineScaleSetOSProfile(_serialization.Model): - """Describes a virtual machine scale set OS profile. - - :ivar computer_name_prefix: Specifies the computer name prefix for all of the virtual machines - in the scale set. Computer name prefixes must be 1 to 15 characters long. - :vartype computer_name_prefix: str - :ivar admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters. - :vartype admin_username: str - :ivar admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :vartype admin_password: str - :ivar custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` For using cloud-init for - your VM, see `Using cloud-init to customize a Linux VM during creation - `_. - :vartype custom_data: str - :ivar windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :vartype windows_configuration: ~azure.mgmt.compute.v2021_07_01.models.WindowsConfiguration - :ivar linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_. - :vartype linux_configuration: ~azure.mgmt.compute.v2021_07_01.models.LinuxConfiguration - :ivar secrets: Specifies set of certificates that should be installed onto the virtual machines - in the scale set. To install certificates on a virtual machine it is recommended to use the - `Azure Key Vault virtual machine extension for Linux - `_ or the `Azure - Key Vault virtual machine extension for Windows - `_. - :vartype secrets: list[~azure.mgmt.compute.v2021_07_01.models.VaultSecretGroup] - """ - - _attribute_map = { - "computer_name_prefix": {"key": "computerNamePrefix", "type": "str"}, - "admin_username": {"key": "adminUsername", "type": "str"}, - "admin_password": {"key": "adminPassword", "type": "str"}, - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - } - - def __init__( - self, - *, - computer_name_prefix: Optional[str] = None, - admin_username: Optional[str] = None, - admin_password: Optional[str] = None, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword computer_name_prefix: Specifies the computer name prefix for all of the virtual - machines in the scale set. Computer name prefixes must be 1 to 15 characters long. - :paramtype computer_name_prefix: str - :keyword admin_username: Specifies the name of the administrator account. :code:`
    `\\ - :code:`
    ` **Windows-only restriction:** Cannot end in "." :code:`
    `\\ :code:`
    ` - **Disallowed values:** "administrator", "admin", "user", "user1", "test", "user2", "test1", - "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", - "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", - "sys", "test2", "test3", "user4", "user5". :code:`
    `\\ :code:`
    ` **Minimum-length - (Linux):** 1 character :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 64 characters - :code:`
    `\\ :code:`
    ` **Max-length (Windows):** 20 characters. - :paramtype admin_username: str - :keyword admin_password: Specifies the password of the administrator account. :code:`
    `\\ - :code:`
    ` **Minimum-length (Windows):** 8 characters :code:`
    `\\ :code:`
    ` - **Minimum-length (Linux):** 6 characters :code:`
    `\\ :code:`
    ` **Max-length (Windows):** - 123 characters :code:`
    `\\ :code:`
    ` **Max-length (Linux):** 72 characters :code:`
    `\\ - :code:`
    ` **Complexity requirements:** 3 out of 4 conditions below need to be fulfilled - :code:`
    ` Has lower characters :code:`
    `Has upper characters :code:`
    ` Has a digit - :code:`
    ` Has a special character (Regex match [\\W_]) :code:`
    `\\ :code:`
    ` - **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", - "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" :code:`
    `\\ :code:`
    ` - For resetting the password, see `How to reset the Remote Desktop service or its login password - in a Windows VM `_ - :code:`
    `\\ :code:`
    ` For resetting root password, see `Manage users, SSH, and check or - repair disks on Azure Linux VMs using the VMAccess Extension - `_. - :paramtype admin_password: str - :keyword custom_data: Specifies a base-64 encoded string of custom data. The base-64 encoded - string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum - length of the binary array is 65535 bytes. :code:`
    `\\ :code:`
    ` For using cloud-init for - your VM, see `Using cloud-init to customize a Linux VM during creation - `_. - :paramtype custom_data: str - :keyword windows_configuration: Specifies Windows operating system settings on the virtual - machine. - :paramtype windows_configuration: ~azure.mgmt.compute.v2021_07_01.models.WindowsConfiguration - :keyword linux_configuration: Specifies the Linux operating system settings on the virtual - machine. :code:`
    `\\ :code:`
    `For a list of supported Linux distributions, see `Linux on - Azure-Endorsed Distributions - `_. - :paramtype linux_configuration: ~azure.mgmt.compute.v2021_07_01.models.LinuxConfiguration - :keyword secrets: Specifies set of certificates that should be installed onto the virtual - machines in the scale set. To install certificates on a virtual machine it is recommended to - use the `Azure Key Vault virtual machine extension for Linux - `_ or the `Azure - Key Vault virtual machine extension for Windows - `_. - :paramtype secrets: list[~azure.mgmt.compute.v2021_07_01.models.VaultSecretGroup] - """ - super().__init__(**kwargs) - self.computer_name_prefix = computer_name_prefix - self.admin_username = admin_username - self.admin_password = admin_password - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - - -class VirtualMachineScaleSetPublicIPAddressConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines scale set IP Configuration's PublicIPAddress configuration. - - All required parameters must be populated in order to send to server. - - :ivar name: The publicIP address configuration name. Required. - :vartype name: str - :ivar sku: Describes the public IP Sku. - :vartype sku: ~azure.mgmt.compute.v2021_07_01.models.PublicIPAddressSku - :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. - :vartype idle_timeout_in_minutes: int - :ivar dns_settings: The dns settings to be applied on the publicIP addresses . - :vartype dns_settings: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - :ivar ip_tags: The list of IP tags associated with the public IP address. - :vartype ip_tags: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetIpTag] - :ivar public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. - :vartype public_ip_prefix: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar public_ip_address_version: 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 'IPv6'. Known values are: "IPv4" and "IPv6". - :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersion - :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Known values - are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "sku": {"key": "sku", "type": "PublicIPAddressSku"}, - "idle_timeout_in_minutes": {"key": "properties.idleTimeoutInMinutes", "type": "int"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings", - }, - "ip_tags": {"key": "properties.ipTags", "type": "[VirtualMachineScaleSetIpTag]"}, - "public_ip_prefix": {"key": "properties.publicIPPrefix", "type": "SubResource"}, - "public_ip_address_version": {"key": "properties.publicIPAddressVersion", "type": "str"}, - "delete_option": {"key": "properties.deleteOption", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - sku: Optional["_models.PublicIPAddressSku"] = None, - idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - ip_tags: Optional[List["_models.VirtualMachineScaleSetIpTag"]] = None, - public_ip_prefix: Optional["_models.SubResource"] = None, - public_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, - delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The publicIP address configuration name. Required. - :paramtype name: str - :keyword sku: Describes the public IP Sku. - :paramtype sku: ~azure.mgmt.compute.v2021_07_01.models.PublicIPAddressSku - :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. - :paramtype idle_timeout_in_minutes: int - :keyword dns_settings: The dns settings to be applied on the publicIP addresses . - :paramtype dns_settings: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - :keyword ip_tags: The list of IP tags associated with the public IP address. - :paramtype ip_tags: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetIpTag] - :keyword public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. - :paramtype public_ip_prefix: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword public_ip_address_version: 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 'IPv6'. Known values are: "IPv4" and "IPv6". - :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersion - :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Known - values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions - """ - super().__init__(**kwargs) - self.name = name - self.sku = sku - self.idle_timeout_in_minutes = idle_timeout_in_minutes - self.dns_settings = dns_settings - self.ip_tags = ip_tags - self.public_ip_prefix = public_ip_prefix - self.public_ip_address_version = public_ip_address_version - self.delete_option = delete_option - - -class VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings( - _serialization.Model -): # pylint: disable=name-too-long - """Describes a virtual machines scale sets network configuration's DNS settings. - - All required parameters must be populated in order to send to server. - - :ivar domain_name_label: The Domain name label.The concatenation of the domain name label and - vm index will be the domain name labels of the PublicIPAddress resources that will be created. - Required. - :vartype domain_name_label: str - """ - - _validation = { - "domain_name_label": {"required": True}, - } - - _attribute_map = { - "domain_name_label": {"key": "domainNameLabel", "type": "str"}, - } - - def __init__(self, *, domain_name_label: str, **kwargs: Any) -> None: - """ - :keyword domain_name_label: The Domain name label.The concatenation of the domain name label - and vm index will be the domain name labels of the PublicIPAddress resources that will be - created. Required. - :paramtype domain_name_label: str - """ - super().__init__(**kwargs) - self.domain_name_label = domain_name_label - - -class VirtualMachineScaleSetVMReimageParameters(VirtualMachineReimageParameters): # pylint: disable=name-too-long - """Describes a Virtual Machine Scale Set VM Reimage Parameters. - - :ivar temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This temp - disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :vartype temp_disk: bool - """ - - -class VirtualMachineScaleSetReimageParameters(VirtualMachineScaleSetVMReimageParameters): - """Describes a Virtual Machine Scale Set VM Reimage Parameters. - - :ivar temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This temp - disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :vartype temp_disk: bool - :ivar instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :vartype instance_ids: list[str] - """ - - _attribute_map = { - "temp_disk": {"key": "tempDisk", "type": "bool"}, - "instance_ids": {"key": "instanceIds", "type": "[str]"}, - } - - def __init__( - self, *, temp_disk: Optional[bool] = None, instance_ids: Optional[List[str]] = None, **kwargs: Any - ) -> None: - """ - :keyword temp_disk: Specifies whether to reimage temp disk. Default value: false. Note: This - temp disk reimage parameter is only supported for VM/VMSS with Ephemeral OS disk. - :paramtype temp_disk: bool - :keyword instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :paramtype instance_ids: list[str] - """ - super().__init__(temp_disk=temp_disk, **kwargs) - self.instance_ids = instance_ids - - -class VirtualMachineScaleSetSku(_serialization.Model): - """Describes an available virtual machine scale set sku. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of resource the sku applies to. - :vartype resource_type: str - :ivar sku: The Sku. - :vartype sku: ~azure.mgmt.compute.v2021_07_01.models.Sku - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetSkuCapacity - """ - - _validation = { - "resource_type": {"readonly": True}, - "sku": {"readonly": True}, - "capacity": {"readonly": True}, - } - - _attribute_map = { - "resource_type": {"key": "resourceType", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "capacity": {"key": "capacity", "type": "VirtualMachineScaleSetSkuCapacity"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_type: Optional[str] = None - self.sku: Optional["_models.Sku"] = None - self.capacity: Optional["_models.VirtualMachineScaleSetSkuCapacity"] = None - - -class VirtualMachineScaleSetSkuCapacity(_serialization.Model): - """Describes scaling information of a sku. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar minimum: The minimum capacity. - :vartype minimum: int - :ivar maximum: The maximum capacity that can be set. - :vartype maximum: int - :ivar default_capacity: The default capacity. - :vartype default_capacity: int - :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic" and - "None". - :vartype scale_type: str or - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetSkuScaleType - """ - - _validation = { - "minimum": {"readonly": True}, - "maximum": {"readonly": True}, - "default_capacity": {"readonly": True}, - "scale_type": {"readonly": True}, - } - - _attribute_map = { - "minimum": {"key": "minimum", "type": "int"}, - "maximum": {"key": "maximum", "type": "int"}, - "default_capacity": {"key": "defaultCapacity", "type": "int"}, - "scale_type": {"key": "scaleType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.minimum: Optional[int] = None - self.maximum: Optional[int] = None - self.default_capacity: Optional[int] = None - self.scale_type: Optional[Union[str, "_models.VirtualMachineScaleSetSkuScaleType"]] = None - - -class VirtualMachineScaleSetStorageProfile(_serialization.Model): - """Describes a virtual machine scale set storage profile. - - :ivar image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :vartype image_reference: ~azure.mgmt.compute.v2021_07_01.models.ImageReference - :ivar os_disk: Specifies information about the operating system disk used by the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :vartype os_disk: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetOSDisk - :ivar data_disks: Specifies the parameters that are used to add data disks to the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :vartype data_disks: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetDataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "VirtualMachineScaleSetOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[VirtualMachineScaleSetDataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: Specifies information about the image to use. You can specify - information about platform images, marketplace images, or virtual machine images. This element - is required when you want to use a platform image, marketplace image, or virtual machine image, - but is not used in other creation operations. - :paramtype image_reference: ~azure.mgmt.compute.v2021_07_01.models.ImageReference - :keyword os_disk: Specifies information about the operating system disk used by the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :paramtype os_disk: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetOSDisk - :keyword data_disks: Specifies the parameters that are used to add data disks to the virtual - machines in the scale set. :code:`
    `\\ :code:`
    ` For more information about disks, see - `About disks and VHDs for Azure virtual machines - `_. - :paramtype data_disks: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetDataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class VirtualMachineScaleSetUpdate(UpdateResource): - """Describes a Virtual Machine Scale Set. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The virtual machine scale set sku. - :vartype sku: ~azure.mgmt.compute.v2021_07_01.models.Sku - :ivar plan: The purchase plan when deploying a virtual machine scale set from VM Marketplace - images. - :vartype plan: ~azure.mgmt.compute.v2021_07_01.models.Plan - :ivar identity: The identity of the virtual machine scale set, if configured. - :vartype identity: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetIdentity - :ivar upgrade_policy: The upgrade policy. - :vartype upgrade_policy: ~azure.mgmt.compute.v2021_07_01.models.UpgradePolicy - :ivar automatic_repairs_policy: Policy for automatic repairs. - :vartype automatic_repairs_policy: - ~azure.mgmt.compute.v2021_07_01.models.AutomaticRepairsPolicy - :ivar virtual_machine_profile: The virtual machine profile. - :vartype virtual_machine_profile: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdateVMProfile - :ivar overprovision: Specifies whether the Virtual Machine Scale Set should be overprovisioned. - :vartype overprovision: bool - :ivar do_not_run_extensions_on_overprovisioned_v_ms: When Overprovision is enabled, extensions - are launched only on the requested number of VMs which are finally kept. This property will - hence ensure that the extensions do not run on the extra overprovisioned VMs. - :vartype do_not_run_extensions_on_overprovisioned_v_ms: bool - :ivar single_placement_group: When true this limits the scale set to a single placement group, - of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be modified to - false. However, if singlePlacementGroup is false, it may not be modified to true. - :vartype single_placement_group: bool - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines - have the capability to support attaching managed data disks with UltraSSD_LRS storage account - type. - :vartype additional_capabilities: ~azure.mgmt.compute.v2021_07_01.models.AdditionalCapabilities - :ivar scale_in_policy: Specifies the policies applied when scaling in Virtual Machines in the - Virtual Machine Scale Set. - :vartype scale_in_policy: ~azure.mgmt.compute.v2021_07_01.models.ScaleInPolicy - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the virtual machine scale set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "identity": {"key": "identity", "type": "VirtualMachineScaleSetIdentity"}, - "upgrade_policy": {"key": "properties.upgradePolicy", "type": "UpgradePolicy"}, - "automatic_repairs_policy": {"key": "properties.automaticRepairsPolicy", "type": "AutomaticRepairsPolicy"}, - "virtual_machine_profile": { - "key": "properties.virtualMachineProfile", - "type": "VirtualMachineScaleSetUpdateVMProfile", - }, - "overprovision": {"key": "properties.overprovision", "type": "bool"}, - "do_not_run_extensions_on_overprovisioned_v_ms": { - "key": "properties.doNotRunExtensionsOnOverprovisionedVMs", - "type": "bool", - }, - "single_placement_group": {"key": "properties.singlePlacementGroup", "type": "bool"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "scale_in_policy": {"key": "properties.scaleInPolicy", "type": "ScaleInPolicy"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["_models.UpgradePolicy"] = None, - automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, - overprovision: Optional[bool] = None, - do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, - single_placement_group: Optional[bool] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - scale_in_policy: Optional["_models.ScaleInPolicy"] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The virtual machine scale set sku. - :paramtype sku: ~azure.mgmt.compute.v2021_07_01.models.Sku - :keyword plan: The purchase plan when deploying a virtual machine scale set from VM Marketplace - images. - :paramtype plan: ~azure.mgmt.compute.v2021_07_01.models.Plan - :keyword identity: The identity of the virtual machine scale set, if configured. - :paramtype identity: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetIdentity - :keyword upgrade_policy: The upgrade policy. - :paramtype upgrade_policy: ~azure.mgmt.compute.v2021_07_01.models.UpgradePolicy - :keyword automatic_repairs_policy: Policy for automatic repairs. - :paramtype automatic_repairs_policy: - ~azure.mgmt.compute.v2021_07_01.models.AutomaticRepairsPolicy - :keyword virtual_machine_profile: The virtual machine profile. - :paramtype virtual_machine_profile: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdateVMProfile - :keyword overprovision: Specifies whether the Virtual Machine Scale Set should be - overprovisioned. - :paramtype overprovision: bool - :keyword do_not_run_extensions_on_overprovisioned_v_ms: When Overprovision is enabled, - extensions are launched only on the requested number of VMs which are finally kept. This - property will hence ensure that the extensions do not run on the extra overprovisioned VMs. - :paramtype do_not_run_extensions_on_overprovisioned_v_ms: bool - :keyword single_placement_group: When true this limits the scale set to a single placement - group, of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be - modified to false. However, if singlePlacementGroup is false, it may not be modified to true. - :paramtype single_placement_group: bool - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines - have the capability to support attaching managed data disks with UltraSSD_LRS storage account - type. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2021_07_01.models.AdditionalCapabilities - :keyword scale_in_policy: Specifies the policies applied when scaling in Virtual Machines in - the Virtual Machine Scale Set. - :paramtype scale_in_policy: ~azure.mgmt.compute.v2021_07_01.models.ScaleInPolicy - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the virtual machine scale set should be assigned to. :code:`
    `\\ :code:`
    `Minimum - api-version: 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - """ - super().__init__(tags=tags, **kwargs) - self.sku = sku - self.plan = plan - self.identity = identity - self.upgrade_policy = upgrade_policy - self.automatic_repairs_policy = automatic_repairs_policy - self.virtual_machine_profile = virtual_machine_profile - self.overprovision = overprovision - self.do_not_run_extensions_on_overprovisioned_v_ms = do_not_run_extensions_on_overprovisioned_v_ms - self.single_placement_group = single_placement_group - self.additional_capabilities = additional_capabilities - self.scale_in_policy = scale_in_policy - self.proximity_placement_group = proximity_placement_group - - -class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's IP configuration. NOTE: The subnet of a - scale set may be modified as long as the original subnet and the new subnet are in the same - virtual network. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The IP configuration name. - :vartype name: str - :ivar subnet: The subnet. - :vartype subnet: ~azure.mgmt.compute.v2021_07_01.models.ApiEntityReference - :ivar primary: Specifies the primary IP Configuration in case the network interface has more - than one IP Configuration. - :vartype primary: bool - :ivar public_ip_address_configuration: The publicIPAddressConfiguration. - :vartype public_ip_address_configuration: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration - :ivar private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersion - :ivar application_gateway_backend_address_pools: The application gateway backend address pools. - :vartype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :ivar application_security_groups: Specifies an array of references to application security - group. - :vartype application_security_groups: list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :ivar load_balancer_backend_address_pools: The load balancer backend address pools. - :vartype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :ivar load_balancer_inbound_nat_pools: The load balancer inbound nat pools. - :vartype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subnet": {"key": "properties.subnet", "type": "ApiEntityReference"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "public_ip_address_configuration": { - "key": "properties.publicIPAddressConfiguration", - "type": "VirtualMachineScaleSetUpdatePublicIPAddressConfiguration", - }, - "private_ip_address_version": {"key": "properties.privateIPAddressVersion", "type": "str"}, - "application_gateway_backend_address_pools": { - "key": "properties.applicationGatewayBackendAddressPools", - "type": "[SubResource]", - }, - "application_security_groups": {"key": "properties.applicationSecurityGroups", "type": "[SubResource]"}, - "load_balancer_backend_address_pools": { - "key": "properties.loadBalancerBackendAddressPools", - "type": "[SubResource]", - }, - "load_balancer_inbound_nat_pools": {"key": "properties.loadBalancerInboundNatPools", "type": "[SubResource]"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - subnet: Optional["_models.ApiEntityReference"] = None, - primary: Optional[bool] = None, - public_ip_address_configuration: Optional[ - "_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration" - ] = None, - private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, - application_security_groups: Optional[List["_models.SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The IP configuration name. - :paramtype name: str - :keyword subnet: The subnet. - :paramtype subnet: ~azure.mgmt.compute.v2021_07_01.models.ApiEntityReference - :keyword primary: Specifies the primary IP Configuration in case the network interface has more - than one IP Configuration. - :paramtype primary: bool - :keyword public_ip_address_configuration: The publicIPAddressConfiguration. - :paramtype public_ip_address_configuration: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration - :keyword private_ip_address_version: 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'. Known values are: "IPv4" and "IPv6". - :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersion - :keyword application_gateway_backend_address_pools: The application gateway backend address - pools. - :paramtype application_gateway_backend_address_pools: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :keyword application_security_groups: Specifies an array of references to application security - group. - :paramtype application_security_groups: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :keyword load_balancer_backend_address_pools: The load balancer backend address pools. - :paramtype load_balancer_backend_address_pools: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - :keyword load_balancer_inbound_nat_pools: The load balancer inbound nat pools. - :paramtype load_balancer_inbound_nat_pools: - list[~azure.mgmt.compute.v2021_07_01.models.SubResource] - """ - super().__init__(id=id, **kwargs) - self.name = name - self.subnet = subnet - self.primary = primary - self.public_ip_address_configuration = public_ip_address_configuration - self.private_ip_address_version = private_ip_address_version - self.application_gateway_backend_address_pools = application_gateway_backend_address_pools - self.application_security_groups = application_security_groups - self.load_balancer_backend_address_pools = load_balancer_backend_address_pools - self.load_balancer_inbound_nat_pools = load_balancer_inbound_nat_pools - - -class VirtualMachineScaleSetUpdateNetworkConfiguration(SubResource): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile's network configurations. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The network configuration name. - :vartype name: str - :ivar primary: Whether this is a primary NIC on a virtual machine. - :vartype primary: bool - :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :vartype enable_accelerated_networking: bool - :ivar enable_fpga: Specifies whether the network interface is FPGA networking-enabled. - :vartype enable_fpga: bool - :ivar network_security_group: The network security group. - :vartype network_security_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar dns_settings: The dns settings to be applied on the network interfaces. - :vartype dns_settings: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :ivar ip_configurations: The virtual machine scale set IP Configuration. - :vartype ip_configurations: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdateIPConfiguration] - :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :vartype enable_ip_forwarding: bool - :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Known values are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "primary": {"key": "properties.primary", "type": "bool"}, - "enable_accelerated_networking": {"key": "properties.enableAcceleratedNetworking", "type": "bool"}, - "enable_fpga": {"key": "properties.enableFpga", "type": "bool"}, - "network_security_group": {"key": "properties.networkSecurityGroup", "type": "SubResource"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetNetworkConfigurationDnsSettings", - }, - "ip_configurations": { - "key": "properties.ipConfigurations", - "type": "[VirtualMachineScaleSetUpdateIPConfiguration]", - }, - "enable_ip_forwarding": {"key": "properties.enableIPForwarding", "type": "bool"}, - "delete_option": {"key": "properties.deleteOption", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - primary: Optional[bool] = None, - enable_accelerated_networking: Optional[bool] = None, - enable_fpga: Optional[bool] = None, - network_security_group: Optional["_models.SubResource"] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, - enable_ip_forwarding: Optional[bool] = None, - delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The network configuration name. - :paramtype name: str - :keyword primary: Whether this is a primary NIC on a virtual machine. - :paramtype primary: bool - :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated - networking-enabled. - :paramtype enable_accelerated_networking: bool - :keyword enable_fpga: Specifies whether the network interface is FPGA networking-enabled. - :paramtype enable_fpga: bool - :keyword network_security_group: The network security group. - :paramtype network_security_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword dns_settings: The dns settings to be applied on the network interfaces. - :paramtype dns_settings: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetNetworkConfigurationDnsSettings - :keyword ip_configurations: The virtual machine scale set IP Configuration. - :paramtype ip_configurations: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdateIPConfiguration] - :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. - :paramtype enable_ip_forwarding: bool - :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Known values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions - """ - super().__init__(id=id, **kwargs) - self.name = name - self.primary = primary - self.enable_accelerated_networking = enable_accelerated_networking - self.enable_fpga = enable_fpga - self.network_security_group = network_security_group - self.dns_settings = dns_settings - self.ip_configurations = ip_configurations - self.enable_ip_forwarding = enable_ip_forwarding - self.delete_option = delete_option - - -class VirtualMachineScaleSetUpdateNetworkProfile(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machine scale set network profile. - - :ivar health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :vartype health_probe: ~azure.mgmt.compute.v2021_07_01.models.ApiEntityReference - :ivar network_interface_configurations: The list of network configurations. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] - :ivar network_api_version: specifies the Microsoft.Network API version used when creating - networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. "2020-11-01" - :vartype network_api_version: str or ~azure.mgmt.compute.v2021_07_01.models.NetworkApiVersion - """ - - _attribute_map = { - "health_probe": {"key": "healthProbe", "type": "ApiEntityReference"}, - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineScaleSetUpdateNetworkConfiguration]", - }, - "network_api_version": {"key": "networkApiVersion", "type": "str"}, - } - - def __init__( - self, - *, - health_probe: Optional["_models.ApiEntityReference"] = None, - network_interface_configurations: Optional[ - List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"] - ] = None, - network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword health_probe: A reference to a load balancer probe used to determine the health of an - instance in the virtual machine scale set. The reference will be in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. - :paramtype health_probe: ~azure.mgmt.compute.v2021_07_01.models.ApiEntityReference - :keyword network_interface_configurations: The list of network configurations. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] - :keyword network_api_version: specifies the Microsoft.Network API version used when creating - networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. "2020-11-01" - :paramtype network_api_version: str or ~azure.mgmt.compute.v2021_07_01.models.NetworkApiVersion - """ - super().__init__(**kwargs) - self.health_probe = health_probe - self.network_interface_configurations = network_interface_configurations - self.network_api_version = network_api_version - - -class VirtualMachineScaleSetUpdateOSDisk(_serialization.Model): - """Describes virtual machine scale set operating system disk Update Object. This should be used - for Updating VMSS OS Disk. - - :ivar caching: The caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :vartype write_accelerator_enabled: bool - :ivar disk_size_gb: Specifies the size of the operating system disk in gigabytes. This element - can be used to overwrite the size of the disk in a virtual machine image. :code:`
    `\\ - :code:`
    ` This value cannot be larger than 1023 GB. - :vartype disk_size_gb: int - :ivar image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before - using it to attach to the Virtual Machine. If SourceImage is provided, the destination - VirtualHardDisk should not exist. - :vartype image: ~azure.mgmt.compute.v2021_07_01.models.VirtualHardDisk - :ivar vhd_containers: The list of virtual hard disk container uris. - :vartype vhd_containers: list[str] - :ivar managed_disk: The managed disk parameters. - :vartype managed_disk: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - - _attribute_map = { - "caching": {"key": "caching", "type": "str"}, - "write_accelerator_enabled": {"key": "writeAcceleratorEnabled", "type": "bool"}, - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "image": {"key": "image", "type": "VirtualHardDisk"}, - "vhd_containers": {"key": "vhdContainers", "type": "[str]"}, - "managed_disk": {"key": "managedDisk", "type": "VirtualMachineScaleSetManagedDiskParameters"}, - } - - def __init__( - self, - *, - caching: Optional[Union[str, "_models.CachingTypes"]] = None, - write_accelerator_enabled: Optional[bool] = None, - disk_size_gb: Optional[int] = None, - image: Optional["_models.VirtualHardDisk"] = None, - vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword caching: The caching type. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes - :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or - disabled on the disk. - :paramtype write_accelerator_enabled: bool - :keyword disk_size_gb: Specifies the size of the operating system disk in gigabytes. This - element can be used to overwrite the size of the disk in a virtual machine image. - :code:`
    `\\ :code:`
    ` This value cannot be larger than 1023 GB. - :paramtype disk_size_gb: int - :keyword image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied - before using it to attach to the Virtual Machine. If SourceImage is provided, the destination - VirtualHardDisk should not exist. - :paramtype image: ~azure.mgmt.compute.v2021_07_01.models.VirtualHardDisk - :keyword vhd_containers: The list of virtual hard disk container uris. - :paramtype vhd_containers: list[str] - :keyword managed_disk: The managed disk parameters. - :paramtype managed_disk: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetManagedDiskParameters - """ - super().__init__(**kwargs) - self.caching = caching - self.write_accelerator_enabled = write_accelerator_enabled - self.disk_size_gb = disk_size_gb - self.image = image - self.vhd_containers = vhd_containers - self.managed_disk = managed_disk - - -class VirtualMachineScaleSetUpdateOSProfile(_serialization.Model): - """Describes a virtual machine scale set OS profile. - - :ivar custom_data: A base-64 encoded string of custom data. - :vartype custom_data: str - :ivar windows_configuration: The Windows Configuration of the OS profile. - :vartype windows_configuration: ~azure.mgmt.compute.v2021_07_01.models.WindowsConfiguration - :ivar linux_configuration: The Linux Configuration of the OS profile. - :vartype linux_configuration: ~azure.mgmt.compute.v2021_07_01.models.LinuxConfiguration - :ivar secrets: The List of certificates for addition to the VM. - :vartype secrets: list[~azure.mgmt.compute.v2021_07_01.models.VaultSecretGroup] - """ - - _attribute_map = { - "custom_data": {"key": "customData", "type": "str"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "WindowsConfiguration"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "LinuxConfiguration"}, - "secrets": {"key": "secrets", "type": "[VaultSecretGroup]"}, - } - - def __init__( - self, - *, - custom_data: Optional[str] = None, - windows_configuration: Optional["_models.WindowsConfiguration"] = None, - linux_configuration: Optional["_models.LinuxConfiguration"] = None, - secrets: Optional[List["_models.VaultSecretGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword custom_data: A base-64 encoded string of custom data. - :paramtype custom_data: str - :keyword windows_configuration: The Windows Configuration of the OS profile. - :paramtype windows_configuration: ~azure.mgmt.compute.v2021_07_01.models.WindowsConfiguration - :keyword linux_configuration: The Linux Configuration of the OS profile. - :paramtype linux_configuration: ~azure.mgmt.compute.v2021_07_01.models.LinuxConfiguration - :keyword secrets: The List of certificates for addition to the VM. - :paramtype secrets: list[~azure.mgmt.compute.v2021_07_01.models.VaultSecretGroup] - """ - super().__init__(**kwargs) - self.custom_data = custom_data - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - self.secrets = secrets - - -class VirtualMachineScaleSetUpdatePublicIPAddressConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machines scale set IP Configuration's PublicIPAddress configuration. - - :ivar name: The publicIP address configuration name. - :vartype name: str - :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. - :vartype idle_timeout_in_minutes: int - :ivar dns_settings: The dns settings to be applied on the publicIP addresses . - :vartype dns_settings: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Known values - are: "Delete" and "Detach". - :vartype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "idle_timeout_in_minutes": {"key": "properties.idleTimeoutInMinutes", "type": "int"}, - "dns_settings": { - "key": "properties.dnsSettings", - "type": "VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings", - }, - "delete_option": {"key": "properties.deleteOption", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The publicIP address configuration name. - :paramtype name: str - :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. - :paramtype idle_timeout_in_minutes: int - :keyword dns_settings: The dns settings to be applied on the publicIP addresses . - :paramtype dns_settings: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Known - values are: "Delete" and "Detach". - :paramtype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions - """ - super().__init__(**kwargs) - self.name = name - self.idle_timeout_in_minutes = idle_timeout_in_minutes - self.dns_settings = dns_settings - self.delete_option = delete_option - - -class VirtualMachineScaleSetUpdateStorageProfile(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machine scale set storage profile. - - :ivar image_reference: The image reference. - :vartype image_reference: ~azure.mgmt.compute.v2021_07_01.models.ImageReference - :ivar os_disk: The OS disk. - :vartype os_disk: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdateOSDisk - :ivar data_disks: The data disks. - :vartype data_disks: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetDataDisk] - """ - - _attribute_map = { - "image_reference": {"key": "imageReference", "type": "ImageReference"}, - "os_disk": {"key": "osDisk", "type": "VirtualMachineScaleSetUpdateOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[VirtualMachineScaleSetDataDisk]"}, - } - - def __init__( - self, - *, - image_reference: Optional["_models.ImageReference"] = None, - os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword image_reference: The image reference. - :paramtype image_reference: ~azure.mgmt.compute.v2021_07_01.models.ImageReference - :keyword os_disk: The OS disk. - :paramtype os_disk: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdateOSDisk - :keyword data_disks: The data disks. - :paramtype data_disks: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetDataDisk] - """ - super().__init__(**kwargs) - self.image_reference = image_reference - self.os_disk = os_disk - self.data_disks = data_disks - - -class VirtualMachineScaleSetUpdateVMProfile(_serialization.Model): - """Describes a virtual machine scale set virtual machine profile. - - :ivar os_profile: The virtual machine scale set OS profile. - :vartype os_profile: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdateOSProfile - :ivar storage_profile: The virtual machine scale set storage profile. - :vartype storage_profile: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdateStorageProfile - :ivar network_profile: The virtual machine scale set network profile. - :vartype network_profile: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdateNetworkProfile - :ivar security_profile: The virtual machine scale set Security profile. - :vartype security_profile: ~azure.mgmt.compute.v2021_07_01.models.SecurityProfile - :ivar diagnostics_profile: The virtual machine scale set diagnostics profile. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2021_07_01.models.DiagnosticsProfile - :ivar extension_profile: The virtual machine scale set extension profile. - :vartype extension_profile: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtensionProfile - :ivar license_type: The license type, which is for bring your own license scenario. - :vartype license_type: str - :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2021_07_01.models.BillingProfile - :ivar scheduled_events_profile: Specifies Scheduled Event related configurations. - :vartype scheduled_events_profile: - ~azure.mgmt.compute.v2021_07_01.models.ScheduledEventsProfile - :ivar user_data: UserData for the VM, which must be base-64 encoded. Customer should not pass - any secrets in here. :code:`
    `\\ :code:`
    `Minimum api-version: 2021-03-01. - :vartype user_data: str - """ - - _attribute_map = { - "os_profile": {"key": "osProfile", "type": "VirtualMachineScaleSetUpdateOSProfile"}, - "storage_profile": {"key": "storageProfile", "type": "VirtualMachineScaleSetUpdateStorageProfile"}, - "network_profile": {"key": "networkProfile", "type": "VirtualMachineScaleSetUpdateNetworkProfile"}, - "security_profile": {"key": "securityProfile", "type": "SecurityProfile"}, - "diagnostics_profile": {"key": "diagnosticsProfile", "type": "DiagnosticsProfile"}, - "extension_profile": {"key": "extensionProfile", "type": "VirtualMachineScaleSetExtensionProfile"}, - "license_type": {"key": "licenseType", "type": "str"}, - "billing_profile": {"key": "billingProfile", "type": "BillingProfile"}, - "scheduled_events_profile": {"key": "scheduledEventsProfile", "type": "ScheduledEventsProfile"}, - "user_data": {"key": "userData", "type": "str"}, - } - - def __init__( - self, - *, - os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, - security_profile: Optional["_models.SecurityProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, - license_type: Optional[str] = None, - billing_profile: Optional["_models.BillingProfile"] = None, - scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, - user_data: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_profile: The virtual machine scale set OS profile. - :paramtype os_profile: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdateOSProfile - :keyword storage_profile: The virtual machine scale set storage profile. - :paramtype storage_profile: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdateStorageProfile - :keyword network_profile: The virtual machine scale set network profile. - :paramtype network_profile: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdateNetworkProfile - :keyword security_profile: The virtual machine scale set Security profile. - :paramtype security_profile: ~azure.mgmt.compute.v2021_07_01.models.SecurityProfile - :keyword diagnostics_profile: The virtual machine scale set diagnostics profile. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2021_07_01.models.DiagnosticsProfile - :keyword extension_profile: The virtual machine scale set extension profile. - :paramtype extension_profile: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtensionProfile - :keyword license_type: The license type, which is for bring your own license scenario. - :paramtype license_type: str - :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2021_07_01.models.BillingProfile - :keyword scheduled_events_profile: Specifies Scheduled Event related configurations. - :paramtype scheduled_events_profile: - ~azure.mgmt.compute.v2021_07_01.models.ScheduledEventsProfile - :keyword user_data: UserData for the VM, which must be base-64 encoded. Customer should not - pass any secrets in here. :code:`
    `\\ :code:`
    `Minimum api-version: 2021-03-01. - :paramtype user_data: str - """ - super().__init__(**kwargs) - self.os_profile = os_profile - self.storage_profile = storage_profile - self.network_profile = network_profile - self.security_profile = security_profile - self.diagnostics_profile = diagnostics_profile - self.extension_profile = extension_profile - self.license_type = license_type - self.billing_profile = billing_profile - self.scheduled_events_profile = scheduled_events_profile - self.user_data = user_data - - -class VirtualMachineScaleSetVM(Resource): - """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. - :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] - :ivar instance_id: The virtual machine instance ID. - :vartype instance_id: str - :ivar sku: The virtual machine SKU. - :vartype sku: ~azure.mgmt.compute.v2021_07_01.models.Sku - :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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2021_07_01.models.Plan - :ivar resources: The virtual machine child extension resources. - :vartype resources: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension] - :ivar zones: The virtual machine zones. - :vartype zones: list[str] - :ivar latest_model_applied: Specifies whether the latest model has been applied to the virtual - machine. - :vartype latest_model_applied: bool - :ivar vm_id: Azure VM unique ID. - :vartype vm_id: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceView - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2021_07_01.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2021_07_01.models.StorageProfile - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine in the scale set. For instance: whether the virtual machine has the capability - to support attaching managed data disks with UltraSSD_LRS storage account type. - :vartype additional_capabilities: ~azure.mgmt.compute.v2021_07_01.models.AdditionalCapabilities - :ivar os_profile: Specifies the operating system settings for the virtual machine. - :vartype os_profile: ~azure.mgmt.compute.v2021_07_01.models.OSProfile - :ivar security_profile: Specifies the Security related profile settings for the virtual - machine. - :vartype security_profile: ~azure.mgmt.compute.v2021_07_01.models.SecurityProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2021_07_01.models.NetworkProfile - :ivar network_profile_configuration: Specifies the network profile configuration of the virtual - machine. - :vartype network_profile_configuration: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMNetworkProfileConfiguration - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2021_07_01.models.DiagnosticsProfile - :ivar availability_set: 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 overview - `_. :code:`
    `\\ - :code:`
    ` For more information on Azure planned maintenance, see `Maintenance and updates - for Virtual Machines in Azure - `_ :code:`
    `\\ - :code:`
    ` Currently, a VM can only be added to availability set at creation time. An - existing VM cannot be added to an availability set. - :vartype availability_set: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. :code:`
    `\\ :code:`
    ` Possible values for Windows Server operating system - are: :code:`
    `\\ :code:`
    ` Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server - :code:`
    `\\ :code:`
    ` Possible values for Linux Server operating system are: - :code:`
    `\\ :code:`
    ` RHEL_BYOS (for RHEL) :code:`
    `\\ :code:`
    ` SLES_BYOS (for - SUSE) :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid Use Benefit for - Windows Server - `_ - :code:`
    `\\ :code:`
    ` `Azure Hybrid Use Benefit for Linux Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar model_definition_applied: Specifies whether the model applied to the virtual machine is - the model of the virtual machine scale set or the customized model for the virtual machine. - :vartype model_definition_applied: str - :ivar protection_policy: Specifies the protection policy of the virtual machine. - :vartype protection_policy: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMProtectionPolicy - :ivar user_data: UserData for the VM, which must be base-64 encoded. Customer should not pass - any secrets in here. :code:`
    `\\ :code:`
    `Minimum api-version: 2021-03-01. - :vartype user_data: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "instance_id": {"readonly": True}, - "sku": {"readonly": True}, - "resources": {"readonly": True}, - "zones": {"readonly": True}, - "latest_model_applied": {"readonly": True}, - "vm_id": {"readonly": True}, - "instance_view": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "model_definition_applied": {"readonly": 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}"}, - "instance_id": {"key": "instanceId", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "plan": {"key": "plan", "type": "Plan"}, - "resources": {"key": "resources", "type": "[VirtualMachineExtension]"}, - "zones": {"key": "zones", "type": "[str]"}, - "latest_model_applied": {"key": "properties.latestModelApplied", "type": "bool"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineScaleSetVMInstanceView"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "security_profile": {"key": "properties.securityProfile", "type": "SecurityProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "network_profile_configuration": { - "key": "properties.networkProfileConfiguration", - "type": "VirtualMachineScaleSetVMNetworkProfileConfiguration", - }, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "model_definition_applied": {"key": "properties.modelDefinitionApplied", "type": "str"}, - "protection_policy": {"key": "properties.protectionPolicy", "type": "VirtualMachineScaleSetVMProtectionPolicy"}, - "user_data": {"key": "properties.userData", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - os_profile: Optional["_models.OSProfile"] = None, - security_profile: Optional["_models.SecurityProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - network_profile_configuration: Optional["_models.VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - protection_policy: Optional["_models.VirtualMachineScaleSetVMProtectionPolicy"] = None, - user_data: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2021_07_01.models.Plan - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2021_07_01.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2021_07_01.models.StorageProfile - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine in the scale set. For instance: whether the virtual machine has the capability - to support attaching managed data disks with UltraSSD_LRS storage account type. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2021_07_01.models.AdditionalCapabilities - :keyword os_profile: Specifies the operating system settings for the virtual machine. - :paramtype os_profile: ~azure.mgmt.compute.v2021_07_01.models.OSProfile - :keyword security_profile: Specifies the Security related profile settings for the virtual - machine. - :paramtype security_profile: ~azure.mgmt.compute.v2021_07_01.models.SecurityProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2021_07_01.models.NetworkProfile - :keyword network_profile_configuration: Specifies the network profile configuration of the - virtual machine. - :paramtype network_profile_configuration: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMNetworkProfileConfiguration - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2021_07_01.models.DiagnosticsProfile - :keyword availability_set: 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 overview - `_. :code:`
    `\\ - :code:`
    ` For more information on Azure planned maintenance, see `Maintenance and updates - for Virtual Machines in Azure - `_ :code:`
    `\\ - :code:`
    ` Currently, a VM can only be added to availability set at creation time. An - existing VM cannot be added to an availability set. - :paramtype availability_set: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. :code:`
    `\\ :code:`
    ` Possible values for Windows Server operating system - are: :code:`
    `\\ :code:`
    ` Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server - :code:`
    `\\ :code:`
    ` Possible values for Linux Server operating system are: - :code:`
    `\\ :code:`
    ` RHEL_BYOS (for RHEL) :code:`
    `\\ :code:`
    ` SLES_BYOS (for - SUSE) :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid Use Benefit for - Windows Server - `_ - :code:`
    `\\ :code:`
    ` `Azure Hybrid Use Benefit for Linux Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - :keyword protection_policy: Specifies the protection policy of the virtual machine. - :paramtype protection_policy: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMProtectionPolicy - :keyword user_data: UserData for the VM, which must be base-64 encoded. Customer should not - pass any secrets in here. :code:`
    `\\ :code:`
    `Minimum api-version: 2021-03-01. - :paramtype user_data: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.instance_id: Optional[str] = None - self.sku: Optional["_models.Sku"] = None - self.plan = plan - self.resources: Optional[List["_models.VirtualMachineExtension"]] = None - self.zones: Optional[List[str]] = None - self.latest_model_applied: Optional[bool] = None - self.vm_id: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineScaleSetVMInstanceView"] = None - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.additional_capabilities = additional_capabilities - self.os_profile = os_profile - self.security_profile = security_profile - self.network_profile = network_profile - self.network_profile_configuration = network_profile_configuration - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.provisioning_state: Optional[str] = None - self.license_type = license_type - self.model_definition_applied: Optional[str] = None - self.protection_policy = protection_policy - self.user_data = user_data - - -class VirtualMachineScaleSetVMExtension(SubResourceReadOnly): - """Describes a VMSS VM Extension. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the extension. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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. - :vartype instance_view: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionInstanceView - :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. - :vartype suppress_failures: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "enable_automatic_upgrade": {"key": "properties.enableAutomaticUpgrade", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineExtensionInstanceView"}, - "suppress_failures": {"key": "properties.suppressFailures", "type": "bool"}, - } - - def __init__( - self, - *, - 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, - instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, - suppress_failures: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :keyword instance_view: The virtual machine extension instance view. - :paramtype instance_view: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionInstanceView - :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. - :paramtype suppress_failures: bool - """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.type: Optional[str] = None - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.enable_automatic_upgrade = enable_automatic_upgrade - self.settings = settings - self.protected_settings = protected_settings - self.provisioning_state: Optional[str] = None - self.instance_view = instance_view - self.suppress_failures = suppress_failures - - -class VirtualMachineScaleSetVMExtensionsListResult(_serialization.Model): # pylint: disable=name-too-long - """The List VMSS VM Extension operation response. - - :ivar value: The list of VMSS VM extensions. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtension] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetVMExtension]"}, - } - - def __init__( - self, *, value: Optional[List["_models.VirtualMachineScaleSetVMExtension"]] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of VMSS VM extensions. - :paramtype value: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtension] - """ - super().__init__(**kwargs) - self.value = value - - -class VirtualMachineScaleSetVMExtensionsSummary(_serialization.Model): # pylint: disable=name-too-long - """Extensions summary for virtual machines of a virtual machine scale set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The extension name. - :vartype name: str - :ivar statuses_summary: The extensions information. - :vartype statuses_summary: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineStatusCodeCount] - """ - - _validation = { - "name": {"readonly": True}, - "statuses_summary": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "statuses_summary": {"key": "statusesSummary", "type": "[VirtualMachineStatusCodeCount]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.statuses_summary: Optional[List["_models.VirtualMachineStatusCodeCount"]] = None - - -class VirtualMachineScaleSetVMExtensionUpdate(SubResourceReadOnly): - """Describes a VMSS VM Extension. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the extension. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :vartype force_update_tag: str - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :vartype auto_upgrade_minor_version: bool - :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :ivar protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON - :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. - :vartype suppress_failures: bool - """ - - _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"}, - "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, - "enable_automatic_upgrade": {"key": "properties.enableAutomaticUpgrade", "type": "bool"}, - "settings": {"key": "properties.settings", "type": "object"}, - "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, - "suppress_failures": {"key": "properties.suppressFailures", "type": "bool"}, - } - - def __init__( - self, - *, - 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, - suppress_failures: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :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 - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str - :keyword type_handler_version: Specifies the version of the script handler. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :paramtype auto_upgrade_minor_version: bool - :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically - 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 - :keyword protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON - :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. - :paramtype suppress_failures: bool - """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.type: Optional[str] = None - self.force_update_tag = force_update_tag - self.publisher = publisher - self.type_properties_type = type_properties_type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.enable_automatic_upgrade = enable_automatic_upgrade - self.settings = settings - self.protected_settings = protected_settings - self.suppress_failures = suppress_failures - - -class VirtualMachineScaleSetVMInstanceIDs(_serialization.Model): - """Specifies a list of virtual machine instance IDs from the VM scale set. - - :ivar instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :vartype instance_ids: list[str] - """ - - _attribute_map = { - "instance_ids": {"key": "instanceIds", "type": "[str]"}, - } - - def __init__(self, *, instance_ids: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword instance_ids: The virtual machine scale set instance ids. Omitting the virtual machine - scale set instance ids will result in the operation being performed on all virtual machines in - the virtual machine scale set. - :paramtype instance_ids: list[str] - """ - super().__init__(**kwargs) - self.instance_ids = instance_ids - - -class VirtualMachineScaleSetVMInstanceRequiredIDs(_serialization.Model): # pylint: disable=name-too-long - """Specifies a list of virtual machine instance IDs from the VM scale set. - - All required parameters must be populated in order to send to server. - - :ivar instance_ids: The virtual machine scale set instance ids. Required. - :vartype instance_ids: list[str] - """ - - _validation = { - "instance_ids": {"required": True}, - } - - _attribute_map = { - "instance_ids": {"key": "instanceIds", "type": "[str]"}, - } - - def __init__(self, *, instance_ids: List[str], **kwargs: Any) -> None: - """ - :keyword instance_ids: The virtual machine scale set instance ids. Required. - :paramtype instance_ids: list[str] - """ - super().__init__(**kwargs) - self.instance_ids = instance_ids - - -class VirtualMachineScaleSetVMInstanceView(_serialization.Model): - """The instance view of a virtual machine scale set VM. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar platform_update_domain: The Update Domain count. - :vartype platform_update_domain: int - :ivar platform_fault_domain: The Fault Domain count. - :vartype platform_fault_domain: int - :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. - :vartype rdp_thumb_print: str - :ivar vm_agent: The VM Agent running on the virtual machine. - :vartype vm_agent: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineAgentInstanceView - :ivar maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :vartype maintenance_redeploy_status: - ~azure.mgmt.compute.v2021_07_01.models.MaintenanceRedeployStatus - :ivar disks: The disks information. - :vartype disks: list[~azure.mgmt.compute.v2021_07_01.models.DiskInstanceView] - :ivar extensions: The extensions information. - :vartype extensions: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionInstanceView] - :ivar vm_health: The health status for the VM. - :vartype vm_health: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineHealthStatus - :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :vartype boot_diagnostics: ~azure.mgmt.compute.v2021_07_01.models.BootDiagnosticsInstanceView - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - :ivar assigned_host: Resource id of the dedicated host, on which the virtual machine is - allocated through automatic placement, when the virtual machine is associated with a dedicated - host group that has automatic placement enabled. :code:`
    `\\ :code:`
    `Minimum - api-version: 2020-06-01. - :vartype assigned_host: str - :ivar placement_group_id: The placement group in which the VM is running. If the VM is - deallocated it will not have a placementGroupId. - :vartype placement_group_id: str - """ - - _validation = { - "vm_health": {"readonly": True}, - "assigned_host": {"readonly": True}, - } - - _attribute_map = { - "platform_update_domain": {"key": "platformUpdateDomain", "type": "int"}, - "platform_fault_domain": {"key": "platformFaultDomain", "type": "int"}, - "rdp_thumb_print": {"key": "rdpThumbPrint", "type": "str"}, - "vm_agent": {"key": "vmAgent", "type": "VirtualMachineAgentInstanceView"}, - "maintenance_redeploy_status": {"key": "maintenanceRedeployStatus", "type": "MaintenanceRedeployStatus"}, - "disks": {"key": "disks", "type": "[DiskInstanceView]"}, - "extensions": {"key": "extensions", "type": "[VirtualMachineExtensionInstanceView]"}, - "vm_health": {"key": "vmHealth", "type": "VirtualMachineHealthStatus"}, - "boot_diagnostics": {"key": "bootDiagnostics", "type": "BootDiagnosticsInstanceView"}, - "statuses": {"key": "statuses", "type": "[InstanceViewStatus]"}, - "assigned_host": {"key": "assignedHost", "type": "str"}, - "placement_group_id": {"key": "placementGroupId", "type": "str"}, - } - - def __init__( - self, - *, - platform_update_domain: Optional[int] = None, - platform_fault_domain: Optional[int] = None, - rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, - disks: Optional[List["_models.DiskInstanceView"]] = None, - extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["_models.InstanceViewStatus"]] = None, - placement_group_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword platform_update_domain: The Update Domain count. - :paramtype platform_update_domain: int - :keyword platform_fault_domain: The Fault Domain count. - :paramtype platform_fault_domain: int - :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. - :paramtype rdp_thumb_print: str - :keyword vm_agent: The VM Agent running on the virtual machine. - :paramtype vm_agent: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineAgentInstanceView - :keyword maintenance_redeploy_status: The Maintenance Operation status on the virtual machine. - :paramtype maintenance_redeploy_status: - ~azure.mgmt.compute.v2021_07_01.models.MaintenanceRedeployStatus - :keyword disks: The disks information. - :paramtype disks: list[~azure.mgmt.compute.v2021_07_01.models.DiskInstanceView] - :keyword extensions: The extensions information. - :paramtype extensions: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionInstanceView] - :keyword boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view - Console Output and Screenshot to diagnose VM status. :code:`
    `\\ :code:`
    ` You can easily - view the output of your console log. :code:`
    `\\ :code:`
    ` Azure also enables you to see - a screenshot of the VM from the hypervisor. - :paramtype boot_diagnostics: ~azure.mgmt.compute.v2021_07_01.models.BootDiagnosticsInstanceView - :keyword statuses: The resource status information. - :paramtype statuses: list[~azure.mgmt.compute.v2021_07_01.models.InstanceViewStatus] - :keyword placement_group_id: The placement group in which the VM is running. If the VM is - deallocated it will not have a placementGroupId. - :paramtype placement_group_id: str - """ - super().__init__(**kwargs) - self.platform_update_domain = platform_update_domain - self.platform_fault_domain = platform_fault_domain - self.rdp_thumb_print = rdp_thumb_print - self.vm_agent = vm_agent - self.maintenance_redeploy_status = maintenance_redeploy_status - self.disks = disks - self.extensions = extensions - self.vm_health: Optional["_models.VirtualMachineHealthStatus"] = None - self.boot_diagnostics = boot_diagnostics - self.statuses = statuses - self.assigned_host: Optional[str] = None - self.placement_group_id = placement_group_id - - -class VirtualMachineScaleSetVMListResult(_serialization.Model): - """The List Virtual Machine Scale Set VMs operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of virtual machine scale sets VMs. Required. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM] - :ivar next_link: The uri to fetch the next page of Virtual Machine Scale Set VMs. Call - ListNext() with this to fetch the next page of VMSS VMs. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineScaleSetVM]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of virtual machine scale sets VMs. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM] - :keyword next_link: The uri to fetch the next page of Virtual Machine Scale Set VMs. Call - ListNext() with this to fetch the next page of VMSS VMs. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class VirtualMachineScaleSetVMNetworkProfileConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Describes a virtual machine scale set VM network profile. - - :ivar network_interface_configurations: The list of network configurations. - :vartype network_interface_configurations: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetNetworkConfiguration] - """ - - _attribute_map = { - "network_interface_configurations": { - "key": "networkInterfaceConfigurations", - "type": "[VirtualMachineScaleSetNetworkConfiguration]", - }, - } - - def __init__( - self, - *, - network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword network_interface_configurations: The list of network configurations. - :paramtype network_interface_configurations: - list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetNetworkConfiguration] - """ - super().__init__(**kwargs) - self.network_interface_configurations = network_interface_configurations - - -class VirtualMachineScaleSetVMProfile(_serialization.Model): - """Describes a virtual machine scale set virtual machine profile. - - :ivar os_profile: Specifies the operating system settings for the virtual machines in the scale - set. - :vartype os_profile: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetOSProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetStorageProfile - :ivar network_profile: Specifies properties of the network interfaces of the virtual machines - in the scale set. - :vartype network_profile: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetNetworkProfile - :ivar security_profile: Specifies the Security related profile settings for the virtual - machines in the scale set. - :vartype security_profile: ~azure.mgmt.compute.v2021_07_01.models.SecurityProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2021_07_01.models.DiagnosticsProfile - :ivar extension_profile: Specifies a collection of settings for extensions installed on virtual - machines in the scale set. - :vartype extension_profile: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtensionProfile - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. :code:`
    `\\ :code:`
    ` Possible values for Windows Server operating system - are: :code:`
    `\\ :code:`
    ` Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server - :code:`
    `\\ :code:`
    ` Possible values for Linux Server operating system are: - :code:`
    `\\ :code:`
    ` RHEL_BYOS (for RHEL) :code:`
    `\\ :code:`
    ` SLES_BYOS (for - SUSE) :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid Use Benefit for - Windows Server - `_ - :code:`
    `\\ :code:`
    ` `Azure Hybrid Use Benefit for Linux Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
    `\\ :code:`
    `Minimum api-version: 2017-10-30-preview. Known values are: - "Regular", "Low", and "Spot". - :vartype priority: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePriorityTypes - :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, both - 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. - :code:`
    `\\ :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are - supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and - "Delete". - :vartype eviction_policy: str or - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineEvictionPolicyTypes - :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2021_07_01.models.BillingProfile - :ivar scheduled_events_profile: Specifies Scheduled Event related configurations. - :vartype scheduled_events_profile: - ~azure.mgmt.compute.v2021_07_01.models.ScheduledEventsProfile - :ivar user_data: UserData for the virtual machines in the scale set, which must be base-64 - encoded. Customer should not pass any secrets in here. :code:`
    `\\ :code:`
    `Minimum - api-version: 2021-03-01. - :vartype user_data: str - :ivar capacity_reservation: Specifies the capacity reservation related details of a scale set. - :code:`
    `\\ :code:`
    `Minimum api-version: 2021-04-01. - :vartype capacity_reservation: - ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationProfile - :ivar application_profile: Specifies the gallery applications that should be made available to - the VM/VMSS. - :vartype application_profile: ~azure.mgmt.compute.v2021_07_01.models.ApplicationProfile - """ - - _attribute_map = { - "os_profile": {"key": "osProfile", "type": "VirtualMachineScaleSetOSProfile"}, - "storage_profile": {"key": "storageProfile", "type": "VirtualMachineScaleSetStorageProfile"}, - "network_profile": {"key": "networkProfile", "type": "VirtualMachineScaleSetNetworkProfile"}, - "security_profile": {"key": "securityProfile", "type": "SecurityProfile"}, - "diagnostics_profile": {"key": "diagnosticsProfile", "type": "DiagnosticsProfile"}, - "extension_profile": {"key": "extensionProfile", "type": "VirtualMachineScaleSetExtensionProfile"}, - "license_type": {"key": "licenseType", "type": "str"}, - "priority": {"key": "priority", "type": "str"}, - "eviction_policy": {"key": "evictionPolicy", "type": "str"}, - "billing_profile": {"key": "billingProfile", "type": "BillingProfile"}, - "scheduled_events_profile": {"key": "scheduledEventsProfile", "type": "ScheduledEventsProfile"}, - "user_data": {"key": "userData", "type": "str"}, - "capacity_reservation": {"key": "capacityReservation", "type": "CapacityReservationProfile"}, - "application_profile": {"key": "applicationProfile", "type": "ApplicationProfile"}, - } - - def __init__( - self, - *, - os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, - security_profile: Optional["_models.SecurityProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, - license_type: Optional[str] = None, - priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["_models.BillingProfile"] = None, - scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, - user_data: Optional[str] = None, - capacity_reservation: Optional["_models.CapacityReservationProfile"] = None, - application_profile: Optional["_models.ApplicationProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_profile: Specifies the operating system settings for the virtual machines in the - scale set. - :paramtype os_profile: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetOSProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetStorageProfile - :keyword network_profile: Specifies properties of the network interfaces of the virtual - machines in the scale set. - :paramtype network_profile: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetNetworkProfile - :keyword security_profile: Specifies the Security related profile settings for the virtual - machines in the scale set. - :paramtype security_profile: ~azure.mgmt.compute.v2021_07_01.models.SecurityProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2021_07_01.models.DiagnosticsProfile - :keyword extension_profile: Specifies a collection of settings for extensions installed on - virtual machines in the scale set. - :paramtype extension_profile: - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtensionProfile - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. :code:`
    `\\ :code:`
    ` Possible values for Windows Server operating system - are: :code:`
    `\\ :code:`
    ` Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server - :code:`
    `\\ :code:`
    ` Possible values for Linux Server operating system are: - :code:`
    `\\ :code:`
    ` RHEL_BYOS (for RHEL) :code:`
    `\\ :code:`
    ` SLES_BYOS (for - SUSE) :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid Use Benefit for - Windows Server - `_ - :code:`
    `\\ :code:`
    ` `Azure Hybrid Use Benefit for Linux Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
    `\\ :code:`
    `Minimum api-version: 2017-10-30-preview. Known values are: - "Regular", "Low", and "Spot". - :paramtype priority: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePriorityTypes - :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, both - 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. - :code:`
    `\\ :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are - supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and - "Delete". - :paramtype eviction_policy: str or - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineEvictionPolicyTypes - :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2021_07_01.models.BillingProfile - :keyword scheduled_events_profile: Specifies Scheduled Event related configurations. - :paramtype scheduled_events_profile: - ~azure.mgmt.compute.v2021_07_01.models.ScheduledEventsProfile - :keyword user_data: UserData for the virtual machines in the scale set, which must be base-64 - encoded. Customer should not pass any secrets in here. :code:`
    `\\ :code:`
    `Minimum - api-version: 2021-03-01. - :paramtype user_data: str - :keyword capacity_reservation: Specifies the capacity reservation related details of a scale - set. :code:`
    `\\ :code:`
    `Minimum api-version: 2021-04-01. - :paramtype capacity_reservation: - ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationProfile - :keyword application_profile: Specifies the gallery applications that should be made available - to the VM/VMSS. - :paramtype application_profile: ~azure.mgmt.compute.v2021_07_01.models.ApplicationProfile - """ - super().__init__(**kwargs) - self.os_profile = os_profile - self.storage_profile = storage_profile - self.network_profile = network_profile - self.security_profile = security_profile - self.diagnostics_profile = diagnostics_profile - self.extension_profile = extension_profile - self.license_type = license_type - self.priority = priority - self.eviction_policy = eviction_policy - self.billing_profile = billing_profile - self.scheduled_events_profile = scheduled_events_profile - self.user_data = user_data - self.capacity_reservation = capacity_reservation - self.application_profile = application_profile - - -class VirtualMachineScaleSetVMProtectionPolicy(_serialization.Model): - """The protection policy of a virtual machine scale set VM. - - :ivar protect_from_scale_in: Indicates that the virtual machine scale set VM shouldn't be - considered for deletion during a scale-in operation. - :vartype protect_from_scale_in: bool - :ivar protect_from_scale_set_actions: Indicates that model updates or actions (including - scale-in) initiated on the virtual machine scale set should not be applied to the virtual - machine scale set VM. - :vartype protect_from_scale_set_actions: bool - """ - - _attribute_map = { - "protect_from_scale_in": {"key": "protectFromScaleIn", "type": "bool"}, - "protect_from_scale_set_actions": {"key": "protectFromScaleSetActions", "type": "bool"}, - } - - def __init__( - self, - *, - protect_from_scale_in: Optional[bool] = None, - protect_from_scale_set_actions: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword protect_from_scale_in: Indicates that the virtual machine scale set VM shouldn't be - considered for deletion during a scale-in operation. - :paramtype protect_from_scale_in: bool - :keyword protect_from_scale_set_actions: Indicates that model updates or actions (including - scale-in) initiated on the virtual machine scale set should not be applied to the virtual - machine scale set VM. - :paramtype protect_from_scale_set_actions: bool - """ - super().__init__(**kwargs) - self.protect_from_scale_in = protect_from_scale_in - self.protect_from_scale_set_actions = protect_from_scale_set_actions - - -class VirtualMachineSize(_serialization.Model): - """Describes the properties of a VM size. - - :ivar name: The name of the virtual machine size. - :vartype name: str - :ivar number_of_cores: The number of cores supported by the virtual machine size. For - Constrained vCPU capable VM sizes, this number represents the total vCPUs of quota that the VM - uses. For accurate vCPU count, please refer to - https://docs.microsoft.com/azure/virtual-machines/constrained-vcpu or - https://docs.microsoft.com/rest/api/compute/resourceskus/list. - :vartype number_of_cores: int - :ivar os_disk_size_in_mb: The OS disk size, in MB, allowed by the virtual machine size. - :vartype os_disk_size_in_mb: int - :ivar resource_disk_size_in_mb: The resource disk size, in MB, allowed by the virtual machine - size. - :vartype resource_disk_size_in_mb: int - :ivar memory_in_mb: The amount of memory, in MB, supported by the virtual machine size. - :vartype memory_in_mb: int - :ivar max_data_disk_count: The maximum number of data disks that can be attached to the virtual - machine size. - :vartype max_data_disk_count: int - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "number_of_cores": {"key": "numberOfCores", "type": "int"}, - "os_disk_size_in_mb": {"key": "osDiskSizeInMB", "type": "int"}, - "resource_disk_size_in_mb": {"key": "resourceDiskSizeInMB", "type": "int"}, - "memory_in_mb": {"key": "memoryInMB", "type": "int"}, - "max_data_disk_count": {"key": "maxDataDiskCount", "type": "int"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - number_of_cores: Optional[int] = None, - os_disk_size_in_mb: Optional[int] = None, - resource_disk_size_in_mb: Optional[int] = None, - memory_in_mb: Optional[int] = None, - max_data_disk_count: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the virtual machine size. - :paramtype name: str - :keyword number_of_cores: The number of cores supported by the virtual machine size. For - Constrained vCPU capable VM sizes, this number represents the total vCPUs of quota that the VM - uses. For accurate vCPU count, please refer to - https://docs.microsoft.com/azure/virtual-machines/constrained-vcpu or - https://docs.microsoft.com/rest/api/compute/resourceskus/list. - :paramtype number_of_cores: int - :keyword os_disk_size_in_mb: The OS disk size, in MB, allowed by the virtual machine size. - :paramtype os_disk_size_in_mb: int - :keyword resource_disk_size_in_mb: The resource disk size, in MB, allowed by the virtual - machine size. - :paramtype resource_disk_size_in_mb: int - :keyword memory_in_mb: The amount of memory, in MB, supported by the virtual machine size. - :paramtype memory_in_mb: int - :keyword max_data_disk_count: The maximum number of data disks that can be attached to the - virtual machine size. - :paramtype max_data_disk_count: int - """ - super().__init__(**kwargs) - self.name = name - self.number_of_cores = number_of_cores - self.os_disk_size_in_mb = os_disk_size_in_mb - self.resource_disk_size_in_mb = resource_disk_size_in_mb - self.memory_in_mb = memory_in_mb - self.max_data_disk_count = max_data_disk_count - - -class VirtualMachineSizeListResult(_serialization.Model): - """The List Virtual Machine operation response. - - :ivar value: The list of virtual machine sizes. - :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineSize] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualMachineSize]"}, - } - - def __init__(self, *, value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of virtual machine sizes. - :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineSize] - """ - super().__init__(**kwargs) - self.value = value - - -class VirtualMachineSoftwarePatchProperties(_serialization.Model): - """Describes the properties of a Virtual Machine software patch. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar patch_id: A unique identifier for the patch. - :vartype patch_id: str - :ivar name: The friendly name of the patch. - :vartype name: str - :ivar version: The version number of the patch. This property applies only to Linux patches. - :vartype version: str - :ivar kb_id: The KBID of the patch. Only applies to Windows patches. - :vartype kb_id: str - :ivar classifications: The classification(s) of the patch as provided by the patch publisher. - :vartype classifications: list[str] - :ivar reboot_behavior: Describes the reboot requirements of the patch. Known values are: - "Unknown", "NeverReboots", "AlwaysRequiresReboot", and "CanRequestReboot". - :vartype reboot_behavior: str or - ~azure.mgmt.compute.v2021_07_01.models.VMGuestPatchRebootBehavior - :ivar activity_id: The activity ID of the operation that produced this result. It is used to - correlate across CRP and extension logs. - :vartype activity_id: str - :ivar published_date: The UTC timestamp when the repository published this patch. - :vartype published_date: ~datetime.datetime - :ivar last_modified_date_time: The UTC timestamp of the last update to this patch record. - :vartype last_modified_date_time: ~datetime.datetime - :ivar assessment_state: Describes the availability of a given patch. Known values are: - "Unknown" and "Available". - :vartype assessment_state: str or ~azure.mgmt.compute.v2021_07_01.models.PatchAssessmentState - """ - - _validation = { - "patch_id": {"readonly": True}, - "name": {"readonly": True}, - "version": {"readonly": True}, - "kb_id": {"readonly": True}, - "classifications": {"readonly": True}, - "reboot_behavior": {"readonly": True}, - "activity_id": {"readonly": True}, - "published_date": {"readonly": True}, - "last_modified_date_time": {"readonly": True}, - "assessment_state": {"readonly": True}, - } - - _attribute_map = { - "patch_id": {"key": "patchId", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "version": {"key": "version", "type": "str"}, - "kb_id": {"key": "kbId", "type": "str"}, - "classifications": {"key": "classifications", "type": "[str]"}, - "reboot_behavior": {"key": "rebootBehavior", "type": "str"}, - "activity_id": {"key": "activityId", "type": "str"}, - "published_date": {"key": "publishedDate", "type": "iso-8601"}, - "last_modified_date_time": {"key": "lastModifiedDateTime", "type": "iso-8601"}, - "assessment_state": {"key": "assessmentState", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.patch_id: Optional[str] = None - self.name: Optional[str] = None - self.version: Optional[str] = None - self.kb_id: Optional[str] = None - self.classifications: Optional[List[str]] = None - self.reboot_behavior: Optional[Union[str, "_models.VMGuestPatchRebootBehavior"]] = None - self.activity_id: Optional[str] = None - self.published_date: Optional[datetime.datetime] = None - self.last_modified_date_time: Optional[datetime.datetime] = None - self.assessment_state: Optional[Union[str, "_models.PatchAssessmentState"]] = None - - -class VirtualMachineStatusCodeCount(_serialization.Model): - """The status code and count of the virtual machine scale set instance view status summary. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The instance view status code. - :vartype code: str - :ivar count: The number of instances having a particular status code. - :vartype count: int - """ - - _validation = { - "code": {"readonly": True}, - "count": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "count": {"key": "count", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.count: Optional[int] = None - - -class VirtualMachineUpdate(UpdateResource): - """Describes a Virtual Machine Update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :vartype plan: ~azure.mgmt.compute.v2021_07_01.models.Plan - :ivar identity: The identity of the virtual machine, if configured. - :vartype identity: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineIdentity - :ivar zones: The virtual machine zones. - :vartype zones: list[str] - :ivar hardware_profile: Specifies the hardware settings for the virtual machine. - :vartype hardware_profile: ~azure.mgmt.compute.v2021_07_01.models.HardwareProfile - :ivar storage_profile: Specifies the storage settings for the virtual machine disks. - :vartype storage_profile: ~azure.mgmt.compute.v2021_07_01.models.StorageProfile - :ivar additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine. - :vartype additional_capabilities: ~azure.mgmt.compute.v2021_07_01.models.AdditionalCapabilities - :ivar os_profile: Specifies the operating system settings used while creating the virtual - machine. Some of the settings cannot be changed once VM is provisioned. - :vartype os_profile: ~azure.mgmt.compute.v2021_07_01.models.OSProfile - :ivar network_profile: Specifies the network interfaces of the virtual machine. - :vartype network_profile: ~azure.mgmt.compute.v2021_07_01.models.NetworkProfile - :ivar security_profile: Specifies the Security related profile settings for the virtual - machine. - :vartype security_profile: ~azure.mgmt.compute.v2021_07_01.models.SecurityProfile - :ivar diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :vartype diagnostics_profile: ~azure.mgmt.compute.v2021_07_01.models.DiagnosticsProfile - :ivar availability_set: 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 overview - `_. :code:`
    `\\ - :code:`
    ` For more information on Azure planned maintenance, see `Maintenance and updates - for Virtual Machines in Azure - `_ :code:`
    `\\ - :code:`
    ` Currently, a VM can only be added to availability set at creation time. The - availability set to which the VM is being added should be under the same resource group as the - availability set resource. An existing VM cannot be added to an availability set. - :code:`
    `\\ :code:`
    `This property cannot exist along with a non-null - properties.virtualMachineScaleSet reference. - :vartype availability_set: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar virtual_machine_scale_set: Specifies information about the virtual machine scale set that - the virtual machine should be assigned to. Virtual machines specified in the same virtual - machine scale set are allocated to different nodes to maximize availability. Currently, a VM - can only be added to virtual machine scale set at creation time. An existing VM cannot be added - to a virtual machine scale set. :code:`
    `\\ :code:`
    `This property cannot exist along - with a non-null properties.availabilitySet reference. :code:`
    `\\ :code:`
    `Minimum - api‐version: 2019‐03‐01. - :vartype virtual_machine_scale_set: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar proximity_placement_group: Specifies information about the proximity placement group that - the virtual machine should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :vartype proximity_placement_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar priority: Specifies the priority for the virtual machine. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :vartype priority: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePriorityTypes - :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, both - 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. - :code:`
    `\\ :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are - supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and - "Delete". - :vartype eviction_policy: str or - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineEvictionPolicyTypes - :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. - :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :vartype billing_profile: ~azure.mgmt.compute.v2021_07_01.models.BillingProfile - :ivar host: Specifies information about the dedicated host that the virtual machine resides in. - :code:`
    `\\ :code:`
    `Minimum api-version: 2018-10-01. - :vartype host: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar host_group: Specifies information about the dedicated host group that the virtual machine - resides in. :code:`
    `\\ :code:`
    `Minimum api-version: 2020-06-01. :code:`
    `\\ - :code:`
    `NOTE: User cannot specify both host and hostGroup properties. - :vartype host_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar instance_view: The virtual machine instance view. - :vartype instance_view: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineInstanceView - :ivar license_type: Specifies that the image or disk that is being used was licensed - on-premises. :code:`
    `\\ :code:`
    ` Possible values for Windows Server operating system - are: :code:`
    `\\ :code:`
    ` Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server - :code:`
    `\\ :code:`
    ` Possible values for Linux Server operating system are: - :code:`
    `\\ :code:`
    ` RHEL_BYOS (for RHEL) :code:`
    `\\ :code:`
    ` SLES_BYOS (for - SUSE) :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid Use Benefit for - Windows Server - `_ - :code:`
    `\\ :code:`
    ` `Azure Hybrid Use Benefit for Linux Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :vartype license_type: str - :ivar vm_id: Specifies the VM unique ID which is a 128-bits identifier that is encoded and - stored in all Azure IaaS VMs SMBIOS and can be read using platform BIOS commands. - :vartype vm_id: str - :ivar extensions_time_budget: Specifies the time alloted for all extensions to start. The time - duration should be between 15 minutes and 120 minutes (inclusive) and should be specified in - ISO 8601 format. The default value is 90 minutes (PT1H30M). :code:`
    `\\ :code:`
    ` Minimum - api-version: 2020-06-01. - :vartype extensions_time_budget: str - :ivar platform_fault_domain: Specifies the scale set logical fault domain into which the - Virtual Machine will be created. By default, the Virtual Machine will by automatically assigned - to a fault domain that best maintains balance across available fault domains.\\ :code:`
    `\\ - :code:`
  • `This is applicable only if the 'virtualMachineScaleSet' property of this Virtual - Machine is set.\\ :code:`
  • `The Virtual Machine Scale Set that is referenced, must have - 'platformFaultDomainCount' > 1.\\ :code:`
  • `This property cannot be updated once the - Virtual Machine is created.\\ :code:`
  • `Fault domain assignment can be viewed in the Virtual - Machine Instance View.\\ :code:`
    `\\ :code:`
    `Minimum api‐version: 2020‐12‐01. - :vartype platform_fault_domain: int - :ivar scheduled_events_profile: Specifies Scheduled Event related configurations. - :vartype scheduled_events_profile: - ~azure.mgmt.compute.v2021_07_01.models.ScheduledEventsProfile - :ivar user_data: UserData for the VM, which must be base-64 encoded. Customer should not pass - any secrets in here. :code:`
    `\\ :code:`
    `Minimum api-version: 2021-03-01. - :vartype user_data: str - :ivar capacity_reservation: Specifies information about the capacity reservation that is used - to allocate virtual machine. :code:`
    `\\ :code:`
    `Minimum api-version: 2021-04-01. - :vartype capacity_reservation: - ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationProfile - :ivar application_profile: Specifies the gallery applications that should be made available to - the VM/VMSS. - :vartype application_profile: ~azure.mgmt.compute.v2021_07_01.models.ApplicationProfile - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "instance_view": {"readonly": True}, - "vm_id": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "plan": {"key": "plan", "type": "Plan"}, - "identity": {"key": "identity", "type": "VirtualMachineIdentity"}, - "zones": {"key": "zones", "type": "[str]"}, - "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, - "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfile"}, - "additional_capabilities": {"key": "properties.additionalCapabilities", "type": "AdditionalCapabilities"}, - "os_profile": {"key": "properties.osProfile", "type": "OSProfile"}, - "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, - "security_profile": {"key": "properties.securityProfile", "type": "SecurityProfile"}, - "diagnostics_profile": {"key": "properties.diagnosticsProfile", "type": "DiagnosticsProfile"}, - "availability_set": {"key": "properties.availabilitySet", "type": "SubResource"}, - "virtual_machine_scale_set": {"key": "properties.virtualMachineScaleSet", "type": "SubResource"}, - "proximity_placement_group": {"key": "properties.proximityPlacementGroup", "type": "SubResource"}, - "priority": {"key": "properties.priority", "type": "str"}, - "eviction_policy": {"key": "properties.evictionPolicy", "type": "str"}, - "billing_profile": {"key": "properties.billingProfile", "type": "BillingProfile"}, - "host": {"key": "properties.host", "type": "SubResource"}, - "host_group": {"key": "properties.hostGroup", "type": "SubResource"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "instance_view": {"key": "properties.instanceView", "type": "VirtualMachineInstanceView"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "vm_id": {"key": "properties.vmId", "type": "str"}, - "extensions_time_budget": {"key": "properties.extensionsTimeBudget", "type": "str"}, - "platform_fault_domain": {"key": "properties.platformFaultDomain", "type": "int"}, - "scheduled_events_profile": {"key": "properties.scheduledEventsProfile", "type": "ScheduledEventsProfile"}, - "user_data": {"key": "properties.userData", "type": "str"}, - "capacity_reservation": {"key": "properties.capacityReservation", "type": "CapacityReservationProfile"}, - "application_profile": {"key": "properties.applicationProfile", "type": "ApplicationProfile"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - tags: Optional[Dict[str, str]] = None, - plan: Optional["_models.Plan"] = None, - identity: Optional["_models.VirtualMachineIdentity"] = None, - zones: Optional[List[str]] = None, - hardware_profile: Optional["_models.HardwareProfile"] = None, - storage_profile: Optional["_models.StorageProfile"] = None, - additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, - os_profile: Optional["_models.OSProfile"] = None, - network_profile: Optional["_models.NetworkProfile"] = None, - security_profile: Optional["_models.SecurityProfile"] = None, - diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, - availability_set: Optional["_models.SubResource"] = None, - virtual_machine_scale_set: Optional["_models.SubResource"] = None, - proximity_placement_group: Optional["_models.SubResource"] = None, - priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["_models.BillingProfile"] = None, - host: Optional["_models.SubResource"] = None, - host_group: Optional["_models.SubResource"] = None, - license_type: Optional[str] = None, - extensions_time_budget: Optional[str] = None, - platform_fault_domain: Optional[int] = None, - scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, - user_data: Optional[str] = None, - capacity_reservation: Optional["_models.CapacityReservationProfile"] = None, - application_profile: Optional["_models.ApplicationProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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 - the marketplace image that you want to use and then click **Want to deploy programmatically, - Get Started ->**. Enter any required information and then click **Save**. - :paramtype plan: ~azure.mgmt.compute.v2021_07_01.models.Plan - :keyword identity: The identity of the virtual machine, if configured. - :paramtype identity: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineIdentity - :keyword zones: The virtual machine zones. - :paramtype zones: list[str] - :keyword hardware_profile: Specifies the hardware settings for the virtual machine. - :paramtype hardware_profile: ~azure.mgmt.compute.v2021_07_01.models.HardwareProfile - :keyword storage_profile: Specifies the storage settings for the virtual machine disks. - :paramtype storage_profile: ~azure.mgmt.compute.v2021_07_01.models.StorageProfile - :keyword additional_capabilities: Specifies additional capabilities enabled or disabled on the - virtual machine. - :paramtype additional_capabilities: - ~azure.mgmt.compute.v2021_07_01.models.AdditionalCapabilities - :keyword os_profile: Specifies the operating system settings used while creating the virtual - machine. Some of the settings cannot be changed once VM is provisioned. - :paramtype os_profile: ~azure.mgmt.compute.v2021_07_01.models.OSProfile - :keyword network_profile: Specifies the network interfaces of the virtual machine. - :paramtype network_profile: ~azure.mgmt.compute.v2021_07_01.models.NetworkProfile - :keyword security_profile: Specifies the Security related profile settings for the virtual - machine. - :paramtype security_profile: ~azure.mgmt.compute.v2021_07_01.models.SecurityProfile - :keyword diagnostics_profile: Specifies the boot diagnostic settings state. :code:`
    `\\ - :code:`
    `Minimum api-version: 2015-06-15. - :paramtype diagnostics_profile: ~azure.mgmt.compute.v2021_07_01.models.DiagnosticsProfile - :keyword availability_set: 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 overview - `_. :code:`
    `\\ - :code:`
    ` For more information on Azure planned maintenance, see `Maintenance and updates - for Virtual Machines in Azure - `_ :code:`
    `\\ - :code:`
    ` Currently, a VM can only be added to availability set at creation time. The - availability set to which the VM is being added should be under the same resource group as the - availability set resource. An existing VM cannot be added to an availability set. - :code:`
    `\\ :code:`
    `This property cannot exist along with a non-null - properties.virtualMachineScaleSet reference. - :paramtype availability_set: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword virtual_machine_scale_set: Specifies information about the virtual machine scale set - that the virtual machine should be assigned to. Virtual machines specified in the same virtual - machine scale set are allocated to different nodes to maximize availability. Currently, a VM - can only be added to virtual machine scale set at creation time. An existing VM cannot be added - to a virtual machine scale set. :code:`
    `\\ :code:`
    `This property cannot exist along - with a non-null properties.availabilitySet reference. :code:`
    `\\ :code:`
    `Minimum - api‐version: 2019‐03‐01. - :paramtype virtual_machine_scale_set: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword proximity_placement_group: Specifies information about the proximity placement group - that the virtual machine should be assigned to. :code:`
    `\\ :code:`
    `Minimum api-version: - 2018-04-01. - :paramtype proximity_placement_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword priority: Specifies the priority for the virtual machine. :code:`
    `\\ - :code:`
    `Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", and "Spot". - :paramtype priority: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePriorityTypes - :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and - Azure Spot scale set. :code:`
    `\\ :code:`
    `For Azure Spot virtual machines, both - 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. - :code:`
    `\\ :code:`
    `For Azure Spot scale sets, both 'Deallocate' and 'Delete' are - supported and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate" and - "Delete". - :paramtype eviction_policy: str or - ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineEvictionPolicyTypes - :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual - machine. :code:`
    `\\ :code:`
    `Minimum api-version: 2019-03-01. - :paramtype billing_profile: ~azure.mgmt.compute.v2021_07_01.models.BillingProfile - :keyword host: Specifies information about the dedicated host that the virtual machine resides - in. :code:`
    `\\ :code:`
    `Minimum api-version: 2018-10-01. - :paramtype host: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword host_group: Specifies information about the dedicated host group that the virtual - machine resides in. :code:`
    `\\ :code:`
    `Minimum api-version: 2020-06-01. :code:`
    `\\ - :code:`
    `NOTE: User cannot specify both host and hostGroup properties. - :paramtype host_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource - :keyword license_type: Specifies that the image or disk that is being used was licensed - on-premises. :code:`
    `\\ :code:`
    ` Possible values for Windows Server operating system - are: :code:`
    `\\ :code:`
    ` Windows_Client :code:`
    `\\ :code:`
    ` Windows_Server - :code:`
    `\\ :code:`
    ` Possible values for Linux Server operating system are: - :code:`
    `\\ :code:`
    ` RHEL_BYOS (for RHEL) :code:`
    `\\ :code:`
    ` SLES_BYOS (for - SUSE) :code:`
    `\\ :code:`
    ` For more information, see `Azure Hybrid Use Benefit for - Windows Server - `_ - :code:`
    `\\ :code:`
    ` `Azure Hybrid Use Benefit for Linux Server - `_ - :code:`
    `\\ :code:`
    ` Minimum api-version: 2015-06-15. - :paramtype license_type: str - :keyword extensions_time_budget: Specifies the time alloted for all extensions to start. The - time duration should be between 15 minutes and 120 minutes (inclusive) and should be specified - in ISO 8601 format. The default value is 90 minutes (PT1H30M). :code:`
    `\\ :code:`
    ` - Minimum api-version: 2020-06-01. - :paramtype extensions_time_budget: str - :keyword platform_fault_domain: Specifies the scale set logical fault domain into which the - Virtual Machine will be created. By default, the Virtual Machine will by automatically assigned - to a fault domain that best maintains balance across available fault domains.\\ :code:`
    `\\ - :code:`
  • `This is applicable only if the 'virtualMachineScaleSet' property of this Virtual - Machine is set.\\ :code:`
  • `The Virtual Machine Scale Set that is referenced, must have - 'platformFaultDomainCount' > 1.\\ :code:`
  • `This property cannot be updated once the - Virtual Machine is created.\\ :code:`
  • `Fault domain assignment can be viewed in the Virtual - Machine Instance View.\\ :code:`
    `\\ :code:`
    `Minimum api‐version: 2020‐12‐01. - :paramtype platform_fault_domain: int - :keyword scheduled_events_profile: Specifies Scheduled Event related configurations. - :paramtype scheduled_events_profile: - ~azure.mgmt.compute.v2021_07_01.models.ScheduledEventsProfile - :keyword user_data: UserData for the VM, which must be base-64 encoded. Customer should not - pass any secrets in here. :code:`
    `\\ :code:`
    `Minimum api-version: 2021-03-01. - :paramtype user_data: str - :keyword capacity_reservation: Specifies information about the capacity reservation that is - used to allocate virtual machine. :code:`
    `\\ :code:`
    `Minimum api-version: 2021-04-01. - :paramtype capacity_reservation: - ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationProfile - :keyword application_profile: Specifies the gallery applications that should be made available - to the VM/VMSS. - :paramtype application_profile: ~azure.mgmt.compute.v2021_07_01.models.ApplicationProfile - """ - super().__init__(tags=tags, **kwargs) - self.plan = plan - self.identity = identity - self.zones = zones - self.hardware_profile = hardware_profile - self.storage_profile = storage_profile - self.additional_capabilities = additional_capabilities - self.os_profile = os_profile - self.network_profile = network_profile - self.security_profile = security_profile - self.diagnostics_profile = diagnostics_profile - self.availability_set = availability_set - self.virtual_machine_scale_set = virtual_machine_scale_set - self.proximity_placement_group = proximity_placement_group - self.priority = priority - self.eviction_policy = eviction_policy - self.billing_profile = billing_profile - self.host = host - self.host_group = host_group - self.provisioning_state: Optional[str] = None - self.instance_view: Optional["_models.VirtualMachineInstanceView"] = None - self.license_type = license_type - self.vm_id: Optional[str] = None - self.extensions_time_budget = extensions_time_budget - self.platform_fault_domain = platform_fault_domain - self.scheduled_events_profile = scheduled_events_profile - self.user_data = user_data - self.capacity_reservation = capacity_reservation - self.application_profile = application_profile - - -class VMGalleryApplication(_serialization.Model): - """Specifies the required information to reference a compute gallery application version. - - All required parameters must be populated in order to send to server. - - :ivar tags: Optional, Specifies a passthrough value for more generic context. - :vartype tags: str - :ivar order: Optional, Specifies the order in which the packages have to be installed. - :vartype order: int - :ivar package_reference_id: Specifies the GalleryApplicationVersion resource id on the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{application}/versions/{version}. - Required. - :vartype package_reference_id: str - :ivar configuration_reference: Optional, Specifies the uri to an azure blob that will replace - the default configuration for the package if provided. - :vartype configuration_reference: str - """ - - _validation = { - "package_reference_id": {"required": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "str"}, - "order": {"key": "order", "type": "int"}, - "package_reference_id": {"key": "packageReferenceId", "type": "str"}, - "configuration_reference": {"key": "configurationReference", "type": "str"}, - } - - def __init__( - self, - *, - package_reference_id: str, - tags: Optional[str] = None, - order: Optional[int] = None, - configuration_reference: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Optional, Specifies a passthrough value for more generic context. - :paramtype tags: str - :keyword order: Optional, Specifies the order in which the packages have to be installed. - :paramtype order: int - :keyword package_reference_id: Specifies the GalleryApplicationVersion resource id on the form - of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{application}/versions/{version}. - Required. - :paramtype package_reference_id: str - :keyword configuration_reference: Optional, Specifies the uri to an azure blob that will - replace the default configuration for the package if provided. - :paramtype configuration_reference: str - """ - super().__init__(**kwargs) - self.tags = tags - self.order = order - self.package_reference_id = package_reference_id - self.configuration_reference = configuration_reference - - -class VMScaleSetConvertToSinglePlacementGroupInput(_serialization.Model): # pylint: disable=name-too-long - """VMScaleSetConvertToSinglePlacementGroupInput. - - :ivar active_placement_group_id: Id of the placement group in which you want future virtual - machine instances to be placed. To query placement group Id, please use Virtual Machine Scale - Set VMs - Get API. If not provided, the platform will choose one with maximum number of virtual - machine instances. - :vartype active_placement_group_id: str - """ - - _attribute_map = { - "active_placement_group_id": {"key": "activePlacementGroupId", "type": "str"}, - } - - def __init__(self, *, active_placement_group_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword active_placement_group_id: Id of the placement group in which you want future virtual - machine instances to be placed. To query placement group Id, please use Virtual Machine Scale - Set VMs - Get API. If not provided, the platform will choose one with maximum number of virtual - machine instances. - :paramtype active_placement_group_id: str - """ - super().__init__(**kwargs) - self.active_placement_group_id = active_placement_group_id - - -class VMSizeProperties(_serialization.Model): - """Specifies VM Size Property settings on the virtual machine. - - :ivar v_cpus_available: Specifies the number of vCPUs available for the VM. :code:`
    `\\ - :code:`
    ` When this property is not specified in the request body the default behavior is to - set it to the value of vCPUs available for that VM size exposed in api response of `List all - available virtual machine sizes in a region - `_ . - :vartype v_cpus_available: int - :ivar v_cpus_per_core: Specifies the vCPU to physical core ratio. :code:`
    `\\ :code:`
    ` - When this property is not specified in the request body the default behavior is set to the - value of vCPUsPerCore for the VM Size exposed in api response of `List all available virtual - machine sizes in a region - `_ :code:`
    `\\ - :code:`
    ` Setting this property to 1 also means that hyper-threading is disabled. - :vartype v_cpus_per_core: int - """ - - _attribute_map = { - "v_cpus_available": {"key": "vCPUsAvailable", "type": "int"}, - "v_cpus_per_core": {"key": "vCPUsPerCore", "type": "int"}, - } - - def __init__( - self, *, v_cpus_available: Optional[int] = None, v_cpus_per_core: Optional[int] = None, **kwargs: Any - ) -> None: - """ - :keyword v_cpus_available: Specifies the number of vCPUs available for the VM. :code:`
    `\\ - :code:`
    ` When this property is not specified in the request body the default behavior is to - set it to the value of vCPUs available for that VM size exposed in api response of `List all - available virtual machine sizes in a region - `_ . - :paramtype v_cpus_available: int - :keyword v_cpus_per_core: Specifies the vCPU to physical core ratio. :code:`
    `\\ - :code:`
    ` When this property is not specified in the request body the default behavior is - set to the value of vCPUsPerCore for the VM Size exposed in api response of `List all available - virtual machine sizes in a region - `_ :code:`
    `\\ - :code:`
    ` Setting this property to 1 also means that hyper-threading is disabled. - :paramtype v_cpus_per_core: int - """ - super().__init__(**kwargs) - self.v_cpus_available = v_cpus_available - self.v_cpus_per_core = v_cpus_per_core - - -class WindowsConfiguration(_serialization.Model): - """Specifies Windows operating system settings on the virtual machine. - - :ivar provision_vm_agent: Indicates whether virtual machine agent should be provisioned on the - virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the request - body, default behavior is to set it to true. This will ensure that VM Agent is installed on - the VM so that extensions can be added to the VM later. - :vartype provision_vm_agent: bool - :ivar enable_automatic_updates: Indicates whether Automatic Updates is enabled for the Windows - virtual machine. Default value is true. :code:`
    `\\ :code:`
    ` For virtual machine scale - sets, this property can be updated and updates will take effect on OS reprovisioning. - :vartype enable_automatic_updates: bool - :ivar time_zone: Specifies the time zone of the virtual machine. e.g. "Pacific Standard Time". - :code:`
    `\\ :code:`
    ` Possible values can be `TimeZoneInfo.Id - `_ value - from time zones returned by `TimeZoneInfo.GetSystemTimeZones - `_. - :vartype time_zone: str - :ivar additional_unattend_content: Specifies additional base-64 encoded XML formatted - information that can be included in the Unattend.xml file, which is used by Windows Setup. - :vartype additional_unattend_content: - list[~azure.mgmt.compute.v2021_07_01.models.AdditionalUnattendContent] - :ivar patch_settings: [Preview Feature] Specifies settings related to VM Guest Patching on - Windows. - :vartype patch_settings: ~azure.mgmt.compute.v2021_07_01.models.PatchSettings - :ivar win_rm: Specifies the Windows Remote Management listeners. This enables remote Windows - PowerShell. - :vartype win_rm: ~azure.mgmt.compute.v2021_07_01.models.WinRMConfiguration - """ - - _attribute_map = { - "provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"}, - "enable_automatic_updates": {"key": "enableAutomaticUpdates", "type": "bool"}, - "time_zone": {"key": "timeZone", "type": "str"}, - "additional_unattend_content": {"key": "additionalUnattendContent", "type": "[AdditionalUnattendContent]"}, - "patch_settings": {"key": "patchSettings", "type": "PatchSettings"}, - "win_rm": {"key": "winRM", "type": "WinRMConfiguration"}, - } - - def __init__( - self, - *, - provision_vm_agent: Optional[bool] = None, - enable_automatic_updates: Optional[bool] = None, - time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, - patch_settings: Optional["_models.PatchSettings"] = None, - win_rm: Optional["_models.WinRMConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword provision_vm_agent: Indicates whether virtual machine agent should be provisioned on - the virtual machine. :code:`
    `\\ :code:`
    ` When this property is not specified in the - request body, default behavior is to set it to true. This will ensure that VM Agent is - installed on the VM so that extensions can be added to the VM later. - :paramtype provision_vm_agent: bool - :keyword enable_automatic_updates: Indicates whether Automatic Updates is enabled for the - Windows virtual machine. Default value is true. :code:`
    `\\ :code:`
    ` For virtual machine - scale sets, this property can be updated and updates will take effect on OS reprovisioning. - :paramtype enable_automatic_updates: bool - :keyword time_zone: Specifies the time zone of the virtual machine. e.g. "Pacific Standard - Time". :code:`
    `\\ :code:`
    ` Possible values can be `TimeZoneInfo.Id - `_ value - from time zones returned by `TimeZoneInfo.GetSystemTimeZones - `_. - :paramtype time_zone: str - :keyword additional_unattend_content: Specifies additional base-64 encoded XML formatted - information that can be included in the Unattend.xml file, which is used by Windows Setup. - :paramtype additional_unattend_content: - list[~azure.mgmt.compute.v2021_07_01.models.AdditionalUnattendContent] - :keyword patch_settings: [Preview Feature] Specifies settings related to VM Guest Patching on - Windows. - :paramtype patch_settings: ~azure.mgmt.compute.v2021_07_01.models.PatchSettings - :keyword win_rm: Specifies the Windows Remote Management listeners. This enables remote Windows - PowerShell. - :paramtype win_rm: ~azure.mgmt.compute.v2021_07_01.models.WinRMConfiguration - """ - super().__init__(**kwargs) - self.provision_vm_agent = provision_vm_agent - self.enable_automatic_updates = enable_automatic_updates - self.time_zone = time_zone - self.additional_unattend_content = additional_unattend_content - self.patch_settings = patch_settings - self.win_rm = win_rm - - -class WindowsParameters(_serialization.Model): - """Input for InstallPatches on a Windows VM, as directly received by the API. - - :ivar classifications_to_include: The update classifications to select when installing patches - for Windows. - :vartype classifications_to_include: list[str or - ~azure.mgmt.compute.v2021_07_01.models.VMGuestPatchClassificationWindows] - :ivar kb_numbers_to_include: Kbs to include in the patch operation. - :vartype kb_numbers_to_include: list[str] - :ivar kb_numbers_to_exclude: Kbs to exclude in the patch operation. - :vartype kb_numbers_to_exclude: list[str] - :ivar exclude_kbs_requiring_reboot: Filters out Kbs that don't have an - InstallationRebootBehavior of 'NeverReboots' when this is set to true. - :vartype exclude_kbs_requiring_reboot: bool - :ivar max_patch_publish_date: This is used to install patches that were published on or before - this given max published date. - :vartype max_patch_publish_date: ~datetime.datetime - """ - - _attribute_map = { - "classifications_to_include": {"key": "classificationsToInclude", "type": "[str]"}, - "kb_numbers_to_include": {"key": "kbNumbersToInclude", "type": "[str]"}, - "kb_numbers_to_exclude": {"key": "kbNumbersToExclude", "type": "[str]"}, - "exclude_kbs_requiring_reboot": {"key": "excludeKbsRequiringReboot", "type": "bool"}, - "max_patch_publish_date": {"key": "maxPatchPublishDate", "type": "iso-8601"}, - } - - def __init__( - self, - *, - classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationWindows"]]] = None, - kb_numbers_to_include: Optional[List[str]] = None, - kb_numbers_to_exclude: Optional[List[str]] = None, - exclude_kbs_requiring_reboot: Optional[bool] = None, - max_patch_publish_date: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword classifications_to_include: The update classifications to select when installing - patches for Windows. - :paramtype classifications_to_include: list[str or - ~azure.mgmt.compute.v2021_07_01.models.VMGuestPatchClassificationWindows] - :keyword kb_numbers_to_include: Kbs to include in the patch operation. - :paramtype kb_numbers_to_include: list[str] - :keyword kb_numbers_to_exclude: Kbs to exclude in the patch operation. - :paramtype kb_numbers_to_exclude: list[str] - :keyword exclude_kbs_requiring_reboot: Filters out Kbs that don't have an - InstallationRebootBehavior of 'NeverReboots' when this is set to true. - :paramtype exclude_kbs_requiring_reboot: bool - :keyword max_patch_publish_date: This is used to install patches that were published on or - before this given max published date. - :paramtype max_patch_publish_date: ~datetime.datetime - """ - super().__init__(**kwargs) - self.classifications_to_include = classifications_to_include - self.kb_numbers_to_include = kb_numbers_to_include - self.kb_numbers_to_exclude = kb_numbers_to_exclude - self.exclude_kbs_requiring_reboot = exclude_kbs_requiring_reboot - self.max_patch_publish_date = max_patch_publish_date - - -class WinRMConfiguration(_serialization.Model): - """Describes Windows Remote Management configuration of the VM. - - :ivar listeners: The list of Windows Remote Management listeners. - :vartype listeners: list[~azure.mgmt.compute.v2021_07_01.models.WinRMListener] - """ - - _attribute_map = { - "listeners": {"key": "listeners", "type": "[WinRMListener]"}, - } - - def __init__(self, *, listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs: Any) -> None: - """ - :keyword listeners: The list of Windows Remote Management listeners. - :paramtype listeners: list[~azure.mgmt.compute.v2021_07_01.models.WinRMListener] - """ - super().__init__(**kwargs) - self.listeners = listeners - - -class WinRMListener(_serialization.Model): - """Describes Protocol and thumbprint of Windows Remote Management listener. - - :ivar protocol: Specifies the protocol of WinRM listener. :code:`
    `\\ :code:`
    ` Possible - values are: :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. Known values are: - "Http" and "Https". - :vartype protocol: str or ~azure.mgmt.compute.v2021_07_01.models.ProtocolTypes - :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as - a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `} :code:`
    ` To install - certificates on a virtual machine it is recommended to use the `Azure Key Vault virtual machine - extension for Linux - `_ or the `Azure - Key Vault virtual machine extension for Windows - `_. - :vartype certificate_url: str - """ - - _attribute_map = { - "protocol": {"key": "protocol", "type": "str"}, - "certificate_url": {"key": "certificateUrl", "type": "str"}, - } - - def __init__( - self, - *, - protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, - certificate_url: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword protocol: Specifies the protocol of WinRM listener. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ **http** :code:`
    `\\ :code:`
    ` **https**. Known - values are: "Http" and "Https". - :paramtype protocol: str or ~azure.mgmt.compute.v2021_07_01.models.ProtocolTypes - :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault - as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault - `_. In this case, your - certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded - in UTF-8: :code:`
    `\\ :code:`
    ` {\\ :code:`
    ` "data":"\\ - :code:``",\\ :code:`
    ` "dataType":"pfx",\\ :code:`
    ` - "password":"\\ :code:``"\\ :code:`
    `} :code:`
    ` To install - certificates on a virtual machine it is recommended to use the `Azure Key Vault virtual machine - extension for Linux - `_ or the `Azure - Key Vault virtual machine extension for Windows - `_. - :paramtype certificate_url: str - """ - super().__init__(**kwargs) - self.protocol = protocol - self.certificate_url = certificate_url diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/__init__.py deleted file mode 100644 index 240530fe0fdb..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/__init__.py +++ /dev/null @@ -1,101 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import Operations # type: ignore -from ._operations import AvailabilitySetsOperations # 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 VirtualMachineExtensionImagesOperations # type: ignore -from ._operations import VirtualMachineExtensionsOperations # type: ignore -from ._operations import VirtualMachineImagesOperations # type: ignore -from ._operations import VirtualMachineImagesEdgeZoneOperations # type: ignore -from ._operations import UsageOperations # type: ignore -from ._operations import VirtualMachinesOperations # type: ignore -from ._operations import VirtualMachineScaleSetsOperations # type: ignore -from ._operations import VirtualMachineSizesOperations # 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 CapacityReservationsOperations # 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 LogAnalyticsOperations # type: ignore -from ._operations import VirtualMachineRunCommandsOperations # type: ignore -from ._operations import VirtualMachineScaleSetVMRunCommandsOperations # type: ignore -from ._operations import ResourceSkusOperations # type: ignore -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 ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AvailabilitySetsOperations", - "ProximityPlacementGroupsOperations", - "DedicatedHostGroupsOperations", - "DedicatedHostsOperations", - "SshPublicKeysOperations", - "VirtualMachineExtensionImagesOperations", - "VirtualMachineExtensionsOperations", - "VirtualMachineImagesOperations", - "VirtualMachineImagesEdgeZoneOperations", - "UsageOperations", - "VirtualMachinesOperations", - "VirtualMachineScaleSetsOperations", - "VirtualMachineSizesOperations", - "ImagesOperations", - "RestorePointCollectionsOperations", - "RestorePointsOperations", - "CapacityReservationGroupsOperations", - "CapacityReservationsOperations", - "VirtualMachineScaleSetExtensionsOperations", - "VirtualMachineScaleSetRollingUpgradesOperations", - "VirtualMachineScaleSetVMExtensionsOperations", - "VirtualMachineScaleSetVMsOperations", - "LogAnalyticsOperations", - "VirtualMachineRunCommandsOperations", - "VirtualMachineScaleSetVMRunCommandsOperations", - "ResourceSkusOperations", - "GalleriesOperations", - "GalleryImagesOperations", - "GalleryImageVersionsOperations", - "GalleryApplicationsOperations", - "GalleryApplicationVersionsOperations", - "GallerySharingProfileOperations", - "SharedGalleriesOperations", - "SharedGalleryImagesOperations", - "SharedGalleryImageVersionsOperations", - "CommunityGalleriesOperations", - "CommunityGalleryImagesOperations", - "CommunityGalleryImageVersionsOperations", -] -__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/v2021_07_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_operations.py deleted file mode 100644 index 9a29a24c5e43..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_operations.py +++ /dev/null @@ -1,31444 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterator, List, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import ComputeManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_operations_list_request(**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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/operations") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-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}", - ) - 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"), - } - - _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_availability_sets_delete_request( - resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_availability_sets_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes", - ) - 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"), - } - - _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_proximity_placement_groups_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-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}", - ) - 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"), - } - - _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_proximity_placement_groups_update_request( # pylint: disable=name-too-long - resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-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}", - ) - 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"), - } - - _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_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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 -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", - ) - 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"), - } - - _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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dedicated_host_groups_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2021-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}", - ) - 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"), - } - - _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_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", "2021-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}", - ) - 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"), - } - - _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_dedicated_host_groups_delete_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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 -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", - ) - 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"), - } - - _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) - - -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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dedicated_hosts_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2021-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}", - ) - 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"), - } - - _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_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", "2021-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}", - ) - 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"), - } - - _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_dedicated_hosts_delete_request( - resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_dedicated_hosts_get_request( - resource_group_name: str, - host_group_name: str, - host_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", - ) - 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"), - } - - _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) - - -def build_dedicated_hosts_list_by_host_group_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/sshPublicKeys") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2021-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}", - ) - 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"), - } - - _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_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", "2021-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}", - ) - 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"), - } - - _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_ssh_public_keys_delete_request( - resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", - ) - 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"), - } - - _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_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}/generateKeyPair", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_extension_images_get_request( # pylint: disable=name-too-long - location: str, publisher_name: str, type: str, version: str, subscription_id: str, **kwargs: Any -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types", - ) - 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"), - } - - _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_extension_images_list_versions_request( # pylint: disable=name-too-long - location: str, - publisher_name: str, - type: str, - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - if orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2021-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-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}", - ) - 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"), - } - - _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_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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 -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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) - - -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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", - ) - 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"), - } - - _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) - - -def build_virtual_machine_images_list_offers_request( # pylint: disable=name-too-long - location: str, publisher_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers" - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_images_list_skus_request( # pylint: disable=name-too-long - location: str, publisher_name: str, offer: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - 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}", - ) - 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"), - } - - _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_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", "2021-07-01")) - 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", - ) - 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"), - } - - _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) - - -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", "2021-07-01")) - 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", - ) - 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"), - } - - _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_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers", - ) - 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"), - } - - _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_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", "2021-07-01")) - 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", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages" - ) - 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines", - ) - 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_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", "2021-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}/capture", - ) - 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"), - } - - _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_machines_create_or_update_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", "2021-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_update_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", "2021-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}", - ) - 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"), - } - - _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_virtual_machines_delete_request( - resource_group_name: str, - vm_name: str, - subscription_id: str, - *, - force_deletion: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", - ) - 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"), - } - - _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") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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 -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", - ) - 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"), - } - - _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) - - -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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView", - ) - 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"), - } - - _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_machines_convert_to_managed_disks_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_generalize_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_list_all_request( - subscription_id: str, *, status_only: 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if status_only is not None: - _params["statusOnly"] = _SERIALIZER.query("status_only", status_only, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes", - ) - 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"), - } - - _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_machines_power_off_request( - resource_group_name: str, vm_name: str, subscription_id: str, *, skip_shutdown: bool = False, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reapply", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_restart_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_start_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machines_redeploy_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -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", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage", - ) - 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"), - } - - _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") - - 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 -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/retrieveBootDiagnosticsData", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if sas_uri_expiration_time_in_minutes is not None: - _params["sasUriExpirationTimeInMinutes"] = _SERIALIZER.query( - "sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, "int" - ) - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/simulateEviction", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/assessPatches", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_install_patches_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-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}/installPatches", - ) - 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"), - } - - _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_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", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachineScaleSets", - ) - 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_scale_sets_create_or_update_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", "2021-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_update_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", "2021-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}", - ) - 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"), - } - - _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_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", - ) - 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"), - } - - _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") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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 -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_deallocate_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", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_delete_instances_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - subscription_id: str, - *, - force_deletion: Optional[bool] = None, - **kwargs: Any -) -> 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", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_get_instance_view_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_list_all_request( # pylint: disable=name-too-long - subscription_id: str, **kwargs: Any -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_list_skus_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory", - ) - 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"), - } - - _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_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 -) -> 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", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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, - **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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk", - ) - 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"), - } - - _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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", 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 -) -> 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", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", 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 -) -> 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", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/setOrchestrationServiceState", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_sizes_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes" - ) - 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-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}", - ) - 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"), - } - - _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_images_delete_request( - resource_group_name: str, image_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", - ) - 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"), - } - - _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) - - -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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2021-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}", - ) - 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" - ), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-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}", - ) - 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" - ), - } - - _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_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}", - ) - 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" - ), - } - - _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) - - -def build_restore_point_collections_get_request( # pylint: disable=name-too-long - resource_group_name: str, - restore_point_collection_name: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.RestorePointCollectionExpandOptions]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}", - ) - 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" - ), - } - - _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) - - -def build_restore_point_collections_list_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/restorePointCollections" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2021-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}/restorePoints/{restorePointName}", - ) - 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" - ), - "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") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}", - ) - 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" - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", 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, - **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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}", - ) - 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" - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2021-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}", - ) - 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"), - } - - _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_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", "2021-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}", - ) - 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"), - } - - _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_capacity_reservation_groups_delete_request( # pylint: disable=name-too-long - resource_group_name: str, capacity_reservation_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", - ) - 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"), - } - - _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) - - -def build_capacity_reservation_groups_list_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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, - **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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/capacityReservationGroups" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_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", "2021-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}", - ) - 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" - ), - "capacityReservationName": _SERIALIZER.url("capacity_reservation_name", capacity_reservation_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-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}", - ) - 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" - ), - "capacityReservationName": _SERIALIZER.url("capacity_reservation_name", capacity_reservation_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", 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 -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}", - ) - 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" - ), - "capacityReservationName": _SERIALIZER.url("capacity_reservation_name", capacity_reservation_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", 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 -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}", - ) - 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" - ), - "capacityReservationName": _SERIALIZER.url("capacity_reservation_name", capacity_reservation_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations", - ) - 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"), - } - - _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_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", "2021-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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", "2021-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}", - ) - 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"), - } - - _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_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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 -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions", - ) - 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"), - } - - _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_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest", - ) - 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"), - } - - _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_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", "2021-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}/extensions/{vmExtensionName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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", "2021-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}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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) - - -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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions", - ) - 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"), - } - - _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) - - -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", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_set_vms_reimage_all_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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, **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", "2021-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}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", - ) - 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"), - } - - _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") - - return HttpRequest(method="DELETE", url=_url, params=_params, **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 -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView", - ) - 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"), - } - - _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_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines", - ) - 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"), - } - - _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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machine_scale_set_vms_redeploy_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - subscription_id: str, - *, - sas_uri_expiration_time_in_minutes: Optional[int] = None, - **kwargs: Any -) -> 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", "2021-07-01")) - 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", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if sas_uri_expiration_time_in_minutes is not None: - _params["sasUriExpirationTimeInMinutes"] = _SERIALIZER.query( - "sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, "int" - ) - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/simulateEviction", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> 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", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand", - ) - 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"), - } - - _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_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", "2021-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", - ) - 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 -) -> 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", "2021-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", - ) - 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", "2021-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" - ) - 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", "2021-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}", - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"), - "commandId": _SERIALIZER.url("command_id", command_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_run_commands_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, run_command_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_run_commands_update_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, run_command_name: str, subscription_id: str, **kwargs: Any -) -> 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", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="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 -) -> 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 - 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - 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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands", - ) - 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"), - } - - _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) - - -def build_virtual_machine_scale_set_vm_run_commands_create_or_update_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, - **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", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_set_vm_run_commands_update_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, - **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", "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", - ) - 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"), - } - - _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_virtual_machine_scale_set_vm_run_commands_delete_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, - **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", "2021-07-01")) - 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}/runCommands/{runCommandName}", - ) - 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"), - } - - _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) - - -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", "2021-07-01")) - 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}/runCommands/{runCommandName}", - ) - 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"), - } - - _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) - - -def build_virtual_machine_scale_set_vm_run_commands_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - 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}/runCommands", - ) - 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"), - } - - _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) - - -def build_resource_skus_list_request( - subscription_id: str, - *, - filter: Optional[str] = None, - include_extended_locations: 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/skus") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if include_extended_locations is not None: - _params["includeExtendedLocations"] = _SERIALIZER.query( - "include_extended_locations", include_extended_locations, "str" - ) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2021-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/galleries/{galleryName}", - ) - 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"), - } - - _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_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", "2021-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/galleries/{galleryName}", - ) - 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"), - } - - _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_galleries_get_request( - resource_group_name: str, - gallery_name: str, - subscription_id: str, - *, - select: Optional[Union[str, _models.SelectPermissions]] = 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", - ) - 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"), - } - - _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) - - -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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2021-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/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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_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", "2021-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/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images", - ) - 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"), - } - - _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_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, - **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", "2021-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/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", - ) - 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"), - } - - _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_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", "2021-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/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", - ) - 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"), - } - - _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_image_versions_get_request( - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image_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", "2021-07-01")) - 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}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - 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}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - 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", - ) - 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"), - } - - _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_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", "2021-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/galleries/{galleryName}/applications/{galleryApplicationName}", - ) - 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"), - } - - _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", "2021-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/galleries/{galleryName}/applications/{galleryApplicationName}", - ) - 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"), - } - - _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_get_request( - 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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", - ) - 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"), - } - - _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_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", - ) - 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"), - } - - _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) - - -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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications", - ) - 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"), - } - - _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_gallery_application_versions_create_or_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, - **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", "2021-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/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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_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, - **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", "2021-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/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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) - - -def build_gallery_application_versions_delete_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, - **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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions", - ) - 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"), - } - - _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_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", "2021-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/galleries/{galleryName}/share", - ) - 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"), - } - - _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_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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "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) - - -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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}", - ) - 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"), - } - - _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_shared_gallery_images_list_request( - location: str, - gallery_unique_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}", - ) - 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"), - "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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - 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", - ) - 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"), - "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) - - -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", "2021-07-01")) - 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}", - ) - 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"), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}", - ) - 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}", - ) - 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_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", "2021-07-01")) - 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}", - ) - 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"), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.ComputeOperationValue"]: - """Gets a list of compute operations. - - :return: An iterator like instance of either ComputeOperationValue or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.ComputeOperationValue] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[_models.ComputeOperationListResult] = 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_operations_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def 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) - - 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 AvailabilitySetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`availability_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: _models.AvailabilitySet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2021_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: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySet, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Is either a - AvailabilitySet type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySet") - - _request = build_availability_sets_create_or_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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, - availability_set_name: str, - parameters: _models.AvailabilitySetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2021_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: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Is either a - AvailabilitySetUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySetUpdate or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySetUpdate") - - _request = build_availability_sets_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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 "2021-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.v2021_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 = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", 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) - - _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("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription( - self, *, expand: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. - - :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.v2021_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 "2021-07-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets 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 AvailabilitySet or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_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 "2021-07-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - 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_available_sizes( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes that can be used to create a new virtual machine in - an existing availability set. - - :param resource_group_name: The name of the resource group. Required. - :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.v2021_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 "2021-07-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_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 - - if response.status_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 ProximityPlacementGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`proximity_placement_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - resource_group_name: str, - proximity_placement_group_name: str, - parameters: _models.ProximityPlacementGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Create or update a proximity placement group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Create Proximity Placement Group operation. - Required. - :type parameters: ~azure.mgmt.compute.v2021_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.v2021_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. 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.v2021_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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 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. Is - either a ProximityPlacementGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup or IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("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. 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.v2021_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.v2021_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. 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.v2021_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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 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. Is - either a ProximityPlacementGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroupUpdate or - IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ProximityPlacementGroupUpdate") - - _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, - ) - _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("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any - ) -> None: - """Delete a proximity placement group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - 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 "2021-07-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _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, - 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 - - @distributed_trace - 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. 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.v2021_07_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - _request = build_proximity_placement_groups_get_request( - resource_group_name=resource_group_name, - proximity_placement_group_name=proximity_placement_group_name, - subscription_id=self._config.subscription_id, - include_colocation_status=include_colocation_status, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a subscription. - - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_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 "2021-07-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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 - ) -> ItemPaged["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a resource group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_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 "2021-07-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProximityPlacementGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class DedicatedHostGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`dedicated_host_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: _models.DedicatedHostGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: ~azure.mgmt.compute.v2021_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: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroup, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Is either a - DedicatedHostGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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, "DedicatedHostGroup") - - _request = build_dedicated_host_groups_create_or_update_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: _models.DedicatedHostGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. - :type parameters: ~azure.mgmt.compute.v2021_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: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :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: IO[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.v2021_07_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroupUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Is either - a DedicatedHostGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroupUpdate or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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") - - _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) - - _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("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: - """ - 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 "2021-07-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_dedicated_host_groups_delete_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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, - 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. 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.v2021_07_01.models.InstanceViewTypes - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-07-01")) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", 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) - - _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("DedicatedHostGroup", 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 - ) -> ItemPaged["_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. - :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.v2021_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 "2021-07-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 - - if response.status_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, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2021_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 "2021-07-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_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 - - if response.status_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 DedicatedHostsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`dedicated_hosts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, 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 "2021-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, "DedicatedHost") - - _request = build_dedicated_hosts_create_or_update_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHost, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHost - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. 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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Dedicated Host. Is either a DedicatedHost - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHost or IO[bytes] - :return: An instance of LROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] - :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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, 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 "2021-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, "DedicatedHostUpdate") - - _request = build_dedicated_hosts_update_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, - 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]: - 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, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHostUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostUpdate - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host 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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Is either a - DedicatedHostUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostUpdate or IO[bytes] - :return: An instance of LROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] - :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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_delete_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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, host_group_name: str, host_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete 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 - :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 "2021-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, - host_group_name=host_group_name, - host_name=host_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def 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.v2021_07_01.models.InstanceViewTypes - :return: DedicatedHost or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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 - ) -> ItemPaged["_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. - :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.v2021_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 "2021-07-01")) - cls: ClsType[_models.DedicatedHostListResult] = 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_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, - 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("DedicatedHostListResult", 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 SshPublicKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`ssh_public_keys` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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.v2021_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 "2021-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_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) - - 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 - ) -> ItemPaged["_models.SshPublicKeyResource"]: - """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in - the response to get the next page of SSH public keys. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either SshPublicKeyResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_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 "2021-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 - - def extract_data(pipeline_response): - deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @overload - def create( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: _models.SshPublicKeyResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to create the SSH public key. Required. - :type parameters: ~azure.mgmt.compute.v2021_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.v2021_07_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. - - :param resource_group_name: The name of the resource group. 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.v2021_07_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: Union[_models.SshPublicKeyResource, IO[bytes]], - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. - - :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.v2021_07_01.models.SshPublicKeyResource or IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource - :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 "2021-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") - - _request = build_ssh_public_keys_create_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SshPublicKeyResource", 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, - ssh_public_key_name: str, - parameters: _models.SshPublicKeyUpdateResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _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 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.v2021_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.v2021_07_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_07_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_07_01.models.SshPublicKeyUpdateResource or - IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource - :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 "2021-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( - resource_group_name=resource_group_name, - ssh_public_key_name=ssh_public_key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("SshPublicKeyResource", 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, ssh_public_key_name: str, **kwargs: Any - ) -> None: - """Delete an SSH public key. - - :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: - """ - 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 "2021-07-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_ssh_public_keys_delete_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) - - _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, 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. - :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.v2021_07_01.models.SshPublicKeyResource - :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 "2021-07-01")) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - - _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) - - _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("SshPublicKeyResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def generate_key_pair( - self, resource_group_name: str, ssh_public_key_name: str, **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. 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: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyGenerateKeyPairResult - :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 "2021-07-01")) - cls: ClsType[_models.SshPublicKeyGenerateKeyPairResult] = kwargs.pop("cls", None) - - _request = build_ssh_public_keys_generate_key_pair_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) - - _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("SshPublicKeyGenerateKeyPairResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class VirtualMachineExtensionImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_extension_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, type: str, version: str, **kwargs: Any - ) -> _models.VirtualMachineExtensionImage: - """Gets a virtual machine extension image. - - :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.v2021_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 "2021-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 - - @distributed_trace - def list_types( - self, location: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineExtensionImage]: - """Gets a list of virtual machine extension image types. - - :param location: The name of 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.v2021_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 "2021-07-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - - _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) - - _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 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 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.v2021_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 "2021-07-01")) - 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 - - -class VirtualMachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, 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 "2021-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, "VirtualMachineExtension") - - _request = build_virtual_machine_extensions_create_or_update_request( - resource_group_name=resource_group_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2021_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 VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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] - :keyword content_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.v2021_07_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2021_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.v2021_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - 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 "2021-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, "VirtualMachineExtensionUpdate") - - _request = build_virtual_machine_extensions_update_request( - resource_group_name=resource_group_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, - 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]: - 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, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to update the extension. - - :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: - ~azure.mgmt.compute.v2021_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 VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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 - ) -> 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_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 LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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.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.v2021_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.v2021_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.VirtualMachineExtension]( - 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 - ) -> 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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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) - - _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, vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The operation to delete the extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the extension should be deleted. - 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, - 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) - - 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_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.v2021_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 "2021-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) - - deserialized = self._deserialize("VirtualMachineExtension", 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_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.v2021_07_01.models.VirtualMachineExtensionsListResult - :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 "2021-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) - - deserialized = self._deserialize("VirtualMachineExtensionsListResult", 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.v2021_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.v2021_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 "2021-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.v2021_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 "2021-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. - - :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.v2021_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 "2021-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) - 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.v2021_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 "2021-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 = 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_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 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.v2021_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 "2021-07-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _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) - - _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 - - -class VirtualMachineImagesEdgeZoneOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_images_edge_zone` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, 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 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.v2021_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 "2021-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 - - @distributed_trace - def list( - self, - location: str, - edge_zone: str, - publisher_name: str, - offer: str, - skus: str, - *, - expand: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of all virtual machine image versions for the specified location, edge zone, - publisher, offer, and SKU. - - :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.v2021_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 "2021-07-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = 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, - 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, edge_zone: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of virtual machine image offers for the specified location, edge zone and - publisher. - - :param location: The name of 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.v2021_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 "2021-07-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_edge_zone_list_offers_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_publishers( - self, location: str, edge_zone: str, **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of virtual machine image publishers for the specified Azure location and edge zone. - - :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.v2021_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 "2021-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, - 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_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.v2021_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 "2021-07-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_edge_zone_list_skus_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - offer=offer, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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 - - -class UsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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 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.v2021_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 "2021-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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -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.v2021_07_01.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.VirtualMachine"]: - """Gets all the virtual machines under the specified subscription for the specified location. - - :param location: The location for which virtual machines under the subscription are queried. - Required. - :type location: str - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_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 "2021-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 - - 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) - - def _capture_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2021-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 - - 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_capture( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachineCaptureParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. - - :param resource_group_name: The name of the resource group. Required. - :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.v2021_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.v2021_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. - - :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.v2021_07_01.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_capture( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. - - :param resource_group_name: The name of the resource group. 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.v2021_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.v2021_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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) - - 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 - - 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 - ) - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, 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 "2021-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, "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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachine, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :param resource_group_name: The name of the resource group. 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.v2021_07_01.models.VirtualMachine - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :param resource_group_name: The name of the resource group. 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 content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :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 Create Virtual Machine operation. Is either a - VirtualMachine type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachine or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_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 "2021-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._create_or_update_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("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 _update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineUpdate, 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 "2021-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, "VirtualMachineUpdate") - - _request = build_virtual_machines_update_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 - - 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) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachineUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. - - :param resource_group_name: The name of the resource group. 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.v2021_07_01.models.VirtualMachineUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. - - :param resource_group_name: The name of the resource group. 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 content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_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]], - **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.v2021_07_01.models.VirtualMachineUpdate or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_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 "2021-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, - 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 "2021-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 - - @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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword force_deletion: Optional parameter to force delete virtual machines. 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 "2021-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, - 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_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.v2021_07_01.models.InstanceViewTypes - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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.v2021_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 "2021-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 - ) - - response = pipeline_response.http_response - - if response.status_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 - ) -> 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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_convert_to_managed_disks_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. - :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 "2021-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._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 - ) - 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 _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, - 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 "2021-07-01")) - cls: ClsType[Iterator[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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. - :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. (Feature in Preview). - 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 {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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._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 - ) - 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 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. :code:`
    `For Windows, please refer to - `Create a managed image of a generalized VM in Azure - `_.\\ - :code:`
    `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 "2021-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 - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_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 "2021-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, - 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, **kwargs: Any) -> ItemPaged["_models.VirtualMachine"]: - """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 - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_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 "2021-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, - 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_available_sizes( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes to which the specified virtual machine can be - resized. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_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 "2021-07-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_available_sizes_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _power_off_initial( - self, resource_group_name: str, vm_name: str, *, skip_shutdown: bool = False, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_power_off_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_power_off( - self, resource_group_name: str, vm_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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool - :return: An instance of 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 "2021-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, **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, - 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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_reapply_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. - :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 "2021-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_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 _restart_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_restart_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. - :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 "2021-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._restart_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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_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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_start(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[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 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 "2021-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, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_redeploy_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_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 "2021-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]: - 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 "2021-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( - 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 - - 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_reimage( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[_models.VirtualMachineReimageParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: ~azure.mgmt.compute.v2021_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 the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. 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 the virtual machine which has an ephemeral OS disk back to its initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. 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.v2021_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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # 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 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. :code:`
    `\\ :code:`
    `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.v2021_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 "2021-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 = 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_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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. - :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 "2021-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._perform_maintenance_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 - - @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 "2021-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]: - 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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. - :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.v2021_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 "2021-07-01")) - 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._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 - ) - 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) - 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.VirtualMachineAssessPatchesResult].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 - ) - - 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 "2021-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(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, - ) - _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_install_patches( - self, - resource_group_name: str, - vm_name: str, - install_patches_input: _models.VirtualMachineInstallPatchesParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param install_patches_input: Input for InstallPatches as directly received by the API. - Required. - :type install_patches_input: - ~azure.mgmt.compute.v2021_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.v2021_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. 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.v2021_07_01.models.VirtualMachineInstallPatchesResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_install_patches( - self, - resource_group_name: str, - vm_name: str, - install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param install_patches_input: Input for InstallPatches as directly received by the API. Is - either a VirtualMachineInstallPatchesParameters type or a IO[bytes] type. Required. - :type install_patches_input: - ~azure.mgmt.compute.v2021_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.v2021_07_01.models.VirtualMachineInstallPatchesResult] - :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 "2021-07-01")) - 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._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, - **kwargs - ) - 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) - 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.VirtualMachineInstallPatchesResult].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 - ) - - def _run_command_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, 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 "2021-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, "RunCommandInput") - - _request = build_virtual_machines_run_command_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 - - 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_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2021_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 RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_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.v2021_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._run_command_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -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.v2021_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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. - 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.v2021_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 "2021-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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - 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]], - **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 "2021-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") - - _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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet - :keyword content_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.v2021_07_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. 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 VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update 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 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.v2021_07_01.models.VirtualMachineScaleSet or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_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 "2021-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, - 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]], - **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 "2021-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, "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, - 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]: - 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, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. - - :param resource_group_name: The name of the resource group. 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.v2021_07_01.models.VirtualMachineScaleSetUpdate - :keyword content_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.v2021_07_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. - - :param resource_group_name: The name of the resource group. 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: IO[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 VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_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]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update 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 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.v2021_07_01.models.VirtualMachineScaleSetUpdate or - IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_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 "2021-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, - 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, - 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 "2021-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) - - 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, 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 "2021-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. - - :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 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.v2021_07_01.models.ExpandTypesForGetVMScaleSets - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _deallocate_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 "2021-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 - - _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, - 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_deallocate( - 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]: - """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. - :type 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.v2021_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_deallocate( - 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]: - """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. - :type 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_deallocate( - 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]: - """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. - :type 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.v2021_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 "2021-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, - 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 _delete_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - *, - force_deletion: Optional[bool] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 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 "2021-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") - - _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 = 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_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - force_deletion: Optional[bool] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Deletes virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type 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.v2021_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 None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - force_deletion: Optional[bool] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Deletes virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale - set. (Feature in Preview). Default value is None. - :paramtype force_deletion: bool - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - *, - force_deletion: Optional[bool] = None, - **kwargs: Any - ) -> LROPoller[None]: - """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.v2021_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 "2021-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. - - :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.v2021_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 "2021-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 - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_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 - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_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 "2021-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_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: - 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) -> ItemPaged["_models.VirtualMachineScaleSet"]: - """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource - group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this - till nextLink is null to fetch all the VM Scale Sets. - - :return: An iterator like instance of either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_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 "2021-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = 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_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("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) - - 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_skus( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineScaleSetSku"]: - """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM - instances allowed for each SKU. - - :param resource_group_name: The name of the resource group. Required. - :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.v2021_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 "2021-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) - - @distributed_trace - def get_os_upgrade_history( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.UpgradeOperationHistoricalStatusInfo"]: - """Gets list of OS upgrades 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 - :return: An iterator like instance of either UpgradeOperationHistoricalStatusInfo or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_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 "2021-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 - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListOSUpgradeHistory", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _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 - ) -> 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 "2021-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 - - _request = build_virtual_machine_scale_sets_power_off_request( - resource_group_name=resource_group_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, - 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_power_off( - self, - resource_group_name: str, - vm_scale_set_name: 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) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_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.v2021_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 - :keyword content_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: 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. - - :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 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 - :keyword content_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_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: bool = False, - **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. Required. - :type 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.v2021_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] - :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 "2021-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, - 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 "2021-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 - - _request = build_virtual_machine_scale_sets_restart_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2021_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_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :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.v2021_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 "2021-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, - 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 "2021-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 - - _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 - 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_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.v2021_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. - - :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.v2021_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 "2021-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 _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]: - 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 "2021-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 - - _request = build_virtual_machine_scale_sets_redeploy_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_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.v2021_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.v2021_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 "2021-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 - ) -> 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 "2021-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 - - _request = build_virtual_machine_scale_sets_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_perform_maintenance( - 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]: - """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. - :type 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.v2021_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_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. - - :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_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. - - :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.v2021_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 "2021-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( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2021-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") - - _request = build_virtual_machine_scale_sets_update_instances_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :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.v2021_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: - """ - - @overload - def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2021_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 "2021-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._update_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _reimage_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2021-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( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_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.v2021_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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Is either a - VirtualMachineScaleSetReimageParameters type or a IO[bytes] type. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2021_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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, - vm_scale_set_reimage_input=vm_scale_set_reimage_input, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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_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 "2021-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 - - _request = build_virtual_machine_scale_sets_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_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.v2021_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. - - :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.v2021_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 "2021-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 - - @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, **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 - :return: RecoveryWalkResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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, - 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("RecoveryWalkResponse", 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.v2021_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. 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 - 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. 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.v2021_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 "2021-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 = 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 _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]: - 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 "2021-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") - - _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, - 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_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. - - :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.v2021_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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_set_orchestration_service_state( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Changes ServiceState property for a given service. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the virtual machine scale set to create or update. - Required. - :type vm_scale_set_name: str - :param parameters: The input object for SetOrchestrationServiceState API. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_set_orchestration_service_state( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Changes ServiceState property for a given service. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the virtual machine scale set to create or update. - Required. - :type vm_scale_set_name: str - :param parameters: The input object for SetOrchestrationServiceState API. Is either a - OrchestrationServiceStateInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - -class VirtualMachineSizesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.VirtualMachineSize"]: - """This API is deprecated. Use `Resources Skus - `_. - - :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.v2021_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 "2021-07-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_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 - - 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 - - if response.status_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 ImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any - ) -> 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 "2021-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, "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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: _models.Image, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Create or update 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 - :param parameters: Parameters supplied to the Create Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2021_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Create or update 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 - :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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Image] - :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. - - :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 - :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.v2021_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.v2021_07_01.models.Image] - :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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._create_or_update_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: 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.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Image]( - 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]], - **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 "2021-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, "ImageUpdate") - - _request = build_images_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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, - image_name: str, - parameters: _models.ImageUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Update 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 - :param parameters: Parameters supplied to the Update Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2021_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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Update 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 - :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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Update 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 - :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.v2021_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.v2021_07_01.models.Image] - :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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: 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.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Image]( - 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]: - 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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_images_delete_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, image_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes an Image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, - image_name=image_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, resource_group_name: str, image_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.Image: - """Gets an image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: Image or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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 - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Image", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Image"]: - """Gets the list of images 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 Image or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_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 "2021-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 - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_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.v2021_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 "2021-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_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class RestorePointCollectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`restore_point_collections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - restore_point_collection_name: str, - parameters: _models.RestorePointCollection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to create or update the restore point collection. Please refer to - https://aka.ms/RestorePoints for more details. When updating a restore point collection, only - tags may be modified. - - :param resource_group_name: The name of the resource group. Required. - :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.v2021_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.v2021_07_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to create or update the restore point collection. Please refer to - https://aka.ms/RestorePoints for more details. When updating a restore point collection, only - tags may be modified. - - :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.v2021_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]], - **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.v2021_07_01.models.RestorePointCollection or IO[bytes] - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, "RestorePointCollection") - - _request = build_restore_point_collections_create_or_update_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RestorePointCollection", 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, - restore_point_collection_name: str, - parameters: _models.RestorePointCollectionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to update the restore point collection. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Update restore point collection operation. - Required. - :type parameters: ~azure.mgmt.compute.v2021_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: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to update the restore point collection. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Update restore point collection operation. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: Union[_models.RestorePointCollectionUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to update the restore point collection. - - :param resource_group_name: The name of the resource group. 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.v2021_07_01.models.RestorePointCollectionUpdate or - IO[bytes] - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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") - - _request = build_restore_point_collections_update_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) - - 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 - ) -> 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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_restore_point_collections_delete_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, restore_point_collection_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The operation to delete the restore point collection. This operation will also delete all the - contained restore points. - - :param resource_group_name: The name of the resource group. Required. - :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 "2021-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, - 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, - 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.v2021_07_01.models.RestorePointCollectionExpandOptions - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) - - _request = build_restore_point_collections_get_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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) -> ItemPaged["_models.RestorePointCollection"]: - """Gets the list of restore point collections in a resource group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either RestorePointCollection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_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 "2021-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) -> ItemPaged["_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.v2021_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 "2021-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. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`restore_points` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_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, - 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 "2021-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, "RestorePoint") - - _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) - - _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 [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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - parameters: _models.RestorePoint, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RestorePoint]: - """The operation to create the restore point. Updating properties of an existing restore point is - not allowed. - - :param resource_group_name: The name of the resource group. Required. - :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.v2021_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 LROPoller that returns either RestorePoint or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.RestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RestorePoint]: - """The operation to create the restore point. Updating properties of an existing restore point is - not allowed. - - :param resource_group_name: The name of the resource group. Required. - :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.v2021_07_01.models.RestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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. Is either a - RestorePoint type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_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.v2021_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 "2021-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): - deserialized = self._deserialize("RestorePoint", 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.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, - 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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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) - - _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, 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. - :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 - :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 "2021-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) - - 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, restore_point_collection_name: str, restore_point_name: str, **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 - :return: RestorePoint or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RestorePoint", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class CapacityReservationGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`capacity_reservation_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: _models.CapacityReservationGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to create or update a capacity reservation group. When updating a capacity - reservation group, only tags may be modified. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Create capacity reservation Group. Required. - :type parameters: ~azure.mgmt.compute.v2021_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.v2021_07_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to create or update a capacity reservation group. When updating a capacity - reservation group, only tags may be modified. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Create capacity reservation Group. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: Union[_models.CapacityReservationGroup, IO[bytes]], - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to create or update a capacity reservation group. When updating a capacity - reservation group, only tags 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.v2021_07_01.models.CapacityReservationGroup or IO[bytes] - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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") - - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CapacityReservationGroup", 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, - 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 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. - Required. - :type parameters: ~azure.mgmt.compute.v2021_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.v2021_07_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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 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. - 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.v2021_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 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.v2021_07_01.models.CapacityReservationGroupUpdate or - IO[bytes] - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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 = 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 - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any - ) -> None: - """The operation to delete a capacity reservation group. This operation is allowed only if all the - associated resources are disassociated from the reservation group and all capacity reservations - under the reservation group have also been deleted. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. Required. - :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 "2021-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) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def get( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - *, - expand: Optional[Union[str, _models.CapacityReservationGroupInstanceViewTypes]] = None, - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation that retrieves information about a capacity reservation group. - - :param resource_group_name: The name of the resource group. Required. - :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.v2021_07_01.models.CapacityReservationGroupInstanceViewTypes - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) - - _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) - - _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("CapacityReservationGroup", 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, - *, - expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, - **kwargs: Any - ) -> ItemPaged["_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 - :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.v2021_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.v2021_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 "2021-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 - ) - response = pipeline_response.http_response - - if response.status_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, **kwargs: Any - ) -> ItemPaged["_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.v2021_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.v2021_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 "2021-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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CapacityReservationGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - 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.v2021_07_01.ComputeManagementClient`'s - :attr:`capacity_reservations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - 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, - 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 "2021-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( - 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) - - _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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: _models.CapacityReservation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CapacityReservation]: - """The operation to create or update a capacity reservation. Please note some properties can be - set only during capacity reservation creation. Please refer to - https://aka.ms/CapacityReservation for more details. - - :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.v2021_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.v2021_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.v2021_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. - - :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. Is either a - CapacityReservation type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_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.v2021_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 "2021-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, **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, - 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 "2021-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, "CapacityReservationUpdate") - - _request = build_capacity_reservations_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) - - _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, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: _models.CapacityReservationUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CapacityReservation]: - """The operation to update a capacity reservation. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Update capacity reservation operation. Required. - :type parameters: ~azure.mgmt.compute.v2021_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: An instance of LROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CapacityReservation]: - """The operation to update a capacity reservation. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Update capacity reservation operation. Required. - :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.v2021_07_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.CapacityReservation]: - """The operation to update a capacity reservation. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Update capacity reservation operation. Is either - a CapacityReservationUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_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.v2021_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 "2021-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._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, **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 _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, - 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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_capacity_reservations_delete_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, - 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, - capacity_reservation_group_name: str, - capacity_reservation_name: 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. - - :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 - :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 "2021-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, - 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) - - 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, - 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. - :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.v2021_07_01.models.CapacityReservationInstanceViewTypes - :return: CapacityReservation or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-07-01")) - 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 - - @distributed_trace - def list_by_capacity_reservation_group( - self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any - ) -> ItemPaged["_models.CapacityReservation"]: - """Lists all of the capacity reservations in the specified capacity reservation group. Use the - nextLink property in the response to get the next page of capacity reservations. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :return: An iterator like instance of either CapacityReservation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_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 "2021-07-01")) - cls: ClsType[_models.CapacityReservationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_capacity_reservations_list_by_capacity_reservation_group_request( - resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CapacityReservationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -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.v2021_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtension, 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 "2021-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") - - _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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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. - - :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.v2021_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.v2021_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.v2021_07_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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.v2021_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.v2021_07_01.models.VirtualMachineScaleSetExtension] - :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 "2021-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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - 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 "2021-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, "VirtualMachineScaleSetExtensionUpdate") - - _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, - 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]: - 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, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2021_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 VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :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.v2021_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.v2021_07_01.models.VirtualMachineScaleSetExtension] - :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 "2021-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._update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2021-07-01")) - 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, - 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, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The operation to delete the extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be deleted. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, - vmss_extension_name=vmss_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSetExtension: - """The operation to get the extension. - - :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.v2021_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 "2021-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 - - @distributed_trace - def list( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_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.v2021_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 "2021-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) - - -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.v2021_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_rolling_upgrades_cancel_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - 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 - - 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. - - :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 "2021-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 - - 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_os_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request( - resource_group_name=resource_group_name, - 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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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 "2021-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 - ) -> 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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = 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, - 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 - - return deserialized # type: ignore - - @distributed_trace - def begin_start_extension_upgrade( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Starts a rolling upgrade to move all extensions for all virtual machine scale set instances to - the latest available extension version. Instances which are already running the latest - extension versions are not affected. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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 - - 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_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.v2021_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 "2021-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 - ) - - response = pipeline_response.http_response - - if response.status_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.v2021_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vm_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - 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 "2021-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, "VirtualMachineScaleSetVMExtension") - - _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) - - _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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetVMExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2021_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.v2021_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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_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. - - :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.v2021_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.v2021_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSetVMExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetVMExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 "2021-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( - 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) - - _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]: - 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, - 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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2021_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.v2021_07_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_07_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_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.v2021_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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 - ) - - 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, - 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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_extensions_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - 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, 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 resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :return: An instance of 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 "2021-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) - - 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, - 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. - :type 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.v2021_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 "2021-07-01")) - 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 - - @distributed_trace - def list( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: - """The operation to get all extensions of an instance in Virtual Machine Scaleset. - - :param resource_group_name: The name of the resource group. Required. - :type 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.v2021_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 "2021-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 = 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 - - -class VirtualMachineScaleSetVMsOperations: # 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.v2021_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _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 - ) -> 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 "2021-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_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, - 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 - 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_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Default value is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2021_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: - """ - - @overload - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Default value is None. - :type vm_scale_set_vm_reimage_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[ - Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] - ] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Is either a VirtualMachineScaleSetVMReimageParameters type or a IO[bytes] type. Default value - is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2021_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 "2021-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, **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, - 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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_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. - :type 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 "2021-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._reimage_all_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - 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 "2021-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) - - 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_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. - :type 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 "2021-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._deallocate_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, 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 "2021-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, "VirtualMachineScaleSetVM") - - _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, - 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, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.VirtualMachineScaleSetVM, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM - :keyword content_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.v2021_07_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 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. - 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 VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. - Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM] - :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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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, - 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("VirtualMachineScaleSetVM", 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.VirtualMachineScaleSetVM].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetVM]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: 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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - force_deletion=force_deletion, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, - vm_scale_set_name: str, - instance_id: str, - *, - force_deletion: Optional[bool] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes 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 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, - 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, - 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.v2021_07_01.models.InstanceViewTypes - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_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 "2021-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.v2021_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 "2021-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 - ) -> ItemPaged["_models.VirtualMachineScaleSetVM"]: - """Gets a list of all virtual machines in a VM scale sets. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param virtual_machine_scale_set_name: The name of the VM scale set. Required. - :type virtual_machine_scale_set_name: str - :keyword filter: The filter to apply to the operation. Allowed values are - 'startswith(instanceView/statuses/code, 'PowerState') eq true', 'properties/latestModelApplied - eq true', 'properties/latestModelApplied eq false'. Default value is None. - :paramtype filter: str - :keyword select: The list parameters. Allowed values are 'instanceView', - 'instanceView/statuses'. Default value is None. - :paramtype select: str - :keyword expand: The expand expression to apply to the operation. Allowed values are - 'instanceView'. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_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 "2021-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 - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVMListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _power_off_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - skip_shutdown: bool = False, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_power_off_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - skip_shutdown: bool = False, - **kwargs: Any - ) -> LROPoller[None]: - """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached - and you are getting charged for the resources. Instead, use deallocate to release resources and - avoid charges. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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 "2021-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 - - return deserialized # type: ignore - - @distributed_trace - def begin_restart( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Restarts a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type 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 "2021-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._restart_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 - - 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, - 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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_start_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 - - return deserialized # type: ignore - - @distributed_trace - def begin_start( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Starts a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM 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 "2021-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_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 - - 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, - 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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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 vm_scale_set_name: The name of the VM 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 "2021-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) - - 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 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. Required. - :type 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. :code:`
    `\\ :code:`
    `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.v2021_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 "2021-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, - 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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_perform_maintenance( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Performs maintenance on a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def simulate_eviction( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> None: - """The operation to simulate the eviction of spot virtual machine in a VM scale set. - - :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 "2021-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 _run_command_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, 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 "2021-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, "RunCommandInput") - - _request = build_virtual_machine_scale_set_vms_run_command_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 - 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_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - :type 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.v2021_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 RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> 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. - :type 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.v2021_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.v2021_07_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._run_command_initial( - resource_group_name=resource_group_name, - vm_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("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, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class LogAnalyticsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`log_analytics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - 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 "2021-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, "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, - ) - _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_export_request_rate_by_interval( - self, - location: str, - parameters: _models.RequestRateByIntervalInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. - - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. - Required. - :type parameters: ~azure.mgmt.compute.v2021_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 LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.LogAnalyticsOperationResult] - :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. - - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_export_request_rate_by_interval( - self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. - - :param location: The 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.v2021_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.v2021_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 "2021-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, 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, - 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("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, 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.LogAnalyticsOperationResult].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 - ) - - def _export_throttled_requests_initial( - self, location: str, parameters: Union[_models.ThrottledRequestsInput, 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 "2021-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, - 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_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.v2021_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.v2021_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.v2021_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. - - :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.v2021_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.v2021_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 "2021-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, 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, - 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("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, 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.LogAnalyticsOperationResult].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 - ) - - -class VirtualMachineRunCommandsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.RunCommandDocumentBase"]: - """Lists all available run commands for a subscription in a location. - - :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 - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_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 "2021-07-01")) - cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_run_commands_list_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RunCommandListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - 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, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: - """Gets specific run command for a subscription in a location. - - :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.v2021_07_01.models.RunCommandDocument - :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 "2021-07-01")) - cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) - - _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, - 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("RunCommandDocument", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 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 "2021-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(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_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, - ) - _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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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. - :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. - :type run_command_name: str - :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. - Required. - :type run_command: ~azure.mgmt.compute.v2021_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.v2021_07_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - run_command: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update the run command. - - :param resource_group_name: The name of the resource group. 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. - :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". - :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.v2021_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. 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. - :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.v2021_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.v2021_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 "2021-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): - deserialized = self._deserialize("VirtualMachineRunCommand", 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.VirtualMachineRunCommand].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineRunCommand]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommandUpdate, 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 "2021-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(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_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, - ) - _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]: - 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, - vm_name: 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. - - :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. - Required. - :type vm_name: 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. - Required. - :type run_command: ~azure.mgmt.compute.v2021_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 VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - run_command: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the run command. - - :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. - Required. - :type vm_name: 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. - 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". - :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.v2021_07_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the run command. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be updated. - Required. - :type vm_name: 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.v2021_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.v2021_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 "2021-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._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): - deserialized = self._deserialize("VirtualMachineRunCommand", 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.VirtualMachineRunCommand].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineRunCommand]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, vm_name: str, run_command_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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_run_commands_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - run_command_name=run_command_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, 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. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be deleted. - Required. - :type vm_name: str - :param run_command_name: The name of the virtual machine run command. 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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) - - 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_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. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine containing the run command. 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.v2021_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 "2021-07-01")) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - - _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) - - _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_by_virtual_machine( - self, resource_group_name: str, vm_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineRunCommand"]: - """The operation to get all run commands 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 run command. 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.v2021_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 "2021-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_run_commands_list_by_virtual_machine_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommandsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -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.v2021_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vm_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommand, 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 "2021-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(run_command, (IOBase, bytes)): - _content = run_command - else: - _json = self._serialize.body(run_command, "VirtualMachineRunCommand") - - _request = build_virtual_machine_scale_set_vm_run_commands_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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 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 - :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. - Required. - :type run_command: ~azure.mgmt.compute.v2021_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.v2021_07_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update 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 - :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". - :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.v2021_07_01.models.VirtualMachineRunCommand] - :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, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update 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 - :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.v2021_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.v2021_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 "2021-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_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, - 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("VirtualMachineRunCommand", 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.VirtualMachineRunCommand].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineRunCommand]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _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]], - **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 "2021-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(run_command, (IOBase, bytes)): - _content = run_command - else: - _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") - - _request = build_virtual_machine_scale_set_vm_run_commands_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, - 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]: - 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, - 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 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 - :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. - Required. - :type run_command: ~azure.mgmt.compute.v2021_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 VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_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 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 - :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. - Known values are: 'application/json', 'text/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) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] - :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]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """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_scale_set_name: The name of the VM 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.v2021_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.v2021_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 "2021-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._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, - 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("VirtualMachineRunCommand", 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.VirtualMachineRunCommand].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineRunCommand]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - 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, - 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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_run_commands_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, - 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, vm_scale_set_name: str, instance_id: str, run_command_name: str, **kwargs: Any - ) -> LROPoller[None]: - """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_scale_set_name: The name of the VM 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 - :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 "2021-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, - 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) - - 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, - 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.v2021_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 "2021-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 - ) -> ItemPaged["_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.v2021_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 "2021-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) - - -class ResourceSkusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`resource_skus` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, *, filter: Optional[str] = None, include_extended_locations: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.ResourceSku"]: - """Gets the list of Microsoft.Compute SKUs available for your Subscription. - - :keyword filter: The filter to apply on the operation. Only **location** filter is supported - currently. Default value is None. - :paramtype filter: str - :keyword include_extended_locations: To Include Extended Locations information or not in the - response. Default value is None. - :paramtype include_extended_locations: str - :return: An iterator like instance of either ResourceSku or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.ResourceSku] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[_models.ResourceSkusResult] = 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_resource_skus_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - include_extended_locations=include_extended_locations, - 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("ResourceSkusResult", 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 GalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2021-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(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 - - 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) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: _models.Gallery, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_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. - Required. - :type gallery_name: str - :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. - Required. - :type gallery: ~azure.mgmt.compute.v2021_07_01.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.v2021_07_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_07_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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. Is - either a Gallery type or a IO[bytes] type. Required. - :type gallery: ~azure.mgmt.compute.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - 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) - - 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, **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 _update_initial( - self, - resource_group_name: str, - gallery_name: str, - gallery: Union[_models.GalleryUpdate, 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 "2021-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(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) - - _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]: - 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, - 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. 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 update Shared Image Gallery operation. Required. - :type gallery: ~azure.mgmt.compute.v2021_07_01.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.v2021_07_01.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. 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 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.v2021_07_01.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. 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 update Shared Image Gallery operation. Is either a - GalleryUpdate type or a IO[bytes] type. Required. - :type gallery: ~azure.mgmt.compute.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - 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, **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 - ) - - @distributed_trace - def get( - self, - resource_group_name: str, - gallery_name: str, - *, - select: Optional[Union[str, _models.SelectPermissions]] = 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.v2021_07_01.models.SelectPermissions - :return: Gallery or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - 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, - 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("Gallery", 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, **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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_galleries_delete_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) - - _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, gallery_name: str, **kwargs: Any) -> LROPoller[None]: - """Delete 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 to be deleted. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, - gallery_name=gallery_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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - 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 - - 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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_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.v2021_07_01.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 "2021-07-01")) - 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 - - 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) - - 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 GalleryImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_image_name: str, - gallery_image: Union[_models.GalleryImage, 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 "2021-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(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 = 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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.v2021_07_01.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.v2021_07_01.models.GalleryImage] - :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: IO[bytes], - *, - 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: IO[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.v2021_07_01.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - 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) - - 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: 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, - ) - return LROPoller[_models.GalleryImage]( - 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: Union[_models.GalleryImageUpdate, 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 "2021-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(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 = 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: - 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, - 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.v2021_07_01.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.v2021_07_01.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_07_01.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image: Union[_models.GalleryImageUpdate, IO[bytes]], - **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. Is either a - GalleryImageUpdate type or a IO[bytes] type. Required. - :type gallery_image: ~azure.mgmt.compute.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - 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) - - 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: 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, - ) - 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_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.v2021_07_01.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 "2021-07-01")) - cls: ClsType[_models.GalleryImage] = kwargs.pop("cls", None) - - _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) - raise HttpResponseError(response=response, 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 _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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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) - - _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, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> LROPoller[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 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 "2021-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, - 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 - ) -> ItemPaged["_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.v2021_07_01.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 "2021-07-01")) - cls: ClsType[_models.GalleryImageList] = 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_images_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("GalleryImageList", 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 GalleryImageVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_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 "2021-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(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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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.v2021_07_01.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.v2021_07_01.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. 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.v2021_07_01.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - 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, **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, - 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 "2021-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(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) - - _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]: - 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, - 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. - - :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.v2021_07_01.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.v2021_07_01.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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 LROPoller that returns either GalleryImageVersion or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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 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.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - 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) - - 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, **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 - ) - - @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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationStatusTypes - :return: GalleryImageVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - 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( - 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, - 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 "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - **kwargs: Any - ) -> LROPoller[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 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 "2021-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, - 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 - - 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_image( - self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> ItemPaged["_models.GalleryImageVersion"]: - """List gallery image versions in 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 - resides. 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) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - cls: ClsType[_models.GalleryImageVersionList] = 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_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, - 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("GalleryImageVersionList", 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 GalleryApplicationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`gallery_applications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application: Union[_models.GalleryApplication, 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 "2021-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(gallery_application, (IOBase, bytes)): - _content = gallery_application - else: - _json = self._serialize.body(gallery_application, "GalleryApplication") - - _request = build_gallery_applications_create_or_update_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, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: _models.GalleryApplication, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2021_07_01.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 GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_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]: - """Create or update 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 is to be created. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the create or 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.v2021_07_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplication, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - 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._create_or_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, **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 _update_initial( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, 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 "2021-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(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_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, - ) - _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]: - 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, - gallery_application_name: str, - gallery_application: _models.GalleryApplicationUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the update gallery Application operation. - Required. - :type gallery_application: ~azure.mgmt.compute.v2021_07_01.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.v2021_07_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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 is to be updated. 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. - :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.v2021_07_01.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. 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. - :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. - :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.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - 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, **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 - ) - - @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.v2021_07_01.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 "2021-07-01")) - 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 - ) -> 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 "2021-07-01")) - 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) - 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, 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. 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. - :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be deleted. - 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 "2021-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, - 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, **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 - ) -> ItemPaged["_models.GalleryApplication"]: - """List gallery Application 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 Application Gallery from which Application - Definitions are to be listed. 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.v2021_07_01.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 "2021-07-01")) - cls: ClsType[_models.GalleryApplicationList] = 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_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: - 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 GalleryApplicationVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`gallery_application_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: Union[_models.GalleryApplicationVersion, 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 "2021-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(gallery_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersion") - - _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, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersion, - *, - 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. - :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 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.v2021_07_01.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 GalleryApplicationVersion or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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], - *, - 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. - :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 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] - :keyword content_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.v2021_07_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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]], - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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) - if cont_token is None: - 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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.GalleryApplicationVersion]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - 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]], - **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 "2021-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(gallery_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersionUpdate") - - _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, - 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]: - 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, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2021_07_01.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 GalleryApplicationVersion or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update 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 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] - :keyword content_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.v2021_07_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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]], - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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) - 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_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 - ) - 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: 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.GalleryApplicationVersion].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - 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, - 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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationStatusTypes - :return: GalleryApplicationVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - 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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Delete 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 - deleted. 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-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, - 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, - 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_application( - self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> ItemPaged["_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.v2021_07_01.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 "2021-07-01")) - 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.v2021_07_01.ComputeManagementClient`'s - :attr:`gallery_sharing_profile` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 "2021-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(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.v2021_07_01.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.v2021_07_01.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.v2021_07_01.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.v2021_07_01.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.v2021_07_01.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 "2021-07-01")) - 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.v2021_07_01.ComputeManagementClient`'s - :attr:`shared_galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_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.v2021_07_01.models.SharedToValues - :return: An iterator like instance of either SharedGallery or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - 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.v2021_07_01.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 "2021-07-01")) - 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.v2021_07_01.ComputeManagementClient`'s - :attr:`shared_gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_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.v2021_07_01.models.SharedToValues - :return: An iterator like instance of either SharedGalleryImage or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - 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.v2021_07_01.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 "2021-07-01")) - 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 - - -class SharedGalleryImageVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`shared_gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.SharedGalleryImageVersion"]: - """List shared gallery image versions 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 - :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.v2021_07_01.models.SharedToValues - :return: An iterator like instance of either SharedGalleryImageVersion or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.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 "2021-07-01")) - 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 - - 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, 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, - gallery_image_version_name: str, - **kwargs: Any - ) -> _models.SharedGalleryImageVersion: - """Get a shared gallery image version 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 - :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.v2021_07_01.models.SharedGalleryImageVersion - :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 "2021-07-01")) - cls: ClsType[_models.SharedGalleryImageVersion] = kwargs.pop("cls", None) - - _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, - 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("SharedGalleryImageVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class CommunityGalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s - :attr:`community_galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, **kwargs: Any) -> _models.CommunityGallery: - """Get a community gallery by gallery public name. - - :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.v2021_07_01.models.CommunityGallery - :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 "2021-07-01")) - cls: ClsType[_models.CommunityGallery] = kwargs.pop("cls", 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) - - _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("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.v2021_07_01.ComputeManagementClient`'s - :attr:`community_gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.v2021_07_01.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 "2021-07-01")) - 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) - raise HttpResponseError(response=response, 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.v2021_07_01.ComputeManagementClient`'s - :attr:`community_gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - gallery_image_version_name: str, - **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.v2021_07_01.models.CommunityGalleryImageVersion - :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 "2021-07-01")) - cls: ClsType[_models.CommunityGalleryImageVersion] = 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, - 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("CommunityGalleryImageVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2021_10_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_compute_management_client.py deleted file mode 100644 index 9e6d1ff1dc98..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_compute_management_client.py +++ /dev/null @@ -1,154 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ( - GalleriesOperations, - GalleryApplicationVersionsOperations, - GalleryApplicationsOperations, - GalleryImageVersionsOperations, - GalleryImagesOperations, - GallerySharingProfileOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar galleries: GalleriesOperations operations - :vartype galleries: azure.mgmt.compute.v2021_10_01.operations.GalleriesOperations - :ivar gallery_images: GalleryImagesOperations operations - :vartype gallery_images: azure.mgmt.compute.v2021_10_01.operations.GalleryImagesOperations - :ivar gallery_image_versions: GalleryImageVersionsOperations operations - :vartype gallery_image_versions: - azure.mgmt.compute.v2021_10_01.operations.GalleryImageVersionsOperations - :ivar gallery_applications: GalleryApplicationsOperations operations - :vartype gallery_applications: - azure.mgmt.compute.v2021_10_01.operations.GalleryApplicationsOperations - :ivar gallery_application_versions: GalleryApplicationVersionsOperations operations - :vartype gallery_application_versions: - azure.mgmt.compute.v2021_10_01.operations.GalleryApplicationVersionsOperations - :ivar gallery_sharing_profile: GallerySharingProfileOperations operations - :vartype gallery_sharing_profile: - azure.mgmt.compute.v2021_10_01.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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.galleries = GalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-10-01" - ) - self.gallery_images = GalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-10-01" - ) - self.gallery_image_versions = GalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-10-01" - ) - self.gallery_applications = GalleryApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-10-01" - ) - self.gallery_application_versions = GalleryApplicationVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-10-01" - ) - self.gallery_sharing_profile = GallerySharingProfileOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-10-01" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_configuration.py deleted file mode 100644 index 3d2615a22e90..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2021-10-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_metadata.json deleted file mode 100644 index 2be900274dec..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_metadata.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "chosen_version": "2021-10-01", - "total_api_version_list": ["2021-10-01"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "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.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "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.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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": { - "galleries": "GalleriesOperations", - "gallery_images": "GalleryImagesOperations", - "gallery_image_versions": "GalleryImageVersionsOperations", - "gallery_applications": "GalleryApplicationsOperations", - "gallery_application_versions": "GalleryApplicationVersionsOperations", - "gallery_sharing_profile": "GallerySharingProfileOperations" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node
    is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj 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 deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2021_10_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/_compute_management_client.py deleted file mode 100644 index 8c0871696df5..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/_compute_management_client.py +++ /dev/null @@ -1,158 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ( - GalleriesOperations, - GalleryApplicationVersionsOperations, - GalleryApplicationsOperations, - GalleryImageVersionsOperations, - GalleryImagesOperations, - GallerySharingProfileOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar galleries: GalleriesOperations operations - :vartype galleries: azure.mgmt.compute.v2021_10_01.aio.operations.GalleriesOperations - :ivar gallery_images: GalleryImagesOperations operations - :vartype gallery_images: azure.mgmt.compute.v2021_10_01.aio.operations.GalleryImagesOperations - :ivar gallery_image_versions: GalleryImageVersionsOperations operations - :vartype gallery_image_versions: - azure.mgmt.compute.v2021_10_01.aio.operations.GalleryImageVersionsOperations - :ivar gallery_applications: GalleryApplicationsOperations operations - :vartype gallery_applications: - azure.mgmt.compute.v2021_10_01.aio.operations.GalleryApplicationsOperations - :ivar gallery_application_versions: GalleryApplicationVersionsOperations operations - :vartype gallery_application_versions: - azure.mgmt.compute.v2021_10_01.aio.operations.GalleryApplicationVersionsOperations - :ivar gallery_sharing_profile: GallerySharingProfileOperations operations - :vartype gallery_sharing_profile: - azure.mgmt.compute.v2021_10_01.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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.galleries = GalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-10-01" - ) - self.gallery_images = GalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-10-01" - ) - self.gallery_image_versions = GalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-10-01" - ) - self.gallery_applications = GalleryApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-10-01" - ) - self.gallery_application_versions = GalleryApplicationVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-10-01" - ) - self.gallery_sharing_profile = GallerySharingProfileOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-10-01" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/_configuration.py deleted file mode 100644 index d5fdb47b129c..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2021-10-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/__init__.py deleted file mode 100644 index 1362411892f0..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/__init__.py +++ /dev/null @@ -1,35 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - 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 ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "GalleriesOperations", - "GalleryImagesOperations", - "GalleryImageVersionsOperations", - "GalleryApplicationsOperations", - "GalleryApplicationVersionsOperations", - "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/v2021_10_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_operations.py deleted file mode 100644 index 2d8843bcf78b..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_operations.py +++ /dev/null @@ -1,3973 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import ( - build_galleries_create_or_update_request, - build_galleries_delete_request, - build_galleries_get_request, - build_galleries_list_by_resource_group_request, - build_galleries_list_request, - build_galleries_update_request, - build_gallery_application_versions_create_or_update_request, - build_gallery_application_versions_delete_request, - build_gallery_application_versions_get_request, - build_gallery_application_versions_list_by_gallery_application_request, - build_gallery_application_versions_update_request, - build_gallery_applications_create_or_update_request, - build_gallery_applications_delete_request, - build_gallery_applications_get_request, - build_gallery_applications_list_by_gallery_request, - build_gallery_applications_update_request, - build_gallery_image_versions_create_or_update_request, - build_gallery_image_versions_delete_request, - build_gallery_image_versions_get_request, - build_gallery_image_versions_list_by_gallery_image_request, - build_gallery_image_versions_update_request, - build_gallery_images_create_or_update_request, - build_gallery_images_delete_request, - build_gallery_images_get_request, - build_gallery_images_list_by_gallery_request, - build_gallery_images_update_request, - build_gallery_sharing_profile_update_request, -) -from .._configuration import ComputeManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_10_01.aio.ComputeManagementClient`'s - :attr:`galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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: Union[_models.Gallery, 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 "2021-10-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(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 = 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: _models.Gallery, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - Required. - :type gallery_name: str - :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. - Required. - :type gallery: ~azure.mgmt.compute.v2021_10_01.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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - 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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, gallery_name: str, gallery: Union[_models.Gallery, IO[bytes]], **kwargs: Any - ) -> 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. - 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.v2021_10_01.models.Gallery or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.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 "2021-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Gallery] = 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=gallery, - 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("Gallery", 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.Gallery].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Gallery]( - 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: Union[_models.GalleryUpdate, 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 "2021-10-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(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) - - _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: _models.GalleryUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - Required. - :type gallery_name: str - :param gallery: Parameters supplied to the update Shared Image Gallery operation. Required. - :type gallery: ~azure.mgmt.compute.v2021_10_01.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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - 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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: Union[_models.GalleryUpdate, IO[bytes]], - **kwargs: Any - ) -> 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. - 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.v2021_10_01.models.GalleryUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.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 "2021-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Gallery] = 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=gallery, - 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("Gallery", 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.Gallery].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Gallery]( - 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.v2021_10_01.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.v2021_10_01.models.GalleryExpandParams - :return: Gallery or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_10_01.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 "2021-10-01")) - 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, - 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 "2021-10-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_galleries_delete_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) - - _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, gallery_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Delete 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 to be deleted. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-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, - gallery_name=gallery_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) -> AsyncItemPaged["_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.v2021_10_01.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 "2021-10-01")) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2021_10_01.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 "2021-10-01")) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class GalleryImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_10_01.aio.ComputeManagementClient`'s - :attr:`gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 "2021-10-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(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.v2021_10_01.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.v2021_10_01.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.v2021_10_01.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.v2021_10_01.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.v2021_10_01.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 "2021-10-01")) - 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 "2021-10-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(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.v2021_10_01.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.v2021_10_01.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.v2021_10_01.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.v2021_10_01.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.v2021_10_01.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 "2021-10-01")) - 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.v2021_10_01.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 "2021-10-01")) - cls: ClsType[_models.GalleryImage] = kwargs.pop("cls", None) - - _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 = 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("GalleryImage", 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]: - 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 "2021-10-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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) - - _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, 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-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, - 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, **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_gallery( - self, resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_10_01.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 "2021-10-01")) - cls: ClsType[_models.GalleryImageList] = 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_images_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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryImageList", 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 GalleryImageVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_10_01.aio.ComputeManagementClient`'s - :attr:`gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 "2021-10-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(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.v2021_10_01.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.v2021_10_01.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.v2021_10_01.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.v2021_10_01.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.v2021_10_01.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 "2021-10-01")) - 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]: - 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 "2021-10-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(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) - - _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_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.v2021_10_01.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.v2021_10_01.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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 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.v2021_10_01.models.GalleryImageVersion] - :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_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. 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.v2021_10_01.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.v2021_10_01.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 "2021-10-01")) - 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) - - 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 - ) - - @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. - - :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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2021_10_01.models.ReplicationStatusTypes - :return: GalleryImageVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_10_01.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 "2021-10-01")) - 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) - 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 - - 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, - 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 "2021-10-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-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, - 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) - - 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_gallery_image( - self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.GalleryImageVersion"]: - """List gallery image versions in 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 - resides. 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) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_10_01.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 "2021-10-01")) - cls: ClsType[_models.GalleryImageVersionList] = 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_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, - 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("GalleryImageVersionList", 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 GalleryApplicationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_10_01.aio.ComputeManagementClient`'s - :attr:`gallery_applications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application: Union[_models.GalleryApplication, 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 "2021-10-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(gallery_application, (IOBase, bytes)): - _content = gallery_application - else: - _json = self._serialize.body(gallery_application, "GalleryApplication") - - _request = build_gallery_applications_create_or_update_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, - 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_application_name: str, - gallery_application: _models.GalleryApplication, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2021_10_01.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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the create or 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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplication, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2021_10_01.models.GalleryApplication or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.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 "2021-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryApplication] = 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_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 - ) - await 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: 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.GalleryApplication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GalleryApplication]( - 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_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, 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 "2021-10-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(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_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, - ) - _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_application_name: str, - gallery_application: _models.GalleryApplicationUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the update gallery Application operation. - Required. - :type gallery_application: ~azure.mgmt.compute.v2021_10_01.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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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 - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :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.v2021_10_01.models.GalleryApplicationUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.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 "2021-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryApplication] = 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=gallery_application, - 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("GalleryApplication", 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.GalleryApplication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GalleryApplication]( - 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.v2021_10_01.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 "2021-10-01")) - 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]: - 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 "2021-10-01")) - cls: ClsType[AsyncIterator[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 = 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, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete a gallery Application. - - :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 is to be deleted. Required. - :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be deleted. - 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-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, - 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 - ) - 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_gallery( - self, resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.GalleryApplication"]: - """List gallery Application 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 Application Gallery from which Application - Definitions are to be listed. Required. - :type gallery_name: str - :return: An iterator like instance of either GalleryApplication or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_10_01.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 "2021-10-01")) - cls: ClsType[_models.GalleryApplicationList] = 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_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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryApplicationList", 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 GalleryApplicationVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_10_01.aio.ComputeManagementClient`'s - :attr:`gallery_application_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: Union[_models.GalleryApplicationVersion, 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 "2021-10-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(gallery_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersion") - - _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, - 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersion, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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.v2021_10_01.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 AsyncLROPoller that returns either GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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] - :keyword content_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 GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async 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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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.v2021_10_01.models.GalleryApplicationVersion 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.v2021_10_01.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 "2021-10-01")) - 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._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, - 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 - ) - - async 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]], - **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 "2021-10-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(gallery_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersionUpdate") - - _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, - 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2021_10_01.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 AsyncLROPoller that returns either GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Update 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 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] - :keyword content_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 GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async 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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2021_10_01.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.v2021_10_01.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 "2021-10-01")) - 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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2021_10_01.models.ReplicationStatusTypes - :return: GalleryApplicationVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_10_01.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 "2021-10-01")) - 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) - - deserialized = self._deserialize("GalleryApplicationVersion", 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, - gallery_application_version_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 "2021-10-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete 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 - deleted. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-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, - 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, - 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_gallery_application( - self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_10_01.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 "2021-10-01")) - 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 - - async 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, 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 GallerySharingProfileOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_10_01.aio.ComputeManagementClient`'s - :attr:`gallery_sharing_profile` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _update_initial( - self, - resource_group_name: str, - gallery_name: str, - sharing_update: Union[_models.SharingUpdate, 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 "2021-10-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(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 = 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( - 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 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.v2021_10_01.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.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.SharingUpdate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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 AsyncLROPoller that returns either SharingUpdate or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.SharingUpdate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_10_01.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.v2021_10_01.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 "2021-10-01")) - 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) - - 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: 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.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/v2021_10_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/__init__.py deleted file mode 100644 index bd1ccef893c6..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/__init__.py +++ /dev/null @@ -1,184 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - ApiError, - ApiErrorBase, - CommunityGalleryInfo, - DataDiskImageEncryption, - Disallowed, - DiskImageEncryption, - EncryptionImages, - Gallery, - GalleryApplication, - GalleryApplicationList, - GalleryApplicationUpdate, - GalleryApplicationVersion, - GalleryApplicationVersionList, - GalleryApplicationVersionPublishingProfile, - GalleryApplicationVersionUpdate, - GalleryArtifactPublishingProfileBase, - GalleryArtifactSource, - GalleryArtifactVersionSource, - GalleryDataDiskImage, - GalleryDiskImage, - GalleryExtendedLocation, - GalleryIdentifier, - GalleryImage, - GalleryImageFeature, - GalleryImageIdentifier, - GalleryImageList, - GalleryImageUpdate, - GalleryImageVersion, - GalleryImageVersionList, - GalleryImageVersionPublishingProfile, - GalleryImageVersionStorageProfile, - GalleryImageVersionUpdate, - GalleryList, - GalleryOSDiskImage, - GalleryTargetExtendedLocation, - GalleryUpdate, - ImagePurchasePlan, - InnerError, - ManagedArtifact, - OSDiskImageEncryption, - OSDiskImageSecurityProfile, - RecommendedMachineConfiguration, - RegionalReplicationStatus, - RegionalSharingStatus, - ReplicationStatus, - Resource, - ResourceRange, - SharingProfile, - SharingProfileGroup, - SharingStatus, - SharingUpdate, - SoftDeletePolicy, - TargetRegion, - UpdateResourceDefinition, - UserArtifactManage, - UserArtifactSource, -) - -from ._compute_management_client_enums import ( # type: ignore - AggregatedReplicationState, - Architecture, - ConfidentialVMEncryptionType, - GalleryApplicationVersionPropertiesProvisioningState, - GalleryExpandParams, - GalleryExtendedLocationType, - GalleryImagePropertiesProvisioningState, - GalleryImageVersionPropertiesProvisioningState, - GalleryPropertiesProvisioningState, - GallerySharingPermissionTypes, - HostCaching, - HyperVGeneration, - OperatingSystemStateTypes, - OperatingSystemTypes, - ReplicationMode, - ReplicationState, - ReplicationStatusTypes, - SelectPermissions, - SharingProfileGroupTypes, - SharingState, - SharingUpdateOperationTypes, - StorageAccountType, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ApiError", - "ApiErrorBase", - "CommunityGalleryInfo", - "DataDiskImageEncryption", - "Disallowed", - "DiskImageEncryption", - "EncryptionImages", - "Gallery", - "GalleryApplication", - "GalleryApplicationList", - "GalleryApplicationUpdate", - "GalleryApplicationVersion", - "GalleryApplicationVersionList", - "GalleryApplicationVersionPublishingProfile", - "GalleryApplicationVersionUpdate", - "GalleryArtifactPublishingProfileBase", - "GalleryArtifactSource", - "GalleryArtifactVersionSource", - "GalleryDataDiskImage", - "GalleryDiskImage", - "GalleryExtendedLocation", - "GalleryIdentifier", - "GalleryImage", - "GalleryImageFeature", - "GalleryImageIdentifier", - "GalleryImageList", - "GalleryImageUpdate", - "GalleryImageVersion", - "GalleryImageVersionList", - "GalleryImageVersionPublishingProfile", - "GalleryImageVersionStorageProfile", - "GalleryImageVersionUpdate", - "GalleryList", - "GalleryOSDiskImage", - "GalleryTargetExtendedLocation", - "GalleryUpdate", - "ImagePurchasePlan", - "InnerError", - "ManagedArtifact", - "OSDiskImageEncryption", - "OSDiskImageSecurityProfile", - "RecommendedMachineConfiguration", - "RegionalReplicationStatus", - "RegionalSharingStatus", - "ReplicationStatus", - "Resource", - "ResourceRange", - "SharingProfile", - "SharingProfileGroup", - "SharingStatus", - "SharingUpdate", - "SoftDeletePolicy", - "TargetRegion", - "UpdateResourceDefinition", - "UserArtifactManage", - "UserArtifactSource", - "AggregatedReplicationState", - "Architecture", - "ConfidentialVMEncryptionType", - "GalleryApplicationVersionPropertiesProvisioningState", - "GalleryExpandParams", - "GalleryExtendedLocationType", - "GalleryImagePropertiesProvisioningState", - "GalleryImageVersionPropertiesProvisioningState", - "GalleryPropertiesProvisioningState", - "GallerySharingPermissionTypes", - "HostCaching", - "HyperVGeneration", - "OperatingSystemStateTypes", - "OperatingSystemTypes", - "ReplicationMode", - "ReplicationState", - "ReplicationStatusTypes", - "SelectPermissions", - "SharingProfileGroupTypes", - "SharingState", - "SharingUpdateOperationTypes", - "StorageAccountType", -] -__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/v2021_10_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/_compute_management_client_enums.py deleted file mode 100644 index c6c798b20cfc..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/_compute_management_client_enums.py +++ /dev/null @@ -1,208 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AggregatedReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is the aggregated replication status based on all the regional replication status flags.""" - - UNKNOWN = "Unknown" - IN_PROGRESS = "InProgress" - COMPLETED = "Completed" - FAILED = "Failed" - - -class Architecture(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The architecture of the image. Applicable to OS disks only.""" - - X64 = "x64" - ARM64 = "Arm64" - - -class ConfidentialVMEncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """confidential VM encryption types.""" - - ENCRYPTED_VM_GUEST_STATE_ONLY_WITH_PMK = "EncryptedVMGuestStateOnlyWithPmk" - ENCRYPTED_WITH_PMK = "EncryptedWithPmk" - ENCRYPTED_WITH_CMK = "EncryptedWithCmk" - - -class GalleryApplicationVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state, which only appears in the response.""" - - CREATING = "Creating" - UPDATING = "Updating" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - MIGRATING = "Migrating" - - -class GalleryExpandParams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """GalleryExpandParams.""" - - SHARING_PROFILE_GROUPS = "SharingProfile/Groups" - - -class GalleryExtendedLocationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """It is type of the extended location.""" - - EDGE_ZONE = "EdgeZone" - UNKNOWN = "Unknown" - - -class GalleryImagePropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state, which only appears in the response.""" - - CREATING = "Creating" - UPDATING = "Updating" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - MIGRATING = "Migrating" - - -class GalleryImageVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state, which only appears in the response.""" - - CREATING = "Creating" - UPDATING = "Updating" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - MIGRATING = "Migrating" - - -class GalleryPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state, which only appears in the response.""" - - CREATING = "Creating" - UPDATING = "Updating" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - MIGRATING = "Migrating" - - -class GallerySharingPermissionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows you to specify the permission of sharing gallery. :code:`
    `\\ - :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Private** :code:`
    `\\ - :code:`
    ` **Groups**. - """ - - PRIVATE = "Private" - GROUPS = "Groups" - - -class HostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'.""" - - NONE = "None" - READ_ONLY = "ReadOnly" - READ_WRITE = "ReadWrite" - - -class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The hypervisor generation of the Virtual Machine. Applicable to OS disks only.""" - - V1 = "V1" - V2 = "V2" - - -class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows the user to specify whether the virtual machines created under this image - are 'Generalized' or 'Specialized'. - """ - - GENERALIZED = "Generalized" - SPECIALIZED = "Specialized" - - -class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows you to specify the supported type of the OS that application is built for. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Windows** - :code:`
    `\\ :code:`
    ` **Linux**. - """ - - WINDOWS = "Windows" - LINUX = "Linux" - - -class ReplicationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Optional parameter which specifies the mode to be used for replication. This property is not - updatable. - """ - - FULL = "Full" - SHALLOW = "Shallow" - - -class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is the regional replication state.""" - - UNKNOWN = "Unknown" - REPLICATING = "Replicating" - COMPLETED = "Completed" - FAILED = "Failed" - - -class ReplicationStatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ReplicationStatusTypes.""" - - REPLICATION_STATUS = "ReplicationStatus" - - -class SelectPermissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SelectPermissions.""" - - PERMISSIONS = "Permissions" - - -class SharingProfileGroupTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows you to specify the type of sharing group. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Subscriptions** :code:`
    `\\ :code:`
    ` - **AADTenants** :code:`
    `\\ :code:`
    ` **Community**. - """ - - SUBSCRIPTIONS = "Subscriptions" - AAD_TENANTS = "AADTenants" - COMMUNITY = "Community" - - -class SharingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The sharing state of the gallery, which only appears in the response.""" - - SUCCEEDED = "Succeeded" - IN_PROGRESS = "InProgress" - FAILED = "Failed" - UNKNOWN = "Unknown" - - -class SharingUpdateOperationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows you to specify the operation type of gallery sharing update. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Add** - :code:`
    `\\ :code:`
    ` **Remove** :code:`
    `\\ :code:`
    ` **Reset**. - """ - - ADD = "Add" - REMOVE = "Remove" - RESET = "Reset" - ENABLE_COMMUNITY = "EnableCommunity" - - -class StorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the storage account type to be used to store the image. This property is not - updatable. - """ - - STANDARD_LRS = "Standard_LRS" - STANDARD_ZRS = "Standard_ZRS" - PREMIUM_LRS = "Premium_LRS" - STANDARD_SSD_LRS = "StandardSSD_LRS" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/_models_py3.py deleted file mode 100644 index b08a828ba310..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/_models_py3.py +++ /dev/null @@ -1,2873 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# 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 .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -class ApiError(_serialization.Model): - """Api error. - - :ivar details: The Api error details. - :vartype details: list[~azure.mgmt.compute.v2021_10_01.models.ApiErrorBase] - :ivar innererror: The Api inner error. - :vartype innererror: ~azure.mgmt.compute.v2021_10_01.models.InnerError - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "details": {"key": "details", "type": "[ApiErrorBase]"}, - "innererror": {"key": "innererror", "type": "InnerError"}, - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - details: Optional[List["_models.ApiErrorBase"]] = None, - innererror: Optional["_models.InnerError"] = None, - code: Optional[str] = None, - target: Optional[str] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword details: The Api error details. - :paramtype details: list[~azure.mgmt.compute.v2021_10_01.models.ApiErrorBase] - :keyword innererror: The Api inner error. - :paramtype innererror: ~azure.mgmt.compute.v2021_10_01.models.InnerError - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.details = details - self.innererror = innererror - self.code = code - self.target = target - self.message = message - - -class ApiErrorBase(_serialization.Model): - """Api error base. - - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.target = target - self.message = message - - -class CommunityGalleryInfo(_serialization.Model): - """Information of community gallery if current gallery is shared to community. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar publisher_uri: Community gallery publisher uri. - :vartype publisher_uri: str - :ivar publisher_contact: Community gallery publisher contact email. - :vartype publisher_contact: str - :ivar eula: Community gallery publisher eula. - :vartype eula: str - :ivar public_name_prefix: Community gallery public name prefix. - :vartype public_name_prefix: str - :ivar community_gallery_enabled: Contains info about whether community gallery sharing is - enabled. - :vartype community_gallery_enabled: bool - :ivar public_names: Community gallery public name list. - :vartype public_names: list[str] - """ - - _validation = { - "community_gallery_enabled": {"readonly": True}, - "public_names": {"readonly": True}, - } - - _attribute_map = { - "publisher_uri": {"key": "publisherUri", "type": "str"}, - "publisher_contact": {"key": "publisherContact", "type": "str"}, - "eula": {"key": "eula", "type": "str"}, - "public_name_prefix": {"key": "publicNamePrefix", "type": "str"}, - "community_gallery_enabled": {"key": "communityGalleryEnabled", "type": "bool"}, - "public_names": {"key": "publicNames", "type": "[str]"}, - } - - def __init__( - self, - *, - publisher_uri: Optional[str] = None, - publisher_contact: Optional[str] = None, - eula: Optional[str] = None, - public_name_prefix: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword publisher_uri: Community gallery publisher uri. - :paramtype publisher_uri: str - :keyword publisher_contact: Community gallery publisher contact email. - :paramtype publisher_contact: str - :keyword eula: Community gallery publisher eula. - :paramtype eula: str - :keyword public_name_prefix: Community gallery public name prefix. - :paramtype public_name_prefix: str - """ - super().__init__(**kwargs) - self.publisher_uri = publisher_uri - self.publisher_contact = publisher_contact - self.eula = eula - self.public_name_prefix = public_name_prefix - self.community_gallery_enabled: Optional[bool] = None - self.public_names: Optional[List[str]] = None - - -class DiskImageEncryption(_serialization.Model): - """This is the disk image encryption base class. - - :ivar disk_encryption_set_id: A relative URI containing the resource ID of the disk encryption - set. - :vartype disk_encryption_set_id: str - """ - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - } - - def __init__(self, *, disk_encryption_set_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword disk_encryption_set_id: A relative URI containing the resource ID of the disk - encryption set. - :paramtype disk_encryption_set_id: str - """ - super().__init__(**kwargs) - self.disk_encryption_set_id = disk_encryption_set_id - - -class DataDiskImageEncryption(DiskImageEncryption): - """Contains encryption settings for a data disk image. - - All required parameters must be populated in order to send to server. - - :ivar disk_encryption_set_id: A relative URI containing the resource ID of the disk encryption - set. - :vartype disk_encryption_set_id: str - :ivar 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. - :vartype lun: int - """ - - _validation = { - "lun": {"required": True}, - } - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__(self, *, lun: int, disk_encryption_set_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword disk_encryption_set_id: A relative URI containing the resource ID of the disk - encryption set. - :paramtype disk_encryption_set_id: str - :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__(disk_encryption_set_id=disk_encryption_set_id, **kwargs) - self.lun = lun - - -class Disallowed(_serialization.Model): - """Describes the disallowed disk types. - - :ivar disk_types: A list of disk types. - :vartype disk_types: list[str] - """ - - _attribute_map = { - "disk_types": {"key": "diskTypes", "type": "[str]"}, - } - - def __init__(self, *, disk_types: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword disk_types: A list of disk types. - :paramtype disk_types: list[str] - """ - super().__init__(**kwargs) - self.disk_types = disk_types - - -class EncryptionImages(_serialization.Model): - """Optional. Allows users to provide customer managed keys for encrypting the OS and data disks in - the gallery artifact. - - :ivar os_disk_image: Contains encryption settings for an OS disk image. - :vartype os_disk_image: ~azure.mgmt.compute.v2021_10_01.models.OSDiskImageEncryption - :ivar data_disk_images: A list of encryption specifications for data disk images. - :vartype data_disk_images: list[~azure.mgmt.compute.v2021_10_01.models.DataDiskImageEncryption] - """ - - _attribute_map = { - "os_disk_image": {"key": "osDiskImage", "type": "OSDiskImageEncryption"}, - "data_disk_images": {"key": "dataDiskImages", "type": "[DataDiskImageEncryption]"}, - } - - def __init__( - self, - *, - os_disk_image: Optional["_models.OSDiskImageEncryption"] = None, - data_disk_images: Optional[List["_models.DataDiskImageEncryption"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_disk_image: Contains encryption settings for an OS disk image. - :paramtype os_disk_image: ~azure.mgmt.compute.v2021_10_01.models.OSDiskImageEncryption - :keyword data_disk_images: A list of encryption specifications for data disk images. - :paramtype data_disk_images: - list[~azure.mgmt.compute.v2021_10_01.models.DataDiskImageEncryption] - """ - super().__init__(**kwargs) - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - - -class Resource(_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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - - -class Gallery(Resource): - """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. - :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] - :ivar description: The description of this Shared Image Gallery resource. This property is - updatable. - :vartype description: str - :ivar identifier: Describes the gallery unique name. - :vartype identifier: ~azure.mgmt.compute.v2021_10_01.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2021_10_01.models.GalleryPropertiesProvisioningState - :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. - :vartype sharing_profile: ~azure.mgmt.compute.v2021_10_01.models.SharingProfile - :ivar soft_delete_policy: Contains information about the soft deletion policy of the gallery. - :vartype soft_delete_policy: ~azure.mgmt.compute.v2021_10_01.models.SoftDeletePolicy - :ivar sharing_status: Sharing status of current gallery. - :vartype sharing_status: ~azure.mgmt.compute.v2021_10_01.models.SharingStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "sharing_status": {"readonly": 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}"}, - "description": {"key": "properties.description", "type": "str"}, - "identifier": {"key": "properties.identifier", "type": "GalleryIdentifier"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "sharing_profile": {"key": "properties.sharingProfile", "type": "SharingProfile"}, - "soft_delete_policy": {"key": "properties.softDeletePolicy", "type": "SoftDeletePolicy"}, - "sharing_status": {"key": "properties.sharingStatus", "type": "SharingStatus"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - identifier: Optional["_models.GalleryIdentifier"] = None, - sharing_profile: Optional["_models.SharingProfile"] = None, - soft_delete_policy: Optional["_models.SoftDeletePolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this Shared Image Gallery resource. This property is - updatable. - :paramtype description: str - :keyword identifier: Describes the gallery unique name. - :paramtype identifier: ~azure.mgmt.compute.v2021_10_01.models.GalleryIdentifier - :keyword sharing_profile: Profile for gallery sharing to subscription or tenant. - :paramtype sharing_profile: ~azure.mgmt.compute.v2021_10_01.models.SharingProfile - :keyword soft_delete_policy: Contains information about the soft deletion policy of the - gallery. - :paramtype soft_delete_policy: ~azure.mgmt.compute.v2021_10_01.models.SoftDeletePolicy - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.identifier = identifier - self.provisioning_state: Optional[Union[str, "_models.GalleryPropertiesProvisioningState"]] = None - self.sharing_profile = sharing_profile - self.soft_delete_policy = soft_delete_policy - self.sharing_status: Optional["_models.SharingStatus"] = None - - -class GalleryApplication(Resource): - """Specifies information about the gallery Application 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. - :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] - :ivar description: The description of this gallery Application Definition resource. This - property is updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery Application Definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar supported_os_type: This property allows you to specify the supported type of the OS that - application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :vartype supported_os_type: str or ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemTypes - """ - - _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}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "supported_os_type": {"key": "properties.supportedOSType", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery Application Definition resource. This - property is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery Application Definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: str - :keyword end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword supported_os_type: This property allows you to specify the supported type of the OS - that application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :paramtype supported_os_type: str or - ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemTypes - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.end_of_life_date = end_of_life_date - self.supported_os_type = supported_os_type - - -class GalleryApplicationList(_serialization.Model): - """The List Gallery Applications operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of Gallery Applications. Required. - :vartype value: list[~azure.mgmt.compute.v2021_10_01.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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryApplication]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.GalleryApplication"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of Gallery Applications. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_10_01.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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class UpdateResourceDefinition(_serialization.Model): - """The Update Resource model definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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 = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.tags = tags - - -class GalleryApplicationUpdate(UpdateResourceDefinition): - """Specifies information about the gallery Application Definition that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar description: The description of this gallery Application Definition resource. This - property is updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery Application Definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar supported_os_type: This property allows you to specify the supported type of the OS that - application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :vartype supported_os_type: str or ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemTypes - """ - - _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"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "supported_os_type": {"key": "properties.supportedOSType", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery Application Definition resource. This - property is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery Application Definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: str - :keyword end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword supported_os_type: This property allows you to specify the supported type of the OS - that application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :paramtype supported_os_type: str or - ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemTypes - """ - super().__init__(tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.end_of_life_date = end_of_life_date - self.supported_os_type = supported_os_type - - -class GalleryApplicationVersion(Resource): - """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. - :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] - :ivar publishing_profile: The publishing profile of a gallery image version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersionPropertiesProvisioningState - :ivar replication_status: This is the replication status of the gallery image version. - :vartype replication_status: ~azure.mgmt.compute.v2021_10_01.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": 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}"}, - "publishing_profile": { - "key": "properties.publishingProfile", - "type": "GalleryApplicationVersionPublishingProfile", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersionPublishingProfile - """ - super().__init__(location=location, tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[ - Union[str, "_models.GalleryApplicationVersionPropertiesProvisioningState"] - ] = None - self.replication_status: Optional["_models.ReplicationStatus"] = None - - -class GalleryApplicationVersionList(_serialization.Model): - """The List Gallery Application version operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of gallery Application Versions. Required. - :vartype value: list[~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersion] - :ivar next_link: The uri to fetch the next page of gallery Application Versions. Call - ListNext() with this to fetch the next page of gallery Application Versions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryApplicationVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.GalleryApplicationVersion"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of gallery Application Versions. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersion] - :keyword next_link: The uri to fetch the next page of gallery Application Versions. Call - ListNext() with this to fetch the next page of gallery Application Versions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryArtifactPublishingProfileBase(_serialization.Model): - """Describes the basic gallery artifact publishing profile. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar target_regions: The target regions where the Image Version is going to be replicated to. - This property is updatable. - :vartype target_regions: list[~azure.mgmt.compute.v2021_10_01.models.TargetRegion] - :ivar replica_count: The number of replicas of the Image Version to be created per region. This - property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :vartype replica_count: int - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar published_date: The timestamp for when the gallery image version is published. - :vartype published_date: ~datetime.datetime - :ivar end_of_life_date: The end of life date of the gallery image version. This property can be - used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "Premium_LRS", and "StandardSSD_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType - :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Known values are: "Full" and "Shallow". - :vartype replication_mode: str or ~azure.mgmt.compute.v2021_10_01.models.ReplicationMode - :ivar target_extended_locations: The target extended locations where the Image Version is going - to be replicated to. This property is updatable. - :vartype target_extended_locations: - list[~azure.mgmt.compute.v2021_10_01.models.GalleryTargetExtendedLocation] - """ - - _validation = { - "published_date": {"readonly": True}, - } - - _attribute_map = { - "target_regions": {"key": "targetRegions", "type": "[TargetRegion]"}, - "replica_count": {"key": "replicaCount", "type": "int"}, - "exclude_from_latest": {"key": "excludeFromLatest", "type": "bool"}, - "published_date": {"key": "publishedDate", "type": "iso-8601"}, - "end_of_life_date": {"key": "endOfLifeDate", "type": "iso-8601"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "replication_mode": {"key": "replicationMode", "type": "str"}, - "target_extended_locations": {"key": "targetExtendedLocations", "type": "[GalleryTargetExtendedLocation]"}, - } - - def __init__( - self, - *, - target_regions: Optional[List["_models.TargetRegion"]] = None, - replica_count: Optional[int] = None, - exclude_from_latest: Optional[bool] = None, - end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, - target_extended_locations: Optional[List["_models.GalleryTargetExtendedLocation"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword target_regions: The target regions where the Image Version is going to be replicated - to. This property is updatable. - :paramtype target_regions: list[~azure.mgmt.compute.v2021_10_01.models.TargetRegion] - :keyword replica_count: The number of replicas of the Image Version to be created per region. - This property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :paramtype replica_count: int - :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 end_of_life_date: The end of life date of the gallery image version. This property can - be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "Premium_LRS", and "StandardSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType - :keyword replication_mode: Optional parameter which specifies the mode to be used for - replication. This property is not updatable. Known values are: "Full" and "Shallow". - :paramtype replication_mode: str or ~azure.mgmt.compute.v2021_10_01.models.ReplicationMode - :keyword target_extended_locations: The target extended locations where the Image Version is - going to be replicated to. This property is updatable. - :paramtype target_extended_locations: - list[~azure.mgmt.compute.v2021_10_01.models.GalleryTargetExtendedLocation] - """ - super().__init__(**kwargs) - self.target_regions = target_regions - self.replica_count = replica_count - self.exclude_from_latest = exclude_from_latest - self.published_date: Optional[datetime.datetime] = None - self.end_of_life_date = end_of_life_date - self.storage_account_type = storage_account_type - self.replication_mode = replication_mode - self.target_extended_locations = target_extended_locations - - -class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfileBase): # pylint: disable=name-too-long - """The publishing profile of a gallery image version. - - 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 target_regions: The target regions where the Image Version is going to be replicated to. - This property is updatable. - :vartype target_regions: list[~azure.mgmt.compute.v2021_10_01.models.TargetRegion] - :ivar replica_count: The number of replicas of the Image Version to be created per region. This - property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :vartype replica_count: int - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar published_date: The timestamp for when the gallery image version is published. - :vartype published_date: ~datetime.datetime - :ivar end_of_life_date: The end of life date of the gallery image version. This property can be - used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "Premium_LRS", and "StandardSSD_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType - :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Known values are: "Full" and "Shallow". - :vartype replication_mode: str or ~azure.mgmt.compute.v2021_10_01.models.ReplicationMode - :ivar target_extended_locations: The target extended locations where the Image Version is going - to be replicated to. This property is updatable. - :vartype target_extended_locations: - list[~azure.mgmt.compute.v2021_10_01.models.GalleryTargetExtendedLocation] - :ivar source: The source image from which the Image Version is going to be created. Required. - :vartype source: ~azure.mgmt.compute.v2021_10_01.models.UserArtifactSource - :ivar manage_actions: - :vartype manage_actions: ~azure.mgmt.compute.v2021_10_01.models.UserArtifactManage - :ivar enable_health_check: Optional. Whether or not this application reports health. - :vartype enable_health_check: bool - """ - - _validation = { - "published_date": {"readonly": True}, - "source": {"required": True}, - } - - _attribute_map = { - "target_regions": {"key": "targetRegions", "type": "[TargetRegion]"}, - "replica_count": {"key": "replicaCount", "type": "int"}, - "exclude_from_latest": {"key": "excludeFromLatest", "type": "bool"}, - "published_date": {"key": "publishedDate", "type": "iso-8601"}, - "end_of_life_date": {"key": "endOfLifeDate", "type": "iso-8601"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "replication_mode": {"key": "replicationMode", "type": "str"}, - "target_extended_locations": {"key": "targetExtendedLocations", "type": "[GalleryTargetExtendedLocation]"}, - "source": {"key": "source", "type": "UserArtifactSource"}, - "manage_actions": {"key": "manageActions", "type": "UserArtifactManage"}, - "enable_health_check": {"key": "enableHealthCheck", "type": "bool"}, - } - - def __init__( - self, - *, - source: "_models.UserArtifactSource", - target_regions: Optional[List["_models.TargetRegion"]] = None, - replica_count: Optional[int] = None, - exclude_from_latest: Optional[bool] = None, - end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, - target_extended_locations: Optional[List["_models.GalleryTargetExtendedLocation"]] = None, - manage_actions: Optional["_models.UserArtifactManage"] = None, - enable_health_check: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword target_regions: The target regions where the Image Version is going to be replicated - to. This property is updatable. - :paramtype target_regions: list[~azure.mgmt.compute.v2021_10_01.models.TargetRegion] - :keyword replica_count: The number of replicas of the Image Version to be created per region. - This property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :paramtype replica_count: int - :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 end_of_life_date: The end of life date of the gallery image version. This property can - be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "Premium_LRS", and "StandardSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType - :keyword replication_mode: Optional parameter which specifies the mode to be used for - replication. This property is not updatable. Known values are: "Full" and "Shallow". - :paramtype replication_mode: str or ~azure.mgmt.compute.v2021_10_01.models.ReplicationMode - :keyword target_extended_locations: The target extended locations where the Image Version is - going to be replicated to. This property is updatable. - :paramtype target_extended_locations: - list[~azure.mgmt.compute.v2021_10_01.models.GalleryTargetExtendedLocation] - :keyword source: The source image from which the Image Version is going to be created. - Required. - :paramtype source: ~azure.mgmt.compute.v2021_10_01.models.UserArtifactSource - :keyword manage_actions: - :paramtype manage_actions: ~azure.mgmt.compute.v2021_10_01.models.UserArtifactManage - :keyword enable_health_check: Optional. Whether or not this application reports health. - :paramtype enable_health_check: bool - """ - super().__init__( - target_regions=target_regions, - replica_count=replica_count, - exclude_from_latest=exclude_from_latest, - end_of_life_date=end_of_life_date, - storage_account_type=storage_account_type, - replication_mode=replication_mode, - target_extended_locations=target_extended_locations, - **kwargs - ) - self.source = source - self.manage_actions = manage_actions - self.enable_health_check = enable_health_check - - -class GalleryApplicationVersionUpdate(UpdateResourceDefinition): - """Specifies information about the gallery Application Version that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar publishing_profile: The publishing profile of a gallery image version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersionPropertiesProvisioningState - :ivar replication_status: This is the replication status of the gallery image version. - :vartype replication_status: ~azure.mgmt.compute.v2021_10_01.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "publishing_profile": { - "key": "properties.publishingProfile", - "type": "GalleryApplicationVersionPublishingProfile", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersionPublishingProfile - """ - super().__init__(tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[ - Union[str, "_models.GalleryApplicationVersionPropertiesProvisioningState"] - ] = None - self.replication_status: Optional["_models.ReplicationStatus"] = 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.v2021_10_01.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.v2021_10_01.models.ManagedArtifact - """ - super().__init__(**kwargs) - self.managed_image = managed_image - - -class GalleryArtifactVersionSource(_serialization.Model): - """The gallery artifact version source. - - :ivar id: The id of the gallery artifact version source. Can specify a disk uri, snapshot uri, - user image or storage account resource. - :vartype id: str - :ivar uri: The uri of the gallery artifact version source. Currently used to specify vhd/blob - source. - :vartype uri: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "uri": {"key": "uri", "type": "str"}, - } - - def __init__( - self, *, id: Optional[str] = None, uri: Optional[str] = None, **kwargs: Any # pylint: disable=redefined-builtin - ) -> None: - """ - :keyword id: The id of the gallery artifact version source. Can specify a disk uri, snapshot - uri, user image or storage account resource. - :paramtype id: str - :keyword uri: The uri of the gallery artifact version source. Currently used to specify - vhd/blob source. - :paramtype uri: str - """ - super().__init__(**kwargs) - self.id = id - self.uri = uri - - -class GalleryDiskImage(_serialization.Model): - """This is the disk image base class. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar size_in_gb: This property indicates the size of the VHD to be created. - :vartype size_in_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2021_10_01.models.HostCaching - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2021_10_01.models.GalleryArtifactVersionSource - """ - - _validation = { - "size_in_gb": {"readonly": True}, - } - - _attribute_map = { - "size_in_gb": {"key": "sizeInGB", "type": "int"}, - "host_caching": {"key": "hostCaching", "type": "str"}, - "source": {"key": "source", "type": "GalleryArtifactVersionSource"}, - } - - def __init__( - self, - *, - host_caching: Optional[Union[str, "_models.HostCaching"]] = None, - source: Optional["_models.GalleryArtifactVersionSource"] = 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.v2021_10_01.models.HostCaching - :keyword source: The gallery artifact version source. - :paramtype source: ~azure.mgmt.compute.v2021_10_01.models.GalleryArtifactVersionSource - """ - super().__init__(**kwargs) - self.size_in_gb: Optional[int] = None - self.host_caching = host_caching - self.source = source - - -class GalleryDataDiskImage(GalleryDiskImage): - """This is the data disk 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 size_in_gb: This property indicates the size of the VHD to be created. - :vartype size_in_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2021_10_01.models.HostCaching - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2021_10_01.models.GalleryArtifactVersionSource - :ivar 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. - :vartype lun: int - """ - - _validation = { - "size_in_gb": {"readonly": True}, - "lun": {"required": True}, - } - - _attribute_map = { - "size_in_gb": {"key": "sizeInGB", "type": "int"}, - "host_caching": {"key": "hostCaching", "type": "str"}, - "source": {"key": "source", "type": "GalleryArtifactVersionSource"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__( - self, - *, - lun: int, - host_caching: Optional[Union[str, "_models.HostCaching"]] = None, - source: Optional["_models.GalleryArtifactVersionSource"] = 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.v2021_10_01.models.HostCaching - :keyword source: The gallery artifact version source. - :paramtype source: ~azure.mgmt.compute.v2021_10_01.models.GalleryArtifactVersionSource - :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, source=source, **kwargs) - self.lun = lun - - -class GalleryExtendedLocation(_serialization.Model): - """The name of the extended location. - - :ivar name: - :vartype name: str - :ivar type: It is type of the extended location. Known values are: "EdgeZone" and "Unknown". - :vartype type: str or ~azure.mgmt.compute.v2021_10_01.models.GalleryExtendedLocationType - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[Union[str, "_models.GalleryExtendedLocationType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: - :paramtype name: str - :keyword type: It is type of the extended location. Known values are: "EdgeZone" and "Unknown". - :paramtype type: str or ~azure.mgmt.compute.v2021_10_01.models.GalleryExtendedLocationType - """ - super().__init__(**kwargs) - self.name = name - self.type = type - - -class GalleryIdentifier(_serialization.Model): - """Describes the gallery unique name. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar unique_name: The unique name of the Shared Image Gallery. This name is generated - automatically by Azure. - :vartype unique_name: str - """ - - _validation = { - "unique_name": {"readonly": True}, - } - - _attribute_map = { - "unique_name": {"key": "uniqueName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.unique_name: Optional[str] = None - - -class GalleryImage(Resource): - """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. - :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] - :ivar description: The description of this gallery image definition resource. This property is - updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery image definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar 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. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values - are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemTypes - :ivar 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". - :vartype os_state: str or ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemStateTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_10_01.models.HyperVGeneration - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar identifier: This is the gallery image definition identifier. - :vartype identifier: ~azure.mgmt.compute.v2021_10_01.models.GalleryImageIdentifier - :ivar recommended: The properties describe the recommended machine configuration for this Image - Definition. These properties are updatable. - :vartype recommended: ~azure.mgmt.compute.v2021_10_01.models.RecommendedMachineConfiguration - :ivar disallowed: Describes the disallowed disk types. - :vartype disallowed: ~azure.mgmt.compute.v2021_10_01.models.Disallowed - :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :vartype purchase_plan: ~azure.mgmt.compute.v2021_10_01.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2021_10_01.models.GalleryImagePropertiesProvisioningState - :ivar features: A list of gallery image features. - :vartype features: list[~azure.mgmt.compute.v2021_10_01.models.GalleryImageFeature] - :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values - are: "x64" and "Arm64". - :vartype architecture: str or ~azure.mgmt.compute.v2021_10_01.models.Architecture - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "os_state": {"key": "properties.osState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, - "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "features": {"key": "properties.features", "type": "[GalleryImageFeature]"}, - "architecture": {"key": "properties.architecture", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["_models.GalleryImageIdentifier"] = None, - recommended: Optional["_models.RecommendedMachineConfiguration"] = None, - disallowed: Optional["_models.Disallowed"] = None, - purchase_plan: Optional["_models.ImagePurchasePlan"] = None, - features: Optional[List["_models.GalleryImageFeature"]] = None, - architecture: Optional[Union[str, "_models.Architecture"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery image definition resource. This property - is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery image definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: 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. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2021_10_01.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.v2021_10_01.models.OperatingSystemStateTypes - :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.v2021_10_01.models.HyperVGeneration - :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.v2021_10_01.models.GalleryImageIdentifier - :keyword recommended: The properties describe the recommended machine configuration for this - Image Definition. These properties are updatable. - :paramtype recommended: ~azure.mgmt.compute.v2021_10_01.models.RecommendedMachineConfiguration - :keyword disallowed: Describes the disallowed disk types. - :paramtype disallowed: ~azure.mgmt.compute.v2021_10_01.models.Disallowed - :keyword purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :paramtype purchase_plan: ~azure.mgmt.compute.v2021_10_01.models.ImagePurchasePlan - :keyword features: A list of gallery image features. - :paramtype features: list[~azure.mgmt.compute.v2021_10_01.models.GalleryImageFeature] - :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.v2021_10_01.models.Architecture - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.os_type = os_type - self.os_state = os_state - self.hyper_v_generation = hyper_v_generation - self.end_of_life_date = end_of_life_date - self.identifier = identifier - self.recommended = recommended - self.disallowed = disallowed - self.purchase_plan = purchase_plan - self.provisioning_state: Optional[Union[str, "_models.GalleryImagePropertiesProvisioningState"]] = None - self.features = features - self.architecture = architecture - - -class GalleryImageFeature(_serialization.Model): - """A feature for gallery image. - - :ivar name: The name of the gallery image feature. - :vartype name: str - :ivar value: The value of the gallery image feature. - :vartype value: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: The name of the gallery image feature. - :paramtype name: str - :keyword value: The value of the gallery image feature. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class GalleryImageIdentifier(_serialization.Model): - """This is the gallery image definition identifier. - - All required parameters must be populated in order to send to server. - - :ivar publisher: The name of the gallery image definition publisher. Required. - :vartype publisher: str - :ivar offer: The name of the gallery image definition offer. Required. - :vartype offer: str - :ivar sku: The name of the gallery image definition SKU. Required. - :vartype sku: str - """ - - _validation = { - "publisher": {"required": True}, - "offer": {"required": True}, - "sku": {"required": True}, - } - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "offer": {"key": "offer", "type": "str"}, - "sku": {"key": "sku", "type": "str"}, - } - - def __init__(self, *, publisher: str, offer: str, sku: str, **kwargs: Any) -> None: - """ - :keyword publisher: The name of the gallery image definition publisher. Required. - :paramtype publisher: str - :keyword offer: The name of the gallery image definition offer. Required. - :paramtype offer: str - :keyword sku: The name of the gallery image definition SKU. Required. - :paramtype sku: str - """ - super().__init__(**kwargs) - self.publisher = publisher - self.offer = offer - self.sku = sku - - -class GalleryImageList(_serialization.Model): - """The List Gallery Images operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of Shared Image Gallery images. Required. - :vartype value: list[~azure.mgmt.compute.v2021_10_01.models.GalleryImage] - :ivar next_link: The uri to fetch the next page of Image Definitions in the Shared Image - Gallery. Call ListNext() with this to fetch the next page of gallery image definitions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryImage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.GalleryImage"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of Shared Image Gallery images. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_10_01.models.GalleryImage] - :keyword next_link: The uri to fetch the next page of Image Definitions in the Shared Image - Gallery. Call ListNext() with this to fetch the next page of gallery image definitions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryImageUpdate(UpdateResourceDefinition): - """Specifies information about the gallery image definition that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar description: The description of this gallery image definition resource. This property is - updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery image definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar 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. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values - are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemTypes - :ivar 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". - :vartype os_state: str or ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemStateTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_10_01.models.HyperVGeneration - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar identifier: This is the gallery image definition identifier. - :vartype identifier: ~azure.mgmt.compute.v2021_10_01.models.GalleryImageIdentifier - :ivar recommended: The properties describe the recommended machine configuration for this Image - Definition. These properties are updatable. - :vartype recommended: ~azure.mgmt.compute.v2021_10_01.models.RecommendedMachineConfiguration - :ivar disallowed: Describes the disallowed disk types. - :vartype disallowed: ~azure.mgmt.compute.v2021_10_01.models.Disallowed - :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :vartype purchase_plan: ~azure.mgmt.compute.v2021_10_01.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2021_10_01.models.GalleryImagePropertiesProvisioningState - :ivar features: A list of gallery image features. - :vartype features: list[~azure.mgmt.compute.v2021_10_01.models.GalleryImageFeature] - :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values - are: "x64" and "Arm64". - :vartype architecture: str or ~azure.mgmt.compute.v2021_10_01.models.Architecture - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "os_state": {"key": "properties.osState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, - "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "features": {"key": "properties.features", "type": "[GalleryImageFeature]"}, - "architecture": {"key": "properties.architecture", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["_models.GalleryImageIdentifier"] = None, - recommended: Optional["_models.RecommendedMachineConfiguration"] = None, - disallowed: Optional["_models.Disallowed"] = None, - purchase_plan: Optional["_models.ImagePurchasePlan"] = None, - features: Optional[List["_models.GalleryImageFeature"]] = None, - architecture: Optional[Union[str, "_models.Architecture"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery image definition resource. This property - is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery image definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: 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. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2021_10_01.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.v2021_10_01.models.OperatingSystemStateTypes - :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.v2021_10_01.models.HyperVGeneration - :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.v2021_10_01.models.GalleryImageIdentifier - :keyword recommended: The properties describe the recommended machine configuration for this - Image Definition. These properties are updatable. - :paramtype recommended: ~azure.mgmt.compute.v2021_10_01.models.RecommendedMachineConfiguration - :keyword disallowed: Describes the disallowed disk types. - :paramtype disallowed: ~azure.mgmt.compute.v2021_10_01.models.Disallowed - :keyword purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :paramtype purchase_plan: ~azure.mgmt.compute.v2021_10_01.models.ImagePurchasePlan - :keyword features: A list of gallery image features. - :paramtype features: list[~azure.mgmt.compute.v2021_10_01.models.GalleryImageFeature] - :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.v2021_10_01.models.Architecture - """ - super().__init__(tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.os_type = os_type - self.os_state = os_state - self.hyper_v_generation = hyper_v_generation - self.end_of_life_date = end_of_life_date - self.identifier = identifier - self.recommended = recommended - self.disallowed = disallowed - self.purchase_plan = purchase_plan - self.provisioning_state: Optional[Union[str, "_models.GalleryImagePropertiesProvisioningState"]] = None - self.features = features - self.architecture = architecture - - -class GalleryImageVersion(Resource): - """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. - :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] - :ivar publishing_profile: The publishing profile of a gallery image Version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersionPropertiesProvisioningState - :ivar storage_profile: This is the storage profile of a Gallery Image Version. - :vartype storage_profile: - ~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersionStorageProfile - :ivar replication_status: This is the replication status of the gallery image version. - :vartype replication_status: ~azure.mgmt.compute.v2021_10_01.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": 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}"}, - "publishing_profile": {"key": "properties.publishingProfile", "type": "GalleryImageVersionPublishingProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image Version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersionPublishingProfile - :keyword storage_profile: This is the storage profile of a Gallery Image Version. - :paramtype storage_profile: - ~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersionStorageProfile - """ - super().__init__(location=location, tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[Union[str, "_models.GalleryImageVersionPropertiesProvisioningState"]] = None - self.storage_profile = storage_profile - self.replication_status: Optional["_models.ReplicationStatus"] = None - - -class GalleryImageVersionList(_serialization.Model): - """The List Gallery Image version operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of gallery image versions. Required. - :vartype value: list[~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersion] - :ivar next_link: The uri to fetch the next page of gallery image versions. Call ListNext() with - this to fetch the next page of gallery image versions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryImageVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.GalleryImageVersion"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of gallery image versions. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersion] - :keyword next_link: The uri to fetch the next page of gallery image versions. Call ListNext() - with this to fetch the next page of gallery image versions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase): - """The publishing profile of a gallery image Version. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar target_regions: The target regions where the Image Version is going to be replicated to. - This property is updatable. - :vartype target_regions: list[~azure.mgmt.compute.v2021_10_01.models.TargetRegion] - :ivar replica_count: The number of replicas of the Image Version to be created per region. This - property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :vartype replica_count: int - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar published_date: The timestamp for when the gallery image version is published. - :vartype published_date: ~datetime.datetime - :ivar end_of_life_date: The end of life date of the gallery image version. This property can be - used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "Premium_LRS", and "StandardSSD_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType - :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Known values are: "Full" and "Shallow". - :vartype replication_mode: str or ~azure.mgmt.compute.v2021_10_01.models.ReplicationMode - :ivar target_extended_locations: The target extended locations where the Image Version is going - to be replicated to. This property is updatable. - :vartype target_extended_locations: - list[~azure.mgmt.compute.v2021_10_01.models.GalleryTargetExtendedLocation] - """ - - -class GalleryImageVersionStorageProfile(_serialization.Model): - """This is the storage profile of a Gallery Image Version. - - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2021_10_01.models.GalleryArtifactVersionSource - :ivar os_disk_image: This is the OS disk image. - :vartype os_disk_image: ~azure.mgmt.compute.v2021_10_01.models.GalleryOSDiskImage - :ivar data_disk_images: A list of data disk images. - :vartype data_disk_images: list[~azure.mgmt.compute.v2021_10_01.models.GalleryDataDiskImage] - """ - - _attribute_map = { - "source": {"key": "source", "type": "GalleryArtifactVersionSource"}, - "os_disk_image": {"key": "osDiskImage", "type": "GalleryOSDiskImage"}, - "data_disk_images": {"key": "dataDiskImages", "type": "[GalleryDataDiskImage]"}, - } - - def __init__( - self, - *, - source: Optional["_models.GalleryArtifactVersionSource"] = None, - os_disk_image: Optional["_models.GalleryOSDiskImage"] = None, - data_disk_images: Optional[List["_models.GalleryDataDiskImage"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source: The gallery artifact version source. - :paramtype source: ~azure.mgmt.compute.v2021_10_01.models.GalleryArtifactVersionSource - :keyword os_disk_image: This is the OS disk image. - :paramtype os_disk_image: ~azure.mgmt.compute.v2021_10_01.models.GalleryOSDiskImage - :keyword data_disk_images: A list of data disk images. - :paramtype data_disk_images: list[~azure.mgmt.compute.v2021_10_01.models.GalleryDataDiskImage] - """ - super().__init__(**kwargs) - self.source = source - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - - -class GalleryImageVersionUpdate(UpdateResourceDefinition): - """Specifies information about the gallery image version that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar publishing_profile: The publishing profile of a gallery image Version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersionPropertiesProvisioningState - :ivar storage_profile: This is the storage profile of a Gallery Image Version. - :vartype storage_profile: - ~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersionStorageProfile - :ivar replication_status: This is the replication status of the gallery image version. - :vartype replication_status: ~azure.mgmt.compute.v2021_10_01.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "publishing_profile": {"key": "properties.publishingProfile", "type": "GalleryImageVersionPublishingProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image Version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersionPublishingProfile - :keyword storage_profile: This is the storage profile of a Gallery Image Version. - :paramtype storage_profile: - ~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersionStorageProfile - """ - super().__init__(tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[Union[str, "_models.GalleryImageVersionPropertiesProvisioningState"]] = None - self.storage_profile = storage_profile - self.replication_status: Optional["_models.ReplicationStatus"] = None - - -class GalleryList(_serialization.Model): - """The List Galleries operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of galleries. Required. - :vartype value: list[~azure.mgmt.compute.v2021_10_01.models.Gallery] - :ivar next_link: The uri to fetch the next page of galleries. Call ListNext() with this to - fetch the next page of galleries. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Gallery]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Gallery"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of galleries. Required. - :paramtype value: list[~azure.mgmt.compute.v2021_10_01.models.Gallery] - :keyword next_link: The uri to fetch the next page of galleries. Call ListNext() with this to - fetch the next page of galleries. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryOSDiskImage(GalleryDiskImage): - """This is the OS disk image. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar size_in_gb: This property indicates the size of the VHD to be created. - :vartype size_in_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2021_10_01.models.HostCaching - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2021_10_01.models.GalleryArtifactVersionSource - """ - - -class GalleryTargetExtendedLocation(_serialization.Model): - """GalleryTargetExtendedLocation. - - :ivar name: The name of the region. - :vartype name: str - :ivar extended_location: The name of the extended location. - :vartype extended_location: ~azure.mgmt.compute.v2021_10_01.models.GalleryExtendedLocation - :ivar extended_location_replica_count: The number of replicas of the Image Version to be - created per extended location. This property is updatable. - :vartype extended_location_replica_count: int - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "Premium_LRS", and "StandardSSD_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType - :ivar encryption: Optional. Allows users to provide customer managed keys for encrypting the OS - and data disks in the gallery artifact. - :vartype encryption: ~azure.mgmt.compute.v2021_10_01.models.EncryptionImages - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "extended_location": {"key": "extendedLocation", "type": "GalleryExtendedLocation"}, - "extended_location_replica_count": {"key": "extendedLocationReplicaCount", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "encryption": {"key": "encryption", "type": "EncryptionImages"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - extended_location: Optional["_models.GalleryExtendedLocation"] = None, - extended_location_replica_count: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - encryption: Optional["_models.EncryptionImages"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the region. - :paramtype name: str - :keyword extended_location: The name of the extended location. - :paramtype extended_location: ~azure.mgmt.compute.v2021_10_01.models.GalleryExtendedLocation - :keyword extended_location_replica_count: The number of replicas of the Image Version to be - created per extended location. This property is updatable. - :paramtype extended_location_replica_count: int - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "Premium_LRS", and "StandardSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType - :keyword encryption: Optional. Allows users to provide customer managed keys for encrypting the - OS and data disks in the gallery artifact. - :paramtype encryption: ~azure.mgmt.compute.v2021_10_01.models.EncryptionImages - """ - super().__init__(**kwargs) - self.name = name - self.extended_location = extended_location - self.extended_location_replica_count = extended_location_replica_count - self.storage_account_type = storage_account_type - self.encryption = encryption - - -class GalleryUpdate(UpdateResourceDefinition): - """Specifies information about the Shared Image Gallery that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar description: The description of this Shared Image Gallery resource. This property is - updatable. - :vartype description: str - :ivar identifier: Describes the gallery unique name. - :vartype identifier: ~azure.mgmt.compute.v2021_10_01.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2021_10_01.models.GalleryPropertiesProvisioningState - :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. - :vartype sharing_profile: ~azure.mgmt.compute.v2021_10_01.models.SharingProfile - :ivar soft_delete_policy: Contains information about the soft deletion policy of the gallery. - :vartype soft_delete_policy: ~azure.mgmt.compute.v2021_10_01.models.SoftDeletePolicy - :ivar sharing_status: Sharing status of current gallery. - :vartype sharing_status: ~azure.mgmt.compute.v2021_10_01.models.SharingStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "sharing_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "identifier": {"key": "properties.identifier", "type": "GalleryIdentifier"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "sharing_profile": {"key": "properties.sharingProfile", "type": "SharingProfile"}, - "soft_delete_policy": {"key": "properties.softDeletePolicy", "type": "SoftDeletePolicy"}, - "sharing_status": {"key": "properties.sharingStatus", "type": "SharingStatus"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - identifier: Optional["_models.GalleryIdentifier"] = None, - sharing_profile: Optional["_models.SharingProfile"] = None, - soft_delete_policy: Optional["_models.SoftDeletePolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this Shared Image Gallery resource. This property is - updatable. - :paramtype description: str - :keyword identifier: Describes the gallery unique name. - :paramtype identifier: ~azure.mgmt.compute.v2021_10_01.models.GalleryIdentifier - :keyword sharing_profile: Profile for gallery sharing to subscription or tenant. - :paramtype sharing_profile: ~azure.mgmt.compute.v2021_10_01.models.SharingProfile - :keyword soft_delete_policy: Contains information about the soft deletion policy of the - gallery. - :paramtype soft_delete_policy: ~azure.mgmt.compute.v2021_10_01.models.SoftDeletePolicy - """ - super().__init__(tags=tags, **kwargs) - self.description = description - self.identifier = identifier - self.provisioning_state: Optional[Union[str, "_models.GalleryPropertiesProvisioningState"]] = None - self.sharing_profile = sharing_profile - self.soft_delete_policy = soft_delete_policy - self.sharing_status: Optional["_models.SharingStatus"] = None - - -class ImagePurchasePlan(_serialization.Model): - """Describes the gallery image definition purchase plan. This is used by marketplace images. - - :ivar name: The plan ID. - :vartype name: str - :ivar publisher: The publisher ID. - :vartype publisher: str - :ivar product: The product ID. - :vartype product: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - publisher: Optional[str] = None, - product: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The plan ID. - :paramtype name: str - :keyword publisher: The publisher ID. - :paramtype publisher: str - :keyword product: The product ID. - :paramtype product: str - """ - super().__init__(**kwargs) - self.name = name - self.publisher = publisher - self.product = product - - -class InnerError(_serialization.Model): - """Inner error details. - - :ivar exceptiontype: The exception type. - :vartype exceptiontype: str - :ivar errordetail: The internal error message or exception dump. - :vartype errordetail: str - """ - - _attribute_map = { - "exceptiontype": {"key": "exceptiontype", "type": "str"}, - "errordetail": {"key": "errordetail", "type": "str"}, - } - - def __init__( - self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword exceptiontype: The exception type. - :paramtype exceptiontype: str - :keyword errordetail: The internal error message or exception dump. - :paramtype errordetail: str - """ - super().__init__(**kwargs) - self.exceptiontype = exceptiontype - self.errordetail = errordetail - - -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. - - :ivar disk_encryption_set_id: A relative URI containing the resource ID of the disk encryption - set. - :vartype disk_encryption_set_id: str - :ivar security_profile: This property specifies the security profile of an OS disk image. - :vartype security_profile: ~azure.mgmt.compute.v2021_10_01.models.OSDiskImageSecurityProfile - """ - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - "security_profile": {"key": "securityProfile", "type": "OSDiskImageSecurityProfile"}, - } - - def __init__( - self, - *, - disk_encryption_set_id: Optional[str] = None, - security_profile: Optional["_models.OSDiskImageSecurityProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_set_id: A relative URI containing the resource ID of the disk - encryption set. - :paramtype disk_encryption_set_id: str - :keyword security_profile: This property specifies the security profile of an OS disk image. - :paramtype security_profile: ~azure.mgmt.compute.v2021_10_01.models.OSDiskImageSecurityProfile - """ - super().__init__(disk_encryption_set_id=disk_encryption_set_id, **kwargs) - self.security_profile = security_profile - - -class OSDiskImageSecurityProfile(_serialization.Model): - """Contains security profile for an OS disk image. - - :ivar confidential_vm_encryption_type: confidential VM encryption types. Known values are: - "EncryptedVMGuestStateOnlyWithPmk", "EncryptedWithPmk", and "EncryptedWithCmk". - :vartype confidential_vm_encryption_type: str or - ~azure.mgmt.compute.v2021_10_01.models.ConfidentialVMEncryptionType - :ivar secure_vm_disk_encryption_set_id: secure VM disk encryption set id. - :vartype secure_vm_disk_encryption_set_id: str - """ - - _attribute_map = { - "confidential_vm_encryption_type": {"key": "confidentialVMEncryptionType", "type": "str"}, - "secure_vm_disk_encryption_set_id": {"key": "secureVMDiskEncryptionSetId", "type": "str"}, - } - - def __init__( - self, - *, - confidential_vm_encryption_type: Optional[Union[str, "_models.ConfidentialVMEncryptionType"]] = None, - secure_vm_disk_encryption_set_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword confidential_vm_encryption_type: confidential VM encryption types. Known values are: - "EncryptedVMGuestStateOnlyWithPmk", "EncryptedWithPmk", and "EncryptedWithCmk". - :paramtype confidential_vm_encryption_type: str or - ~azure.mgmt.compute.v2021_10_01.models.ConfidentialVMEncryptionType - :keyword secure_vm_disk_encryption_set_id: secure VM disk encryption set id. - :paramtype secure_vm_disk_encryption_set_id: str - """ - super().__init__(**kwargs) - self.confidential_vm_encryption_type = confidential_vm_encryption_type - self.secure_vm_disk_encryption_set_id = secure_vm_disk_encryption_set_id - - -class RecommendedMachineConfiguration(_serialization.Model): - """The properties describe the recommended machine configuration for this Image Definition. These - properties are updatable. - - :ivar v_cp_us: Describes the resource range. - :vartype v_cp_us: ~azure.mgmt.compute.v2021_10_01.models.ResourceRange - :ivar memory: Describes the resource range. - :vartype memory: ~azure.mgmt.compute.v2021_10_01.models.ResourceRange - """ - - _attribute_map = { - "v_cp_us": {"key": "vCPUs", "type": "ResourceRange"}, - "memory": {"key": "memory", "type": "ResourceRange"}, - } - - def __init__( - self, - *, - v_cp_us: Optional["_models.ResourceRange"] = None, - memory: Optional["_models.ResourceRange"] = None, - **kwargs: Any - ) -> None: - """ - :keyword v_cp_us: Describes the resource range. - :paramtype v_cp_us: ~azure.mgmt.compute.v2021_10_01.models.ResourceRange - :keyword memory: Describes the resource range. - :paramtype memory: ~azure.mgmt.compute.v2021_10_01.models.ResourceRange - """ - super().__init__(**kwargs) - self.v_cp_us = v_cp_us - self.memory = memory - - -class RegionalReplicationStatus(_serialization.Model): - """This is the regional replication status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar region: The region to which the gallery image version is being replicated to. - :vartype region: str - :ivar state: This is the regional replication state. Known values are: "Unknown", - "Replicating", "Completed", and "Failed". - :vartype state: str or ~azure.mgmt.compute.v2021_10_01.models.ReplicationState - :ivar details: The details of the replication status. - :vartype details: str - :ivar progress: It indicates progress of the replication job. - :vartype progress: int - """ - - _validation = { - "region": {"readonly": True}, - "state": {"readonly": True}, - "details": {"readonly": True}, - "progress": {"readonly": True}, - } - - _attribute_map = { - "region": {"key": "region", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "details": {"key": "details", "type": "str"}, - "progress": {"key": "progress", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.region: Optional[str] = None - self.state: Optional[Union[str, "_models.ReplicationState"]] = None - self.details: Optional[str] = None - self.progress: Optional[int] = None - - -class RegionalSharingStatus(_serialization.Model): - """Gallery regional sharing status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar region: Region name. - :vartype region: str - :ivar state: Gallery sharing state in current region. Known values are: "Succeeded", - "InProgress", "Failed", and "Unknown". - :vartype state: str or ~azure.mgmt.compute.v2021_10_01.models.SharingState - :ivar details: Details of gallery regional sharing failure. - :vartype details: str - """ - - _validation = { - "state": {"readonly": True}, - } - - _attribute_map = { - "region": {"key": "region", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "details": {"key": "details", "type": "str"}, - } - - def __init__(self, *, region: Optional[str] = None, details: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword region: Region name. - :paramtype region: str - :keyword details: Details of gallery regional sharing failure. - :paramtype details: str - """ - super().__init__(**kwargs) - self.region = region - self.state: Optional[Union[str, "_models.SharingState"]] = None - self.details = details - - -class ReplicationStatus(_serialization.Model): - """This is the replication status of the gallery image version. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar aggregated_state: This is the aggregated replication status based on all the regional - replication status flags. Known values are: "Unknown", "InProgress", "Completed", and "Failed". - :vartype aggregated_state: str or - ~azure.mgmt.compute.v2021_10_01.models.AggregatedReplicationState - :ivar summary: This is a summary of replication status for each region. - :vartype summary: list[~azure.mgmt.compute.v2021_10_01.models.RegionalReplicationStatus] - """ - - _validation = { - "aggregated_state": {"readonly": True}, - "summary": {"readonly": True}, - } - - _attribute_map = { - "aggregated_state": {"key": "aggregatedState", "type": "str"}, - "summary": {"key": "summary", "type": "[RegionalReplicationStatus]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.aggregated_state: Optional[Union[str, "_models.AggregatedReplicationState"]] = None - self.summary: Optional[List["_models.RegionalReplicationStatus"]] = None - - -class ResourceRange(_serialization.Model): - """Describes the resource range. - - :ivar min: The minimum number of the resource. - :vartype min: int - :ivar max: The maximum number of the resource. - :vartype max: int - """ - - _attribute_map = { - "min": {"key": "min", "type": "int"}, - "max": {"key": "max", "type": "int"}, - } - - def __init__( - self, - *, - min: Optional[int] = None, # pylint: disable=redefined-builtin - max: Optional[int] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword min: The minimum number of the resource. - :paramtype min: int - :keyword max: The maximum number of the resource. - :paramtype max: int - """ - super().__init__(**kwargs) - self.min = min - self.max = max - - -class SharingProfile(_serialization.Model): - """Profile for gallery sharing to subscription or tenant. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar permissions: This property allows you to specify the permission of sharing gallery. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Private** - :code:`
    `\\ :code:`
    ` **Groups**. Known values are: "Private" and "Groups". - :vartype permissions: str or - ~azure.mgmt.compute.v2021_10_01.models.GallerySharingPermissionTypes - :ivar groups: A list of sharing profile groups. - :vartype groups: list[~azure.mgmt.compute.v2021_10_01.models.SharingProfileGroup] - :ivar community_gallery_info: Information of community gallery if current gallery is shared to - community. - :vartype community_gallery_info: ~azure.mgmt.compute.v2021_10_01.models.CommunityGalleryInfo - """ - - _validation = { - "groups": {"readonly": True}, - } - - _attribute_map = { - "permissions": {"key": "permissions", "type": "str"}, - "groups": {"key": "groups", "type": "[SharingProfileGroup]"}, - "community_gallery_info": {"key": "communityGalleryInfo", "type": "CommunityGalleryInfo"}, - } - - def __init__( - self, - *, - permissions: Optional[Union[str, "_models.GallerySharingPermissionTypes"]] = None, - community_gallery_info: Optional["_models.CommunityGalleryInfo"] = None, - **kwargs: Any - ) -> None: - """ - :keyword permissions: This property allows you to specify the permission of sharing gallery. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Private** - :code:`
    `\\ :code:`
    ` **Groups**. Known values are: "Private" and "Groups". - :paramtype permissions: str or - ~azure.mgmt.compute.v2021_10_01.models.GallerySharingPermissionTypes - :keyword community_gallery_info: Information of community gallery if current gallery is shared - to community. - :paramtype community_gallery_info: ~azure.mgmt.compute.v2021_10_01.models.CommunityGalleryInfo - """ - super().__init__(**kwargs) - self.permissions = permissions - self.groups: Optional[List["_models.SharingProfileGroup"]] = None - self.community_gallery_info = community_gallery_info - - -class SharingProfileGroup(_serialization.Model): - """Group of the gallery sharing profile. - - :ivar type: This property allows you to specify the type of sharing group. :code:`
    `\\ - :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Subscriptions** :code:`
    `\\ - :code:`
    ` **AADTenants** :code:`
    `\\ :code:`
    ` **Community**. Known values are: - "Subscriptions", "AADTenants", and "Community". - :vartype type: str or ~azure.mgmt.compute.v2021_10_01.models.SharingProfileGroupTypes - :ivar ids: A list of subscription/tenant ids the gallery is aimed to be shared to. - :vartype ids: list[str] - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "ids": {"key": "ids", "type": "[str]"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.SharingProfileGroupTypes"]] = None, - ids: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: This property allows you to specify the type of sharing group. :code:`
    `\\ - :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Subscriptions** :code:`
    `\\ - :code:`
    ` **AADTenants** :code:`
    `\\ :code:`
    ` **Community**. Known values are: - "Subscriptions", "AADTenants", and "Community". - :paramtype type: str or ~azure.mgmt.compute.v2021_10_01.models.SharingProfileGroupTypes - :keyword ids: A list of subscription/tenant ids the gallery is aimed to be shared to. - :paramtype ids: list[str] - """ - super().__init__(**kwargs) - self.type = type - self.ids = ids - - -class SharingStatus(_serialization.Model): - """Sharing status of current gallery. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar aggregated_state: Aggregated sharing state of current gallery. Known values are: - "Succeeded", "InProgress", "Failed", and "Unknown". - :vartype aggregated_state: str or ~azure.mgmt.compute.v2021_10_01.models.SharingState - :ivar summary: Summary of all regional sharing status. - :vartype summary: list[~azure.mgmt.compute.v2021_10_01.models.RegionalSharingStatus] - """ - - _validation = { - "aggregated_state": {"readonly": True}, - } - - _attribute_map = { - "aggregated_state": {"key": "aggregatedState", "type": "str"}, - "summary": {"key": "summary", "type": "[RegionalSharingStatus]"}, - } - - def __init__(self, *, summary: Optional[List["_models.RegionalSharingStatus"]] = None, **kwargs: Any) -> None: - """ - :keyword summary: Summary of all regional sharing status. - :paramtype summary: list[~azure.mgmt.compute.v2021_10_01.models.RegionalSharingStatus] - """ - super().__init__(**kwargs) - self.aggregated_state: Optional[Union[str, "_models.SharingState"]] = None - self.summary = summary - - -class SharingUpdate(_serialization.Model): - """Specifies information about the gallery sharing profile update. - - All required parameters must be populated in order to send to server. - - :ivar operation_type: This property allows you to specify the operation type of gallery sharing - update. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Add** - :code:`
    `\\ :code:`
    ` **Remove** :code:`
    `\\ :code:`
    ` **Reset**. Required. Known - values are: "Add", "Remove", "Reset", and "EnableCommunity". - :vartype operation_type: str or - ~azure.mgmt.compute.v2021_10_01.models.SharingUpdateOperationTypes - :ivar groups: A list of sharing profile groups. - :vartype groups: list[~azure.mgmt.compute.v2021_10_01.models.SharingProfileGroup] - """ - - _validation = { - "operation_type": {"required": True}, - } - - _attribute_map = { - "operation_type": {"key": "operationType", "type": "str"}, - "groups": {"key": "groups", "type": "[SharingProfileGroup]"}, - } - - def __init__( - self, - *, - operation_type: Union[str, "_models.SharingUpdateOperationTypes"], - groups: Optional[List["_models.SharingProfileGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword operation_type: This property allows you to specify the operation type of gallery - sharing update. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - **Add** :code:`
    `\\ :code:`
    ` **Remove** :code:`
    `\\ :code:`
    ` **Reset**. Required. - Known values are: "Add", "Remove", "Reset", and "EnableCommunity". - :paramtype operation_type: str or - ~azure.mgmt.compute.v2021_10_01.models.SharingUpdateOperationTypes - :keyword groups: A list of sharing profile groups. - :paramtype groups: list[~azure.mgmt.compute.v2021_10_01.models.SharingProfileGroup] - """ - super().__init__(**kwargs) - self.operation_type = operation_type - self.groups = groups - - -class SoftDeletePolicy(_serialization.Model): - """Contains information about the soft deletion policy of the gallery. - - :ivar is_soft_delete_enabled: Enables soft-deletion for resources in this gallery, allowing - them to be recovered within retention time. - :vartype is_soft_delete_enabled: bool - """ - - _attribute_map = { - "is_soft_delete_enabled": {"key": "isSoftDeleteEnabled", "type": "bool"}, - } - - def __init__(self, *, is_soft_delete_enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword is_soft_delete_enabled: Enables soft-deletion for resources in this gallery, allowing - them to be recovered within retention time. - :paramtype is_soft_delete_enabled: bool - """ - super().__init__(**kwargs) - self.is_soft_delete_enabled = is_soft_delete_enabled - - -class TargetRegion(_serialization.Model): - """Describes the target region information. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the region. Required. - :vartype name: str - :ivar regional_replica_count: The number of replicas of the Image Version to be created per - region. This property is updatable. - :vartype regional_replica_count: int - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "Premium_LRS", and "StandardSSD_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType - :ivar encryption: Optional. Allows users to provide customer managed keys for encrypting the OS - and data disks in the gallery artifact. - :vartype encryption: ~azure.mgmt.compute.v2021_10_01.models.EncryptionImages - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "regional_replica_count": {"key": "regionalReplicaCount", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "encryption": {"key": "encryption", "type": "EncryptionImages"}, - } - - def __init__( - self, - *, - name: str, - regional_replica_count: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - encryption: Optional["_models.EncryptionImages"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the region. Required. - :paramtype name: str - :keyword regional_replica_count: The number of replicas of the Image Version to be created per - region. This property is updatable. - :paramtype regional_replica_count: int - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "Premium_LRS", and "StandardSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType - :keyword encryption: Optional. Allows users to provide customer managed keys for encrypting the - OS and data disks in the gallery artifact. - :paramtype encryption: ~azure.mgmt.compute.v2021_10_01.models.EncryptionImages - """ - super().__init__(**kwargs) - self.name = name - self.regional_replica_count = regional_replica_count - self.storage_account_type = storage_account_type - self.encryption = encryption - - -class UserArtifactManage(_serialization.Model): - """UserArtifactManage. - - All required parameters must be populated in order to send to server. - - :ivar install: Required. The path and arguments to install the gallery application. This is - limited to 4096 characters. Required. - :vartype install: str - :ivar remove: Required. The path and arguments to remove the gallery application. This is - limited to 4096 characters. Required. - :vartype remove: str - :ivar update: Optional. The path and arguments to update the gallery application. If not - present, then update operation will invoke remove command on the previous version and install - command on the current version of the gallery application. This is limited to 4096 characters. - :vartype update: str - """ - - _validation = { - "install": {"required": True}, - "remove": {"required": True}, - } - - _attribute_map = { - "install": {"key": "install", "type": "str"}, - "remove": {"key": "remove", "type": "str"}, - "update": {"key": "update", "type": "str"}, - } - - def __init__(self, *, install: str, remove: str, update: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword install: Required. The path and arguments to install the gallery application. This is - limited to 4096 characters. Required. - :paramtype install: str - :keyword remove: Required. The path and arguments to remove the gallery application. This is - limited to 4096 characters. Required. - :paramtype remove: str - :keyword update: Optional. The path and arguments to update the gallery application. If not - present, then update operation will invoke remove command on the previous version and install - command on the current version of the gallery application. This is limited to 4096 characters. - :paramtype update: str - """ - super().__init__(**kwargs) - self.install = install - self.remove = remove - self.update = update - - -class UserArtifactSource(_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 media_link: Required. The mediaLink of the artifact, must be a readable storage page - blob. Required. - :vartype media_link: str - :ivar default_configuration_link: Optional. The defaultConfigurationLink of the artifact, must - be a readable storage page blob. - :vartype default_configuration_link: str - """ - - _validation = { - "media_link": {"required": True}, - } - - _attribute_map = { - "media_link": {"key": "mediaLink", "type": "str"}, - "default_configuration_link": {"key": "defaultConfigurationLink", "type": "str"}, - } - - def __init__(self, *, media_link: str, default_configuration_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword media_link: Required. The mediaLink of the artifact, must be a readable storage page - blob. Required. - :paramtype media_link: str - :keyword default_configuration_link: Optional. The defaultConfigurationLink of the artifact, - must be a readable storage page blob. - :paramtype default_configuration_link: str - """ - super().__init__(**kwargs) - self.media_link = media_link - self.default_configuration_link = default_configuration_link diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/__init__.py deleted file mode 100644 index 1362411892f0..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/__init__.py +++ /dev/null @@ -1,35 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - 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 ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "GalleriesOperations", - "GalleryImagesOperations", - "GalleryImageVersionsOperations", - "GalleryApplicationsOperations", - "GalleryApplicationVersionsOperations", - "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/v2021_10_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_operations.py deleted file mode 100644 index b7525a6d3b7a..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_operations.py +++ /dev/null @@ -1,4889 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import ComputeManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-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/galleries/{galleryName}", - ) - 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"), - } - - _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_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", "2021-10-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/galleries/{galleryName}", - ) - 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"), - } - - _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_galleries_get_request( - resource_group_name: str, - gallery_name: str, - subscription_id: str, - *, - select: Optional[Union[str, _models.SelectPermissions]] = None, - expand: Optional[Union[str, _models.GalleryExpandParams]] = 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", "2021-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", - ) - 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"), - } - - _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) - - -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", "2021-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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", "2021-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2021-10-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/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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_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", "2021-10-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/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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_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", "2021-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images", - ) - 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"), - } - - _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_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, - **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", "2021-10-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/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", - ) - 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"), - } - - _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_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", "2021-10-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/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", - ) - 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"), - } - - _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_image_versions_get_request( - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image_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", "2021-10-01")) - 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}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) - 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}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) - 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", - ) - 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"), - } - - _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_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", "2021-10-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/galleries/{galleryName}/applications/{galleryApplicationName}", - ) - 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"), - } - - _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", "2021-10-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/galleries/{galleryName}/applications/{galleryApplicationName}", - ) - 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"), - } - - _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_get_request( - 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", "2021-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", - ) - 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"), - } - - _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_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", "2021-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", - ) - 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"), - } - - _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) - - -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", "2021-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications", - ) - 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"), - } - - _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_gallery_application_versions_create_or_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, - **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", "2021-10-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/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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_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, - **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", "2021-10-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/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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_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", "2021-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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) - - -def build_gallery_application_versions_delete_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, - **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", "2021-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions", - ) - 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"), - } - - _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_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", "2021-10-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/galleries/{galleryName}/share", - ) - 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"), - } - - _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) - - -class GalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_10_01.ComputeManagementClient`'s - :attr:`galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2021-10-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(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 - - 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) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: _models.Gallery, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_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. - Required. - :type gallery_name: str - :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. - Required. - :type gallery: ~azure.mgmt.compute.v2021_10_01.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.v2021_10_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_10_01.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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. Is - either a Gallery type or a IO[bytes] type. Required. - :type gallery: ~azure.mgmt.compute.v2021_10_01.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.v2021_10_01.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 "2021-10-01")) - 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) - - 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, **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 _update_initial( - self, - resource_group_name: str, - gallery_name: str, - gallery: Union[_models.GalleryUpdate, 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 "2021-10-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(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) - - _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]: - 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, - 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. 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 update Shared Image Gallery operation. Required. - :type gallery: ~azure.mgmt.compute.v2021_10_01.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.v2021_10_01.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. 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 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.v2021_10_01.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. 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 update Shared Image Gallery operation. Is either a - GalleryUpdate type or a IO[bytes] type. Required. - :type gallery: ~azure.mgmt.compute.v2021_10_01.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.v2021_10_01.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 "2021-10-01")) - 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, **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 - ) - - @distributed_trace - 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.v2021_10_01.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.v2021_10_01.models.GalleryExpandParams - :return: Gallery or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_10_01.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 "2021-10-01")) - 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) - 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 - - def _delete_initial(self, resource_group_name: str, gallery_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 "2021-10-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_galleries_delete_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) - - _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, gallery_name: str, **kwargs: Any) -> LROPoller[None]: - """Delete 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 to be deleted. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-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, - gallery_name=gallery_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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2021_10_01.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 "2021-10-01")) - 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 - - 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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_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.v2021_10_01.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 "2021-10-01")) - 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 - - 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) - - 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 GalleryImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_10_01.ComputeManagementClient`'s - :attr:`gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_image_name: str, - gallery_image: Union[_models.GalleryImage, 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 "2021-10-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(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 = 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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.v2021_10_01.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.v2021_10_01.models.GalleryImage] - :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: IO[bytes], - *, - 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: IO[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.v2021_10_01.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_10_01.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.v2021_10_01.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 "2021-10-01")) - 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) - - 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: 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, - ) - return LROPoller[_models.GalleryImage]( - 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: Union[_models.GalleryImageUpdate, 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 "2021-10-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(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 = 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: - 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, - 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.v2021_10_01.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.v2021_10_01.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_10_01.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image: Union[_models.GalleryImageUpdate, IO[bytes]], - **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. Is either a - GalleryImageUpdate type or a IO[bytes] type. Required. - :type gallery_image: ~azure.mgmt.compute.v2021_10_01.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.v2021_10_01.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 "2021-10-01")) - 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) - - 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: 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, - ) - 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_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.v2021_10_01.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 "2021-10-01")) - cls: ClsType[_models.GalleryImage] = kwargs.pop("cls", None) - - _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) - raise HttpResponseError(response=response, 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 _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 "2021-10-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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) - - _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, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> LROPoller[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 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 "2021-10-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, - 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 - ) -> ItemPaged["_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.v2021_10_01.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 "2021-10-01")) - cls: ClsType[_models.GalleryImageList] = 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_images_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("GalleryImageList", 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 GalleryImageVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_10_01.ComputeManagementClient`'s - :attr:`gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_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 "2021-10-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(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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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.v2021_10_01.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.v2021_10_01.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. 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.v2021_10_01.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2021_10_01.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.v2021_10_01.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 "2021-10-01")) - 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, **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, - 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 "2021-10-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(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) - - _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]: - 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, - 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. - - :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.v2021_10_01.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.v2021_10_01.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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 LROPoller that returns either GalleryImageVersion or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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 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.v2021_10_01.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.v2021_10_01.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 "2021-10-01")) - 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) - - 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, **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 - ) - - @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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2021_10_01.models.ReplicationStatusTypes - :return: GalleryImageVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_10_01.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 "2021-10-01")) - 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( - 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, - 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 "2021-10-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - **kwargs: Any - ) -> LROPoller[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 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 "2021-10-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, - 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 - - 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_image( - self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> ItemPaged["_models.GalleryImageVersion"]: - """List gallery image versions in 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 - resides. 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) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_10_01.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 "2021-10-01")) - cls: ClsType[_models.GalleryImageVersionList] = 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_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, - 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("GalleryImageVersionList", 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 GalleryApplicationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_10_01.ComputeManagementClient`'s - :attr:`gallery_applications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application: Union[_models.GalleryApplication, 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 "2021-10-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(gallery_application, (IOBase, bytes)): - _content = gallery_application - else: - _json = self._serialize.body(gallery_application, "GalleryApplication") - - _request = build_gallery_applications_create_or_update_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, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: _models.GalleryApplication, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2021_10_01.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 GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_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]: - """Create or update 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 is to be created. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the create or 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.v2021_10_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplication, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2021_10_01.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.v2021_10_01.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 "2021-10-01")) - 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._create_or_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, **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 _update_initial( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, 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 "2021-10-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(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_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, - ) - _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]: - 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, - gallery_application_name: str, - gallery_application: _models.GalleryApplicationUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the update gallery Application operation. - Required. - :type gallery_application: ~azure.mgmt.compute.v2021_10_01.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.v2021_10_01.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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 is to be updated. 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. - :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.v2021_10_01.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. 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. - :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. - :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.v2021_10_01.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.v2021_10_01.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 "2021-10-01")) - 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, **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 - ) - - @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.v2021_10_01.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 "2021-10-01")) - 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 - ) -> 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 "2021-10-01")) - 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) - 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, 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. 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. - :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be deleted. - 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 "2021-10-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, - 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, **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 - ) -> ItemPaged["_models.GalleryApplication"]: - """List gallery Application 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 Application Gallery from which Application - Definitions are to be listed. 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.v2021_10_01.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 "2021-10-01")) - cls: ClsType[_models.GalleryApplicationList] = 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_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: - 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 GalleryApplicationVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2021_10_01.ComputeManagementClient`'s - :attr:`gallery_application_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: Union[_models.GalleryApplicationVersion, 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 "2021-10-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(gallery_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersion") - - _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, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersion, - *, - 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. - :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 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.v2021_10_01.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 GalleryApplicationVersion or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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], - *, - 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. - :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 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] - :keyword content_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.v2021_10_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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]], - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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.v2021_10_01.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.v2021_10_01.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 "2021-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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) - if cont_token is None: - 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, - 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("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)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.GalleryApplicationVersion]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - 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]], - **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 "2021-10-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(gallery_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersionUpdate") - - _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, - 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]: - 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, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2021_10_01.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 GalleryApplicationVersion or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update 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 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] - :keyword content_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.v2021_10_01.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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]], - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2021_10_01.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.v2021_10_01.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 "2021-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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) - 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_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 - ) - 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: 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.GalleryApplicationVersion].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - 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, - 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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2021_10_01.models.ReplicationStatusTypes - :return: GalleryApplicationVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2021_10_01.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 "2021-10-01")) - 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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Delete 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 - deleted. 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-10-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, - 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, - 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_application( - self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> ItemPaged["_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.v2021_10_01.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 "2021-10-01")) - 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.v2021_10_01.ComputeManagementClient`'s - :attr:`gallery_sharing_profile` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 "2021-10-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(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.v2021_10_01.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.v2021_10_01.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.v2021_10_01.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.v2021_10_01.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.v2021_10_01.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 "2021-10-01")) - 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 - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2022_01_03/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_compute_management_client.py deleted file mode 100644 index 917e7f407945..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_compute_management_client.py +++ /dev/null @@ -1,195 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ( - CommunityGalleriesOperations, - CommunityGalleryImageVersionsOperations, - CommunityGalleryImagesOperations, - GalleriesOperations, - GalleryApplicationVersionsOperations, - GalleryApplicationsOperations, - GalleryImageVersionsOperations, - GalleryImagesOperations, - GallerySharingProfileOperations, - SharedGalleriesOperations, - SharedGalleryImageVersionsOperations, - SharedGalleryImagesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :ivar galleries: GalleriesOperations operations - :vartype galleries: azure.mgmt.compute.v2022_01_03.operations.GalleriesOperations - :ivar gallery_images: GalleryImagesOperations operations - :vartype gallery_images: azure.mgmt.compute.v2022_01_03.operations.GalleryImagesOperations - :ivar gallery_image_versions: GalleryImageVersionsOperations operations - :vartype gallery_image_versions: - azure.mgmt.compute.v2022_01_03.operations.GalleryImageVersionsOperations - :ivar gallery_applications: GalleryApplicationsOperations operations - :vartype gallery_applications: - azure.mgmt.compute.v2022_01_03.operations.GalleryApplicationsOperations - :ivar gallery_application_versions: GalleryApplicationVersionsOperations operations - :vartype gallery_application_versions: - azure.mgmt.compute.v2022_01_03.operations.GalleryApplicationVersionsOperations - :ivar gallery_sharing_profile: GallerySharingProfileOperations operations - :vartype gallery_sharing_profile: - azure.mgmt.compute.v2022_01_03.operations.GallerySharingProfileOperations - :ivar shared_galleries: SharedGalleriesOperations operations - :vartype shared_galleries: azure.mgmt.compute.v2022_01_03.operations.SharedGalleriesOperations - :ivar shared_gallery_images: SharedGalleryImagesOperations operations - :vartype shared_gallery_images: - azure.mgmt.compute.v2022_01_03.operations.SharedGalleryImagesOperations - :ivar shared_gallery_image_versions: SharedGalleryImageVersionsOperations operations - :vartype shared_gallery_image_versions: - azure.mgmt.compute.v2022_01_03.operations.SharedGalleryImageVersionsOperations - :ivar community_galleries: CommunityGalleriesOperations operations - :vartype community_galleries: - azure.mgmt.compute.v2022_01_03.operations.CommunityGalleriesOperations - :ivar community_gallery_images: CommunityGalleryImagesOperations operations - :vartype community_gallery_images: - azure.mgmt.compute.v2022_01_03.operations.CommunityGalleryImagesOperations - :ivar community_gallery_image_versions: CommunityGalleryImageVersionsOperations operations - :vartype community_gallery_image_versions: - azure.mgmt.compute.v2022_01_03.operations.CommunityGalleryImageVersionsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-01-03". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.galleries = GalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.gallery_images = GalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.gallery_image_versions = GalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.gallery_applications = GalleryApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.gallery_application_versions = GalleryApplicationVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.gallery_sharing_profile = GallerySharingProfileOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.shared_galleries = SharedGalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.shared_gallery_images = SharedGalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.community_galleries = CommunityGalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.community_gallery_images = CommunityGalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_configuration.py deleted file mode 100644 index 8e2fa4a1e61a..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-01-03". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2022-01-03") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_metadata.json deleted file mode 100644 index f4b807c6f75a..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_metadata.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "chosen_version": "2022-01-03", - "total_api_version_list": ["2022-01-03"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "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.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "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.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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": { - "galleries": "GalleriesOperations", - "gallery_images": "GalleryImagesOperations", - "gallery_image_versions": "GalleryImageVersionsOperations", - "gallery_applications": "GalleryApplicationsOperations", - "gallery_application_versions": "GalleryApplicationVersionsOperations", - "gallery_sharing_profile": "GallerySharingProfileOperations", - "shared_galleries": "SharedGalleriesOperations", - "shared_gallery_images": "SharedGalleryImagesOperations", - "shared_gallery_image_versions": "SharedGalleryImageVersionsOperations", - "community_galleries": "CommunityGalleriesOperations", - "community_gallery_images": "CommunityGalleryImagesOperations", - "community_gallery_image_versions": "CommunityGalleryImageVersionsOperations" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node
    is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj 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 deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2022_01_03/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/_compute_management_client.py deleted file mode 100644 index 1948b5dfc4ef..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/_compute_management_client.py +++ /dev/null @@ -1,200 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ( - CommunityGalleriesOperations, - CommunityGalleryImageVersionsOperations, - CommunityGalleryImagesOperations, - GalleriesOperations, - GalleryApplicationVersionsOperations, - GalleryApplicationsOperations, - GalleryImageVersionsOperations, - GalleryImagesOperations, - GallerySharingProfileOperations, - SharedGalleriesOperations, - SharedGalleryImageVersionsOperations, - SharedGalleryImagesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :ivar galleries: GalleriesOperations operations - :vartype galleries: azure.mgmt.compute.v2022_01_03.aio.operations.GalleriesOperations - :ivar gallery_images: GalleryImagesOperations operations - :vartype gallery_images: azure.mgmt.compute.v2022_01_03.aio.operations.GalleryImagesOperations - :ivar gallery_image_versions: GalleryImageVersionsOperations operations - :vartype gallery_image_versions: - azure.mgmt.compute.v2022_01_03.aio.operations.GalleryImageVersionsOperations - :ivar gallery_applications: GalleryApplicationsOperations operations - :vartype gallery_applications: - azure.mgmt.compute.v2022_01_03.aio.operations.GalleryApplicationsOperations - :ivar gallery_application_versions: GalleryApplicationVersionsOperations operations - :vartype gallery_application_versions: - azure.mgmt.compute.v2022_01_03.aio.operations.GalleryApplicationVersionsOperations - :ivar gallery_sharing_profile: GallerySharingProfileOperations operations - :vartype gallery_sharing_profile: - azure.mgmt.compute.v2022_01_03.aio.operations.GallerySharingProfileOperations - :ivar shared_galleries: SharedGalleriesOperations operations - :vartype shared_galleries: - azure.mgmt.compute.v2022_01_03.aio.operations.SharedGalleriesOperations - :ivar shared_gallery_images: SharedGalleryImagesOperations operations - :vartype shared_gallery_images: - azure.mgmt.compute.v2022_01_03.aio.operations.SharedGalleryImagesOperations - :ivar shared_gallery_image_versions: SharedGalleryImageVersionsOperations operations - :vartype shared_gallery_image_versions: - azure.mgmt.compute.v2022_01_03.aio.operations.SharedGalleryImageVersionsOperations - :ivar community_galleries: CommunityGalleriesOperations operations - :vartype community_galleries: - azure.mgmt.compute.v2022_01_03.aio.operations.CommunityGalleriesOperations - :ivar community_gallery_images: CommunityGalleryImagesOperations operations - :vartype community_gallery_images: - azure.mgmt.compute.v2022_01_03.aio.operations.CommunityGalleryImagesOperations - :ivar community_gallery_image_versions: CommunityGalleryImageVersionsOperations operations - :vartype community_gallery_image_versions: - azure.mgmt.compute.v2022_01_03.aio.operations.CommunityGalleryImageVersionsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-01-03". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.galleries = GalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.gallery_images = GalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.gallery_image_versions = GalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.gallery_applications = GalleryApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.gallery_application_versions = GalleryApplicationVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.gallery_sharing_profile = GallerySharingProfileOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.shared_galleries = SharedGalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.shared_gallery_images = SharedGalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.community_galleries = CommunityGalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.community_gallery_images = CommunityGalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-01-03" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/_configuration.py deleted file mode 100644 index d7483e6750f4..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-01-03". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2022-01-03") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/__init__.py deleted file mode 100644 index 139d983a5840..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/__init__.py +++ /dev/null @@ -1,47 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - 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 ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "GalleriesOperations", - "GalleryImagesOperations", - "GalleryImageVersionsOperations", - "GalleryApplicationsOperations", - "GalleryApplicationVersionsOperations", - "GallerySharingProfileOperations", - "SharedGalleriesOperations", - "SharedGalleryImagesOperations", - "SharedGalleryImageVersionsOperations", - "CommunityGalleriesOperations", - "CommunityGalleryImagesOperations", - "CommunityGalleryImageVersionsOperations", -] -__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/v2022_01_03/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_operations.py deleted file mode 100644 index 50a499e74722..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_operations.py +++ /dev/null @@ -1,4923 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import ( - build_community_galleries_get_request, - build_community_gallery_image_versions_get_request, - build_community_gallery_image_versions_list_request, - build_community_gallery_images_get_request, - build_community_gallery_images_list_request, - build_galleries_create_or_update_request, - build_galleries_delete_request, - build_galleries_get_request, - build_galleries_list_by_resource_group_request, - build_galleries_list_request, - build_galleries_update_request, - build_gallery_application_versions_create_or_update_request, - build_gallery_application_versions_delete_request, - build_gallery_application_versions_get_request, - build_gallery_application_versions_list_by_gallery_application_request, - build_gallery_application_versions_update_request, - build_gallery_applications_create_or_update_request, - build_gallery_applications_delete_request, - build_gallery_applications_get_request, - build_gallery_applications_list_by_gallery_request, - build_gallery_applications_update_request, - build_gallery_image_versions_create_or_update_request, - build_gallery_image_versions_delete_request, - build_gallery_image_versions_get_request, - build_gallery_image_versions_list_by_gallery_image_request, - build_gallery_image_versions_update_request, - build_gallery_images_create_or_update_request, - build_gallery_images_delete_request, - build_gallery_images_get_request, - build_gallery_images_list_by_gallery_request, - build_gallery_images_update_request, - build_gallery_sharing_profile_update_request, - build_shared_galleries_get_request, - build_shared_galleries_list_request, - build_shared_gallery_image_versions_get_request, - build_shared_gallery_image_versions_list_request, - build_shared_gallery_images_get_request, - build_shared_gallery_images_list_request, -) -from .._configuration import ComputeManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s - :attr:`galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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: Union[_models.Gallery, 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 "2022-01-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, (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 = 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: _models.Gallery, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - Required. - :type gallery_name: str - :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. - Required. - :type gallery: ~azure.mgmt.compute.v2022_01_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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - 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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, gallery_name: str, gallery: Union[_models.Gallery, IO[bytes]], **kwargs: Any - ) -> 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. - 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.v2022_01_03.models.Gallery or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_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 "2022-01-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, 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=gallery, - 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("Gallery", 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.Gallery].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Gallery]( - 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: Union[_models.GalleryUpdate, 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 "2022-01-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, (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) - - _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: _models.GalleryUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - Required. - :type gallery_name: str - :param gallery: Parameters supplied to the update Shared Image Gallery operation. Required. - :type gallery: ~azure.mgmt.compute.v2022_01_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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - 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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: Union[_models.GalleryUpdate, IO[bytes]], - **kwargs: Any - ) -> 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. - 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.v2022_01_03.models.GalleryUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_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 "2022-01-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, 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=gallery, - 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("Gallery", 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.Gallery].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Gallery]( - 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.v2022_01_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.v2022_01_03.models.GalleryExpandParams - :return: Gallery or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_01_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 "2022-01-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, - 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 "2022-01-03")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_galleries_delete_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) - - _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, gallery_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Delete 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 to be deleted. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-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, - 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) -> AsyncItemPaged["_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.v2022_01_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 "2022-01-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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2022_01_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 "2022-01-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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class GalleryImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s - :attr:`gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 "2022-01-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.v2022_01_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.v2022_01_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.v2022_01_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.v2022_01_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.v2022_01_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 "2022-01-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 "2022-01-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.v2022_01_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.v2022_01_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.v2022_01_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.v2022_01_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.v2022_01_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 "2022-01-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.v2022_01_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 "2022-01-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, - 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 = 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("GalleryImage", 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]: - 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 "2022-01-03")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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) - - _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, 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-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, **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_gallery( - self, resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_01_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 "2022-01-03")) - cls: ClsType[_models.GalleryImageList] = 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_images_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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryImageList", 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 GalleryImageVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s - :attr:`gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 "2022-01-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.v2022_01_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.v2022_01_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.v2022_01_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.v2022_01_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.v2022_01_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 "2022-01-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]: - 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 "2022-01-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") - - _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) - - _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_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.v2022_01_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.v2022_01_03.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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 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.v2022_01_03.models.GalleryImageVersion] - :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_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. 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.v2022_01_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.v2022_01_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 "2022-01-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) - - 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 - ) - - @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. - - :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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2022_01_03.models.ReplicationStatusTypes - :return: GalleryImageVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_01_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 "2022-01-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) - 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 - - 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, - 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 "2022-01-03")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-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) - - 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_gallery_image( - self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.GalleryImageVersion"]: - """List gallery image versions in 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 - resides. 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) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_01_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 "2022-01-03")) - cls: ClsType[_models.GalleryImageVersionList] = 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_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, - 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("GalleryImageVersionList", 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 GalleryApplicationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s - :attr:`gallery_applications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application: Union[_models.GalleryApplication, 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 "2022-01-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_application, (IOBase, bytes)): - _content = gallery_application - else: - _json = self._serialize.body(gallery_application, "GalleryApplication") - - _request = build_gallery_applications_create_or_update_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, - 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_application_name: str, - gallery_application: _models.GalleryApplication, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2022_01_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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the create or 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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplication, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2022_01_03.models.GalleryApplication or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_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 "2022-01-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, 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_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 - ) - await 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: 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.GalleryApplication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GalleryApplication]( - 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_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, 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 "2022-01-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_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_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, - ) - _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_application_name: str, - gallery_application: _models.GalleryApplicationUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the update gallery Application operation. - Required. - :type gallery_application: ~azure.mgmt.compute.v2022_01_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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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 - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :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.v2022_01_03.models.GalleryApplicationUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_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 "2022-01-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, 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=gallery_application, - 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("GalleryApplication", 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.GalleryApplication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GalleryApplication]( - 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.v2022_01_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 "2022-01-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]: - 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 "2022-01-03")) - cls: ClsType[AsyncIterator[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 = 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, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete a gallery Application. - - :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 is to be deleted. Required. - :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be deleted. - 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-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_application_name=gallery_application_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_gallery( - self, resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.GalleryApplication"]: - """List gallery Application 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 Application Gallery from which Application - Definitions are to be listed. Required. - :type gallery_name: str - :return: An iterator like instance of either GalleryApplication or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_01_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 "2022-01-03")) - cls: ClsType[_models.GalleryApplicationList] = 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_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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryApplicationList", 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 GalleryApplicationVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s - :attr:`gallery_application_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: Union[_models.GalleryApplicationVersion, 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 "2022-01-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_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersion") - - _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, - 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersion, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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.v2022_01_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 AsyncLROPoller that returns either GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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] - :keyword content_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 GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async 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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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.v2022_01_03.models.GalleryApplicationVersion 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.v2022_01_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 "2022-01-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._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, - 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 - ) - - async 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]], - **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 "2022-01-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_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersionUpdate") - - _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, - 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2022_01_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 AsyncLROPoller that returns either GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Update 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 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] - :keyword content_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 GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async 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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2022_01_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.v2022_01_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 "2022-01-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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2022_01_03.models.ReplicationStatusTypes - :return: GalleryApplicationVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_01_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 "2022-01-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) - - deserialized = self._deserialize("GalleryApplicationVersion", 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, - gallery_application_version_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 "2022-01-03")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete 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 - deleted. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-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_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, - 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_gallery_application( - self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_01_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 "2022-01-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 - - async 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, 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 GallerySharingProfileOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s - :attr:`gallery_sharing_profile` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _update_initial( - self, - resource_group_name: str, - gallery_name: str, - sharing_update: Union[_models.SharingUpdate, 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 "2022-01-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(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 = 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( - 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 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.v2022_01_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.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.SharingUpdate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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 AsyncLROPoller that returns either SharingUpdate or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.SharingUpdate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2022_01_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.v2022_01_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 "2022-01-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) - - 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: 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.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 - ) - - -class SharedGalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s - :attr:`shared_galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_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.v2022_01_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.v2022_01_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 "2022-01-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.v2022_01_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 "2022-01-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 = 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("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.v2022_01_03.aio.ComputeManagementClient`'s - :attr:`shared_gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_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.v2022_01_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.v2022_01_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 "2022-01-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 - - async 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, 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, 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.v2022_01_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 "2022-01-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 = 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("SharedGalleryImage", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class SharedGalleryImageVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s - :attr:`shared_gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.SharedGalleryImageVersion"]: - """List shared gallery image versions 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 - :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.v2022_01_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.v2022_01_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 "2022-01-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) - 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, - gallery_image_version_name: str, - **kwargs: Any - ) -> _models.SharedGalleryImageVersion: - """Get a shared gallery image version 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 - :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.v2022_01_03.models.SharedGalleryImageVersion - :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 "2022-01-03")) - cls: ClsType[_models.SharedGalleryImageVersion] = kwargs.pop("cls", None) - - _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, - 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("SharedGalleryImageVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class CommunityGalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s - :attr:`community_galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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: 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.v2022_01_03.models.CommunityGallery - :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 "2022-01-03")) - cls: ClsType[_models.CommunityGallery] = kwargs.pop("cls", 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) - - _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("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.v2022_01_03.aio.ComputeManagementClient`'s - :attr:`community_gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.v2022_01_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 "2022-01-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 = 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("CommunityGalleryImage", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, location: str, public_gallery_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.CommunityGalleryImage"]: - """List community gallery images inside 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 - :return: An iterator like instance of either CommunityGalleryImage or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_01_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 "2022-01-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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CommunityGalleryImageList", 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 CommunityGalleryImageVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s - :attr:`community_gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - gallery_image_version_name: str, - **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.v2022_01_03.models.CommunityGalleryImageVersion - :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 "2022-01-03")) - cls: ClsType[_models.CommunityGalleryImageVersion] = 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, - 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("CommunityGalleryImageVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, location: str, public_gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.CommunityGalleryImageVersion"]: - """List community gallery image versions inside an 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: An iterator like instance of either CommunityGalleryImageVersion or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_01_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 "2022-01-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) - 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/v2022_01_03/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/__init__.py deleted file mode 100644 index d948d910b797..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/__init__.py +++ /dev/null @@ -1,232 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - ApiError, - ApiErrorBase, - CommunityGallery, - CommunityGalleryImage, - CommunityGalleryImageList, - CommunityGalleryImageVersion, - CommunityGalleryImageVersionList, - CommunityGalleryInfo, - DataDiskImageEncryption, - Disallowed, - DiskImageEncryption, - EncryptionImages, - ExtendedLocation, - Gallery, - GalleryApplication, - GalleryApplicationList, - GalleryApplicationUpdate, - GalleryApplicationVersion, - GalleryApplicationVersionList, - GalleryApplicationVersionPublishingProfile, - GalleryApplicationVersionUpdate, - GalleryArtifactPublishingProfileBase, - GalleryArtifactSource, - GalleryArtifactVersionSource, - GalleryDataDiskImage, - GalleryDiskImage, - GalleryExtendedLocation, - GalleryIdentifier, - GalleryImage, - GalleryImageFeature, - GalleryImageIdentifier, - GalleryImageList, - GalleryImageUpdate, - GalleryImageVersion, - GalleryImageVersionList, - GalleryImageVersionPublishingProfile, - GalleryImageVersionStorageProfile, - GalleryImageVersionUpdate, - GalleryList, - GalleryOSDiskImage, - GalleryTargetExtendedLocation, - GalleryUpdate, - ImagePurchasePlan, - InnerError, - ManagedArtifact, - OSDiskImageEncryption, - OSDiskImageSecurityProfile, - PirCommunityGalleryResource, - PirResource, - PirSharedGalleryResource, - RecommendedMachineConfiguration, - RegionalReplicationStatus, - RegionalSharingStatus, - ReplicationStatus, - Resource, - ResourceRange, - ResourceWithOptionalLocation, - SharedGallery, - SharedGalleryDataDiskImage, - SharedGalleryDiskImage, - SharedGalleryImage, - SharedGalleryImageList, - SharedGalleryImageVersion, - SharedGalleryImageVersionList, - SharedGalleryImageVersionStorageProfile, - SharedGalleryList, - SharedGalleryOSDiskImage, - SharingProfile, - SharingProfileGroup, - SharingStatus, - SharingUpdate, - SoftDeletePolicy, - SubResource, - SubResourceReadOnly, - TargetRegion, - UpdateResourceDefinition, - UserArtifactManage, - UserArtifactSettings, - UserArtifactSource, - UserAssignedIdentitiesValue, -) - -from ._compute_management_client_enums import ( # type: ignore - AggregatedReplicationState, - Architecture, - ConfidentialVMEncryptionType, - ExtendedLocationTypes, - GalleryExpandParams, - GalleryExtendedLocationType, - GalleryProvisioningState, - GallerySharingPermissionTypes, - HostCaching, - HyperVGeneration, - OperatingSystemStateTypes, - OperatingSystemTypes, - ReplicationMode, - ReplicationState, - ReplicationStatusTypes, - SelectPermissions, - SharedGalleryHostCaching, - SharedToValues, - SharingProfileGroupTypes, - SharingState, - SharingUpdateOperationTypes, - StorageAccountType, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ApiError", - "ApiErrorBase", - "CommunityGallery", - "CommunityGalleryImage", - "CommunityGalleryImageList", - "CommunityGalleryImageVersion", - "CommunityGalleryImageVersionList", - "CommunityGalleryInfo", - "DataDiskImageEncryption", - "Disallowed", - "DiskImageEncryption", - "EncryptionImages", - "ExtendedLocation", - "Gallery", - "GalleryApplication", - "GalleryApplicationList", - "GalleryApplicationUpdate", - "GalleryApplicationVersion", - "GalleryApplicationVersionList", - "GalleryApplicationVersionPublishingProfile", - "GalleryApplicationVersionUpdate", - "GalleryArtifactPublishingProfileBase", - "GalleryArtifactSource", - "GalleryArtifactVersionSource", - "GalleryDataDiskImage", - "GalleryDiskImage", - "GalleryExtendedLocation", - "GalleryIdentifier", - "GalleryImage", - "GalleryImageFeature", - "GalleryImageIdentifier", - "GalleryImageList", - "GalleryImageUpdate", - "GalleryImageVersion", - "GalleryImageVersionList", - "GalleryImageVersionPublishingProfile", - "GalleryImageVersionStorageProfile", - "GalleryImageVersionUpdate", - "GalleryList", - "GalleryOSDiskImage", - "GalleryTargetExtendedLocation", - "GalleryUpdate", - "ImagePurchasePlan", - "InnerError", - "ManagedArtifact", - "OSDiskImageEncryption", - "OSDiskImageSecurityProfile", - "PirCommunityGalleryResource", - "PirResource", - "PirSharedGalleryResource", - "RecommendedMachineConfiguration", - "RegionalReplicationStatus", - "RegionalSharingStatus", - "ReplicationStatus", - "Resource", - "ResourceRange", - "ResourceWithOptionalLocation", - "SharedGallery", - "SharedGalleryDataDiskImage", - "SharedGalleryDiskImage", - "SharedGalleryImage", - "SharedGalleryImageList", - "SharedGalleryImageVersion", - "SharedGalleryImageVersionList", - "SharedGalleryImageVersionStorageProfile", - "SharedGalleryList", - "SharedGalleryOSDiskImage", - "SharingProfile", - "SharingProfileGroup", - "SharingStatus", - "SharingUpdate", - "SoftDeletePolicy", - "SubResource", - "SubResourceReadOnly", - "TargetRegion", - "UpdateResourceDefinition", - "UserArtifactManage", - "UserArtifactSettings", - "UserArtifactSource", - "UserAssignedIdentitiesValue", - "AggregatedReplicationState", - "Architecture", - "ConfidentialVMEncryptionType", - "ExtendedLocationTypes", - "GalleryExpandParams", - "GalleryExtendedLocationType", - "GalleryProvisioningState", - "GallerySharingPermissionTypes", - "HostCaching", - "HyperVGeneration", - "OperatingSystemStateTypes", - "OperatingSystemTypes", - "ReplicationMode", - "ReplicationState", - "ReplicationStatusTypes", - "SelectPermissions", - "SharedGalleryHostCaching", - "SharedToValues", - "SharingProfileGroupTypes", - "SharingState", - "SharingUpdateOperationTypes", - "StorageAccountType", -] -__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/v2022_01_03/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/_compute_management_client_enums.py deleted file mode 100644 index 5e4ec088159d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/_compute_management_client_enums.py +++ /dev/null @@ -1,195 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AggregatedReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is the aggregated replication status based on all the regional replication status flags.""" - - UNKNOWN = "Unknown" - IN_PROGRESS = "InProgress" - COMPLETED = "Completed" - FAILED = "Failed" - - -class Architecture(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The architecture of the image. Applicable to OS disks only.""" - - X64 = "x64" - ARM64 = "Arm64" - - -class ConfidentialVMEncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """confidential VM encryption types.""" - - ENCRYPTED_VM_GUEST_STATE_ONLY_WITH_PMK = "EncryptedVMGuestStateOnlyWithPmk" - ENCRYPTED_WITH_PMK = "EncryptedWithPmk" - ENCRYPTED_WITH_CMK = "EncryptedWithCmk" - - -class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of extendedLocation.""" - - EDGE_ZONE = "EdgeZone" - - -class GalleryExpandParams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """GalleryExpandParams.""" - - SHARING_PROFILE_GROUPS = "SharingProfile/Groups" - - -class GalleryExtendedLocationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """It is type of the extended location.""" - - EDGE_ZONE = "EdgeZone" - UNKNOWN = "Unknown" - - -class GalleryProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state, which only appears in the response.""" - - CREATING = "Creating" - UPDATING = "Updating" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - MIGRATING = "Migrating" - - -class GallerySharingPermissionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows you to specify the permission of sharing gallery. :code:`
    `\\ - :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Private** :code:`
    `\\ - :code:`
    ` **Groups** :code:`
    `\\ :code:`
    ` **Community**. - """ - - PRIVATE = "Private" - GROUPS = "Groups" - COMMUNITY = "Community" - - -class HostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'.""" - - NONE = "None" - READ_ONLY = "ReadOnly" - READ_WRITE = "ReadWrite" - - -class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The hypervisor generation of the Virtual Machine. Applicable to OS disks only.""" - - V1 = "V1" - V2 = "V2" - - -class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows the user to specify whether the virtual machines created under this image - are 'Generalized' or 'Specialized'. - """ - - GENERALIZED = "Generalized" - SPECIALIZED = "Specialized" - - -class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows you to specify the supported type of the OS that application is built for. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Windows** - :code:`
    `\\ :code:`
    ` **Linux**. - """ - - WINDOWS = "Windows" - LINUX = "Linux" - - -class ReplicationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Optional parameter which specifies the mode to be used for replication. This property is not - updatable. - """ - - FULL = "Full" - SHALLOW = "Shallow" - - -class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is the regional replication state.""" - - UNKNOWN = "Unknown" - REPLICATING = "Replicating" - COMPLETED = "Completed" - FAILED = "Failed" - - -class ReplicationStatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ReplicationStatusTypes.""" - - REPLICATION_STATUS = "ReplicationStatus" - - -class SelectPermissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SelectPermissions.""" - - PERMISSIONS = "Permissions" - - -class SharedGalleryHostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'.""" - - NONE = "None" - READ_ONLY = "ReadOnly" - READ_WRITE = "ReadWrite" - - -class SharedToValues(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SharedToValues.""" - - TENANT = "tenant" - - -class SharingProfileGroupTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows you to specify the type of sharing group. :code:`
    `\\ :code:`
    ` - Possible values are: :code:`
    `\\ :code:`
    ` **Subscriptions** :code:`
    `\\ :code:`
    ` - **AADTenants**. - """ - - SUBSCRIPTIONS = "Subscriptions" - AAD_TENANTS = "AADTenants" - - -class SharingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The sharing state of the gallery, which only appears in the response.""" - - SUCCEEDED = "Succeeded" - IN_PROGRESS = "InProgress" - FAILED = "Failed" - UNKNOWN = "Unknown" - - -class SharingUpdateOperationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows you to specify the operation type of gallery sharing update. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Add** - :code:`
    `\\ :code:`
    ` **Remove** :code:`
    `\\ :code:`
    ` **Reset**. - """ - - ADD = "Add" - REMOVE = "Remove" - RESET = "Reset" - ENABLE_COMMUNITY = "EnableCommunity" - - -class StorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the storage account type to be used to store the image. This property is not - updatable. - """ - - STANDARD_LRS = "Standard_LRS" - STANDARD_ZRS = "Standard_ZRS" - PREMIUM_LRS = "Premium_LRS" - STANDARD_SSD_LRS = "StandardSSD_LRS" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/_models_py3.py deleted file mode 100644 index 1d13eb920515..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/_models_py3.py +++ /dev/null @@ -1,3934 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# 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 .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -class ApiError(_serialization.Model): - """Api error. - - :ivar details: The Api error details. - :vartype details: list[~azure.mgmt.compute.v2022_01_03.models.ApiErrorBase] - :ivar innererror: The Api inner error. - :vartype innererror: ~azure.mgmt.compute.v2022_01_03.models.InnerError - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "details": {"key": "details", "type": "[ApiErrorBase]"}, - "innererror": {"key": "innererror", "type": "InnerError"}, - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - details: Optional[List["_models.ApiErrorBase"]] = None, - innererror: Optional["_models.InnerError"] = None, - code: Optional[str] = None, - target: Optional[str] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword details: The Api error details. - :paramtype details: list[~azure.mgmt.compute.v2022_01_03.models.ApiErrorBase] - :keyword innererror: The Api inner error. - :paramtype innererror: ~azure.mgmt.compute.v2022_01_03.models.InnerError - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.details = details - self.innererror = innererror - self.code = code - self.target = target - self.message = message - - -class ApiErrorBase(_serialization.Model): - """Api error base. - - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.target = target - self.message = message - - -class PirCommunityGalleryResource(_serialization.Model): - """Base information about the community gallery resource in pir. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar type: Resource type. - :vartype type: str - :ivar unique_id: The unique id of this community gallery. - :vartype unique_id: str - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - } - - 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 - """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.location: Optional[str] = None - self.type: Optional[str] = None - self.unique_id = unique_id - - -class CommunityGallery(PirCommunityGalleryResource): - """Specifies information about the Community Gallery that you want to create or update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar type: Resource type. - :vartype type: str - :ivar unique_id: The unique id of this community gallery. - :vartype unique_id: str - """ - - -class CommunityGalleryImage(PirCommunityGalleryResource): - """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. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar type: Resource type. - :vartype type: str - :ivar unique_id: The unique id of this community gallery. - :vartype unique_id: str - :ivar 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. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values - are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes - :ivar 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". - :vartype os_state: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemStateTypes - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar identifier: This is the gallery image definition identifier. - :vartype identifier: ~azure.mgmt.compute.v2022_01_03.models.GalleryImageIdentifier - :ivar recommended: The properties describe the recommended machine configuration for this Image - Definition. These properties are updatable. - :vartype recommended: ~azure.mgmt.compute.v2022_01_03.models.RecommendedMachineConfiguration - :ivar disallowed: Describes the disallowed disk types. - :vartype disallowed: ~azure.mgmt.compute.v2022_01_03.models.Disallowed - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2022_01_03.models.HyperVGeneration - :ivar features: A list of gallery image features. - :vartype features: list[~azure.mgmt.compute.v2022_01_03.models.GalleryImageFeature] - :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :vartype purchase_plan: ~azure.mgmt.compute.v2022_01_03.models.ImagePurchasePlan - :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values - are: "x64" and "Arm64". - :vartype architecture: str or ~azure.mgmt.compute.v2022_01_03.models.Architecture - :ivar privacy_statement_uri: Privacy statement uri for the current community gallery image. - :vartype privacy_statement_uri: str - :ivar eula: End-user license agreement for the current community gallery image. - :vartype eula: str - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "os_state": {"key": "properties.osState", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, - "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "features": {"key": "properties.features", "type": "[GalleryImageFeature]"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, - "architecture": {"key": "properties.architecture", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - } - - 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, - **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. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2022_01_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.v2022_01_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.v2022_01_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.v2022_01_03.models.RecommendedMachineConfiguration - :keyword disallowed: Describes the disallowed disk types. - :paramtype disallowed: ~azure.mgmt.compute.v2022_01_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.v2022_01_03.models.HyperVGeneration - :keyword features: A list of gallery image features. - :paramtype features: list[~azure.mgmt.compute.v2022_01_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.v2022_01_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.v2022_01_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 - """ - 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.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 - - -class CommunityGalleryImageList(_serialization.Model): - """The List Community Gallery Images operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of community gallery images. Required. - :vartype value: list[~azure.mgmt.compute.v2022_01_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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[CommunityGalleryImage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.CommunityGalleryImage"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of community gallery images. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_01_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class CommunityGalleryImageVersion(PirCommunityGalleryResource): - """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. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar type: Resource type. - :vartype type: str - :ivar unique_id: The unique id of this community gallery. - :vartype unique_id: str - :ivar published_date: The published date of the gallery image version Definition. This property - can be used for decommissioning purposes. This property is updatable. - :vartype published_date: ~datetime.datetime - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar storage_profile: Describes the storage profile of the image version. - :vartype storage_profile: - ~azure.mgmt.compute.v2022_01_03.models.SharedGalleryImageVersionStorageProfile - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - "published_date": {"key": "properties.publishedDate", "type": "iso-8601"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "exclude_from_latest": {"key": "properties.excludeFromLatest", "type": "bool"}, - "storage_profile": {"key": "properties.storageProfile", "type": "SharedGalleryImageVersionStorageProfile"}, - } - - 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, - **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.v2022_01_03.models.SharedGalleryImageVersionStorageProfile - """ - 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 - - -class CommunityGalleryImageVersionList(_serialization.Model): - """The List Community Gallery Image versions operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of community gallery image versions. Required. - :vartype value: list[~azure.mgmt.compute.v2022_01_03.models.CommunityGalleryImageVersion] - :ivar next_link: The uri to fetch the next page of community gallery image versions. Call - ListNext() with this to fetch the next page of community gallery image versions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[CommunityGalleryImageVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.CommunityGalleryImageVersion"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of community gallery image versions. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_01_03.models.CommunityGalleryImageVersion] - :keyword next_link: The uri to fetch the next page of community gallery image versions. Call - ListNext() with this to fetch the next page of community gallery image versions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class CommunityGalleryInfo(_serialization.Model): - """Information of community gallery if current gallery is shared to community. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar publisher_uri: The link to the publisher website. Visible to all users. - :vartype publisher_uri: str - :ivar publisher_contact: Community gallery publisher support email. The email address of the - publisher. Visible to all users. - :vartype publisher_contact: str - :ivar eula: End-user license agreement for community gallery image. - :vartype eula: str - :ivar public_name_prefix: The prefix of the gallery name that will be displayed publicly. - Visible to all users. - :vartype public_name_prefix: str - :ivar community_gallery_enabled: Contains info about whether community gallery sharing is - enabled. - :vartype community_gallery_enabled: bool - :ivar public_names: Community gallery public name list. - :vartype public_names: list[str] - """ - - _validation = { - "community_gallery_enabled": {"readonly": True}, - "public_names": {"readonly": True}, - } - - _attribute_map = { - "publisher_uri": {"key": "publisherUri", "type": "str"}, - "publisher_contact": {"key": "publisherContact", "type": "str"}, - "eula": {"key": "eula", "type": "str"}, - "public_name_prefix": {"key": "publicNamePrefix", "type": "str"}, - "community_gallery_enabled": {"key": "communityGalleryEnabled", "type": "bool"}, - "public_names": {"key": "publicNames", "type": "[str]"}, - } - - def __init__( - self, - *, - publisher_uri: Optional[str] = None, - publisher_contact: Optional[str] = None, - eula: Optional[str] = None, - public_name_prefix: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword publisher_uri: The link to the publisher website. Visible to all users. - :paramtype publisher_uri: str - :keyword publisher_contact: Community gallery publisher support email. The email address of the - publisher. Visible to all users. - :paramtype publisher_contact: str - :keyword eula: End-user license agreement for community gallery image. - :paramtype eula: str - :keyword public_name_prefix: The prefix of the gallery name that will be displayed publicly. - Visible to all users. - :paramtype public_name_prefix: str - """ - super().__init__(**kwargs) - self.publisher_uri = publisher_uri - self.publisher_contact = publisher_contact - self.eula = eula - self.public_name_prefix = public_name_prefix - self.community_gallery_enabled: Optional[bool] = None - self.public_names: Optional[List[str]] = None - - -class DiskImageEncryption(_serialization.Model): - """This is the disk image encryption base class. - - :ivar disk_encryption_set_id: A relative URI containing the resource ID of the disk encryption - set. - :vartype disk_encryption_set_id: str - """ - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - } - - def __init__(self, *, disk_encryption_set_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword disk_encryption_set_id: A relative URI containing the resource ID of the disk - encryption set. - :paramtype disk_encryption_set_id: str - """ - super().__init__(**kwargs) - self.disk_encryption_set_id = disk_encryption_set_id - - -class DataDiskImageEncryption(DiskImageEncryption): - """Contains encryption settings for a data disk image. - - All required parameters must be populated in order to send to server. - - :ivar disk_encryption_set_id: A relative URI containing the resource ID of the disk encryption - set. - :vartype disk_encryption_set_id: str - :ivar 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. - :vartype lun: int - """ - - _validation = { - "lun": {"required": True}, - } - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__(self, *, lun: int, disk_encryption_set_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword disk_encryption_set_id: A relative URI containing the resource ID of the disk - encryption set. - :paramtype disk_encryption_set_id: str - :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__(disk_encryption_set_id=disk_encryption_set_id, **kwargs) - self.lun = lun - - -class Disallowed(_serialization.Model): - """Describes the disallowed disk types. - - :ivar disk_types: A list of disk types. - :vartype disk_types: list[str] - """ - - _attribute_map = { - "disk_types": {"key": "diskTypes", "type": "[str]"}, - } - - def __init__(self, *, disk_types: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword disk_types: A list of disk types. - :paramtype disk_types: list[str] - """ - super().__init__(**kwargs) - self.disk_types = disk_types - - -class EncryptionImages(_serialization.Model): - """Optional. Allows users to provide customer managed keys for encrypting the OS and data disks in - the gallery artifact. - - :ivar os_disk_image: Contains encryption settings for an OS disk image. - :vartype os_disk_image: ~azure.mgmt.compute.v2022_01_03.models.OSDiskImageEncryption - :ivar data_disk_images: A list of encryption specifications for data disk images. - :vartype data_disk_images: list[~azure.mgmt.compute.v2022_01_03.models.DataDiskImageEncryption] - """ - - _attribute_map = { - "os_disk_image": {"key": "osDiskImage", "type": "OSDiskImageEncryption"}, - "data_disk_images": {"key": "dataDiskImages", "type": "[DataDiskImageEncryption]"}, - } - - def __init__( - self, - *, - os_disk_image: Optional["_models.OSDiskImageEncryption"] = None, - data_disk_images: Optional[List["_models.DataDiskImageEncryption"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_disk_image: Contains encryption settings for an OS disk image. - :paramtype os_disk_image: ~azure.mgmt.compute.v2022_01_03.models.OSDiskImageEncryption - :keyword data_disk_images: A list of encryption specifications for data disk images. - :paramtype data_disk_images: - list[~azure.mgmt.compute.v2022_01_03.models.DataDiskImageEncryption] - """ - super().__init__(**kwargs) - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - - -class ExtendedLocation(_serialization.Model): - """The complex type of the extended location. - - :ivar name: The name of the extended location. - :vartype name: str - :ivar type: The type of the extended location. "EdgeZone" - :vartype type: str or ~azure.mgmt.compute.v2022_01_03.models.ExtendedLocationTypes - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the extended location. - :paramtype name: str - :keyword type: The type of the extended location. "EdgeZone" - :paramtype type: str or ~azure.mgmt.compute.v2022_01_03.models.ExtendedLocationTypes - """ - super().__init__(**kwargs) - self.name = name - self.type = type - - -class Resource(_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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - - -class Gallery(Resource): - """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. - :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] - :ivar description: The description of this Shared Image Gallery resource. This property is - updatable. - :vartype description: str - :ivar identifier: Describes the gallery unique name. - :vartype identifier: ~azure.mgmt.compute.v2022_01_03.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2022_01_03.models.GalleryProvisioningState - :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. - :vartype sharing_profile: ~azure.mgmt.compute.v2022_01_03.models.SharingProfile - :ivar soft_delete_policy: Contains information about the soft deletion policy of the gallery. - :vartype soft_delete_policy: ~azure.mgmt.compute.v2022_01_03.models.SoftDeletePolicy - :ivar sharing_status: Sharing status of current gallery. - :vartype sharing_status: ~azure.mgmt.compute.v2022_01_03.models.SharingStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "sharing_status": {"readonly": 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}"}, - "description": {"key": "properties.description", "type": "str"}, - "identifier": {"key": "properties.identifier", "type": "GalleryIdentifier"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "sharing_profile": {"key": "properties.sharingProfile", "type": "SharingProfile"}, - "soft_delete_policy": {"key": "properties.softDeletePolicy", "type": "SoftDeletePolicy"}, - "sharing_status": {"key": "properties.sharingStatus", "type": "SharingStatus"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - identifier: Optional["_models.GalleryIdentifier"] = None, - sharing_profile: Optional["_models.SharingProfile"] = None, - soft_delete_policy: Optional["_models.SoftDeletePolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this Shared Image Gallery resource. This property is - updatable. - :paramtype description: str - :keyword identifier: Describes the gallery unique name. - :paramtype identifier: ~azure.mgmt.compute.v2022_01_03.models.GalleryIdentifier - :keyword sharing_profile: Profile for gallery sharing to subscription or tenant. - :paramtype sharing_profile: ~azure.mgmt.compute.v2022_01_03.models.SharingProfile - :keyword soft_delete_policy: Contains information about the soft deletion policy of the - gallery. - :paramtype soft_delete_policy: ~azure.mgmt.compute.v2022_01_03.models.SoftDeletePolicy - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.identifier = identifier - self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None - self.sharing_profile = sharing_profile - self.soft_delete_policy = soft_delete_policy - self.sharing_status: Optional["_models.SharingStatus"] = None - - -class GalleryApplication(Resource): - """Specifies information about the gallery Application 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. - :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] - :ivar description: The description of this gallery Application Definition resource. This - property is updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery Application Definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar supported_os_type: This property allows you to specify the supported type of the OS that - application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :vartype supported_os_type: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes - """ - - _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}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "supported_os_type": {"key": "properties.supportedOSType", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery Application Definition resource. This - property is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery Application Definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: str - :keyword end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword supported_os_type: This property allows you to specify the supported type of the OS - that application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :paramtype supported_os_type: str or - ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.end_of_life_date = end_of_life_date - self.supported_os_type = supported_os_type - - -class GalleryApplicationList(_serialization.Model): - """The List Gallery Applications operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of Gallery Applications. Required. - :vartype value: list[~azure.mgmt.compute.v2022_01_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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryApplication]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.GalleryApplication"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of Gallery Applications. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_01_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class UpdateResourceDefinition(_serialization.Model): - """The Update Resource model definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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 = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.tags = tags - - -class GalleryApplicationUpdate(UpdateResourceDefinition): - """Specifies information about the gallery Application Definition that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar description: The description of this gallery Application Definition resource. This - property is updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery Application Definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar supported_os_type: This property allows you to specify the supported type of the OS that - application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :vartype supported_os_type: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes - """ - - _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"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "supported_os_type": {"key": "properties.supportedOSType", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery Application Definition resource. This - property is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery Application Definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: str - :keyword end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword supported_os_type: This property allows you to specify the supported type of the OS - that application is built for. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ - :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values are: "Windows" and - "Linux". - :paramtype supported_os_type: str or - ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes - """ - super().__init__(tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.end_of_life_date = end_of_life_date - self.supported_os_type = supported_os_type - - -class GalleryApplicationVersion(Resource): - """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. - :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] - :ivar publishing_profile: The publishing profile of a gallery image version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2022_01_03.models.GalleryProvisioningState - :ivar replication_status: This is the replication status of the gallery image version. - :vartype replication_status: ~azure.mgmt.compute.v2022_01_03.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": 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}"}, - "publishing_profile": { - "key": "properties.publishingProfile", - "type": "GalleryApplicationVersionPublishingProfile", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersionPublishingProfile - """ - super().__init__(location=location, tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None - self.replication_status: Optional["_models.ReplicationStatus"] = None - - -class GalleryApplicationVersionList(_serialization.Model): - """The List Gallery Application version operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of gallery Application Versions. Required. - :vartype value: list[~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersion] - :ivar next_link: The uri to fetch the next page of gallery Application Versions. Call - ListNext() with this to fetch the next page of gallery Application Versions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryApplicationVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.GalleryApplicationVersion"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of gallery Application Versions. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersion] - :keyword next_link: The uri to fetch the next page of gallery Application Versions. Call - ListNext() with this to fetch the next page of gallery Application Versions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryArtifactPublishingProfileBase(_serialization.Model): - """Describes the basic gallery artifact publishing profile. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar target_regions: The target regions where the Image Version is going to be replicated to. - This property is updatable. - :vartype target_regions: list[~azure.mgmt.compute.v2022_01_03.models.TargetRegion] - :ivar replica_count: The number of replicas of the Image Version to be created per region. This - property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :vartype replica_count: int - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar published_date: The timestamp for when the gallery image version is published. - :vartype published_date: ~datetime.datetime - :ivar end_of_life_date: The end of life date of the gallery image version. This property can be - used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "Premium_LRS", and "StandardSSD_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType - :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Known values are: "Full" and "Shallow". - :vartype replication_mode: str or ~azure.mgmt.compute.v2022_01_03.models.ReplicationMode - :ivar target_extended_locations: The target extended locations where the Image Version is going - to be replicated to. This property is updatable. - :vartype target_extended_locations: - list[~azure.mgmt.compute.v2022_01_03.models.GalleryTargetExtendedLocation] - """ - - _validation = { - "published_date": {"readonly": True}, - } - - _attribute_map = { - "target_regions": {"key": "targetRegions", "type": "[TargetRegion]"}, - "replica_count": {"key": "replicaCount", "type": "int"}, - "exclude_from_latest": {"key": "excludeFromLatest", "type": "bool"}, - "published_date": {"key": "publishedDate", "type": "iso-8601"}, - "end_of_life_date": {"key": "endOfLifeDate", "type": "iso-8601"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "replication_mode": {"key": "replicationMode", "type": "str"}, - "target_extended_locations": {"key": "targetExtendedLocations", "type": "[GalleryTargetExtendedLocation]"}, - } - - def __init__( - self, - *, - target_regions: Optional[List["_models.TargetRegion"]] = None, - replica_count: Optional[int] = None, - exclude_from_latest: Optional[bool] = None, - end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, - target_extended_locations: Optional[List["_models.GalleryTargetExtendedLocation"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword target_regions: The target regions where the Image Version is going to be replicated - to. This property is updatable. - :paramtype target_regions: list[~azure.mgmt.compute.v2022_01_03.models.TargetRegion] - :keyword replica_count: The number of replicas of the Image Version to be created per region. - This property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :paramtype replica_count: int - :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 end_of_life_date: The end of life date of the gallery image version. This property can - be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "Premium_LRS", and "StandardSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType - :keyword replication_mode: Optional parameter which specifies the mode to be used for - replication. This property is not updatable. Known values are: "Full" and "Shallow". - :paramtype replication_mode: str or ~azure.mgmt.compute.v2022_01_03.models.ReplicationMode - :keyword target_extended_locations: The target extended locations where the Image Version is - going to be replicated to. This property is updatable. - :paramtype target_extended_locations: - list[~azure.mgmt.compute.v2022_01_03.models.GalleryTargetExtendedLocation] - """ - super().__init__(**kwargs) - self.target_regions = target_regions - self.replica_count = replica_count - self.exclude_from_latest = exclude_from_latest - self.published_date: Optional[datetime.datetime] = None - self.end_of_life_date = end_of_life_date - self.storage_account_type = storage_account_type - self.replication_mode = replication_mode - self.target_extended_locations = target_extended_locations - - -class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfileBase): # pylint: disable=name-too-long - """The publishing profile of a gallery image version. - - 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 target_regions: The target regions where the Image Version is going to be replicated to. - This property is updatable. - :vartype target_regions: list[~azure.mgmt.compute.v2022_01_03.models.TargetRegion] - :ivar replica_count: The number of replicas of the Image Version to be created per region. This - property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :vartype replica_count: int - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar published_date: The timestamp for when the gallery image version is published. - :vartype published_date: ~datetime.datetime - :ivar end_of_life_date: The end of life date of the gallery image version. This property can be - used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "Premium_LRS", and "StandardSSD_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType - :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Known values are: "Full" and "Shallow". - :vartype replication_mode: str or ~azure.mgmt.compute.v2022_01_03.models.ReplicationMode - :ivar target_extended_locations: The target extended locations where the Image Version is going - to be replicated to. This property is updatable. - :vartype target_extended_locations: - list[~azure.mgmt.compute.v2022_01_03.models.GalleryTargetExtendedLocation] - :ivar source: The source image from which the Image Version is going to be created. Required. - :vartype source: ~azure.mgmt.compute.v2022_01_03.models.UserArtifactSource - :ivar manage_actions: - :vartype manage_actions: ~azure.mgmt.compute.v2022_01_03.models.UserArtifactManage - :ivar settings: Additional settings for the VM app that contains the target package and config - file name when it is deployed to target VM or VM scale set. - :vartype settings: ~azure.mgmt.compute.v2022_01_03.models.UserArtifactSettings - :ivar advanced_settings: Optional. Additional settings to pass to the vm-application-manager - extension. For advanced use only. - :vartype advanced_settings: dict[str, str] - :ivar enable_health_check: Optional. Whether or not this application reports health. - :vartype enable_health_check: bool - """ - - _validation = { - "published_date": {"readonly": True}, - "source": {"required": True}, - } - - _attribute_map = { - "target_regions": {"key": "targetRegions", "type": "[TargetRegion]"}, - "replica_count": {"key": "replicaCount", "type": "int"}, - "exclude_from_latest": {"key": "excludeFromLatest", "type": "bool"}, - "published_date": {"key": "publishedDate", "type": "iso-8601"}, - "end_of_life_date": {"key": "endOfLifeDate", "type": "iso-8601"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "replication_mode": {"key": "replicationMode", "type": "str"}, - "target_extended_locations": {"key": "targetExtendedLocations", "type": "[GalleryTargetExtendedLocation]"}, - "source": {"key": "source", "type": "UserArtifactSource"}, - "manage_actions": {"key": "manageActions", "type": "UserArtifactManage"}, - "settings": {"key": "settings", "type": "UserArtifactSettings"}, - "advanced_settings": {"key": "advancedSettings", "type": "{str}"}, - "enable_health_check": {"key": "enableHealthCheck", "type": "bool"}, - } - - def __init__( - self, - *, - source: "_models.UserArtifactSource", - target_regions: Optional[List["_models.TargetRegion"]] = None, - replica_count: Optional[int] = None, - exclude_from_latest: Optional[bool] = None, - end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, - target_extended_locations: Optional[List["_models.GalleryTargetExtendedLocation"]] = None, - manage_actions: Optional["_models.UserArtifactManage"] = None, - settings: Optional["_models.UserArtifactSettings"] = None, - advanced_settings: Optional[Dict[str, str]] = None, - enable_health_check: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword target_regions: The target regions where the Image Version is going to be replicated - to. This property is updatable. - :paramtype target_regions: list[~azure.mgmt.compute.v2022_01_03.models.TargetRegion] - :keyword replica_count: The number of replicas of the Image Version to be created per region. - This property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :paramtype replica_count: int - :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 end_of_life_date: The end of life date of the gallery image version. This property can - be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "Premium_LRS", and "StandardSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType - :keyword replication_mode: Optional parameter which specifies the mode to be used for - replication. This property is not updatable. Known values are: "Full" and "Shallow". - :paramtype replication_mode: str or ~azure.mgmt.compute.v2022_01_03.models.ReplicationMode - :keyword target_extended_locations: The target extended locations where the Image Version is - going to be replicated to. This property is updatable. - :paramtype target_extended_locations: - list[~azure.mgmt.compute.v2022_01_03.models.GalleryTargetExtendedLocation] - :keyword source: The source image from which the Image Version is going to be created. - Required. - :paramtype source: ~azure.mgmt.compute.v2022_01_03.models.UserArtifactSource - :keyword manage_actions: - :paramtype manage_actions: ~azure.mgmt.compute.v2022_01_03.models.UserArtifactManage - :keyword settings: Additional settings for the VM app that contains the target package and - config file name when it is deployed to target VM or VM scale set. - :paramtype settings: ~azure.mgmt.compute.v2022_01_03.models.UserArtifactSettings - :keyword advanced_settings: Optional. Additional settings to pass to the vm-application-manager - extension. For advanced use only. - :paramtype advanced_settings: dict[str, str] - :keyword enable_health_check: Optional. Whether or not this application reports health. - :paramtype enable_health_check: bool - """ - super().__init__( - target_regions=target_regions, - replica_count=replica_count, - exclude_from_latest=exclude_from_latest, - end_of_life_date=end_of_life_date, - storage_account_type=storage_account_type, - replication_mode=replication_mode, - target_extended_locations=target_extended_locations, - **kwargs - ) - self.source = source - self.manage_actions = manage_actions - self.settings = settings - self.advanced_settings = advanced_settings - self.enable_health_check = enable_health_check - - -class GalleryApplicationVersionUpdate(UpdateResourceDefinition): - """Specifies information about the gallery Application Version that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar publishing_profile: The publishing profile of a gallery image version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2022_01_03.models.GalleryProvisioningState - :ivar replication_status: This is the replication status of the gallery image version. - :vartype replication_status: ~azure.mgmt.compute.v2022_01_03.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "publishing_profile": { - "key": "properties.publishingProfile", - "type": "GalleryApplicationVersionPublishingProfile", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersionPublishingProfile - """ - super().__init__(tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None - self.replication_status: Optional["_models.ReplicationStatus"] = 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.v2022_01_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.v2022_01_03.models.ManagedArtifact - """ - super().__init__(**kwargs) - self.managed_image = managed_image - - -class GalleryArtifactVersionSource(_serialization.Model): - """The gallery artifact version source. - - :ivar id: The id of the gallery artifact version source. Can specify a disk uri, snapshot uri, - user image or storage account resource. - :vartype id: str - :ivar uri: The uri of the gallery artifact version source. Currently used to specify vhd/blob - source. - :vartype uri: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "uri": {"key": "uri", "type": "str"}, - } - - def __init__( - self, *, id: Optional[str] = None, uri: Optional[str] = None, **kwargs: Any # pylint: disable=redefined-builtin - ) -> None: - """ - :keyword id: The id of the gallery artifact version source. Can specify a disk uri, snapshot - uri, user image or storage account resource. - :paramtype id: str - :keyword uri: The uri of the gallery artifact version source. Currently used to specify - vhd/blob source. - :paramtype uri: str - """ - super().__init__(**kwargs) - self.id = id - self.uri = uri - - -class GalleryDiskImage(_serialization.Model): - """This is the disk image base class. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar size_in_gb: This property indicates the size of the VHD to be created. - :vartype size_in_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2022_01_03.models.HostCaching - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2022_01_03.models.GalleryArtifactVersionSource - """ - - _validation = { - "size_in_gb": {"readonly": True}, - } - - _attribute_map = { - "size_in_gb": {"key": "sizeInGB", "type": "int"}, - "host_caching": {"key": "hostCaching", "type": "str"}, - "source": {"key": "source", "type": "GalleryArtifactVersionSource"}, - } - - def __init__( - self, - *, - host_caching: Optional[Union[str, "_models.HostCaching"]] = None, - source: Optional["_models.GalleryArtifactVersionSource"] = 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.v2022_01_03.models.HostCaching - :keyword source: The gallery artifact version source. - :paramtype source: ~azure.mgmt.compute.v2022_01_03.models.GalleryArtifactVersionSource - """ - super().__init__(**kwargs) - self.size_in_gb: Optional[int] = None - self.host_caching = host_caching - self.source = source - - -class GalleryDataDiskImage(GalleryDiskImage): - """This is the data disk 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 size_in_gb: This property indicates the size of the VHD to be created. - :vartype size_in_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2022_01_03.models.HostCaching - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2022_01_03.models.GalleryArtifactVersionSource - :ivar 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. - :vartype lun: int - """ - - _validation = { - "size_in_gb": {"readonly": True}, - "lun": {"required": True}, - } - - _attribute_map = { - "size_in_gb": {"key": "sizeInGB", "type": "int"}, - "host_caching": {"key": "hostCaching", "type": "str"}, - "source": {"key": "source", "type": "GalleryArtifactVersionSource"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__( - self, - *, - lun: int, - host_caching: Optional[Union[str, "_models.HostCaching"]] = None, - source: Optional["_models.GalleryArtifactVersionSource"] = 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.v2022_01_03.models.HostCaching - :keyword source: The gallery artifact version source. - :paramtype source: ~azure.mgmt.compute.v2022_01_03.models.GalleryArtifactVersionSource - :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, source=source, **kwargs) - self.lun = lun - - -class GalleryExtendedLocation(_serialization.Model): - """The name of the extended location. - - :ivar name: - :vartype name: str - :ivar type: It is type of the extended location. Known values are: "EdgeZone" and "Unknown". - :vartype type: str or ~azure.mgmt.compute.v2022_01_03.models.GalleryExtendedLocationType - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[Union[str, "_models.GalleryExtendedLocationType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: - :paramtype name: str - :keyword type: It is type of the extended location. Known values are: "EdgeZone" and "Unknown". - :paramtype type: str or ~azure.mgmt.compute.v2022_01_03.models.GalleryExtendedLocationType - """ - super().__init__(**kwargs) - self.name = name - self.type = type - - -class GalleryIdentifier(_serialization.Model): - """Describes the gallery unique name. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar unique_name: The unique name of the Shared Image Gallery. This name is generated - automatically by Azure. - :vartype unique_name: str - """ - - _validation = { - "unique_name": {"readonly": True}, - } - - _attribute_map = { - "unique_name": {"key": "uniqueName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.unique_name: Optional[str] = None - - -class GalleryImage(Resource): - """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. - :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] - :ivar description: The description of this gallery image definition resource. This property is - updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery image definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar 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. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values - are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes - :ivar 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". - :vartype os_state: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemStateTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2022_01_03.models.HyperVGeneration - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar identifier: This is the gallery image definition identifier. - :vartype identifier: ~azure.mgmt.compute.v2022_01_03.models.GalleryImageIdentifier - :ivar recommended: The properties describe the recommended machine configuration for this Image - Definition. These properties are updatable. - :vartype recommended: ~azure.mgmt.compute.v2022_01_03.models.RecommendedMachineConfiguration - :ivar disallowed: Describes the disallowed disk types. - :vartype disallowed: ~azure.mgmt.compute.v2022_01_03.models.Disallowed - :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :vartype purchase_plan: ~azure.mgmt.compute.v2022_01_03.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2022_01_03.models.GalleryProvisioningState - :ivar features: A list of gallery image features. - :vartype features: list[~azure.mgmt.compute.v2022_01_03.models.GalleryImageFeature] - :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values - are: "x64" and "Arm64". - :vartype architecture: str or ~azure.mgmt.compute.v2022_01_03.models.Architecture - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "os_state": {"key": "properties.osState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, - "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "features": {"key": "properties.features", "type": "[GalleryImageFeature]"}, - "architecture": {"key": "properties.architecture", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["_models.GalleryImageIdentifier"] = None, - recommended: Optional["_models.RecommendedMachineConfiguration"] = None, - disallowed: Optional["_models.Disallowed"] = None, - purchase_plan: Optional["_models.ImagePurchasePlan"] = None, - features: Optional[List["_models.GalleryImageFeature"]] = None, - architecture: Optional[Union[str, "_models.Architecture"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery image definition resource. This property - is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery image definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: 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. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2022_01_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.v2022_01_03.models.OperatingSystemStateTypes - :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.v2022_01_03.models.HyperVGeneration - :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.v2022_01_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.v2022_01_03.models.RecommendedMachineConfiguration - :keyword disallowed: Describes the disallowed disk types. - :paramtype disallowed: ~azure.mgmt.compute.v2022_01_03.models.Disallowed - :keyword purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :paramtype purchase_plan: ~azure.mgmt.compute.v2022_01_03.models.ImagePurchasePlan - :keyword features: A list of gallery image features. - :paramtype features: list[~azure.mgmt.compute.v2022_01_03.models.GalleryImageFeature] - :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.v2022_01_03.models.Architecture - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.os_type = os_type - self.os_state = os_state - self.hyper_v_generation = hyper_v_generation - self.end_of_life_date = end_of_life_date - self.identifier = identifier - self.recommended = recommended - self.disallowed = disallowed - self.purchase_plan = purchase_plan - self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None - self.features = features - self.architecture = architecture - - -class GalleryImageFeature(_serialization.Model): - """A feature for gallery image. - - :ivar name: The name of the gallery image feature. - :vartype name: str - :ivar value: The value of the gallery image feature. - :vartype value: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: The name of the gallery image feature. - :paramtype name: str - :keyword value: The value of the gallery image feature. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class GalleryImageIdentifier(_serialization.Model): - """This is the gallery image definition identifier. - - All required parameters must be populated in order to send to server. - - :ivar publisher: The name of the gallery image definition publisher. Required. - :vartype publisher: str - :ivar offer: The name of the gallery image definition offer. Required. - :vartype offer: str - :ivar sku: The name of the gallery image definition SKU. Required. - :vartype sku: str - """ - - _validation = { - "publisher": {"required": True}, - "offer": {"required": True}, - "sku": {"required": True}, - } - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "offer": {"key": "offer", "type": "str"}, - "sku": {"key": "sku", "type": "str"}, - } - - def __init__(self, *, publisher: str, offer: str, sku: str, **kwargs: Any) -> None: - """ - :keyword publisher: The name of the gallery image definition publisher. Required. - :paramtype publisher: str - :keyword offer: The name of the gallery image definition offer. Required. - :paramtype offer: str - :keyword sku: The name of the gallery image definition SKU. Required. - :paramtype sku: str - """ - super().__init__(**kwargs) - self.publisher = publisher - self.offer = offer - self.sku = sku - - -class GalleryImageList(_serialization.Model): - """The List Gallery Images operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of Shared Image Gallery images. Required. - :vartype value: list[~azure.mgmt.compute.v2022_01_03.models.GalleryImage] - :ivar next_link: The uri to fetch the next page of Image Definitions in the Shared Image - Gallery. Call ListNext() with this to fetch the next page of gallery image definitions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryImage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.GalleryImage"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of Shared Image Gallery images. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_01_03.models.GalleryImage] - :keyword next_link: The uri to fetch the next page of Image Definitions in the Shared Image - Gallery. Call ListNext() with this to fetch the next page of gallery image definitions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryImageUpdate(UpdateResourceDefinition): - """Specifies information about the gallery image definition that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar description: The description of this gallery image definition resource. This property is - updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery image definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar 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. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values - are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes - :ivar 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". - :vartype os_state: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemStateTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2022_01_03.models.HyperVGeneration - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar identifier: This is the gallery image definition identifier. - :vartype identifier: ~azure.mgmt.compute.v2022_01_03.models.GalleryImageIdentifier - :ivar recommended: The properties describe the recommended machine configuration for this Image - Definition. These properties are updatable. - :vartype recommended: ~azure.mgmt.compute.v2022_01_03.models.RecommendedMachineConfiguration - :ivar disallowed: Describes the disallowed disk types. - :vartype disallowed: ~azure.mgmt.compute.v2022_01_03.models.Disallowed - :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :vartype purchase_plan: ~azure.mgmt.compute.v2022_01_03.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2022_01_03.models.GalleryProvisioningState - :ivar features: A list of gallery image features. - :vartype features: list[~azure.mgmt.compute.v2022_01_03.models.GalleryImageFeature] - :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values - are: "x64" and "Arm64". - :vartype architecture: str or ~azure.mgmt.compute.v2022_01_03.models.Architecture - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "os_state": {"key": "properties.osState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, - "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "features": {"key": "properties.features", "type": "[GalleryImageFeature]"}, - "architecture": {"key": "properties.architecture", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["_models.GalleryImageIdentifier"] = None, - recommended: Optional["_models.RecommendedMachineConfiguration"] = None, - disallowed: Optional["_models.Disallowed"] = None, - purchase_plan: Optional["_models.ImagePurchasePlan"] = None, - features: Optional[List["_models.GalleryImageFeature"]] = None, - architecture: Optional[Union[str, "_models.Architecture"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery image definition resource. This property - is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery image definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: 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. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2022_01_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.v2022_01_03.models.OperatingSystemStateTypes - :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.v2022_01_03.models.HyperVGeneration - :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.v2022_01_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.v2022_01_03.models.RecommendedMachineConfiguration - :keyword disallowed: Describes the disallowed disk types. - :paramtype disallowed: ~azure.mgmt.compute.v2022_01_03.models.Disallowed - :keyword purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :paramtype purchase_plan: ~azure.mgmt.compute.v2022_01_03.models.ImagePurchasePlan - :keyword features: A list of gallery image features. - :paramtype features: list[~azure.mgmt.compute.v2022_01_03.models.GalleryImageFeature] - :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.v2022_01_03.models.Architecture - """ - super().__init__(tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.os_type = os_type - self.os_state = os_state - self.hyper_v_generation = hyper_v_generation - self.end_of_life_date = end_of_life_date - self.identifier = identifier - self.recommended = recommended - self.disallowed = disallowed - self.purchase_plan = purchase_plan - self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None - self.features = features - self.architecture = architecture - - -class GalleryImageVersion(Resource): - """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. - :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] - :ivar publishing_profile: The publishing profile of a gallery image Version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2022_01_03.models.GalleryProvisioningState - :ivar storage_profile: This is the storage profile of a Gallery Image Version. - :vartype storage_profile: - ~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersionStorageProfile - :ivar replication_status: This is the replication status of the gallery image version. - :vartype replication_status: ~azure.mgmt.compute.v2022_01_03.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": 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}"}, - "publishing_profile": {"key": "properties.publishingProfile", "type": "GalleryImageVersionPublishingProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image Version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersionPublishingProfile - :keyword storage_profile: This is the storage profile of a Gallery Image Version. - :paramtype storage_profile: - ~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersionStorageProfile - """ - super().__init__(location=location, tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None - self.storage_profile = storage_profile - self.replication_status: Optional["_models.ReplicationStatus"] = None - - -class GalleryImageVersionList(_serialization.Model): - """The List Gallery Image version operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of gallery image versions. Required. - :vartype value: list[~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersion] - :ivar next_link: The uri to fetch the next page of gallery image versions. Call ListNext() with - this to fetch the next page of gallery image versions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryImageVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.GalleryImageVersion"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of gallery image versions. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersion] - :keyword next_link: The uri to fetch the next page of gallery image versions. Call ListNext() - with this to fetch the next page of gallery image versions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase): - """The publishing profile of a gallery image Version. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar target_regions: The target regions where the Image Version is going to be replicated to. - This property is updatable. - :vartype target_regions: list[~azure.mgmt.compute.v2022_01_03.models.TargetRegion] - :ivar replica_count: The number of replicas of the Image Version to be created per region. This - property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :vartype replica_count: int - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar published_date: The timestamp for when the gallery image version is published. - :vartype published_date: ~datetime.datetime - :ivar end_of_life_date: The end of life date of the gallery image version. This property can be - used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "Premium_LRS", and "StandardSSD_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType - :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Known values are: "Full" and "Shallow". - :vartype replication_mode: str or ~azure.mgmt.compute.v2022_01_03.models.ReplicationMode - :ivar target_extended_locations: The target extended locations where the Image Version is going - to be replicated to. This property is updatable. - :vartype target_extended_locations: - list[~azure.mgmt.compute.v2022_01_03.models.GalleryTargetExtendedLocation] - """ - - -class GalleryImageVersionStorageProfile(_serialization.Model): - """This is the storage profile of a Gallery Image Version. - - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2022_01_03.models.GalleryArtifactVersionSource - :ivar os_disk_image: This is the OS disk image. - :vartype os_disk_image: ~azure.mgmt.compute.v2022_01_03.models.GalleryOSDiskImage - :ivar data_disk_images: A list of data disk images. - :vartype data_disk_images: list[~azure.mgmt.compute.v2022_01_03.models.GalleryDataDiskImage] - """ - - _attribute_map = { - "source": {"key": "source", "type": "GalleryArtifactVersionSource"}, - "os_disk_image": {"key": "osDiskImage", "type": "GalleryOSDiskImage"}, - "data_disk_images": {"key": "dataDiskImages", "type": "[GalleryDataDiskImage]"}, - } - - def __init__( - self, - *, - source: Optional["_models.GalleryArtifactVersionSource"] = None, - os_disk_image: Optional["_models.GalleryOSDiskImage"] = None, - data_disk_images: Optional[List["_models.GalleryDataDiskImage"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source: The gallery artifact version source. - :paramtype source: ~azure.mgmt.compute.v2022_01_03.models.GalleryArtifactVersionSource - :keyword os_disk_image: This is the OS disk image. - :paramtype os_disk_image: ~azure.mgmt.compute.v2022_01_03.models.GalleryOSDiskImage - :keyword data_disk_images: A list of data disk images. - :paramtype data_disk_images: list[~azure.mgmt.compute.v2022_01_03.models.GalleryDataDiskImage] - """ - super().__init__(**kwargs) - self.source = source - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - - -class GalleryImageVersionUpdate(UpdateResourceDefinition): - """Specifies information about the gallery image version that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar publishing_profile: The publishing profile of a gallery image Version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2022_01_03.models.GalleryProvisioningState - :ivar storage_profile: This is the storage profile of a Gallery Image Version. - :vartype storage_profile: - ~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersionStorageProfile - :ivar replication_status: This is the replication status of the gallery image version. - :vartype replication_status: ~azure.mgmt.compute.v2022_01_03.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "publishing_profile": {"key": "properties.publishingProfile", "type": "GalleryImageVersionPublishingProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image Version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersionPublishingProfile - :keyword storage_profile: This is the storage profile of a Gallery Image Version. - :paramtype storage_profile: - ~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersionStorageProfile - """ - super().__init__(tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None - self.storage_profile = storage_profile - self.replication_status: Optional["_models.ReplicationStatus"] = None - - -class GalleryList(_serialization.Model): - """The List Galleries operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of galleries. Required. - :vartype value: list[~azure.mgmt.compute.v2022_01_03.models.Gallery] - :ivar next_link: The uri to fetch the next page of galleries. Call ListNext() with this to - fetch the next page of galleries. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Gallery]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Gallery"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of galleries. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_01_03.models.Gallery] - :keyword next_link: The uri to fetch the next page of galleries. Call ListNext() with this to - fetch the next page of galleries. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryOSDiskImage(GalleryDiskImage): - """This is the OS disk image. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar size_in_gb: This property indicates the size of the VHD to be created. - :vartype size_in_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2022_01_03.models.HostCaching - :ivar source: The gallery artifact version source. - :vartype source: ~azure.mgmt.compute.v2022_01_03.models.GalleryArtifactVersionSource - """ - - -class GalleryTargetExtendedLocation(_serialization.Model): - """GalleryTargetExtendedLocation. - - :ivar name: The name of the region. - :vartype name: str - :ivar extended_location: The name of the extended location. - :vartype extended_location: ~azure.mgmt.compute.v2022_01_03.models.GalleryExtendedLocation - :ivar extended_location_replica_count: The number of replicas of the Image Version to be - created per extended location. This property is updatable. - :vartype extended_location_replica_count: int - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "Premium_LRS", and "StandardSSD_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType - :ivar encryption: Optional. Allows users to provide customer managed keys for encrypting the OS - and data disks in the gallery artifact. - :vartype encryption: ~azure.mgmt.compute.v2022_01_03.models.EncryptionImages - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "extended_location": {"key": "extendedLocation", "type": "GalleryExtendedLocation"}, - "extended_location_replica_count": {"key": "extendedLocationReplicaCount", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "encryption": {"key": "encryption", "type": "EncryptionImages"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - extended_location: Optional["_models.GalleryExtendedLocation"] = None, - extended_location_replica_count: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - encryption: Optional["_models.EncryptionImages"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the region. - :paramtype name: str - :keyword extended_location: The name of the extended location. - :paramtype extended_location: ~azure.mgmt.compute.v2022_01_03.models.GalleryExtendedLocation - :keyword extended_location_replica_count: The number of replicas of the Image Version to be - created per extended location. This property is updatable. - :paramtype extended_location_replica_count: int - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "Premium_LRS", and "StandardSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType - :keyword encryption: Optional. Allows users to provide customer managed keys for encrypting the - OS and data disks in the gallery artifact. - :paramtype encryption: ~azure.mgmt.compute.v2022_01_03.models.EncryptionImages - """ - super().__init__(**kwargs) - self.name = name - self.extended_location = extended_location - self.extended_location_replica_count = extended_location_replica_count - self.storage_account_type = storage_account_type - self.encryption = encryption - - -class GalleryUpdate(UpdateResourceDefinition): - """Specifies information about the Shared Image Gallery that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar description: The description of this Shared Image Gallery resource. This property is - updatable. - :vartype description: str - :ivar identifier: Describes the gallery unique name. - :vartype identifier: ~azure.mgmt.compute.v2022_01_03.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2022_01_03.models.GalleryProvisioningState - :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. - :vartype sharing_profile: ~azure.mgmt.compute.v2022_01_03.models.SharingProfile - :ivar soft_delete_policy: Contains information about the soft deletion policy of the gallery. - :vartype soft_delete_policy: ~azure.mgmt.compute.v2022_01_03.models.SoftDeletePolicy - :ivar sharing_status: Sharing status of current gallery. - :vartype sharing_status: ~azure.mgmt.compute.v2022_01_03.models.SharingStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "sharing_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "identifier": {"key": "properties.identifier", "type": "GalleryIdentifier"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "sharing_profile": {"key": "properties.sharingProfile", "type": "SharingProfile"}, - "soft_delete_policy": {"key": "properties.softDeletePolicy", "type": "SoftDeletePolicy"}, - "sharing_status": {"key": "properties.sharingStatus", "type": "SharingStatus"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - identifier: Optional["_models.GalleryIdentifier"] = None, - sharing_profile: Optional["_models.SharingProfile"] = None, - soft_delete_policy: Optional["_models.SoftDeletePolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this Shared Image Gallery resource. This property is - updatable. - :paramtype description: str - :keyword identifier: Describes the gallery unique name. - :paramtype identifier: ~azure.mgmt.compute.v2022_01_03.models.GalleryIdentifier - :keyword sharing_profile: Profile for gallery sharing to subscription or tenant. - :paramtype sharing_profile: ~azure.mgmt.compute.v2022_01_03.models.SharingProfile - :keyword soft_delete_policy: Contains information about the soft deletion policy of the - gallery. - :paramtype soft_delete_policy: ~azure.mgmt.compute.v2022_01_03.models.SoftDeletePolicy - """ - super().__init__(tags=tags, **kwargs) - self.description = description - self.identifier = identifier - self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None - self.sharing_profile = sharing_profile - self.soft_delete_policy = soft_delete_policy - self.sharing_status: Optional["_models.SharingStatus"] = None - - -class ImagePurchasePlan(_serialization.Model): - """Describes the gallery image definition purchase plan. This is used by marketplace images. - - :ivar name: The plan ID. - :vartype name: str - :ivar publisher: The publisher ID. - :vartype publisher: str - :ivar product: The product ID. - :vartype product: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - publisher: Optional[str] = None, - product: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The plan ID. - :paramtype name: str - :keyword publisher: The publisher ID. - :paramtype publisher: str - :keyword product: The product ID. - :paramtype product: str - """ - super().__init__(**kwargs) - self.name = name - self.publisher = publisher - self.product = product - - -class InnerError(_serialization.Model): - """Inner error details. - - :ivar exceptiontype: The exception type. - :vartype exceptiontype: str - :ivar errordetail: The internal error message or exception dump. - :vartype errordetail: str - """ - - _attribute_map = { - "exceptiontype": {"key": "exceptiontype", "type": "str"}, - "errordetail": {"key": "errordetail", "type": "str"}, - } - - def __init__( - self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword exceptiontype: The exception type. - :paramtype exceptiontype: str - :keyword errordetail: The internal error message or exception dump. - :paramtype errordetail: str - """ - super().__init__(**kwargs) - self.exceptiontype = exceptiontype - self.errordetail = errordetail - - -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. - - :ivar disk_encryption_set_id: A relative URI containing the resource ID of the disk encryption - set. - :vartype disk_encryption_set_id: str - :ivar security_profile: This property specifies the security profile of an OS disk image. - :vartype security_profile: ~azure.mgmt.compute.v2022_01_03.models.OSDiskImageSecurityProfile - """ - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - "security_profile": {"key": "securityProfile", "type": "OSDiskImageSecurityProfile"}, - } - - def __init__( - self, - *, - disk_encryption_set_id: Optional[str] = None, - security_profile: Optional["_models.OSDiskImageSecurityProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_set_id: A relative URI containing the resource ID of the disk - encryption set. - :paramtype disk_encryption_set_id: str - :keyword security_profile: This property specifies the security profile of an OS disk image. - :paramtype security_profile: ~azure.mgmt.compute.v2022_01_03.models.OSDiskImageSecurityProfile - """ - super().__init__(disk_encryption_set_id=disk_encryption_set_id, **kwargs) - self.security_profile = security_profile - - -class OSDiskImageSecurityProfile(_serialization.Model): - """Contains security profile for an OS disk image. - - :ivar confidential_vm_encryption_type: confidential VM encryption types. Known values are: - "EncryptedVMGuestStateOnlyWithPmk", "EncryptedWithPmk", and "EncryptedWithCmk". - :vartype confidential_vm_encryption_type: str or - ~azure.mgmt.compute.v2022_01_03.models.ConfidentialVMEncryptionType - :ivar secure_vm_disk_encryption_set_id: secure VM disk encryption set id. - :vartype secure_vm_disk_encryption_set_id: str - """ - - _attribute_map = { - "confidential_vm_encryption_type": {"key": "confidentialVMEncryptionType", "type": "str"}, - "secure_vm_disk_encryption_set_id": {"key": "secureVMDiskEncryptionSetId", "type": "str"}, - } - - def __init__( - self, - *, - confidential_vm_encryption_type: Optional[Union[str, "_models.ConfidentialVMEncryptionType"]] = None, - secure_vm_disk_encryption_set_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword confidential_vm_encryption_type: confidential VM encryption types. Known values are: - "EncryptedVMGuestStateOnlyWithPmk", "EncryptedWithPmk", and "EncryptedWithCmk". - :paramtype confidential_vm_encryption_type: str or - ~azure.mgmt.compute.v2022_01_03.models.ConfidentialVMEncryptionType - :keyword secure_vm_disk_encryption_set_id: secure VM disk encryption set id. - :paramtype secure_vm_disk_encryption_set_id: str - """ - super().__init__(**kwargs) - self.confidential_vm_encryption_type = confidential_vm_encryption_type - self.secure_vm_disk_encryption_set_id = secure_vm_disk_encryption_set_id - - -class PirResource(_serialization.Model): - """The Resource model definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.location: Optional[str] = None - - -class PirSharedGalleryResource(PirResource): - """Base information about the shared gallery resource in pir. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar unique_id: The unique id of this shared gallery. - :vartype unique_id: str - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - } - - 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 - """ - super().__init__(**kwargs) - self.unique_id = unique_id - - -class RecommendedMachineConfiguration(_serialization.Model): - """The properties describe the recommended machine configuration for this Image Definition. These - properties are updatable. - - :ivar v_cp_us: Describes the resource range. - :vartype v_cp_us: ~azure.mgmt.compute.v2022_01_03.models.ResourceRange - :ivar memory: Describes the resource range. - :vartype memory: ~azure.mgmt.compute.v2022_01_03.models.ResourceRange - """ - - _attribute_map = { - "v_cp_us": {"key": "vCPUs", "type": "ResourceRange"}, - "memory": {"key": "memory", "type": "ResourceRange"}, - } - - def __init__( - self, - *, - v_cp_us: Optional["_models.ResourceRange"] = None, - memory: Optional["_models.ResourceRange"] = None, - **kwargs: Any - ) -> None: - """ - :keyword v_cp_us: Describes the resource range. - :paramtype v_cp_us: ~azure.mgmt.compute.v2022_01_03.models.ResourceRange - :keyword memory: Describes the resource range. - :paramtype memory: ~azure.mgmt.compute.v2022_01_03.models.ResourceRange - """ - super().__init__(**kwargs) - self.v_cp_us = v_cp_us - self.memory = memory - - -class RegionalReplicationStatus(_serialization.Model): - """This is the regional replication status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar region: The region to which the gallery image version is being replicated to. - :vartype region: str - :ivar state: This is the regional replication state. Known values are: "Unknown", - "Replicating", "Completed", and "Failed". - :vartype state: str or ~azure.mgmt.compute.v2022_01_03.models.ReplicationState - :ivar details: The details of the replication status. - :vartype details: str - :ivar progress: It indicates progress of the replication job. - :vartype progress: int - """ - - _validation = { - "region": {"readonly": True}, - "state": {"readonly": True}, - "details": {"readonly": True}, - "progress": {"readonly": True}, - } - - _attribute_map = { - "region": {"key": "region", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "details": {"key": "details", "type": "str"}, - "progress": {"key": "progress", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.region: Optional[str] = None - self.state: Optional[Union[str, "_models.ReplicationState"]] = None - self.details: Optional[str] = None - self.progress: Optional[int] = None - - -class RegionalSharingStatus(_serialization.Model): - """Gallery regional sharing status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar region: Region name. - :vartype region: str - :ivar state: Gallery sharing state in current region. Known values are: "Succeeded", - "InProgress", "Failed", and "Unknown". - :vartype state: str or ~azure.mgmt.compute.v2022_01_03.models.SharingState - :ivar details: Details of gallery regional sharing failure. - :vartype details: str - """ - - _validation = { - "state": {"readonly": True}, - } - - _attribute_map = { - "region": {"key": "region", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "details": {"key": "details", "type": "str"}, - } - - def __init__(self, *, region: Optional[str] = None, details: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword region: Region name. - :paramtype region: str - :keyword details: Details of gallery regional sharing failure. - :paramtype details: str - """ - super().__init__(**kwargs) - self.region = region - self.state: Optional[Union[str, "_models.SharingState"]] = None - self.details = details - - -class ReplicationStatus(_serialization.Model): - """This is the replication status of the gallery image version. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar aggregated_state: This is the aggregated replication status based on all the regional - replication status flags. Known values are: "Unknown", "InProgress", "Completed", and "Failed". - :vartype aggregated_state: str or - ~azure.mgmt.compute.v2022_01_03.models.AggregatedReplicationState - :ivar summary: This is a summary of replication status for each region. - :vartype summary: list[~azure.mgmt.compute.v2022_01_03.models.RegionalReplicationStatus] - """ - - _validation = { - "aggregated_state": {"readonly": True}, - "summary": {"readonly": True}, - } - - _attribute_map = { - "aggregated_state": {"key": "aggregatedState", "type": "str"}, - "summary": {"key": "summary", "type": "[RegionalReplicationStatus]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.aggregated_state: Optional[Union[str, "_models.AggregatedReplicationState"]] = None - self.summary: Optional[List["_models.RegionalReplicationStatus"]] = None - - -class ResourceRange(_serialization.Model): - """Describes the resource range. - - :ivar min: The minimum number of the resource. - :vartype min: int - :ivar max: The maximum number of the resource. - :vartype max: int - """ - - _attribute_map = { - "min": {"key": "min", "type": "int"}, - "max": {"key": "max", "type": "int"}, - } - - def __init__( - self, - *, - min: Optional[int] = None, # pylint: disable=redefined-builtin - max: Optional[int] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword min: The minimum number of the resource. - :paramtype min: int - :keyword max: The maximum number of the resource. - :paramtype max: int - """ - super().__init__(**kwargs) - self.min = min - self.max = max - - -class ResourceWithOptionalLocation(_serialization.Model): - """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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.tags = tags - - -class SharedGallery(PirSharedGalleryResource): - """Specifies information about the Shared Gallery that you want to create or update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar unique_id: The unique id of this shared gallery. - :vartype unique_id: str - """ - - -class SharedGalleryDiskImage(_serialization.Model): - """This is the disk image base class. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar disk_size_gb: This property indicates the size of the VHD to be created. - :vartype disk_size_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2022_01_03.models.SharedGalleryHostCaching - """ - - _validation = { - "disk_size_gb": {"readonly": True}, - } - - _attribute_map = { - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "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.v2022_01_03.models.SharedGalleryHostCaching - """ - super().__init__(**kwargs) - self.disk_size_gb: Optional[int] = None - self.host_caching = host_caching - - -class SharedGalleryDataDiskImage(SharedGalleryDiskImage): - """This is the data disk 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 disk_size_gb: This property indicates the size of the VHD to be created. - :vartype disk_size_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2022_01_03.models.SharedGalleryHostCaching - :ivar 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. - :vartype lun: int - """ - - _validation = { - "disk_size_gb": {"readonly": True}, - "lun": {"required": True}, - } - - _attribute_map = { - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "host_caching": {"key": "hostCaching", "type": "str"}, - "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.v2022_01_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 - - -class SharedGalleryImage(PirSharedGalleryResource): - """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. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar unique_id: The unique id of this shared gallery. - :vartype unique_id: str - :ivar 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. :code:`
    `\\ :code:`
    ` Possible values are: - :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known values - are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes - :ivar 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". - :vartype os_state: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemStateTypes - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar identifier: This is the gallery image definition identifier. - :vartype identifier: ~azure.mgmt.compute.v2022_01_03.models.GalleryImageIdentifier - :ivar recommended: The properties describe the recommended machine configuration for this Image - Definition. These properties are updatable. - :vartype recommended: ~azure.mgmt.compute.v2022_01_03.models.RecommendedMachineConfiguration - :ivar disallowed: Describes the disallowed disk types. - :vartype disallowed: ~azure.mgmt.compute.v2022_01_03.models.Disallowed - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2022_01_03.models.HyperVGeneration - :ivar features: A list of gallery image features. - :vartype features: list[~azure.mgmt.compute.v2022_01_03.models.GalleryImageFeature] - :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :vartype purchase_plan: ~azure.mgmt.compute.v2022_01_03.models.ImagePurchasePlan - :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values - are: "x64" and "Arm64". - :vartype architecture: str or ~azure.mgmt.compute.v2022_01_03.models.Architecture - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "os_state": {"key": "properties.osState", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, - "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "features": {"key": "properties.features", "type": "[GalleryImageFeature]"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, - "architecture": {"key": "properties.architecture", "type": "str"}, - } - - 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, - **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. :code:`
    `\\ :code:`
    ` Possible values - are: :code:`
    `\\ :code:`
    ` **Windows** :code:`
    `\\ :code:`
    ` **Linux**. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2022_01_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.v2022_01_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.v2022_01_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.v2022_01_03.models.RecommendedMachineConfiguration - :keyword disallowed: Describes the disallowed disk types. - :paramtype disallowed: ~azure.mgmt.compute.v2022_01_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.v2022_01_03.models.HyperVGeneration - :keyword features: A list of gallery image features. - :paramtype features: list[~azure.mgmt.compute.v2022_01_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.v2022_01_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.v2022_01_03.models.Architecture - """ - 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.disallowed = disallowed - self.hyper_v_generation = hyper_v_generation - self.features = features - self.purchase_plan = purchase_plan - self.architecture = architecture - - -class SharedGalleryImageList(_serialization.Model): - """The List Shared Gallery Images operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of shared gallery images. Required. - :vartype value: list[~azure.mgmt.compute.v2022_01_03.models.SharedGalleryImage] - :ivar next_link: The uri to fetch the next page of shared gallery images. Call ListNext() with - this to fetch the next page of shared gallery images. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SharedGalleryImage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.SharedGalleryImage"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of shared gallery images. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_01_03.models.SharedGalleryImage] - :keyword next_link: The uri to fetch the next page of shared gallery images. Call ListNext() - with this to fetch the next page of shared gallery images. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SharedGalleryImageVersion(PirSharedGalleryResource): - """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. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar unique_id: The unique id of this shared gallery. - :vartype unique_id: str - :ivar published_date: The published date of the gallery image version Definition. This property - can be used for decommissioning purposes. This property is updatable. - :vartype published_date: ~datetime.datetime - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar storage_profile: Describes the storage profile of the image version. - :vartype storage_profile: - ~azure.mgmt.compute.v2022_01_03.models.SharedGalleryImageVersionStorageProfile - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - "published_date": {"key": "properties.publishedDate", "type": "iso-8601"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "exclude_from_latest": {"key": "properties.excludeFromLatest", "type": "bool"}, - "storage_profile": {"key": "properties.storageProfile", "type": "SharedGalleryImageVersionStorageProfile"}, - } - - 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, - **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.v2022_01_03.models.SharedGalleryImageVersionStorageProfile - """ - 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 - - -class SharedGalleryImageVersionList(_serialization.Model): - """The List Shared Gallery Image versions operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of shared gallery images versions. Required. - :vartype value: list[~azure.mgmt.compute.v2022_01_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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SharedGalleryImageVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - 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. - :paramtype value: list[~azure.mgmt.compute.v2022_01_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SharedGalleryImageVersionStorageProfile(_serialization.Model): - """This is the storage profile of a Gallery Image Version. - - :ivar os_disk_image: This is the OS disk image. - :vartype os_disk_image: ~azure.mgmt.compute.v2022_01_03.models.SharedGalleryOSDiskImage - :ivar data_disk_images: A list of data disk images. - :vartype data_disk_images: - list[~azure.mgmt.compute.v2022_01_03.models.SharedGalleryDataDiskImage] - """ - - _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.v2022_01_03.models.SharedGalleryOSDiskImage - :keyword data_disk_images: A list of data disk images. - :paramtype data_disk_images: - list[~azure.mgmt.compute.v2022_01_03.models.SharedGalleryDataDiskImage] - """ - super().__init__(**kwargs) - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - - -class SharedGalleryList(_serialization.Model): - """The List Shared Galleries operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of shared galleries. Required. - :vartype value: list[~azure.mgmt.compute.v2022_01_03.models.SharedGallery] - :ivar next_link: The uri to fetch the next page of shared galleries. Call ListNext() with this - to fetch the next page of shared galleries. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SharedGallery]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.SharedGallery"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of shared galleries. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_01_03.models.SharedGallery] - :keyword next_link: The uri to fetch the next page of shared galleries. Call ListNext() with - this to fetch the next page of shared galleries. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SharedGalleryOSDiskImage(SharedGalleryDiskImage): - """This is the OS disk image. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar disk_size_gb: This property indicates the size of the VHD to be created. - :vartype disk_size_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2022_01_03.models.SharedGalleryHostCaching - """ - - -class SharingProfile(_serialization.Model): - """Profile for gallery sharing to subscription or tenant. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar permissions: This property allows you to specify the permission of sharing gallery. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Private** - :code:`
    `\\ :code:`
    ` **Groups** :code:`
    `\\ :code:`
    ` **Community**. Known values - are: "Private", "Groups", and "Community". - :vartype permissions: str or - ~azure.mgmt.compute.v2022_01_03.models.GallerySharingPermissionTypes - :ivar groups: A list of sharing profile groups. - :vartype groups: list[~azure.mgmt.compute.v2022_01_03.models.SharingProfileGroup] - :ivar community_gallery_info: Information of community gallery if current gallery is shared to - community. - :vartype community_gallery_info: ~azure.mgmt.compute.v2022_01_03.models.CommunityGalleryInfo - """ - - _validation = { - "groups": {"readonly": True}, - } - - _attribute_map = { - "permissions": {"key": "permissions", "type": "str"}, - "groups": {"key": "groups", "type": "[SharingProfileGroup]"}, - "community_gallery_info": {"key": "communityGalleryInfo", "type": "CommunityGalleryInfo"}, - } - - def __init__( - self, - *, - permissions: Optional[Union[str, "_models.GallerySharingPermissionTypes"]] = None, - community_gallery_info: Optional["_models.CommunityGalleryInfo"] = None, - **kwargs: Any - ) -> None: - """ - :keyword permissions: This property allows you to specify the permission of sharing gallery. - :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Private** - :code:`
    `\\ :code:`
    ` **Groups** :code:`
    `\\ :code:`
    ` **Community**. Known values - are: "Private", "Groups", and "Community". - :paramtype permissions: str or - ~azure.mgmt.compute.v2022_01_03.models.GallerySharingPermissionTypes - :keyword community_gallery_info: Information of community gallery if current gallery is shared - to community. - :paramtype community_gallery_info: ~azure.mgmt.compute.v2022_01_03.models.CommunityGalleryInfo - """ - super().__init__(**kwargs) - self.permissions = permissions - self.groups: Optional[List["_models.SharingProfileGroup"]] = None - self.community_gallery_info = community_gallery_info - - -class SharingProfileGroup(_serialization.Model): - """Group of the gallery sharing profile. - - :ivar type: This property allows you to specify the type of sharing group. :code:`
    `\\ - :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Subscriptions** :code:`
    `\\ - :code:`
    ` **AADTenants**. Known values are: "Subscriptions" and "AADTenants". - :vartype type: str or ~azure.mgmt.compute.v2022_01_03.models.SharingProfileGroupTypes - :ivar ids: A list of subscription/tenant ids the gallery is aimed to be shared to. - :vartype ids: list[str] - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "ids": {"key": "ids", "type": "[str]"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.SharingProfileGroupTypes"]] = None, - ids: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: This property allows you to specify the type of sharing group. :code:`
    `\\ - :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Subscriptions** :code:`
    `\\ - :code:`
    ` **AADTenants**. Known values are: "Subscriptions" and "AADTenants". - :paramtype type: str or ~azure.mgmt.compute.v2022_01_03.models.SharingProfileGroupTypes - :keyword ids: A list of subscription/tenant ids the gallery is aimed to be shared to. - :paramtype ids: list[str] - """ - super().__init__(**kwargs) - self.type = type - self.ids = ids - - -class SharingStatus(_serialization.Model): - """Sharing status of current gallery. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar aggregated_state: Aggregated sharing state of current gallery. Known values are: - "Succeeded", "InProgress", "Failed", and "Unknown". - :vartype aggregated_state: str or ~azure.mgmt.compute.v2022_01_03.models.SharingState - :ivar summary: Summary of all regional sharing status. - :vartype summary: list[~azure.mgmt.compute.v2022_01_03.models.RegionalSharingStatus] - """ - - _validation = { - "aggregated_state": {"readonly": True}, - } - - _attribute_map = { - "aggregated_state": {"key": "aggregatedState", "type": "str"}, - "summary": {"key": "summary", "type": "[RegionalSharingStatus]"}, - } - - def __init__(self, *, summary: Optional[List["_models.RegionalSharingStatus"]] = None, **kwargs: Any) -> None: - """ - :keyword summary: Summary of all regional sharing status. - :paramtype summary: list[~azure.mgmt.compute.v2022_01_03.models.RegionalSharingStatus] - """ - super().__init__(**kwargs) - self.aggregated_state: Optional[Union[str, "_models.SharingState"]] = None - self.summary = summary - - -class SharingUpdate(_serialization.Model): - """Specifies information about the gallery sharing profile update. - - All required parameters must be populated in order to send to server. - - :ivar operation_type: This property allows you to specify the operation type of gallery sharing - update. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` **Add** - :code:`
    `\\ :code:`
    ` **Remove** :code:`
    `\\ :code:`
    ` **Reset**. Required. Known - values are: "Add", "Remove", "Reset", and "EnableCommunity". - :vartype operation_type: str or - ~azure.mgmt.compute.v2022_01_03.models.SharingUpdateOperationTypes - :ivar groups: A list of sharing profile groups. - :vartype groups: list[~azure.mgmt.compute.v2022_01_03.models.SharingProfileGroup] - """ - - _validation = { - "operation_type": {"required": True}, - } - - _attribute_map = { - "operation_type": {"key": "operationType", "type": "str"}, - "groups": {"key": "groups", "type": "[SharingProfileGroup]"}, - } - - def __init__( - self, - *, - operation_type: Union[str, "_models.SharingUpdateOperationTypes"], - groups: Optional[List["_models.SharingProfileGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword operation_type: This property allows you to specify the operation type of gallery - sharing update. :code:`
    `\\ :code:`
    ` Possible values are: :code:`
    `\\ :code:`
    ` - **Add** :code:`
    `\\ :code:`
    ` **Remove** :code:`
    `\\ :code:`
    ` **Reset**. Required. - Known values are: "Add", "Remove", "Reset", and "EnableCommunity". - :paramtype operation_type: str or - ~azure.mgmt.compute.v2022_01_03.models.SharingUpdateOperationTypes - :keyword groups: A list of sharing profile groups. - :paramtype groups: list[~azure.mgmt.compute.v2022_01_03.models.SharingProfileGroup] - """ - super().__init__(**kwargs) - self.operation_type = operation_type - self.groups = groups - - -class SoftDeletePolicy(_serialization.Model): - """Contains information about the soft deletion policy of the gallery. - - :ivar is_soft_delete_enabled: Enables soft-deletion for resources in this gallery, allowing - them to be recovered within retention time. - :vartype is_soft_delete_enabled: bool - """ - - _attribute_map = { - "is_soft_delete_enabled": {"key": "isSoftDeleteEnabled", "type": "bool"}, - } - - def __init__(self, *, is_soft_delete_enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword is_soft_delete_enabled: Enables soft-deletion for resources in this gallery, allowing - them to be recovered within retention time. - :paramtype is_soft_delete_enabled: bool - """ - super().__init__(**kwargs) - self.is_soft_delete_enabled = is_soft_delete_enabled - - -class SubResource(_serialization.Model): - """SubResource. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class SubResourceReadOnly(_serialization.Model): - """SubResourceReadOnly. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class TargetRegion(_serialization.Model): - """Describes the target region information. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the region. Required. - :vartype name: str - :ivar regional_replica_count: The number of replicas of the Image Version to be created per - region. This property is updatable. - :vartype regional_replica_count: int - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "Premium_LRS", and "StandardSSD_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType - :ivar encryption: Optional. Allows users to provide customer managed keys for encrypting the OS - and data disks in the gallery artifact. - :vartype encryption: ~azure.mgmt.compute.v2022_01_03.models.EncryptionImages - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "regional_replica_count": {"key": "regionalReplicaCount", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "encryption": {"key": "encryption", "type": "EncryptionImages"}, - } - - def __init__( - self, - *, - name: str, - regional_replica_count: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - encryption: Optional["_models.EncryptionImages"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the region. Required. - :paramtype name: str - :keyword regional_replica_count: The number of replicas of the Image Version to be created per - region. This property is updatable. - :paramtype regional_replica_count: int - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "Premium_LRS", and "StandardSSD_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType - :keyword encryption: Optional. Allows users to provide customer managed keys for encrypting the - OS and data disks in the gallery artifact. - :paramtype encryption: ~azure.mgmt.compute.v2022_01_03.models.EncryptionImages - """ - super().__init__(**kwargs) - self.name = name - self.regional_replica_count = regional_replica_count - self.storage_account_type = storage_account_type - self.encryption = encryption - - -class UserArtifactManage(_serialization.Model): - """UserArtifactManage. - - All required parameters must be populated in order to send to server. - - :ivar install: Required. The path and arguments to install the gallery application. This is - limited to 4096 characters. Required. - :vartype install: str - :ivar remove: Required. The path and arguments to remove the gallery application. This is - limited to 4096 characters. Required. - :vartype remove: str - :ivar update: Optional. The path and arguments to update the gallery application. If not - present, then update operation will invoke remove command on the previous version and install - command on the current version of the gallery application. This is limited to 4096 characters. - :vartype update: str - """ - - _validation = { - "install": {"required": True}, - "remove": {"required": True}, - } - - _attribute_map = { - "install": {"key": "install", "type": "str"}, - "remove": {"key": "remove", "type": "str"}, - "update": {"key": "update", "type": "str"}, - } - - def __init__(self, *, install: str, remove: str, update: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword install: Required. The path and arguments to install the gallery application. This is - limited to 4096 characters. Required. - :paramtype install: str - :keyword remove: Required. The path and arguments to remove the gallery application. This is - limited to 4096 characters. Required. - :paramtype remove: str - :keyword update: Optional. The path and arguments to update the gallery application. If not - present, then update operation will invoke remove command on the previous version and install - command on the current version of the gallery application. This is limited to 4096 characters. - :paramtype update: str - """ - super().__init__(**kwargs) - self.install = install - self.remove = remove - self.update = update - - -class UserArtifactSettings(_serialization.Model): - """Additional settings for the VM app that contains the target package and config file name when - it is deployed to target VM or VM scale set. - - :ivar package_file_name: Optional. The name to assign the downloaded package file on the VM. - This is limited to 4096 characters. If not specified, the package file will be named the same - as the Gallery Application name. - :vartype package_file_name: str - :ivar config_file_name: Optional. The name to assign the downloaded config file on the VM. This - is limited to 4096 characters. If not specified, the config file will be named the Gallery - Application name appended with "_config". - :vartype config_file_name: str - """ - - _attribute_map = { - "package_file_name": {"key": "packageFileName", "type": "str"}, - "config_file_name": {"key": "configFileName", "type": "str"}, - } - - def __init__( - self, *, package_file_name: Optional[str] = None, config_file_name: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword package_file_name: Optional. The name to assign the downloaded package file on the VM. - This is limited to 4096 characters. If not specified, the package file will be named the same - as the Gallery Application name. - :paramtype package_file_name: str - :keyword config_file_name: Optional. The name to assign the downloaded config file on the VM. - This is limited to 4096 characters. If not specified, the config file will be named the Gallery - Application name appended with "_config". - :paramtype config_file_name: str - """ - super().__init__(**kwargs) - self.package_file_name = package_file_name - self.config_file_name = config_file_name - - -class UserArtifactSource(_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 media_link: Required. The mediaLink of the artifact, must be a readable storage page - blob. Required. - :vartype media_link: str - :ivar default_configuration_link: Optional. The defaultConfigurationLink of the artifact, must - be a readable storage page blob. - :vartype default_configuration_link: str - """ - - _validation = { - "media_link": {"required": True}, - } - - _attribute_map = { - "media_link": {"key": "mediaLink", "type": "str"}, - "default_configuration_link": {"key": "defaultConfigurationLink", "type": "str"}, - } - - def __init__(self, *, media_link: str, default_configuration_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword media_link: Required. The mediaLink of the artifact, must be a readable storage page - blob. Required. - :paramtype media_link: str - :keyword default_configuration_link: Optional. The defaultConfigurationLink of the artifact, - must be a readable storage page blob. - :paramtype default_configuration_link: str - """ - super().__init__(**kwargs) - self.media_link = media_link - self.default_configuration_link = default_configuration_link - - -class UserAssignedIdentitiesValue(_serialization.Model): - """UserAssignedIdentitiesValue. - - 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: Optional[str] = None - self.client_id: Optional[str] = None diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/__init__.py deleted file mode 100644 index 139d983a5840..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/__init__.py +++ /dev/null @@ -1,47 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - 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 ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "GalleriesOperations", - "GalleryImagesOperations", - "GalleryImageVersionsOperations", - "GalleryApplicationsOperations", - "GalleryApplicationVersionsOperations", - "GallerySharingProfileOperations", - "SharedGalleriesOperations", - "SharedGalleryImagesOperations", - "SharedGalleryImageVersionsOperations", - "CommunityGalleriesOperations", - "CommunityGalleryImagesOperations", - "CommunityGalleryImageVersionsOperations", -] -__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/v2022_01_03/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_operations.py deleted file mode 100644 index 8290fd63771f..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_operations.py +++ /dev/null @@ -1,6205 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import ComputeManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-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}", - ) - 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"), - } - - _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_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", "2022-01-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}", - ) - 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"), - } - - _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_galleries_get_request( - resource_group_name: str, - gallery_name: str, - subscription_id: str, - *, - select: Optional[Union[str, _models.SelectPermissions]] = None, - expand: Optional[Union[str, _models.GalleryExpandParams]] = 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", "2022-01-03")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-03")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", - ) - 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"), - } - - _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) - - -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", "2022-01-03")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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", "2022-01-03")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2022-01-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}", - ) - 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"), - } - - _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_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", "2022-01-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}", - ) - 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"), - } - - _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_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", "2022-01-03")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-03")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-03")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images", - ) - 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"), - } - - _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_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, - **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", "2022-01-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}", - ) - 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"), - } - - _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_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", "2022-01-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}", - ) - 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"), - } - - _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_image_versions_get_request( - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image_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", "2022-01-03")) - 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}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-03")) - 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}", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-03")) - 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", - ) - 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"), - } - - _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_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", "2022-01-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}", - ) - 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"), - } - - _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", "2022-01-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}", - ) - 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"), - } - - _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_get_request( - 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", "2022-01-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}", - ) - 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"), - } - - _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_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", "2022-01-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}", - ) - 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"), - } - - _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) - - -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", "2022-01-03")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications", - ) - 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"), - } - - _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_gallery_application_versions_create_or_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, - **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", "2022-01-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}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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_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, - **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", "2022-01-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}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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_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", "2022-01-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}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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) - - -def build_gallery_application_versions_delete_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, - **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", "2022-01-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}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-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}/versions", - ) - 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"), - } - - _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_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", "2022-01-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", - ) - 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"), - } - - _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_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", "2022-01-03")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "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) - - -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", "2022-01-03")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}", - ) - 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"), - } - - _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_shared_gallery_images_list_request( - location: str, - gallery_unique_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-03")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images", - ) - 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"), - } - - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-03")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}", - ) - 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"), - "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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-03")) - 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", - ) - 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"), - "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) - - -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", "2022-01-03")) - 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}", - ) - 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"), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2022-01-03")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}", - ) - 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-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}", - ) - 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", "2022-01-03")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images", - ) - 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", "2022-01-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}", - ) - 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"), - "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") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-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", - ) - 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) - - -class GalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s - :attr:`galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2022-01-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 - - 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) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: _models.Gallery, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_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. - Required. - :type gallery_name: str - :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. - Required. - :type gallery: ~azure.mgmt.compute.v2022_01_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.v2022_01_03.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2022_01_03.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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. Is - either a Gallery type or a IO[bytes] type. Required. - :type gallery: ~azure.mgmt.compute.v2022_01_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.v2022_01_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 "2022-01-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) - - 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, **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 _update_initial( - self, - resource_group_name: str, - gallery_name: str, - gallery: Union[_models.GalleryUpdate, 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 "2022-01-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, "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) - - _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]: - 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, - 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. 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 update Shared Image Gallery operation. Required. - :type gallery: ~azure.mgmt.compute.v2022_01_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.v2022_01_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. 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 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.v2022_01_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. 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 update Shared Image Gallery operation. Is either a - GalleryUpdate type or a IO[bytes] type. Required. - :type gallery: ~azure.mgmt.compute.v2022_01_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.v2022_01_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 "2022-01-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, **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 - ) - - @distributed_trace - 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.v2022_01_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.v2022_01_03.models.GalleryExpandParams - :return: Gallery or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_01_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 "2022-01-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) - 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 - - def _delete_initial(self, resource_group_name: str, gallery_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 "2022-01-03")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_galleries_delete_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) - - _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, gallery_name: str, **kwargs: Any) -> LROPoller[None]: - """Delete 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 to be deleted. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-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, - 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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2022_01_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 "2022-01-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 - - 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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_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.v2022_01_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 "2022-01-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 - - 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) - - 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 GalleryImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s - :attr:`gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_image_name: str, - gallery_image: Union[_models.GalleryImage, 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 "2022-01-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") - - _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 = 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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.v2022_01_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.v2022_01_03.models.GalleryImage] - :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: IO[bytes], - *, - 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: IO[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.v2022_01_03.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2022_01_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.v2022_01_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 "2022-01-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) - - 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: 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, - ) - return LROPoller[_models.GalleryImage]( - 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: Union[_models.GalleryImageUpdate, 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 "2022-01-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") - - _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 = 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: - 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, - 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.v2022_01_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.v2022_01_03.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2022_01_03.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image: Union[_models.GalleryImageUpdate, IO[bytes]], - **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. Is either a - GalleryImageUpdate type or a IO[bytes] type. Required. - :type gallery_image: ~azure.mgmt.compute.v2022_01_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.v2022_01_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 "2022-01-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) - - 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: 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, - ) - 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_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.v2022_01_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 "2022-01-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, - 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("GalleryImage", 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 "2022-01-03")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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) - - _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, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> LROPoller[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 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 "2022-01-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 - ) -> ItemPaged["_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.v2022_01_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 "2022-01-03")) - cls: ClsType[_models.GalleryImageList] = 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_images_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("GalleryImageList", 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 GalleryImageVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s - :attr:`gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_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 "2022-01-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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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.v2022_01_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.v2022_01_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. 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.v2022_01_03.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2022_01_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.v2022_01_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 "2022-01-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, **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, - 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 "2022-01-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, "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) - - _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]: - 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, - 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. - - :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.v2022_01_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.v2022_01_03.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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 LROPoller that returns either GalleryImageVersion or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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 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.v2022_01_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.v2022_01_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 "2022-01-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._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, **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 - ) - - @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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2022_01_03.models.ReplicationStatusTypes - :return: GalleryImageVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_01_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 "2022-01-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( - 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, - 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 "2022-01-03")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - **kwargs: Any - ) -> LROPoller[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 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 "2022-01-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 - - 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_image( - self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> ItemPaged["_models.GalleryImageVersion"]: - """List gallery image versions in 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 - resides. 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) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_01_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 "2022-01-03")) - cls: ClsType[_models.GalleryImageVersionList] = 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_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, - 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("GalleryImageVersionList", 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 GalleryApplicationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s - :attr:`gallery_applications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application: Union[_models.GalleryApplication, 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 "2022-01-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_application, (IOBase, bytes)): - _content = gallery_application - else: - _json = self._serialize.body(gallery_application, "GalleryApplication") - - _request = build_gallery_applications_create_or_update_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, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: _models.GalleryApplication, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2022_01_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 GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_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]: - """Create or update 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 is to be created. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the create or 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.v2022_01_03.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplication, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.v2022_01_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.v2022_01_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 "2022-01-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._create_or_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, **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 _update_initial( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, 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 "2022-01-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_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_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, - ) - _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]: - 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, - gallery_application_name: str, - gallery_application: _models.GalleryApplicationUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the update gallery Application operation. - Required. - :type gallery_application: ~azure.mgmt.compute.v2022_01_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.v2022_01_03.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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 is to be updated. 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. - :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.v2022_01_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. 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. - :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. - :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.v2022_01_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.v2022_01_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 "2022-01-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, **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 - ) - - @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.v2022_01_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 "2022-01-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 - ) -> 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 "2022-01-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) - 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, 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. 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. - :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be deleted. - 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 "2022-01-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, **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 - ) -> ItemPaged["_models.GalleryApplication"]: - """List gallery Application 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 Application Gallery from which Application - Definitions are to be listed. 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.v2022_01_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 "2022-01-03")) - cls: ClsType[_models.GalleryApplicationList] = 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_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: - 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 GalleryApplicationVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s - :attr:`gallery_application_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: Union[_models.GalleryApplicationVersion, 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 "2022-01-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_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersion") - - _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, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersion, - *, - 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. - :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 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.v2022_01_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 GalleryApplicationVersion or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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], - *, - 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. - :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 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] - :keyword content_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.v2022_01_03.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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]], - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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.v2022_01_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.v2022_01_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 "2022-01-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, 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_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 - ) - 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: 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.GalleryApplicationVersion].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.GalleryApplicationVersion]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - 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]], - **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 "2022-01-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_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersionUpdate") - - _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, - 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]: - 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, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2022_01_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 GalleryApplicationVersion or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update 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 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] - :keyword content_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.v2022_01_03.models.GalleryApplicationVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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]], - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update 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 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.v2022_01_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.v2022_01_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 "2022-01-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, 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_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 - ) - 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: 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.GalleryApplicationVersion].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - 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, - 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. "ReplicationStatus" Default - value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2022_01_03.models.ReplicationStatusTypes - :return: GalleryApplicationVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_01_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 "2022-01-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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-03")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Delete 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 - deleted. 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-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, - gallery_application_version_name=gallery_application_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 - - 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_application( - self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> ItemPaged["_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.v2022_01_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 "2022-01-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.v2022_01_03.ComputeManagementClient`'s - :attr:`gallery_sharing_profile` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 "2022-01-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.v2022_01_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.v2022_01_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.v2022_01_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.v2022_01_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.v2022_01_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 "2022-01-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.v2022_01_03.ComputeManagementClient`'s - :attr:`shared_galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_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.v2022_01_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.v2022_01_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 "2022-01-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.v2022_01_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 "2022-01-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.v2022_01_03.ComputeManagementClient`'s - :attr:`shared_gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_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.v2022_01_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.v2022_01_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 "2022-01-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.v2022_01_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 "2022-01-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 - - -class SharedGalleryImageVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s - :attr:`shared_gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.SharedGalleryImageVersion"]: - """List shared gallery image versions 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 - :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.v2022_01_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.v2022_01_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 "2022-01-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 - - 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, 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, - gallery_image_version_name: str, - **kwargs: Any - ) -> _models.SharedGalleryImageVersion: - """Get a shared gallery image version 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 - :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.v2022_01_03.models.SharedGalleryImageVersion - :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 "2022-01-03")) - cls: ClsType[_models.SharedGalleryImageVersion] = kwargs.pop("cls", None) - - _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, - 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("SharedGalleryImageVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class CommunityGalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s - :attr:`community_galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, **kwargs: Any) -> _models.CommunityGallery: - """Get a community gallery by gallery public name. - - :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.v2022_01_03.models.CommunityGallery - :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 "2022-01-03")) - cls: ClsType[_models.CommunityGallery] = kwargs.pop("cls", 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) - - _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("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.v2022_01_03.ComputeManagementClient`'s - :attr:`community_gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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.v2022_01_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 "2022-01-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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CommunityGalleryImage", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, location: str, public_gallery_name: str, **kwargs: Any - ) -> ItemPaged["_models.CommunityGalleryImage"]: - """List community gallery images inside 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 - :return: An iterator like instance of either CommunityGalleryImage or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_01_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 "2022-01-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 - - def extract_data(pipeline_response): - deserialized = self._deserialize("CommunityGalleryImageList", 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 CommunityGalleryImageVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s - :attr:`community_gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - gallery_image_version_name: str, - **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.v2022_01_03.models.CommunityGalleryImageVersion - :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 "2022-01-03")) - cls: ClsType[_models.CommunityGalleryImageVersion] = 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, - 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("CommunityGalleryImageVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, location: str, public_gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> ItemPaged["_models.CommunityGalleryImageVersion"]: - """List community gallery image versions inside an 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: An iterator like instance of either CommunityGalleryImageVersion or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_01_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 "2022-01-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) - 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/v2022_01_03/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2022_03_02/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_compute_management_client.py deleted file mode 100644 index 05d0eecf6cc1..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_compute_management_client.py +++ /dev/null @@ -1,144 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ( - DiskAccessesOperations, - DiskEncryptionSetsOperations, - DiskRestorePointOperations, - DisksOperations, - SnapshotsOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar disks: DisksOperations operations - :vartype disks: azure.mgmt.compute.v2022_03_02.operations.DisksOperations - :ivar disk_accesses: DiskAccessesOperations operations - :vartype disk_accesses: azure.mgmt.compute.v2022_03_02.operations.DiskAccessesOperations - :ivar disk_encryption_sets: DiskEncryptionSetsOperations operations - :vartype disk_encryption_sets: - azure.mgmt.compute.v2022_03_02.operations.DiskEncryptionSetsOperations - :ivar disk_restore_point: DiskRestorePointOperations operations - :vartype disk_restore_point: - azure.mgmt.compute.v2022_03_02.operations.DiskRestorePointOperations - :ivar snapshots: SnapshotsOperations operations - :vartype snapshots: azure.mgmt.compute.v2022_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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-03-02". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - 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, "2022-03-02") - self.disk_accesses = DiskAccessesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-03-02" - ) - self.disk_encryption_sets = DiskEncryptionSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-03-02" - ) - self.disk_restore_point = DiskRestorePointOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-03-02" - ) - self.snapshots = SnapshotsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-03-02" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_configuration.py deleted file mode 100644 index bfdba946c32f..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-03-02". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2022-03-02") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_metadata.json deleted file mode 100644 index 2c7936cee861..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_metadata.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "chosen_version": "2022-03-02", - "total_api_version_list": ["2022-03-02"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "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.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "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.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node
    is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj 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 deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2022_03_02/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/_compute_management_client.py deleted file mode 100644 index acdb9b9576c3..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/_compute_management_client.py +++ /dev/null @@ -1,148 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ( - DiskAccessesOperations, - DiskEncryptionSetsOperations, - DiskRestorePointOperations, - DisksOperations, - SnapshotsOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar disks: DisksOperations operations - :vartype disks: azure.mgmt.compute.v2022_03_02.aio.operations.DisksOperations - :ivar disk_accesses: DiskAccessesOperations operations - :vartype disk_accesses: azure.mgmt.compute.v2022_03_02.aio.operations.DiskAccessesOperations - :ivar disk_encryption_sets: DiskEncryptionSetsOperations operations - :vartype disk_encryption_sets: - azure.mgmt.compute.v2022_03_02.aio.operations.DiskEncryptionSetsOperations - :ivar disk_restore_point: DiskRestorePointOperations operations - :vartype disk_restore_point: - azure.mgmt.compute.v2022_03_02.aio.operations.DiskRestorePointOperations - :ivar snapshots: SnapshotsOperations operations - :vartype snapshots: azure.mgmt.compute.v2022_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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-03-02". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - 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, "2022-03-02") - self.disk_accesses = DiskAccessesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-03-02" - ) - self.disk_encryption_sets = DiskEncryptionSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-03-02" - ) - self.disk_restore_point = DiskRestorePointOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-03-02" - ) - self.snapshots = SnapshotsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-03-02" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/_configuration.py deleted file mode 100644 index d732e673ea42..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-03-02". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2022-03-02") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/__init__.py deleted file mode 100644 index 0e0c2d8aaf8d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -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 SnapshotsOperations # 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", - "SnapshotsOperations", -] -__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/v2022_03_02/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_operations.py deleted file mode 100644 index a7204d6f3a9a..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_operations.py +++ /dev/null @@ -1,4727 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import ( - build_disk_accesses_create_or_update_request, - build_disk_accesses_delete_a_private_endpoint_connection_request, - build_disk_accesses_delete_request, - build_disk_accesses_get_a_private_endpoint_connection_request, - build_disk_accesses_get_private_link_resources_request, - build_disk_accesses_get_request, - build_disk_accesses_list_by_resource_group_request, - build_disk_accesses_list_private_endpoint_connections_request, - build_disk_accesses_list_request, - build_disk_accesses_update_a_private_endpoint_connection_request, - build_disk_accesses_update_request, - build_disk_encryption_sets_create_or_update_request, - build_disk_encryption_sets_delete_request, - build_disk_encryption_sets_get_request, - build_disk_encryption_sets_list_associated_resources_request, - build_disk_encryption_sets_list_by_resource_group_request, - build_disk_encryption_sets_list_request, - build_disk_encryption_sets_update_request, - build_disk_restore_point_get_request, - build_disk_restore_point_grant_access_request, - build_disk_restore_point_list_by_restore_point_request, - build_disk_restore_point_revoke_access_request, - build_disks_create_or_update_request, - build_disks_delete_request, - build_disks_get_request, - build_disks_grant_access_request, - build_disks_list_by_resource_group_request, - build_disks_list_request, - build_disks_revoke_access_request, - build_disks_update_request, - build_snapshots_create_or_update_request, - build_snapshots_delete_request, - build_snapshots_get_request, - build_snapshots_grant_access_request, - build_snapshots_list_by_resource_group_request, - build_snapshots_list_request, - build_snapshots_revoke_access_request, - build_snapshots_update_request, -) -from .._configuration import ComputeManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DisksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_03_02.aio.ComputeManagementClient`'s - :attr:`disks` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_name: str, disk: Union[_models.Disk, 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 "2022-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk, (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_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) - - _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_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. 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.v2022_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.v2022_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. 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.v2022_03_02.models.Disk] - :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. - - :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 - :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.v2022_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.v2022_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 "2022-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, 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, - 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("Disk", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Disk].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Disk]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _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, - 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 "2022-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk, (IOBase, bytes)): - _content = disk - else: - _json = self._serialize.body(disk, "DiskUpdate") - - _request = build_disks_update_request( - resource_group_name=resource_group_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) - - _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( - self, - resource_group_name: str, - disk_name: str, - disk: _models.DiskUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Updates (patches) a disk. - - :param resource_group_name: The name of the resource group. 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.v2022_03_02.models.DiskUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.Disk] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - disk_name: str, - disk: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Updates (patches) a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Patch disk operation. Required. - :type disk: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.Disk] - :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. - - :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 - :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.v2022_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.v2022_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 "2022-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, 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, - 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("Disk", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Disk].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Disk]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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.v2022_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 "2022-03-02")) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) - - _request = build_disks_get_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) - - _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("Disk", 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_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 "2022-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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-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, **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) -> AsyncItemPaged["_models.Disk"]: - """Lists all the disks 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 Disk or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_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 "2022-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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2022_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 "2022-03-02")) - cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disks_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _grant_access_initial( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, 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 "2022-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disks_grant_access_request( - resource_group_name=resource_group_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) - - _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_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2022_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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param grant_access_data: Access data object supplied in the body of the get disk access - operation. Required. - :type grant_access_data: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2022_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.v2022_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 "2022-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, - disk_name=disk_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, 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 "2022-03-02")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disks_revoke_access_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]: - 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_revoke_access( - self, resource_group_name: str, disk_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Revokes access to 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-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) - - 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 DiskAccessesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_03_02.aio.ComputeManagementClient`'s - :attr:`disk_accesses` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2022-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access - else: - _json = self._serialize.body(disk_access, "DiskAccess") - - _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) - - _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_create_or_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccess, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Put disk access operation. - Required. - :type disk_access: ~azure.mgmt.compute.v2022_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.v2022_03_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2022_03_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Put disk access operation. - Is either a DiskAccess type or a IO[bytes] type. Required. - :type disk_access: ~azure.mgmt.compute.v2022_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.v2022_03_02.models.DiskAccess] - :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 "2022-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) - - 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 - - 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 - ) - - async def _update_initial( - 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, - 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 "2022-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access - else: - _json = self._serialize.body(disk_access, "DiskAccessUpdate") - - _request = build_disk_accesses_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) - - _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( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccessUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Patch disk access operation. - Required. - :type disk_access: ~azure.mgmt.compute.v2022_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 DiskAccess or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the 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 DiskAccess or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - 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. - :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.v2022_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.v2022_03_02.models.DiskAccess] - :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 "2022-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._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) - - 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 - - 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 - ) - - @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.v2022_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 "2022-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 - ) -> 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 "2022-03-02")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disk_accesses_delete_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) - - _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_access_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes 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 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 "2022-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: - 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) -> AsyncItemPaged["_models.DiskAccess"]: - """Lists all the disk access resources 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 DiskAccess or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_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 "2022-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 - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2022_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 "2022-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_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. 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.v2022_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 "2022-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 - - 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, - 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 "2022-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.v2022_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.v2022_03_02.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2022_03_02.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long - self, - resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection under disk access resource, this can't be used - to create a new private endpoint connection. - - :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.v2022_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.v2022_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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 polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def get_a_private_endpoint_connection( - self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets information about a private endpoint connection under a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_03_02.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-03-02")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_disk_accesses_get_a_private_endpoint_connection_request( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # 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 - ) -> 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 "2022-03-02")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disk_accesses_delete_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) - - _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_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. - - :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: 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 "2022-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_a_private_endpoint_connection_initial( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_private_endpoint_connections( - self, resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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.v2022_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 "2022-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.v2022_03_02.aio.ComputeManagementClient`'s - :attr:`disk_encryption_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set - else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") - - _request = build_disk_encryption_sets_create_or_update_request( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Is either a DiskEncryptionSet type or a IO[bytes] type. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2022_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.v2022_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 "2022-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._create_or_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, **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 _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, - 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 "2022-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set - else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSetUpdate") - - _request = build_disk_encryption_sets_update_request( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, - 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. - :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.v2022_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.v2022_03_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. 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.v2022_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. 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.v2022_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.v2022_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 "2022-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, **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 - ) - - @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.v2022_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 "2022-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 - ) -> 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 "2022-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) - - 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_encryption_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[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 - :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 "2022-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 - ) -> AsyncItemPaged["_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.v2022_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 "2022-03-02")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2022_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 "2022-03-02")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_associated_resources( - self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> AsyncItemPaged[str]: - """Lists all resources that are encrypted with this 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: 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 "2022-03-02")) - cls: ClsType[_models.ResourceUriList] = 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_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, - 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("ResourceUriList", 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 DiskRestorePointOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_03_02.aio.ComputeManagementClient`'s - :attr:`disk_restore_point` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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. - - :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 - :return: DiskRestorePoint or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_03_02.models.DiskRestorePoint - :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 "2022-03-02")) - cls: ClsType[_models.DiskRestorePoint] = kwargs.pop("cls", None) - - _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) - - _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 - ) -> AsyncItemPaged["_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.v2022_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 "2022-03-02")) - cls: ClsType[_models.DiskRestorePointList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_restore_point_list_by_restore_point_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskRestorePointList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _grant_access_initial( - self, - resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> 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 "2022-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disk_restore_point_grant_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, - 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_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: _models.GrantAccessData, - *, - 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: ~azure.mgmt.compute.v2022_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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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: 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.v2022_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. - - :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.v2022_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.v2022_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 "2022-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 "2022-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 - - @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. - - :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 - :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 "2022-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, - 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, - 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 SnapshotsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_03_02.aio.ComputeManagementClient`'s - :attr:`snapshots` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, snapshot_name: str, snapshot: Union[_models.Snapshot, 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 "2022-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "Snapshot") - - _request = build_snapshots_create_or_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.Snapshot, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: ~azure.mgmt.compute.v2022_03_02.models.Snapshot - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :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.v2022_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.v2022_03_02.models.Snapshot] - :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 "2022-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, 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, - 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, **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 _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, - 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 "2022-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "SnapshotUpdate") - - _request = build_snapshots_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.SnapshotUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. 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.v2022_03_02.models.SnapshotUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. - Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. Is - either a SnapshotUpdate type or a IO[bytes] type. Required. - :type snapshot: ~azure.mgmt.compute.v2022_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.v2022_03_02.models.Snapshot] - :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 "2022-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, 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, **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 - ) - - @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.v2022_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 "2022-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( - 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 "2022-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) - - 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, snapshot_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes 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: 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 "2022-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, - snapshot_name=snapshot_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) -> AsyncItemPaged["_models.Snapshot"]: - """Lists snapshots 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 Snapshot or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_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 "2022-03-02")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - 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(self, **kwargs: Any) -> AsyncItemPaged["_models.Snapshot"]: - """Lists snapshots under a subscription. - - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_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 "2022-03-02")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _grant_access_initial( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, 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 "2022-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_snapshots_grant_access_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param grant_access_data: Access data object supplied in the body of the get snapshot access - operation. Required. - :type grant_access_data: ~azure.mgmt.compute.v2022_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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param 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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param 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.v2022_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.v2022_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 "2022-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, - snapshot_name=snapshot_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, 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 "2022-03-02")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_snapshots_revoke_access_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]: - 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_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. - :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 "2022-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, - snapshot_name=snapshot_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/__init__.py deleted file mode 100644 index 3797ff8db382..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/__init__.py +++ /dev/null @@ -1,168 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - AccessUri, - ApiError, - ApiErrorBase, - CopyCompletionError, - CreationData, - Disk, - DiskAccess, - DiskAccessList, - DiskAccessUpdate, - DiskEncryptionSet, - DiskEncryptionSetList, - DiskEncryptionSetUpdate, - DiskList, - DiskRestorePoint, - DiskRestorePointList, - DiskSecurityProfile, - DiskSku, - DiskUpdate, - Encryption, - EncryptionSetIdentity, - EncryptionSettingsCollection, - EncryptionSettingsElement, - ExtendedLocation, - GrantAccessData, - ImageDiskReference, - InnerError, - KeyForDiskEncryptionSet, - KeyVaultAndKeyReference, - KeyVaultAndSecretReference, - PrivateEndpoint, - PrivateEndpointConnection, - PrivateEndpointConnectionListResult, - PrivateLinkResource, - PrivateLinkResourceListResult, - PrivateLinkServiceConnectionState, - PropertyUpdatesInProgress, - ProxyOnlyResource, - PurchasePlan, - Resource, - ResourceUriList, - ResourceWithOptionalLocation, - ShareInfoElement, - Snapshot, - SnapshotList, - SnapshotSku, - SnapshotUpdate, - SourceVault, - SubResource, - SubResourceReadOnly, - SupportedCapabilities, - UserAssignedIdentitiesValue, -) - -from ._compute_management_client_enums import ( # type: ignore - AccessLevel, - Architecture, - CopyCompletionErrorReason, - DataAccessAuthMode, - DiskCreateOption, - DiskEncryptionSetIdentityType, - DiskEncryptionSetType, - DiskSecurityTypes, - DiskState, - DiskStorageAccountTypes, - EncryptionType, - ExtendedLocationTypes, - HyperVGeneration, - NetworkAccessPolicy, - OperatingSystemTypes, - PrivateEndpointConnectionProvisioningState, - PrivateEndpointServiceConnectionStatus, - PublicNetworkAccess, - SnapshotStorageAccountTypes, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AccessUri", - "ApiError", - "ApiErrorBase", - "CopyCompletionError", - "CreationData", - "Disk", - "DiskAccess", - "DiskAccessList", - "DiskAccessUpdate", - "DiskEncryptionSet", - "DiskEncryptionSetList", - "DiskEncryptionSetUpdate", - "DiskList", - "DiskRestorePoint", - "DiskRestorePointList", - "DiskSecurityProfile", - "DiskSku", - "DiskUpdate", - "Encryption", - "EncryptionSetIdentity", - "EncryptionSettingsCollection", - "EncryptionSettingsElement", - "ExtendedLocation", - "GrantAccessData", - "ImageDiskReference", - "InnerError", - "KeyForDiskEncryptionSet", - "KeyVaultAndKeyReference", - "KeyVaultAndSecretReference", - "PrivateEndpoint", - "PrivateEndpointConnection", - "PrivateEndpointConnectionListResult", - "PrivateLinkResource", - "PrivateLinkResourceListResult", - "PrivateLinkServiceConnectionState", - "PropertyUpdatesInProgress", - "ProxyOnlyResource", - "PurchasePlan", - "Resource", - "ResourceUriList", - "ResourceWithOptionalLocation", - "ShareInfoElement", - "Snapshot", - "SnapshotList", - "SnapshotSku", - "SnapshotUpdate", - "SourceVault", - "SubResource", - "SubResourceReadOnly", - "SupportedCapabilities", - "UserAssignedIdentitiesValue", - "AccessLevel", - "Architecture", - "CopyCompletionErrorReason", - "DataAccessAuthMode", - "DiskCreateOption", - "DiskEncryptionSetIdentityType", - "DiskEncryptionSetType", - "DiskSecurityTypes", - "DiskState", - "DiskStorageAccountTypes", - "EncryptionType", - "ExtendedLocationTypes", - "HyperVGeneration", - "NetworkAccessPolicy", - "OperatingSystemTypes", - "PrivateEndpointConnectionProvisioningState", - "PrivateEndpointServiceConnectionStatus", - "PublicNetworkAccess", - "SnapshotStorageAccountTypes", -] -__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/v2022_03_02/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/_compute_management_client_enums.py deleted file mode 100644 index 77622099b8ac..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/_compute_management_client_enums.py +++ /dev/null @@ -1,257 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AccessLevel.""" - - NONE = "None" - READ = "Read" - WRITE = "Write" - - -class Architecture(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """CPU architecture supported by an OS disk.""" - - X64 = "x64" - ARM64 = "Arm64" - - -class CopyCompletionErrorReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the error code if the background copy of a resource created via the CopyStart - operation fails. - """ - - COPY_SOURCE_NOT_FOUND = "CopySourceNotFound" - """Indicates that the source snapshot was deleted while the background copy of the resource - created via CopyStart operation was in progress.""" - - -class DataAccessAuthMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Additional authentication requirements when exporting or uploading to a disk or snapshot.""" - - AZURE_ACTIVE_DIRECTORY = "AzureActiveDirectory" - """When export/upload URL is used, the system checks if the user has an identity in Azure Active - Directory and has necessary permissions to export/upload the data. Please refer to - aka.ms/DisksAzureADAuth.""" - NONE = "None" - """No additional authentication would be performed when accessing export/upload URL.""" - - -class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This enumerates the possible sources of a disk's creation.""" - - EMPTY = "Empty" - """Create an empty data disk of a size given by diskSizeGB.""" - ATTACH = "Attach" - """Disk will be attached to a VM.""" - FROM_IMAGE = "FromImage" - """Create a new disk from a platform image specified by the given imageReference or - galleryImageReference.""" - IMPORT = "Import" - """Create a disk by importing from a blob specified by a sourceUri in a storage account specified - by storageAccountId.""" - COPY = "Copy" - """Create a new disk or snapshot by copying from a disk or snapshot specified by the given - sourceResourceId.""" - RESTORE = "Restore" - """Create a new disk by copying from a backup recovery point.""" - UPLOAD = "Upload" - """Create a new disk by obtaining a write token and using it to directly upload the contents of - the disk.""" - COPY_START = "CopyStart" - """Create a new disk by using a deep copy process, where the resource creation is considered - complete only after all data has been copied from the source.""" - IMPORT_SECURE = "ImportSecure" - """Similar to Import create option. Create a new Trusted Launch VM or Confidential VM supported - disk by importing additional blob for VM guest state specified by securityDataUri in storage - account specified by storageAccountId""" - UPLOAD_PREPARED_SECURE = "UploadPreparedSecure" - """Similar to Upload create option. Create a new Trusted Launch VM or Confidential VM supported - disk and upload using write token in both disk and VM guest state""" - IMPORT_ENUM = "Import" - """Create a disk by importing from a blob specified by a sourceUri in a storage account specified - by storageAccountId.""" - - -class DiskEncryptionSetIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported - for new creations. Disk Encryption Sets can be updated with Identity type None during migration - of subscription to a new Azure Active Directory tenant; it will cause the encrypted resources - to lose access to the keys. - """ - - SYSTEM_ASSIGNED = "SystemAssigned" - USER_ASSIGNED = "UserAssigned" - SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" - NONE = "None" - - -class DiskEncryptionSetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of key used to encrypt the data of the disk.""" - - ENCRYPTION_AT_REST_WITH_CUSTOMER_KEY = "EncryptionAtRestWithCustomerKey" - """Resource using diskEncryptionSet would be encrypted at rest with Customer managed key that can - be changed and revoked by a customer.""" - ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" - """Resource using diskEncryptionSet would be encrypted at rest with two layers of encryption. One - of the keys is Customer managed and the other key is Platform managed.""" - CONFIDENTIAL_VM_ENCRYPTED_WITH_CUSTOMER_KEY = "ConfidentialVmEncryptedWithCustomerKey" - """Confidential VM supported disk and VM guest state would be encrypted with customer managed key.""" - - -class DiskSecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the SecurityType of the VM. Applicable for OS disks only.""" - - TRUSTED_LAUNCH = "TrustedLaunch" - """Trusted Launch provides security features such as secure boot and virtual Trusted Platform - Module (vTPM)""" - CONFIDENTIAL_VM_VMGUEST_STATE_ONLY_ENCRYPTED_WITH_PLATFORM_KEY = ( - "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey" - ) - """Indicates Confidential VM disk with only VM guest state encrypted""" - CONFIDENTIAL_VM_DISK_ENCRYPTED_WITH_PLATFORM_KEY = "ConfidentialVM_DiskEncryptedWithPlatformKey" - """Indicates Confidential VM disk with both OS disk and VM guest state encrypted with a platform - managed key""" - CONFIDENTIAL_VM_DISK_ENCRYPTED_WITH_CUSTOMER_KEY = "ConfidentialVM_DiskEncryptedWithCustomerKey" - """Indicates Confidential VM disk with both OS disk and VM guest state encrypted with a customer - managed key""" - - -class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This enumerates the possible state of the disk.""" - - UNATTACHED = "Unattached" - """The disk is not being used and can be attached to a VM.""" - ATTACHED = "Attached" - """The disk is currently attached to a running VM.""" - RESERVED = "Reserved" - """The disk is attached to a stopped-deallocated VM.""" - FROZEN = "Frozen" - """The disk is attached to a VM which is in hibernated state.""" - ACTIVE_SAS = "ActiveSAS" - """The disk currently has an Active SAS Uri associated with it.""" - ACTIVE_SAS_FROZEN = "ActiveSASFrozen" - """The disk is attached to a VM in hibernated state and has an active SAS URI associated with it.""" - READY_TO_UPLOAD = "ReadyToUpload" - """A disk is ready to be created by upload by requesting a write token.""" - ACTIVE_UPLOAD = "ActiveUpload" - """A disk is created for upload and a write token has been issued for uploading to it.""" - - -class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The sku name.""" - - STANDARD_LRS = "Standard_LRS" - """Standard HDD locally redundant storage. Best for backup, non-critical, and infrequent access.""" - PREMIUM_LRS = "Premium_LRS" - """Premium SSD locally redundant storage. Best for production and performance sensitive workloads.""" - STANDARD_SSD_LRS = "StandardSSD_LRS" - """Standard SSD locally redundant storage. Best for web servers, lightly used enterprise - applications and dev/test.""" - ULTRA_SSD_LRS = "UltraSSD_LRS" - """Ultra SSD locally redundant storage. Best for IO-intensive workloads such as SAP HANA, top tier - databases (for example, SQL, Oracle), and other transaction-heavy workloads.""" - PREMIUM_ZRS = "Premium_ZRS" - """Premium SSD zone redundant storage. Best for the production workloads that need storage - resiliency against zone failures.""" - STANDARD_SSD_ZRS = "StandardSSD_ZRS" - """Standard SSD zone redundant storage. Best for web servers, lightly used enterprise applications - and dev/test that need storage resiliency against zone failures.""" - PREMIUM_V2_LRS = "PremiumV2_LRS" - """Premium SSD v2 locally redundant storage. Best for production and performance-sensitive - workloads that consistently require low latency and high IOPS and throughput.""" - - -class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of key used to encrypt the data of the disk.""" - - ENCRYPTION_AT_REST_WITH_PLATFORM_KEY = "EncryptionAtRestWithPlatformKey" - """Disk is encrypted at rest with Platform managed key. It is the default encryption type. This is - not a valid encryption type for disk encryption sets.""" - ENCRYPTION_AT_REST_WITH_CUSTOMER_KEY = "EncryptionAtRestWithCustomerKey" - """Disk is encrypted at rest with Customer managed key that can be changed and revoked by a - customer.""" - ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" - """Disk is encrypted at rest with 2 layers of encryption. One of the keys is Customer managed and - the other key is Platform managed.""" - - -class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of extendedLocation.""" - - EDGE_ZONE = "EdgeZone" - - -class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The hypervisor generation of the Virtual Machine. Applicable to OS disks only.""" - - V1 = "V1" - V2 = "V2" - - -class NetworkAccessPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Policy for accessing the disk via network.""" - - ALLOW_ALL = "AllowAll" - """The disk can be exported or uploaded to from any network.""" - ALLOW_PRIVATE = "AllowPrivate" - """The disk can be exported or uploaded to using a DiskAccess resource's private endpoints.""" - DENY_ALL = "DenyAll" - """The disk cannot be exported.""" - - -class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The Operating System type.""" - - WINDOWS = "Windows" - LINUX = "Linux" - - -class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current provisioning state.""" - - SUCCEEDED = "Succeeded" - CREATING = "Creating" - DELETING = "Deleting" - FAILED = "Failed" - - -class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The private endpoint connection status.""" - - PENDING = "Pending" - APPROVED = "Approved" - REJECTED = "Rejected" - - -class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Policy for controlling export on the disk.""" - - ENABLED = "Enabled" - """You can generate a SAS URI to access the underlying data of the disk publicly on the internet - when NetworkAccessPolicy is set to AllowAll. You can access the data via the SAS URI only from - your trusted Azure VNET when NetworkAccessPolicy is set to AllowPrivate.""" - DISABLED = "Disabled" - """You cannot access the underlying data of the disk publicly on the internet even when - NetworkAccessPolicy is set to AllowAll. You can access the data via the SAS URI only from your - trusted Azure VNET when NetworkAccessPolicy is set to AllowPrivate.""" - - -class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The sku name.""" - - STANDARD_LRS = "Standard_LRS" - """Standard HDD locally redundant storage""" - PREMIUM_LRS = "Premium_LRS" - """Premium SSD locally redundant storage""" - STANDARD_ZRS = "Standard_ZRS" - """Standard zone redundant storage""" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/_models_py3.py deleted file mode 100644 index e4fa7f46b495..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/_models_py3.py +++ /dev/null @@ -1,3074 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -class AccessUri(_serialization.Model): - """A disk access SAS uri. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar access_sas: A SAS uri for accessing a disk. - :vartype access_sas: str - :ivar security_data_access_sas: A SAS uri for accessing a VM guest state. - :vartype security_data_access_sas: str - """ - - _validation = { - "access_sas": {"readonly": True}, - "security_data_access_sas": {"readonly": True}, - } - - _attribute_map = { - "access_sas": {"key": "accessSAS", "type": "str"}, - "security_data_access_sas": {"key": "securityDataAccessSAS", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.access_sas: Optional[str] = None - self.security_data_access_sas: Optional[str] = None - - -class ApiError(_serialization.Model): - """Api error. - - :ivar details: The Api error details. - :vartype details: list[~azure.mgmt.compute.v2022_03_02.models.ApiErrorBase] - :ivar innererror: The Api inner error. - :vartype innererror: ~azure.mgmt.compute.v2022_03_02.models.InnerError - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "details": {"key": "details", "type": "[ApiErrorBase]"}, - "innererror": {"key": "innererror", "type": "InnerError"}, - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - details: Optional[List["_models.ApiErrorBase"]] = None, - innererror: Optional["_models.InnerError"] = None, - code: Optional[str] = None, - target: Optional[str] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword details: The Api error details. - :paramtype details: list[~azure.mgmt.compute.v2022_03_02.models.ApiErrorBase] - :keyword innererror: The Api inner error. - :paramtype innererror: ~azure.mgmt.compute.v2022_03_02.models.InnerError - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.details = details - self.innererror = innererror - self.code = code - self.target = target - self.message = message - - -class ApiErrorBase(_serialization.Model): - """Api error base. - - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.target = target - self.message = message - - -class CopyCompletionError(_serialization.Model): - """Indicates the error details if the background copy of a resource created via the CopyStart - operation fails. - - All required parameters must be populated in order to send to server. - - :ivar error_code: Indicates the error code if the background copy of a resource created via the - CopyStart operation fails. Required. "CopySourceNotFound" - :vartype error_code: str or ~azure.mgmt.compute.v2022_03_02.models.CopyCompletionErrorReason - :ivar error_message: Indicates the error message if the background copy of a resource created - via the CopyStart operation fails. Required. - :vartype error_message: str - """ - - _validation = { - "error_code": {"required": True}, - "error_message": {"required": True}, - } - - _attribute_map = { - "error_code": {"key": "errorCode", "type": "str"}, - "error_message": {"key": "errorMessage", "type": "str"}, - } - - def __init__( - self, *, error_code: Union[str, "_models.CopyCompletionErrorReason"], error_message: str, **kwargs: Any - ) -> None: - """ - :keyword error_code: Indicates the error code if the background copy of a resource created via - the CopyStart operation fails. Required. "CopySourceNotFound" - :paramtype error_code: str or ~azure.mgmt.compute.v2022_03_02.models.CopyCompletionErrorReason - :keyword error_message: Indicates the error message if the background copy of a resource - created via the CopyStart operation fails. Required. - :paramtype error_message: str - """ - super().__init__(**kwargs) - self.error_code = error_code - self.error_message = error_message - - -class CreationData(_serialization.Model): - """Data used when creating a disk. - - 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 create_option: This enumerates the possible sources of a disk's creation. Required. Known - values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", "CopyStart", - "ImportSecure", "UploadPreparedSecure", and "Import". - :vartype create_option: str or ~azure.mgmt.compute.v2022_03_02.models.DiskCreateOption - :ivar storage_account_id: Required if createOption is Import. The Azure Resource Manager - identifier of the storage account containing the blob to import as a disk. - :vartype storage_account_id: str - :ivar image_reference: Disk source information for PIR or user images. - :vartype image_reference: ~azure.mgmt.compute.v2022_03_02.models.ImageDiskReference - :ivar gallery_image_reference: Required if creating from a Gallery Image. The - id/sharedGalleryImageId/communityGalleryImageId of the ImageDiskReference will be the ARM id of - the shared galley image version from which to create a disk. - :vartype gallery_image_reference: ~azure.mgmt.compute.v2022_03_02.models.ImageDiskReference - :ivar source_uri: If createOption is Import, this is the URI of a blob to be imported into a - managed disk. - :vartype source_uri: str - :ivar source_resource_id: If createOption is Copy, this is the ARM id of the source snapshot or - disk. - :vartype source_resource_id: str - :ivar source_unique_id: If this field is set, this is the unique id identifying the source of - this resource. - :vartype source_unique_id: str - :ivar upload_size_bytes: If createOption is Upload, this is the size of the contents of the - upload including the VHD footer. This value should be between 20972032 (20 MiB + 512 bytes for - the VHD footer) and 35183298347520 bytes (32 TiB + 512 bytes for the VHD footer). - :vartype upload_size_bytes: int - :ivar logical_sector_size: Logical sector size in bytes for Ultra disks. Supported values are - 512 ad 4096. 4096 is the default. - :vartype logical_sector_size: int - :ivar security_data_uri: If createOption is ImportSecure, this is the URI of a blob to be - imported into VM guest state. - :vartype security_data_uri: str - """ - - _validation = { - "create_option": {"required": True}, - "source_unique_id": {"readonly": True}, - } - - _attribute_map = { - "create_option": {"key": "createOption", "type": "str"}, - "storage_account_id": {"key": "storageAccountId", "type": "str"}, - "image_reference": {"key": "imageReference", "type": "ImageDiskReference"}, - "gallery_image_reference": {"key": "galleryImageReference", "type": "ImageDiskReference"}, - "source_uri": {"key": "sourceUri", "type": "str"}, - "source_resource_id": {"key": "sourceResourceId", "type": "str"}, - "source_unique_id": {"key": "sourceUniqueId", "type": "str"}, - "upload_size_bytes": {"key": "uploadSizeBytes", "type": "int"}, - "logical_sector_size": {"key": "logicalSectorSize", "type": "int"}, - "security_data_uri": {"key": "securityDataUri", "type": "str"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOption"], - storage_account_id: Optional[str] = None, - image_reference: Optional["_models.ImageDiskReference"] = None, - gallery_image_reference: Optional["_models.ImageDiskReference"] = None, - source_uri: Optional[str] = None, - source_resource_id: Optional[str] = None, - upload_size_bytes: Optional[int] = None, - logical_sector_size: Optional[int] = None, - security_data_uri: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword create_option: This enumerates the possible sources of a disk's creation. Required. - Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", - "CopyStart", "ImportSecure", "UploadPreparedSecure", and "Import". - :paramtype create_option: str or ~azure.mgmt.compute.v2022_03_02.models.DiskCreateOption - :keyword storage_account_id: Required if createOption is Import. The Azure Resource Manager - identifier of the storage account containing the blob to import as a disk. - :paramtype storage_account_id: str - :keyword image_reference: Disk source information for PIR or user images. - :paramtype image_reference: ~azure.mgmt.compute.v2022_03_02.models.ImageDiskReference - :keyword gallery_image_reference: Required if creating from a Gallery Image. The - id/sharedGalleryImageId/communityGalleryImageId of the ImageDiskReference will be the ARM id of - the shared galley image version from which to create a disk. - :paramtype gallery_image_reference: ~azure.mgmt.compute.v2022_03_02.models.ImageDiskReference - :keyword source_uri: If createOption is Import, this is the URI of a blob to be imported into a - managed disk. - :paramtype source_uri: str - :keyword source_resource_id: If createOption is Copy, this is the ARM id of the source snapshot - or disk. - :paramtype source_resource_id: str - :keyword upload_size_bytes: If createOption is Upload, this is the size of the contents of the - upload including the VHD footer. This value should be between 20972032 (20 MiB + 512 bytes for - the VHD footer) and 35183298347520 bytes (32 TiB + 512 bytes for the VHD footer). - :paramtype upload_size_bytes: int - :keyword logical_sector_size: Logical sector size in bytes for Ultra disks. Supported values - are 512 ad 4096. 4096 is the default. - :paramtype logical_sector_size: int - :keyword security_data_uri: If createOption is ImportSecure, this is the URI of a blob to be - imported into VM guest state. - :paramtype security_data_uri: str - """ - super().__init__(**kwargs) - self.create_option = create_option - self.storage_account_id = storage_account_id - self.image_reference = image_reference - self.gallery_image_reference = gallery_image_reference - self.source_uri = source_uri - self.source_resource_id = source_resource_id - self.source_unique_id: Optional[str] = None - self.upload_size_bytes = upload_size_bytes - self.logical_sector_size = logical_sector_size - self.security_data_uri = security_data_uri - - -class Resource(_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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - - -class Disk(Resource): - """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. - :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] - :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 - disk attached. maxShares should be set to a value greater than one for disks to allow attaching - them to multiple VMs. - :vartype managed_by_extended: list[str] - :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, - Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS. - :vartype sku: ~azure.mgmt.compute.v2022_03_02.models.DiskSku - :ivar zones: The Logical zone list for Disk. - :vartype zones: list[str] - :ivar extended_location: The extended location where the disk will be created. Extended - location cannot be changed. - :vartype extended_location: ~azure.mgmt.compute.v2022_03_02.models.ExtendedLocation - :ivar time_created: The time when the disk was created. - :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2022_03_02.models.OperatingSystemTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2022_03_02.models.HyperVGeneration - :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.v2022_03_02.models.PurchasePlan - :ivar supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :vartype supported_capabilities: ~azure.mgmt.compute.v2022_03_02.models.SupportedCapabilities - :ivar creation_data: Disk source information. CreationData information cannot be changed after - the disk has been created. - :vartype creation_data: ~azure.mgmt.compute.v2022_03_02.models.CreationData - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. - :vartype disk_size_bytes: int - :ivar unique_id: Unique Guid identifying the resource. - :vartype unique_id: str - :ivar encryption_settings_collection: Encryption settings collection used for Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2022_03_02.models.EncryptionSettingsCollection - :ivar provisioning_state: The disk provisioning state. - :vartype provisioning_state: str - :ivar disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :vartype disk_m_bps_read_write: int - :ivar disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_only: int - :ivar disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :vartype disk_m_bps_read_only: int - :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", - "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", and "ActiveUpload". - :vartype disk_state: str or ~azure.mgmt.compute.v2022_03_02.models.DiskState - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2022_03_02.models.Encryption - :ivar max_shares: The maximum number of VMs that can attach to the disk at the same time. Value - greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :vartype max_shares: int - :ivar share_info: Details of the list of all VMs that have the disk attached. maxShares should - be set to a value greater than one for disks to allow attaching them to multiple VMs. - :vartype share_info: list[~azure.mgmt.compute.v2022_03_02.models.ShareInfoElement] - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar tier: Performance tier of the disk (e.g, P4, S10) as described here: - https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra - disks. - :vartype tier: str - :ivar bursting_enabled: Set to true to enable bursting beyond the provisioned performance - target of the disk. Bursting is disabled by default. Does not apply to Ultra disks. - :vartype bursting_enabled: bool - :ivar property_updates_in_progress: Properties of the disk for which update is pending. - :vartype property_updates_in_progress: - ~azure.mgmt.compute.v2022_03_02.models.PropertyUpdatesInProgress - :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. - :vartype supports_hibernation: bool - :ivar security_profile: Contains the security related information for the resource. - :vartype security_profile: ~azure.mgmt.compute.v2022_03_02.models.DiskSecurityProfile - :ivar completion_percent: Percentage complete for the background copy when a resource is - created via the CopyStart operation. - :vartype completion_percent: float - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess - :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :vartype data_access_auth_mode: str or - ~azure.mgmt.compute.v2022_03_02.models.DataAccessAuthMode - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "managed_by": {"readonly": True}, - "managed_by_extended": {"readonly": True}, - "time_created": {"readonly": True}, - "disk_size_bytes": {"readonly": True}, - "unique_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "disk_state": {"readonly": True}, - "share_info": {"readonly": True}, - "property_updates_in_progress": {"readonly": 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}"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "managed_by_extended": {"key": "managedByExtended", "type": "[str]"}, - "sku": {"key": "sku", "type": "DiskSku"}, - "zones": {"key": "zones", "type": "[str]"}, - "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"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - "creation_data": {"key": "properties.creationData", "type": "CreationData"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "disk_size_bytes": {"key": "properties.diskSizeBytes", "type": "int"}, - "unique_id": {"key": "properties.uniqueId", "type": "str"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "disk_iops_read_write": {"key": "properties.diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "properties.diskMBpsReadWrite", "type": "int"}, - "disk_iops_read_only": {"key": "properties.diskIOPSReadOnly", "type": "int"}, - "disk_m_bps_read_only": {"key": "properties.diskMBpsReadOnly", "type": "int"}, - "disk_state": {"key": "properties.diskState", "type": "str"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "max_shares": {"key": "properties.maxShares", "type": "int"}, - "share_info": {"key": "properties.shareInfo", "type": "[ShareInfoElement]"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - "tier": {"key": "properties.tier", "type": "str"}, - "bursting_enabled": {"key": "properties.burstingEnabled", "type": "bool"}, - "property_updates_in_progress": { - "key": "properties.propertyUpdatesInProgress", - "type": "PropertyUpdatesInProgress", - }, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "security_profile": {"key": "properties.securityProfile", "type": "DiskSecurityProfile"}, - "completion_percent": {"key": "properties.completionPercent", "type": "float"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.DiskSku"] = None, - zones: Optional[List[str]] = None, - 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, - supported_capabilities: Optional["_models.SupportedCapabilities"] = None, - creation_data: Optional["_models.CreationData"] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - disk_iops_read_write: Optional[int] = None, - disk_m_bps_read_write: Optional[int] = None, - disk_iops_read_only: Optional[int] = None, - disk_m_bps_read_only: Optional[int] = None, - encryption: Optional["_models.Encryption"] = None, - max_shares: Optional[int] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - tier: Optional[str] = None, - bursting_enabled: Optional[bool] = None, - supports_hibernation: Optional[bool] = None, - security_profile: Optional["_models.DiskSecurityProfile"] = None, - completion_percent: Optional[float] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2022_03_02.models.DiskSku - :keyword zones: The Logical zone list for Disk. - :paramtype zones: list[str] - :keyword extended_location: The extended location where the disk will be created. Extended - location cannot be changed. - :paramtype extended_location: ~azure.mgmt.compute.v2022_03_02.models.ExtendedLocation - :keyword os_type: The Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2022_03_02.models.OperatingSystemTypes - :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.v2022_03_02.models.HyperVGeneration - :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.v2022_03_02.models.PurchasePlan - :keyword supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :paramtype supported_capabilities: ~azure.mgmt.compute.v2022_03_02.models.SupportedCapabilities - :keyword creation_data: Disk source information. CreationData information cannot be changed - after the disk has been created. - :paramtype creation_data: ~azure.mgmt.compute.v2022_03_02.models.CreationData - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used for Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2022_03_02.models.EncryptionSettingsCollection - :keyword disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_write: int - :keyword disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :paramtype disk_m_bps_read_write: int - :keyword disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_only: int - :keyword disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :paramtype disk_m_bps_read_only: int - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2022_03_02.models.Encryption - :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. - Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :paramtype max_shares: int - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword tier: Performance tier of the disk (e.g, P4, S10) as described here: - https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra - disks. - :paramtype tier: str - :keyword bursting_enabled: Set to true to enable bursting beyond the provisioned performance - target of the disk. Bursting is disabled by default. Does not apply to Ultra disks. - :paramtype bursting_enabled: bool - :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. - :paramtype supports_hibernation: bool - :keyword security_profile: Contains the security related information for the resource. - :paramtype security_profile: ~azure.mgmt.compute.v2022_03_02.models.DiskSecurityProfile - :keyword completion_percent: Percentage complete for the background copy when a resource is - created via the CopyStart operation. - :paramtype completion_percent: float - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess - :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :paramtype data_access_auth_mode: str or - ~azure.mgmt.compute.v2022_03_02.models.DataAccessAuthMode - """ - super().__init__(location=location, tags=tags, **kwargs) - self.managed_by: Optional[str] = None - self.managed_by_extended: Optional[List[str]] = None - self.sku = sku - self.zones = zones - self.extended_location = extended_location - self.time_created: Optional[datetime.datetime] = None - self.os_type = os_type - self.hyper_v_generation = hyper_v_generation - self.purchase_plan = purchase_plan - self.supported_capabilities = supported_capabilities - self.creation_data = creation_data - self.disk_size_gb = disk_size_gb - self.disk_size_bytes: Optional[int] = None - self.unique_id: Optional[str] = None - self.encryption_settings_collection = encryption_settings_collection - self.provisioning_state: Optional[str] = None - self.disk_iops_read_write = disk_iops_read_write - self.disk_m_bps_read_write = disk_m_bps_read_write - self.disk_iops_read_only = disk_iops_read_only - self.disk_m_bps_read_only = disk_m_bps_read_only - self.disk_state: Optional[Union[str, "_models.DiskState"]] = None - self.encryption = encryption - self.max_shares = max_shares - self.share_info: Optional[List["_models.ShareInfoElement"]] = None - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - self.tier = tier - self.bursting_enabled = bursting_enabled - self.property_updates_in_progress: Optional["_models.PropertyUpdatesInProgress"] = None - self.supports_hibernation = supports_hibernation - self.security_profile = security_profile - self.completion_percent = completion_percent - self.public_network_access = public_network_access - self.data_access_auth_mode = data_access_auth_mode - - -class DiskAccess(Resource): - """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. - :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] - :ivar extended_location: The extended location where the disk access will be created. Extended - location cannot be changed. - :vartype extended_location: ~azure.mgmt.compute.v2022_03_02.models.ExtendedLocation - :ivar private_endpoint_connections: A readonly collection of private endpoint connections - created on the disk. Currently only one endpoint connection is supported. - :vartype private_endpoint_connections: - list[~azure.mgmt.compute.v2022_03_02.models.PrivateEndpointConnection] - :ivar provisioning_state: The disk access resource provisioning state. - :vartype provisioning_state: str - :ivar time_created: The time when the disk access was created. - :vartype time_created: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "private_endpoint_connections": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "time_created": {"readonly": 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}"}, - "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - "private_endpoint_connections": { - "key": "properties.privateEndpointConnections", - "type": "[PrivateEndpointConnection]", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - extended_location: Optional["_models.ExtendedLocation"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2022_03_02.models.ExtendedLocation - """ - super().__init__(location=location, tags=tags, **kwargs) - self.extended_location = extended_location - self.private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None - self.provisioning_state: Optional[str] = None - self.time_created: Optional[datetime.datetime] = None - - -class DiskAccessList(_serialization.Model): - """The List disk access operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of disk access resources. Required. - :vartype value: list[~azure.mgmt.compute.v2022_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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DiskAccess]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.DiskAccess"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of disk access resources. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DiskAccessUpdate(_serialization.Model): - """Used for updating a disk access resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class DiskEncryptionSet(Resource): - """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. - :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] - :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.v2022_03_02.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and - "ConfidentialVmEncryptedWithCustomerKey". - :vartype encryption_type: str or ~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSetType - :ivar active_key: The key vault key which is currently used by this disk encryption set. - :vartype active_key: ~azure.mgmt.compute.v2022_03_02.models.KeyForDiskEncryptionSet - :ivar previous_keys: A readonly collection of key vault keys previously used by this disk - encryption set while a key rotation is in progress. It will be empty if there is no ongoing key - rotation. - :vartype previous_keys: list[~azure.mgmt.compute.v2022_03_02.models.KeyForDiskEncryptionSet] - :ivar provisioning_state: The disk encryption set provisioning state. - :vartype provisioning_state: str - :ivar rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating of - this disk encryption set to the latest key version. - :vartype rotation_to_latest_key_version_enabled: bool - :ivar last_key_rotation_timestamp: The time when the active key of this disk encryption set was - updated. - :vartype last_key_rotation_timestamp: ~datetime.datetime - :ivar auto_key_rotation_error: The error that was encountered during auto-key rotation. If an - error is present, then auto-key rotation will not be attempted until the error on this disk - encryption set is fixed. - :vartype auto_key_rotation_error: ~azure.mgmt.compute.v2022_03_02.models.ApiError - :ivar federated_client_id: Multi-tenant application client id to access key vault in a - different tenant. Setting the value to 'None' will clear the property. - :vartype federated_client_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "previous_keys": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "last_key_rotation_timestamp": {"readonly": True}, - "auto_key_rotation_error": {"readonly": 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}"}, - "identity": {"key": "identity", "type": "EncryptionSetIdentity"}, - "encryption_type": {"key": "properties.encryptionType", "type": "str"}, - "active_key": {"key": "properties.activeKey", "type": "KeyForDiskEncryptionSet"}, - "previous_keys": {"key": "properties.previousKeys", "type": "[KeyForDiskEncryptionSet]"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "rotation_to_latest_key_version_enabled": { - "key": "properties.rotationToLatestKeyVersionEnabled", - "type": "bool", - }, - "last_key_rotation_timestamp": {"key": "properties.lastKeyRotationTimestamp", "type": "iso-8601"}, - "auto_key_rotation_error": {"key": "properties.autoKeyRotationError", "type": "ApiError"}, - "federated_client_id": {"key": "properties.federatedClientId", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, - active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, - rotation_to_latest_key_version_enabled: Optional[bool] = None, - federated_client_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2022_03_02.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values - are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and - "ConfidentialVmEncryptedWithCustomerKey". - :paramtype encryption_type: str or ~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSetType - :keyword active_key: The key vault key which is currently used by this disk encryption set. - :paramtype active_key: ~azure.mgmt.compute.v2022_03_02.models.KeyForDiskEncryptionSet - :keyword rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating - of this disk encryption set to the latest key version. - :paramtype rotation_to_latest_key_version_enabled: bool - :keyword federated_client_id: Multi-tenant application client id to access key vault in a - different tenant. Setting the value to 'None' will clear the property. - :paramtype federated_client_id: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.identity = identity - self.encryption_type = encryption_type - self.active_key = active_key - self.previous_keys: Optional[List["_models.KeyForDiskEncryptionSet"]] = None - self.provisioning_state: Optional[str] = None - self.rotation_to_latest_key_version_enabled = rotation_to_latest_key_version_enabled - self.last_key_rotation_timestamp: Optional[datetime.datetime] = None - self.auto_key_rotation_error: Optional["_models.ApiError"] = None - self.federated_client_id = federated_client_id - - -class DiskEncryptionSetList(_serialization.Model): - """The List disk encryption set operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of disk encryption sets. Required. - :vartype value: list[~azure.mgmt.compute.v2022_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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DiskEncryptionSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DiskEncryptionSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of disk encryption sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DiskEncryptionSetUpdate(_serialization.Model): - """disk encryption set update resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, 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.v2022_03_02.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and - "ConfidentialVmEncryptedWithCustomerKey". - :vartype encryption_type: str or ~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSetType - :ivar active_key: Key Vault Key Url to be used for server side encryption of Managed Disks and - Snapshots. - :vartype active_key: ~azure.mgmt.compute.v2022_03_02.models.KeyForDiskEncryptionSet - :ivar rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating of - this disk encryption set to the latest key version. - :vartype rotation_to_latest_key_version_enabled: bool - :ivar federated_client_id: Multi-tenant application client id to access key vault in a - different tenant. Setting the value to 'None' will clear the property. - :vartype federated_client_id: str - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "identity": {"key": "identity", "type": "EncryptionSetIdentity"}, - "encryption_type": {"key": "properties.encryptionType", "type": "str"}, - "active_key": {"key": "properties.activeKey", "type": "KeyForDiskEncryptionSet"}, - "rotation_to_latest_key_version_enabled": { - "key": "properties.rotationToLatestKeyVersionEnabled", - "type": "bool", - }, - "federated_client_id": {"key": "properties.federatedClientId", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, - active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, - rotation_to_latest_key_version_enabled: Optional[bool] = None, - federated_client_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2022_03_02.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values - are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and - "ConfidentialVmEncryptedWithCustomerKey". - :paramtype encryption_type: str or ~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSetType - :keyword active_key: Key Vault Key Url to be used for server side encryption of Managed Disks - and Snapshots. - :paramtype active_key: ~azure.mgmt.compute.v2022_03_02.models.KeyForDiskEncryptionSet - :keyword rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating - of this disk encryption set to the latest key version. - :paramtype rotation_to_latest_key_version_enabled: bool - :keyword federated_client_id: Multi-tenant application client id to access key vault in a - different tenant. Setting the value to 'None' will clear the property. - :paramtype federated_client_id: str - """ - super().__init__(**kwargs) - self.tags = tags - self.identity = identity - self.encryption_type = encryption_type - self.active_key = active_key - self.rotation_to_latest_key_version_enabled = rotation_to_latest_key_version_enabled - self.federated_client_id = federated_client_id - - -class DiskList(_serialization.Model): - """The List Disks operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of disks. Required. - :vartype value: list[~azure.mgmt.compute.v2022_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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Disk]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of disks. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ProxyOnlyResource(_serialization.Model): - """The ProxyOnly Resource model definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - - -class DiskRestorePoint(ProxyOnlyResource): - """Properties of disk restore point. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :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. - :vartype source_resource_id: str - :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2022_03_02.models.OperatingSystemTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2022_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.v2022_03_02.models.PurchasePlan - :ivar supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :vartype supported_capabilities: ~azure.mgmt.compute.v2022_03_02.models.SupportedCapabilities - :ivar family_id: id of the backing snapshot's MIS family. - :vartype family_id: str - :ivar source_unique_id: unique incarnation id of the source disk. - :vartype source_unique_id: str - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2022_03_02.models.Encryption - :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. - :vartype supports_hibernation: bool - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar completion_percent: Percentage complete for the background copy of disk restore point - when source resource is from a different region. - :vartype completion_percent: float - :ivar replication_state: Replication state of disk restore point when source resource is from a - different region. - :vartype replication_state: str - :ivar source_resource_location: Location of source disk or source disk restore point when - source resource is from a different region. - :vartype source_resource_location: str - :ivar security_profile: Contains the security related information for the resource. - :vartype security_profile: ~azure.mgmt.compute.v2022_03_02.models.DiskSecurityProfile - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "time_created": {"readonly": True}, - "source_resource_id": {"readonly": True}, - "os_type": {"readonly": True}, - "family_id": {"readonly": True}, - "source_unique_id": {"readonly": True}, - "encryption": {"readonly": True}, - "replication_state": {"readonly": True}, - "source_resource_location": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "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"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - "family_id": {"key": "properties.familyId", "type": "str"}, - "source_unique_id": {"key": "properties.sourceUniqueId", "type": "str"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - "completion_percent": {"key": "properties.completionPercent", "type": "float"}, - "replication_state": {"key": "properties.replicationState", "type": "str"}, - "source_resource_location": {"key": "properties.sourceResourceLocation", "type": "str"}, - "security_profile": {"key": "properties.securityProfile", "type": "DiskSecurityProfile"}, - } - - def __init__( - self, - *, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - purchase_plan: Optional["_models.PurchasePlan"] = None, - supported_capabilities: Optional["_models.SupportedCapabilities"] = None, - supports_hibernation: Optional[bool] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - disk_access_id: Optional[str] = None, - completion_percent: Optional[float] = None, - security_profile: Optional["_models.DiskSecurityProfile"] = None, - **kwargs: Any - ) -> None: - """ - :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.v2022_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.v2022_03_02.models.PurchasePlan - :keyword supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :paramtype supported_capabilities: ~azure.mgmt.compute.v2022_03_02.models.SupportedCapabilities - :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. - :paramtype supports_hibernation: bool - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword completion_percent: Percentage complete for the background copy of disk restore point - when source resource is from a different region. - :paramtype completion_percent: float - :keyword security_profile: Contains the security related information for the resource. - :paramtype security_profile: ~azure.mgmt.compute.v2022_03_02.models.DiskSecurityProfile - """ - super().__init__(**kwargs) - self.time_created: Optional[datetime.datetime] = None - self.source_resource_id: Optional[str] = None - self.os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None - self.hyper_v_generation = hyper_v_generation - self.purchase_plan = purchase_plan - self.supported_capabilities = supported_capabilities - self.family_id: Optional[str] = None - self.source_unique_id: Optional[str] = None - self.encryption: Optional["_models.Encryption"] = None - self.supports_hibernation = supports_hibernation - self.network_access_policy = network_access_policy - self.public_network_access = public_network_access - self.disk_access_id = disk_access_id - self.completion_percent = completion_percent - self.replication_state: Optional[str] = None - self.source_resource_location: Optional[str] = None - self.security_profile = security_profile - - -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.v2022_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.v2022_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. - - :ivar security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. Known - values are: "TrustedLaunch", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", - "ConfidentialVM_DiskEncryptedWithPlatformKey", and - "ConfidentialVM_DiskEncryptedWithCustomerKey". - :vartype security_type: str or ~azure.mgmt.compute.v2022_03_02.models.DiskSecurityTypes - :ivar secure_vm_disk_encryption_set_id: ResourceId of the disk encryption set associated to - Confidential VM supported disk encrypted with customer managed key. - :vartype secure_vm_disk_encryption_set_id: str - """ - - _attribute_map = { - "security_type": {"key": "securityType", "type": "str"}, - "secure_vm_disk_encryption_set_id": {"key": "secureVMDiskEncryptionSetId", "type": "str"}, - } - - def __init__( - self, - *, - security_type: Optional[Union[str, "_models.DiskSecurityTypes"]] = None, - secure_vm_disk_encryption_set_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. - Known values are: "TrustedLaunch", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", - "ConfidentialVM_DiskEncryptedWithPlatformKey", and - "ConfidentialVM_DiskEncryptedWithCustomerKey". - :paramtype security_type: str or ~azure.mgmt.compute.v2022_03_02.models.DiskSecurityTypes - :keyword secure_vm_disk_encryption_set_id: ResourceId of the disk encryption set associated to - Confidential VM supported disk encrypted with customer managed key. - :paramtype secure_vm_disk_encryption_set_id: str - """ - super().__init__(**kwargs) - self.security_type = security_type - self.secure_vm_disk_encryption_set_id = secure_vm_disk_encryption_set_id - - -class DiskSku(_serialization.Model): - """The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, - Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", - "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", and "PremiumV2_LRS". - :vartype name: str or ~azure.mgmt.compute.v2022_03_02.models.DiskStorageAccountTypes - :ivar tier: The sku tier. - :vartype tier: str - """ - - _validation = { - "tier": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__(self, *, name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs: Any) -> None: - """ - :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", and "PremiumV2_LRS". - :paramtype name: str or ~azure.mgmt.compute.v2022_03_02.models.DiskStorageAccountTypes - """ - super().__init__(**kwargs) - self.name = name - self.tier: Optional[str] = None - - -class DiskUpdate(_serialization.Model): - """Disk update resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, - Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS. - :vartype sku: ~azure.mgmt.compute.v2022_03_02.models.DiskSku - :ivar os_type: the Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2022_03_02.models.OperatingSystemTypes - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2022_03_02.models.EncryptionSettingsCollection - :ivar disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :vartype disk_m_bps_read_write: int - :ivar disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_only: int - :ivar disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :vartype disk_m_bps_read_only: int - :ivar max_shares: The maximum number of VMs that can attach to the disk at the same time. Value - greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :vartype max_shares: int - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2022_03_02.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar tier: Performance tier of the disk (e.g, P4, S10) as described here: - https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra - disks. - :vartype tier: str - :ivar bursting_enabled: Set to true to enable bursting beyond the provisioned performance - 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.v2022_03_02.models.PurchasePlan - :ivar supported_capabilities: List of supported capabilities to be added on the OS disk. - :vartype supported_capabilities: ~azure.mgmt.compute.v2022_03_02.models.SupportedCapabilities - :ivar property_updates_in_progress: Properties of the disk for which update is pending. - :vartype property_updates_in_progress: - ~azure.mgmt.compute.v2022_03_02.models.PropertyUpdatesInProgress - :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. - :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess - :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :vartype data_access_auth_mode: str or - ~azure.mgmt.compute.v2022_03_02.models.DataAccessAuthMode - """ - - _validation = { - "property_updates_in_progress": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "DiskSku"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "disk_iops_read_write": {"key": "properties.diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "properties.diskMBpsReadWrite", "type": "int"}, - "disk_iops_read_only": {"key": "properties.diskIOPSReadOnly", "type": "int"}, - "disk_m_bps_read_only": {"key": "properties.diskMBpsReadOnly", "type": "int"}, - "max_shares": {"key": "properties.maxShares", "type": "int"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "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"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - "property_updates_in_progress": { - "key": "properties.propertyUpdatesInProgress", - "type": "PropertyUpdatesInProgress", - }, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.DiskSku"] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - disk_iops_read_write: Optional[int] = None, - disk_m_bps_read_write: Optional[int] = None, - disk_iops_read_only: Optional[int] = None, - disk_m_bps_read_only: Optional[int] = None, - max_shares: Optional[int] = None, - encryption: Optional["_models.Encryption"] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - tier: Optional[str] = None, - bursting_enabled: Optional[bool] = None, - purchase_plan: Optional["_models.PurchasePlan"] = None, - supported_capabilities: Optional["_models.SupportedCapabilities"] = None, - supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2022_03_02.models.DiskSku - :keyword os_type: the Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2022_03_02.models.OperatingSystemTypes - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2022_03_02.models.EncryptionSettingsCollection - :keyword disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_write: int - :keyword disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :paramtype disk_m_bps_read_write: int - :keyword disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_only: int - :keyword disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :paramtype disk_m_bps_read_only: int - :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. - Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :paramtype max_shares: int - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2022_03_02.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword tier: Performance tier of the disk (e.g, P4, S10) as described here: - https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra - disks. - :paramtype tier: str - :keyword bursting_enabled: Set to true to enable bursting beyond the provisioned performance - 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.v2022_03_02.models.PurchasePlan - :keyword supported_capabilities: List of supported capabilities to be added on the OS disk. - :paramtype supported_capabilities: ~azure.mgmt.compute.v2022_03_02.models.SupportedCapabilities - :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. - :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess - :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :paramtype data_access_auth_mode: str or - ~azure.mgmt.compute.v2022_03_02.models.DataAccessAuthMode - """ - super().__init__(**kwargs) - self.tags = tags - self.sku = sku - self.os_type = os_type - self.disk_size_gb = disk_size_gb - self.encryption_settings_collection = encryption_settings_collection - self.disk_iops_read_write = disk_iops_read_write - self.disk_m_bps_read_write = disk_m_bps_read_write - self.disk_iops_read_only = disk_iops_read_only - self.disk_m_bps_read_only = disk_m_bps_read_only - self.max_shares = max_shares - self.encryption = encryption - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - self.tier = tier - self.bursting_enabled = bursting_enabled - self.purchase_plan = purchase_plan - self.supported_capabilities = supported_capabilities - self.property_updates_in_progress: Optional["_models.PropertyUpdatesInProgress"] = None - self.supports_hibernation = supports_hibernation - self.public_network_access = public_network_access - self.data_access_auth_mode = data_access_auth_mode - - -class Encryption(_serialization.Model): - """Encryption at rest settings for disk or snapshot. - - :ivar disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling - encryption at rest. - :vartype disk_encryption_set_id: str - :ivar type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and - "EncryptionAtRestWithPlatformAndCustomerKeys". - :vartype type: str or ~azure.mgmt.compute.v2022_03_02.models.EncryptionType - """ - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - disk_encryption_set_id: Optional[str] = None, - type: Optional[Union[str, "_models.EncryptionType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling - encryption at rest. - :paramtype disk_encryption_set_id: str - :keyword type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and - "EncryptionAtRestWithPlatformAndCustomerKeys". - :paramtype type: str or ~azure.mgmt.compute.v2022_03_02.models.EncryptionType - """ - super().__init__(**kwargs) - self.disk_encryption_set_id = disk_encryption_set_id - self.type = type - - -class EncryptionSetIdentity(_serialization.Model): - """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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is - supported for new creations. Disk Encryption Sets can be updated with Identity type None during - migration of subscription to a new Azure Active Directory tenant; it will cause the encrypted - resources to lose access to the keys. Known values are: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", and "None". - :vartype type: str or ~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSetIdentityType - :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-client-tenant-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype tenant_id: str - :ivar user_assigned_identities: The list of user identities associated with the disk encryption - set. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2022_03_02.models.UserAssignedIdentitiesValue] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentitiesValue}"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.DiskEncryptionSetIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned - is supported for new creations. Disk Encryption Sets can be updated with Identity type None - during migration of subscription to a new Azure Active Directory tenant; it will cause the - encrypted resources to lose access to the keys. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :paramtype type: str or ~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSetIdentityType - :keyword user_assigned_identities: The list of user identities associated with the disk - encryption set. The user identity dictionary key references will be ARM resource ids in the - form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2022_03_02.models.UserAssignedIdentitiesValue] - """ - super().__init__(**kwargs) - self.type = type - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.user_assigned_identities = user_assigned_identities - - -class EncryptionSettingsCollection(_serialization.Model): - """Encryption settings for disk or snapshot. - - All required parameters must be populated in order to send to server. - - :ivar enabled: Set this flag to true and provide DiskEncryptionKey and optional - KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and - KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, - the existing settings remain unchanged. Required. - :vartype enabled: bool - :ivar encryption_settings: A collection of encryption settings, one for each disk volume. - :vartype encryption_settings: - list[~azure.mgmt.compute.v2022_03_02.models.EncryptionSettingsElement] - :ivar encryption_settings_version: Describes what type of encryption is used for the disks. - Once this field is set, it cannot be overwritten. '1.0' corresponds to Azure Disk Encryption - with AAD app.'1.1' corresponds to Azure Disk Encryption. - :vartype encryption_settings_version: str - """ - - _validation = { - "enabled": {"required": True}, - } - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "encryption_settings": {"key": "encryptionSettings", "type": "[EncryptionSettingsElement]"}, - "encryption_settings_version": {"key": "encryptionSettingsVersion", "type": "str"}, - } - - def __init__( - self, - *, - enabled: bool, - encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, - encryption_settings_version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Set this flag to true and provide DiskEncryptionKey and optional - KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and - KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, - the existing settings remain unchanged. Required. - :paramtype enabled: bool - :keyword encryption_settings: A collection of encryption settings, one for each disk volume. - :paramtype encryption_settings: - list[~azure.mgmt.compute.v2022_03_02.models.EncryptionSettingsElement] - :keyword encryption_settings_version: Describes what type of encryption is used for the disks. - Once this field is set, it cannot be overwritten. '1.0' corresponds to Azure Disk Encryption - with AAD app.'1.1' corresponds to Azure Disk Encryption. - :paramtype encryption_settings_version: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.encryption_settings = encryption_settings - self.encryption_settings_version = encryption_settings_version - - -class EncryptionSettingsElement(_serialization.Model): - """Encryption settings for one disk volume. - - :ivar disk_encryption_key: Key Vault Secret Url and vault id of the disk encryption key. - :vartype disk_encryption_key: ~azure.mgmt.compute.v2022_03_02.models.KeyVaultAndSecretReference - :ivar key_encryption_key: Key Vault Key Url and vault id of the key encryption key. - KeyEncryptionKey is optional and when provided is used to unwrap the disk encryption key. - :vartype key_encryption_key: ~azure.mgmt.compute.v2022_03_02.models.KeyVaultAndKeyReference - """ - - _attribute_map = { - "disk_encryption_key": {"key": "diskEncryptionKey", "type": "KeyVaultAndSecretReference"}, - "key_encryption_key": {"key": "keyEncryptionKey", "type": "KeyVaultAndKeyReference"}, - } - - def __init__( - self, - *, - disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_key: Key Vault Secret Url and vault id of the disk encryption key. - :paramtype disk_encryption_key: - ~azure.mgmt.compute.v2022_03_02.models.KeyVaultAndSecretReference - :keyword key_encryption_key: Key Vault Key Url and vault id of the key encryption key. - KeyEncryptionKey is optional and when provided is used to unwrap the disk encryption key. - :paramtype key_encryption_key: ~azure.mgmt.compute.v2022_03_02.models.KeyVaultAndKeyReference - """ - super().__init__(**kwargs) - self.disk_encryption_key = disk_encryption_key - self.key_encryption_key = key_encryption_key - - -class ExtendedLocation(_serialization.Model): - """The complex type of the extended location. - - :ivar name: The name of the extended location. - :vartype name: str - :ivar type: The type of the extended location. "EdgeZone" - :vartype type: str or ~azure.mgmt.compute.v2022_03_02.models.ExtendedLocationTypes - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the extended location. - :paramtype name: str - :keyword type: The type of the extended location. "EdgeZone" - :paramtype type: str or ~azure.mgmt.compute.v2022_03_02.models.ExtendedLocationTypes - """ - super().__init__(**kwargs) - self.name = name - self.type = type - - -class GrantAccessData(_serialization.Model): - """Data used for requesting a SAS. - - All required parameters must be populated in order to send to server. - - :ivar access: Required. Known values are: "None", "Read", and "Write". - :vartype access: str or ~azure.mgmt.compute.v2022_03_02.models.AccessLevel - :ivar duration_in_seconds: Time duration in seconds until the SAS access expires. Required. - :vartype duration_in_seconds: int - :ivar get_secure_vm_guest_state_sas: Set this flag to true to get additional SAS for VM guest - state. - :vartype get_secure_vm_guest_state_sas: bool - """ - - _validation = { - "access": {"required": True}, - "duration_in_seconds": {"required": True}, - } - - _attribute_map = { - "access": {"key": "access", "type": "str"}, - "duration_in_seconds": {"key": "durationInSeconds", "type": "int"}, - "get_secure_vm_guest_state_sas": {"key": "getSecureVMGuestStateSAS", "type": "bool"}, - } - - def __init__( - self, - *, - access: Union[str, "_models.AccessLevel"], - duration_in_seconds: int, - get_secure_vm_guest_state_sas: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword access: Required. Known values are: "None", "Read", and "Write". - :paramtype access: str or ~azure.mgmt.compute.v2022_03_02.models.AccessLevel - :keyword duration_in_seconds: Time duration in seconds until the SAS access expires. Required. - :paramtype duration_in_seconds: int - :keyword get_secure_vm_guest_state_sas: Set this flag to true to get additional SAS for VM - guest state. - :paramtype get_secure_vm_guest_state_sas: bool - """ - super().__init__(**kwargs) - self.access = access - self.duration_in_seconds = duration_in_seconds - self.get_secure_vm_guest_state_sas = get_secure_vm_guest_state_sas - - -class ImageDiskReference(_serialization.Model): - """The source image used for creating the disk. - - :ivar id: A relative uri containing either a Platform Image Repository, user image, or Azure - Compute Gallery image reference. - :vartype id: str - :ivar shared_gallery_image_id: A relative uri containing a direct shared Azure Compute Gallery - image reference. - :vartype shared_gallery_image_id: str - :ivar community_gallery_image_id: A relative uri containing a community Azure Compute Gallery - image reference. - :vartype community_gallery_image_id: str - :ivar lun: If the disk is created from an image's data disk, this is an index that indicates - which of the data disks in the image to use. For OS disks, this field is null. - :vartype lun: int - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "shared_gallery_image_id": {"key": "sharedGalleryImageId", "type": "str"}, - "community_gallery_image_id": {"key": "communityGalleryImageId", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - shared_gallery_image_id: Optional[str] = None, - community_gallery_image_id: Optional[str] = None, - lun: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: A relative uri containing either a Platform Image Repository, user image, or Azure - Compute Gallery image reference. - :paramtype id: str - :keyword shared_gallery_image_id: A relative uri containing a direct shared Azure Compute - Gallery image reference. - :paramtype shared_gallery_image_id: str - :keyword community_gallery_image_id: A relative uri containing a community Azure Compute - Gallery image reference. - :paramtype community_gallery_image_id: str - :keyword lun: If the disk is created from an image's data disk, this is an index that indicates - which of the data disks in the image to use. For OS disks, this field is null. - :paramtype lun: int - """ - super().__init__(**kwargs) - self.id = id - self.shared_gallery_image_id = shared_gallery_image_id - self.community_gallery_image_id = community_gallery_image_id - self.lun = lun - - -class InnerError(_serialization.Model): - """Inner error details. - - :ivar exceptiontype: The exception type. - :vartype exceptiontype: str - :ivar errordetail: The internal error message or exception dump. - :vartype errordetail: str - """ - - _attribute_map = { - "exceptiontype": {"key": "exceptiontype", "type": "str"}, - "errordetail": {"key": "errordetail", "type": "str"}, - } - - def __init__( - self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword exceptiontype: The exception type. - :paramtype exceptiontype: str - :keyword errordetail: The internal error message or exception dump. - :paramtype errordetail: str - """ - super().__init__(**kwargs) - self.exceptiontype = exceptiontype - self.errordetail = errordetail - - -class KeyForDiskEncryptionSet(_serialization.Model): - """Key Vault Key Url to be used for server side encryption of Managed Disks and Snapshots. - - All required parameters must be populated in order to send to server. - - :ivar source_vault: Resource id of the KeyVault containing the key or secret. This property is - optional and cannot be used if the KeyVault subscription is not the same as the Disk Encryption - Set subscription. - :vartype source_vault: ~azure.mgmt.compute.v2022_03_02.models.SourceVault - :ivar key_url: Fully versioned Key Url pointing to a key in KeyVault. Version segment of the - Url is required regardless of rotationToLatestKeyVersionEnabled value. Required. - :vartype key_url: str - """ - - _validation = { - "key_url": {"required": True}, - } - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SourceVault"}, - "key_url": {"key": "keyUrl", "type": "str"}, - } - - def __init__(self, *, key_url: str, source_vault: Optional["_models.SourceVault"] = None, **kwargs: Any) -> None: - """ - :keyword source_vault: Resource id of the KeyVault containing the key or secret. This property - is optional and cannot be used if the KeyVault subscription is not the same as the Disk - Encryption Set subscription. - :paramtype source_vault: ~azure.mgmt.compute.v2022_03_02.models.SourceVault - :keyword key_url: Fully versioned Key Url pointing to a key in KeyVault. Version segment of the - Url is required regardless of rotationToLatestKeyVersionEnabled value. Required. - :paramtype key_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.key_url = key_url - - -class KeyVaultAndKeyReference(_serialization.Model): - """Key Vault Key Url and vault id of KeK, KeK is optional and when provided is used to unwrap the - encryptionKey. - - All required parameters must be populated in order to send to server. - - :ivar source_vault: Resource id of the KeyVault containing the key or secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2022_03_02.models.SourceVault - :ivar key_url: Url pointing to a key or secret in KeyVault. Required. - :vartype key_url: str - """ - - _validation = { - "source_vault": {"required": True}, - "key_url": {"required": True}, - } - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SourceVault"}, - "key_url": {"key": "keyUrl", "type": "str"}, - } - - def __init__(self, *, source_vault: "_models.SourceVault", key_url: str, **kwargs: Any) -> None: - """ - :keyword source_vault: Resource id of the KeyVault containing the key or secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2022_03_02.models.SourceVault - :keyword key_url: Url pointing to a key or secret in KeyVault. Required. - :paramtype key_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.key_url = key_url - - -class KeyVaultAndSecretReference(_serialization.Model): - """Key Vault Secret Url and vault id of the encryption key. - - All required parameters must be populated in order to send to server. - - :ivar source_vault: Resource id of the KeyVault containing the key or secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2022_03_02.models.SourceVault - :ivar secret_url: Url pointing to a key or secret in KeyVault. Required. - :vartype secret_url: str - """ - - _validation = { - "source_vault": {"required": True}, - "secret_url": {"required": True}, - } - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SourceVault"}, - "secret_url": {"key": "secretUrl", "type": "str"}, - } - - def __init__(self, *, source_vault: "_models.SourceVault", secret_url: str, **kwargs: Any) -> None: - """ - :keyword source_vault: Resource id of the KeyVault containing the key or secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2022_03_02.models.SourceVault - :keyword secret_url: Url pointing to a key or secret in KeyVault. Required. - :paramtype secret_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.secret_url = secret_url - - -class PrivateEndpoint(_serialization.Model): - """The Private Endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ARM identifier for Private Endpoint. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class PrivateEndpointConnection(_serialization.Model): - """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. - :vartype id: str - :ivar name: private endpoint connection name. - :vartype name: str - :ivar type: private endpoint connection type. - :vartype type: str - :ivar private_endpoint: The resource of private end point. - :vartype private_endpoint: ~azure.mgmt.compute.v2022_03_02.models.PrivateEndpoint - :ivar private_link_service_connection_state: A collection of information about the state of the - connection between DiskAccess and Virtual Network. - :vartype private_link_service_connection_state: - ~azure.mgmt.compute.v2022_03_02.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2022_03_02.models.PrivateEndpointConnectionProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "private_endpoint": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionState", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_link_service_connection_state: A collection of information about the state of - the connection between DiskAccess and Virtual Network. - :paramtype private_link_service_connection_state: - ~azure.mgmt.compute.v2022_03_02.models.PrivateLinkServiceConnectionState - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.private_endpoint: Optional["_models.PrivateEndpoint"] = None - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = None - - -class PrivateEndpointConnectionListResult(_serialization.Model): - """A list of private link resources. - - :ivar value: Array of private endpoint connections. - :vartype value: list[~azure.mgmt.compute.v2022_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. - :vartype next_link: str - """ - - _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 - ) -> None: - """ - :keyword value: Array of private endpoint connections. - :paramtype value: list[~azure.mgmt.compute.v2022_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class PrivateLinkResource(_serialization.Model): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: private link resource Id. - :vartype id: str - :ivar name: private link resource name. - :vartype name: str - :ivar type: private link resource type. - :vartype type: str - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - :ivar required_zone_names: The private link resource DNS zone name. - :vartype required_zone_names: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "group_id": {"readonly": True}, - "required_members": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "group_id": {"key": "properties.groupId", "type": "str"}, - "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, - } - - def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword required_zone_names: The private link resource DNS zone name. - :paramtype required_zone_names: list[str] - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.group_id: Optional[str] = None - self.required_members: Optional[List[str]] = None - self.required_zone_names = required_zone_names - - -class PrivateLinkResourceListResult(_serialization.Model): - """A list of private link resources. - - :ivar value: Array of private link resources. - :vartype value: list[~azure.mgmt.compute.v2022_03_02.models.PrivateLinkResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateLinkResource]"}, - } - - def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Array of private link resources. - :paramtype value: list[~azure.mgmt.compute.v2022_03_02.models.PrivateLinkResource] - """ - super().__init__(**kwargs) - self.value = value - - -class PrivateLinkServiceConnectionState(_serialization.Model): - """A collection of information about the state of the connection between service consumer and - provider. - - :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", and "Rejected". - :vartype status: str or - ~azure.mgmt.compute.v2022_03_02.models.PrivateEndpointServiceConnectionStatus - :ivar description: The reason for approval/rejection of the connection. - :vartype description: str - :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :vartype actions_required: str - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", and "Rejected". - :paramtype status: str or - ~azure.mgmt.compute.v2022_03_02.models.PrivateEndpointServiceConnectionStatus - :keyword description: The reason for approval/rejection of the connection. - :paramtype description: str - :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :paramtype actions_required: str - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required = actions_required - - -class PropertyUpdatesInProgress(_serialization.Model): - """Properties of the disk for which update is pending. - - :ivar target_tier: The target performance tier of the disk if a tier change operation is in - progress. - :vartype target_tier: str - """ - - _attribute_map = { - "target_tier": {"key": "targetTier", "type": "str"}, - } - - def __init__(self, *, target_tier: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword target_tier: The target performance tier of the disk if a tier change operation is in - progress. - :paramtype target_tier: str - """ - super().__init__(**kwargs) - self.target_tier = target_tier - - -class PurchasePlan(_serialization.Model): - """Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. - - All required parameters must be populated in order to send to server. - - :ivar name: The plan ID. Required. - :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 - """ - - _validation = { - "name": {"required": True}, - "publisher": {"required": True}, - "product": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - "promotion_code": {"key": "promotionCode", "type": "str"}, - } - - 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.name = name - self.publisher = publisher - self.product = product - self.promotion_code = promotion_code - - -class ResourceUriList(_serialization.Model): - """The List resources which are encrypted with the disk encryption set. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of IDs or Owner IDs of resources which are encrypted with the disk - encryption set. Required. - :vartype value: list[str] - :ivar next_link: The uri to fetch the next page of encrypted resources. Call ListNext() with - this to fetch the next page of encrypted resources. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[str]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List[str], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of IDs or Owner IDs of resources which are encrypted with the disk - encryption set. Required. - :paramtype value: list[str] - :keyword next_link: The uri to fetch the next page of encrypted resources. Call ListNext() with - this to fetch the next page of encrypted resources. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ResourceWithOptionalLocation(_serialization.Model): - """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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.tags = tags - - -class ShareInfoElement(_serialization.Model): - """ShareInfoElement. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar vm_uri: A relative URI containing the ID of the VM that has the disk attached. - :vartype vm_uri: str - """ - - _validation = { - "vm_uri": {"readonly": True}, - } - - _attribute_map = { - "vm_uri": {"key": "vmUri", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.vm_uri: Optional[str] = None - - -class Snapshot(Resource): - """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. - :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] - :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 - an optional parameter for incremental snapshot and the default behavior is the SKU will be set - to the same sku as the previous snapshot. - :vartype sku: ~azure.mgmt.compute.v2022_03_02.models.SnapshotSku - :ivar extended_location: The extended location where the snapshot will be created. Extended - location cannot be changed. - :vartype extended_location: ~azure.mgmt.compute.v2022_03_02.models.ExtendedLocation - :ivar time_created: The time when the snapshot was created. - :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2022_03_02.models.OperatingSystemTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2022_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.v2022_03_02.models.PurchasePlan - :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.v2022_03_02.models.SupportedCapabilities - :ivar creation_data: Disk source information. CreationData information cannot be changed after - the disk has been created. - :vartype creation_data: ~azure.mgmt.compute.v2022_03_02.models.CreationData - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. - :vartype disk_size_bytes: int - :ivar disk_state: The state of the snapshot. Known values are: "Unattached", "Attached", - "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", and "ActiveUpload". - :vartype disk_state: str or ~azure.mgmt.compute.v2022_03_02.models.DiskState - :ivar unique_id: Unique Guid identifying the resource. - :vartype unique_id: str - :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2022_03_02.models.EncryptionSettingsCollection - :ivar provisioning_state: The disk provisioning state. - :vartype provisioning_state: str - :ivar incremental: Whether a snapshot is incremental. Incremental snapshots on the same disk - occupy less space than full snapshots and can be diffed. - :vartype incremental: bool - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2022_03_02.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar security_profile: Contains the security related information for the resource. - :vartype security_profile: ~azure.mgmt.compute.v2022_03_02.models.DiskSecurityProfile - :ivar supports_hibernation: Indicates the OS on a snapshot supports hibernation. - :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess - :ivar completion_percent: Percentage complete for the background copy when a resource is - created via the CopyStart operation. - :vartype completion_percent: float - :ivar copy_completion_error: Indicates the error details if the background copy of a resource - created via the CopyStart operation fails. - :vartype copy_completion_error: ~azure.mgmt.compute.v2022_03_02.models.CopyCompletionError - :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :vartype data_access_auth_mode: str or - ~azure.mgmt.compute.v2022_03_02.models.DataAccessAuthMode - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "managed_by": {"readonly": True}, - "time_created": {"readonly": True}, - "disk_size_bytes": {"readonly": True}, - "disk_state": {"readonly": True}, - "unique_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "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"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - "creation_data": {"key": "properties.creationData", "type": "CreationData"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "disk_size_bytes": {"key": "properties.diskSizeBytes", "type": "int"}, - "disk_state": {"key": "properties.diskState", "type": "str"}, - "unique_id": {"key": "properties.uniqueId", "type": "str"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "incremental": {"key": "properties.incremental", "type": "bool"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - "security_profile": {"key": "properties.securityProfile", "type": "DiskSecurityProfile"}, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "completion_percent": {"key": "properties.completionPercent", "type": "float"}, - "copy_completion_error": {"key": "properties.copyCompletionError", "type": "CopyCompletionError"}, - "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.SnapshotSku"] = None, - 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, - supported_capabilities: Optional["_models.SupportedCapabilities"] = None, - creation_data: Optional["_models.CreationData"] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - incremental: Optional[bool] = None, - encryption: Optional["_models.Encryption"] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - security_profile: Optional["_models.DiskSecurityProfile"] = None, - supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - completion_percent: Optional[float] = None, - copy_completion_error: Optional["_models.CopyCompletionError"] = None, - data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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. - :paramtype sku: ~azure.mgmt.compute.v2022_03_02.models.SnapshotSku - :keyword extended_location: The extended location where the snapshot will be created. Extended - location cannot be changed. - :paramtype extended_location: ~azure.mgmt.compute.v2022_03_02.models.ExtendedLocation - :keyword os_type: The Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2022_03_02.models.OperatingSystemTypes - :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.v2022_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.v2022_03_02.models.PurchasePlan - :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.v2022_03_02.models.SupportedCapabilities - :keyword creation_data: Disk source information. CreationData information cannot be changed - after the disk has been created. - :paramtype creation_data: ~azure.mgmt.compute.v2022_03_02.models.CreationData - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2022_03_02.models.EncryptionSettingsCollection - :keyword incremental: Whether a snapshot is incremental. Incremental snapshots on the same disk - occupy less space than full snapshots and can be diffed. - :paramtype incremental: bool - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2022_03_02.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword security_profile: Contains the security related information for the resource. - :paramtype security_profile: ~azure.mgmt.compute.v2022_03_02.models.DiskSecurityProfile - :keyword supports_hibernation: Indicates the OS on a snapshot supports hibernation. - :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess - :keyword completion_percent: Percentage complete for the background copy when a resource is - created via the CopyStart operation. - :paramtype completion_percent: float - :keyword copy_completion_error: Indicates the error details if the background copy of a - resource created via the CopyStart operation fails. - :paramtype copy_completion_error: ~azure.mgmt.compute.v2022_03_02.models.CopyCompletionError - :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :paramtype data_access_auth_mode: str or - ~azure.mgmt.compute.v2022_03_02.models.DataAccessAuthMode - """ - super().__init__(location=location, tags=tags, **kwargs) - self.managed_by: Optional[str] = None - self.sku = sku - self.extended_location = extended_location - self.time_created: Optional[datetime.datetime] = None - self.os_type = os_type - self.hyper_v_generation = hyper_v_generation - self.purchase_plan = purchase_plan - self.supported_capabilities = supported_capabilities - self.creation_data = creation_data - self.disk_size_gb = disk_size_gb - self.disk_size_bytes: Optional[int] = None - self.disk_state: Optional[Union[str, "_models.DiskState"]] = None - self.unique_id: Optional[str] = None - self.encryption_settings_collection = encryption_settings_collection - self.provisioning_state: Optional[str] = None - self.incremental = incremental - self.encryption = encryption - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - self.security_profile = security_profile - self.supports_hibernation = supports_hibernation - self.public_network_access = public_network_access - self.completion_percent = completion_percent - self.copy_completion_error = copy_completion_error - self.data_access_auth_mode = data_access_auth_mode - - -class SnapshotList(_serialization.Model): - """The List Snapshots operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of snapshots. Required. - :vartype value: list[~azure.mgmt.compute.v2022_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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Snapshot]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of snapshots. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SnapshotSku(_serialization.Model): - """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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", and "Standard_ZRS". - :vartype name: str or ~azure.mgmt.compute.v2022_03_02.models.SnapshotStorageAccountTypes - :ivar tier: The sku tier. - :vartype tier: str - """ - - _validation = { - "tier": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__( - self, *, name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs: Any - ) -> None: - """ - :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", and - "Standard_ZRS". - :paramtype name: str or ~azure.mgmt.compute.v2022_03_02.models.SnapshotStorageAccountTypes - """ - super().__init__(**kwargs) - self.name = name - self.tier: Optional[str] = None - - -class SnapshotUpdate(_serialization.Model): - """Snapshot update resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar 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. - :vartype sku: ~azure.mgmt.compute.v2022_03_02.models.SnapshotSku - :ivar os_type: the Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2022_03_02.models.OperatingSystemTypes - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2022_03_02.models.EncryptionSettingsCollection - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2022_03_02.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar supports_hibernation: Indicates the OS on a snapshot supports hibernation. - :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess - :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :vartype data_access_auth_mode: str or - ~azure.mgmt.compute.v2022_03_02.models.DataAccessAuthMode - :ivar supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :vartype supported_capabilities: ~azure.mgmt.compute.v2022_03_02.models.SupportedCapabilities - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "SnapshotSku"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.SnapshotSku"] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - encryption: Optional["_models.Encryption"] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, - supported_capabilities: Optional["_models.SupportedCapabilities"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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. - :paramtype sku: ~azure.mgmt.compute.v2022_03_02.models.SnapshotSku - :keyword os_type: the Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2022_03_02.models.OperatingSystemTypes - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2022_03_02.models.EncryptionSettingsCollection - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2022_03_02.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword supports_hibernation: Indicates the OS on a snapshot supports hibernation. - :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess - :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :paramtype data_access_auth_mode: str or - ~azure.mgmt.compute.v2022_03_02.models.DataAccessAuthMode - :keyword supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :paramtype supported_capabilities: ~azure.mgmt.compute.v2022_03_02.models.SupportedCapabilities - """ - super().__init__(**kwargs) - self.tags = tags - self.sku = sku - self.os_type = os_type - self.disk_size_gb = disk_size_gb - self.encryption_settings_collection = encryption_settings_collection - self.encryption = encryption - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - self.supports_hibernation = supports_hibernation - self.public_network_access = public_network_access - self.data_access_auth_mode = data_access_auth_mode - self.supported_capabilities = supported_capabilities - - -class SourceVault(_serialization.Model): - """The vault id is an Azure Resource Manager Resource id in the form - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class SubResource(_serialization.Model): - """SubResource. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class SubResourceReadOnly(_serialization.Model): - """SubResourceReadOnly. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class SupportedCapabilities(_serialization.Model): - """List of supported capabilities persisted on the disk resource for VM use. - - :ivar accelerated_network: True if the image from which the OS disk is created supports - accelerated networking. - :vartype accelerated_network: bool - :ivar architecture: CPU architecture supported by an OS disk. Known values are: "x64" and - "Arm64". - :vartype architecture: str or ~azure.mgmt.compute.v2022_03_02.models.Architecture - """ - - _attribute_map = { - "accelerated_network": {"key": "acceleratedNetwork", "type": "bool"}, - "architecture": {"key": "architecture", "type": "str"}, - } - - def __init__( - self, - *, - accelerated_network: Optional[bool] = None, - architecture: Optional[Union[str, "_models.Architecture"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword accelerated_network: True if the image from which the OS disk is created supports - accelerated networking. - :paramtype accelerated_network: bool - :keyword architecture: CPU architecture supported by an OS disk. Known values are: "x64" and - "Arm64". - :paramtype architecture: str or ~azure.mgmt.compute.v2022_03_02.models.Architecture - """ - super().__init__(**kwargs) - self.accelerated_network = accelerated_network - self.architecture = architecture - - -class UserAssignedIdentitiesValue(_serialization.Model): - """UserAssignedIdentitiesValue. - - 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: Optional[str] = None - self.client_id: Optional[str] = None diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/__init__.py deleted file mode 100644 index 0e0c2d8aaf8d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -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 SnapshotsOperations # 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", - "SnapshotsOperations", -] -__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/v2022_03_02/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_operations.py deleted file mode 100644 index e51e5ec24340..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_operations.py +++ /dev/null @@ -1,5848 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import ComputeManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-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}", - ) - 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"), - } - - _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_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", "2022-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}", - ) - 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"), - } - - _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_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", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", - ) - 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"), - } - - _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_disks_delete_request( - resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-02")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2022-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", - ) - 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"), - } - - _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_disks_revoke_access_request( - resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-02")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> 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", "2022-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}", - ) - 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"), - } - - _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_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", "2022-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", - ) - 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"), - } - - _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) - - -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", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateLinkResources", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-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}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - 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" - ), - } - - _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_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", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - 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" - ), - } - - _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_disk_accesses_delete_a_private_endpoint_connection_request( # pylint: disable=name-too-long - resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - 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" - ), - } - - _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) - - -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", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections", - ) - 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"), - } - - _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_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", "2022-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", - ) - 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"), - } - - _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) - - -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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}/associatedResources", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-02")) - 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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-02")) - 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", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-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", - ) - 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"), - } - - _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_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", "2022-03-02")) - 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", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2022-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}", - ) - 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"), - } - - _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_snapshots_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", "2022-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}", - ) - 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"), - } - - _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_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", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", - ) - 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"), - } - - _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_snapshots_delete_request( - resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-02")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2022-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}/beginGetAccess", - ) - 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"), - } - - _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_snapshots_revoke_access_request( - resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-02")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -class DisksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_03_02.ComputeManagementClient`'s - :attr:`disks` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_name: str, disk: Union[_models.Disk, 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 "2022-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, (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_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) - - _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_create_or_update( - self, - resource_group_name: str, - disk_name: str, - disk: _models.Disk, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Creates or updates 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 - :param disk: Disk object supplied in the body of the Put disk operation. Required. - :type disk: ~azure.mgmt.compute.v2022_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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.Disk] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_name: str, - disk: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Creates or updates 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 - :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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.Disk] - :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. - - :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 - :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.v2022_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.v2022_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 "2022-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._create_or_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, **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 _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, - 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 "2022-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, (IOBase, bytes)): - _content = disk - else: - _json = self._serialize.body(disk, "DiskUpdate") - - _request = build_disks_update_request( - resource_group_name=resource_group_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) - - _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, - disk_name: str, - disk: _models.DiskUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Updates (patches) a disk. - - :param resource_group_name: The name of the resource group. Required. - :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.v2022_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.v2022_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. 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.v2022_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. 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.v2022_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.v2022_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 "2022-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, **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 - ) - - @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.v2022_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 "2022-03-02")) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) - - _request = build_disks_get_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) - - _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("Disk", 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_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 "2022-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. - :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 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 "2022-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_name=disk_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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Disk"]: - """Lists all the disks 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 Disk or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_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 "2022-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 list(self, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2022_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 "2022-03-02")) - cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disks_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) - - 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, - 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 "2022-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disks_grant_access_request( - resource_group_name=resource_group_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) - - _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_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_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.v2022_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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_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.v2022_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.v2022_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 "2022-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, - disk_name=disk_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, 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-03-02")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disks_revoke_access_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]: - 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_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. - :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 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 "2022-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._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 - ) - 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 DiskAccessesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_03_02.ComputeManagementClient`'s - :attr:`disk_accesses` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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 "2022-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access - else: - _json = self._serialize.body(disk_access, "DiskAccess") - - _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) - - _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_create_or_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccess, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Put disk access operation. - Required. - :type disk_access: ~azure.mgmt.compute.v2022_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.v2022_03_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2022_03_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Put disk access operation. - Is either a DiskAccess type or a IO[bytes] type. Required. - :type disk_access: ~azure.mgmt.compute.v2022_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.v2022_03_02.models.DiskAccess] - :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 "2022-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) - - 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 - - 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 - ) - - def _update_initial( - 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, - 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 "2022-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access - else: - _json = self._serialize.body(disk_access, "DiskAccessUpdate") - - _request = build_disk_accesses_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) - - _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, - disk_access_name: str, - disk_access: _models.DiskAccessUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Patch disk access operation. - Required. - :type disk_access: ~azure.mgmt.compute.v2022_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 DiskAccess or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the 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 DiskAccess or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - 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. - :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.v2022_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.v2022_03_02.models.DiskAccess] - :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 "2022-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._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) - - 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 - - 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 - ) - - @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.v2022_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 "2022-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]: - 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 "2022-03-02")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disk_accesses_delete_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) - - _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_access_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes 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 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 "2022-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 - - 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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.DiskAccess"]: - """Lists all the disk access resources 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 DiskAccess or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_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 "2022-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 list(self, **kwargs: Any) -> ItemPaged["_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.v2022_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 "2022-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 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. - :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.v2022_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 "2022-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 = 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 - - 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 - ) -> 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 "2022-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(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 = 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_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 - ) -> 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. - :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.v2022_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 PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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 - ) -> 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. - :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 LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.PrivateEndpointConnection] - :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. - - :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.v2022_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.v2022_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-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, 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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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 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.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - 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.v2022_03_02.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-03-02")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_disk_accesses_get_a_private_endpoint_connection_request( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _delete_a_private_endpoint_connection_initial( # pylint: disable=name-too-long - self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> 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 "2022-03-02")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disk_accesses_delete_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) - - _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_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. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-03-02")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_a_private_endpoint_connection_initial( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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_private_endpoint_connections( - self, resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> ItemPaged["_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.v2022_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 "2022-03-02")) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_accesses_list_private_endpoint_connections_request( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class DiskEncryptionSetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_03_02.ComputeManagementClient`'s - :attr:`disk_encryption_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 "2022-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set - else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") - - _request = build_disk_encryption_sets_create_or_update_request( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Is either a DiskEncryptionSet type or a IO[bytes] type. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2022_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.v2022_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 "2022-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._create_or_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 - ) - - 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, - 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 "2022-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( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, - 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. - :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.v2022_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.v2022_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.v2022_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.v2022_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.v2022_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 "2022-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.v2022_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 "2022-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 "2022-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 - :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 "2022-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, **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) -> ItemPaged["_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.v2022_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 "2022-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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_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.v2022_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 "2022-03-02")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 list_associated_resources( - self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> ItemPaged[str]: - """Lists all resources that are encrypted with this 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: 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 "2022-03-02")) - cls: ClsType[_models.ResourceUriList] = 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_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, - 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("ResourceUriList", 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 DiskRestorePointOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_03_02.ComputeManagementClient`'s - :attr:`disk_restore_point` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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. - - :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 - :return: DiskRestorePoint or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2022_03_02.models.DiskRestorePoint - :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 "2022-03-02")) - cls: ClsType[_models.DiskRestorePoint] = kwargs.pop("cls", None) - - _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) - - _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 - ) -> ItemPaged["_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.v2022_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 "2022-03-02")) - cls: ClsType[_models.DiskRestorePointList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_restore_point_list_by_restore_point_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DiskRestorePointList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _grant_access_initial( - self, - resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> 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 "2022-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disk_restore_point_grant_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, - 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_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: _models.GrantAccessData, - *, - 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: ~azure.mgmt.compute.v2022_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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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: 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.v2022_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.v2022_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.v2022_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 "2022-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 "2022-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 - - return deserialized # type: ignore - - @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. - - :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 - :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 "2022-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._revoke_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, - 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 SnapshotsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2022_03_02.ComputeManagementClient`'s - :attr:`snapshots` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, snapshot_name: str, snapshot: Union[_models.Snapshot, 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 "2022-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "Snapshot") - - _request = build_snapshots_create_or_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.Snapshot, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: ~azure.mgmt.compute.v2022_03_02.models.Snapshot - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :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.v2022_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.v2022_03_02.models.Snapshot] - :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 "2022-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._create_or_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, **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 _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, - 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 "2022-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "SnapshotUpdate") - - _request = build_snapshots_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, - snapshot_name: str, - snapshot: _models.SnapshotUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. 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.v2022_03_02.models.SnapshotUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. - Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. Is - either a SnapshotUpdate type or a IO[bytes] type. Required. - :type snapshot: ~azure.mgmt.compute.v2022_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.v2022_03_02.models.Snapshot] - :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 "2022-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, **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 - ) - - @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.v2022_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 "2022-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]: - 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 "2022-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) - - 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, snapshot_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes 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: 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 "2022-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, - snapshot_name=snapshot_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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Snapshot"]: - """Lists snapshots 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 Snapshot or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_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 "2022-03-02")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.Snapshot"]: - """Lists snapshots under a subscription. - - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_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 "2022-03-02")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _grant_access_initial( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, 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 "2022-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_snapshots_grant_access_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param grant_access_data: Access data object supplied in the body of the get snapshot access - operation. Required. - :type grant_access_data: ~azure.mgmt.compute.v2022_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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param 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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param 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.v2022_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.v2022_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 "2022-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, - snapshot_name=snapshot_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, 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 "2022-03-02")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_snapshots_revoke_access_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]: - 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_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. - :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 "2022-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._revoke_access_initial( - resource_group_name=resource_group_name, - snapshot_name=snapshot_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2022_09_04/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_compute_management_client.py deleted file mode 100644 index 4ac089c2a611..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_compute_management_client.py +++ /dev/null @@ -1,148 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ( - CloudServiceOperatingSystemsOperations, - CloudServiceRoleInstancesOperations, - CloudServiceRolesOperations, - CloudServicesOperations, - CloudServicesUpdateDomainOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar cloud_service_role_instances: CloudServiceRoleInstancesOperations operations - :vartype cloud_service_role_instances: - azure.mgmt.compute.v2022_09_04.operations.CloudServiceRoleInstancesOperations - :ivar cloud_service_roles: CloudServiceRolesOperations operations - :vartype cloud_service_roles: - azure.mgmt.compute.v2022_09_04.operations.CloudServiceRolesOperations - :ivar cloud_services: CloudServicesOperations operations - :vartype cloud_services: azure.mgmt.compute.v2022_09_04.operations.CloudServicesOperations - :ivar cloud_services_update_domain: CloudServicesUpdateDomainOperations operations - :vartype cloud_services_update_domain: - azure.mgmt.compute.v2022_09_04.operations.CloudServicesUpdateDomainOperations - :ivar cloud_service_operating_systems: CloudServiceOperatingSystemsOperations operations - :vartype cloud_service_operating_systems: - azure.mgmt.compute.v2022_09_04.operations.CloudServiceOperatingSystemsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-09-04". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.cloud_service_role_instances = CloudServiceRoleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-09-04" - ) - self.cloud_service_roles = CloudServiceRolesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-09-04" - ) - self.cloud_services = CloudServicesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-09-04" - ) - self.cloud_services_update_domain = CloudServicesUpdateDomainOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-09-04" - ) - self.cloud_service_operating_systems = CloudServiceOperatingSystemsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-09-04" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_configuration.py deleted file mode 100644 index 8cd85ff7c762..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-09-04". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2022-09-04") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_metadata.json deleted file mode 100644 index 0f1f6e0845b4..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_metadata.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "chosen_version": "2022-09-04", - "total_api_version_list": ["2022-09-04"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "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.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "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.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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": { - "cloud_service_role_instances": "CloudServiceRoleInstancesOperations", - "cloud_service_roles": "CloudServiceRolesOperations", - "cloud_services": "CloudServicesOperations", - "cloud_services_update_domain": "CloudServicesUpdateDomainOperations", - "cloud_service_operating_systems": "CloudServiceOperatingSystemsOperations" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj 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 deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2022_09_04/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/_compute_management_client.py deleted file mode 100644 index 1747db955644..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/_compute_management_client.py +++ /dev/null @@ -1,152 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ( - CloudServiceOperatingSystemsOperations, - CloudServiceRoleInstancesOperations, - CloudServiceRolesOperations, - CloudServicesOperations, - CloudServicesUpdateDomainOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar cloud_service_role_instances: CloudServiceRoleInstancesOperations operations - :vartype cloud_service_role_instances: - azure.mgmt.compute.v2022_09_04.aio.operations.CloudServiceRoleInstancesOperations - :ivar cloud_service_roles: CloudServiceRolesOperations operations - :vartype cloud_service_roles: - azure.mgmt.compute.v2022_09_04.aio.operations.CloudServiceRolesOperations - :ivar cloud_services: CloudServicesOperations operations - :vartype cloud_services: azure.mgmt.compute.v2022_09_04.aio.operations.CloudServicesOperations - :ivar cloud_services_update_domain: CloudServicesUpdateDomainOperations operations - :vartype cloud_services_update_domain: - azure.mgmt.compute.v2022_09_04.aio.operations.CloudServicesUpdateDomainOperations - :ivar cloud_service_operating_systems: CloudServiceOperatingSystemsOperations operations - :vartype cloud_service_operating_systems: - azure.mgmt.compute.v2022_09_04.aio.operations.CloudServiceOperatingSystemsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-09-04". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.cloud_service_role_instances = CloudServiceRoleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-09-04" - ) - self.cloud_service_roles = CloudServiceRolesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-09-04" - ) - self.cloud_services = CloudServicesOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-09-04" - ) - self.cloud_services_update_domain = CloudServicesUpdateDomainOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-09-04" - ) - self.cloud_service_operating_systems = CloudServiceOperatingSystemsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-09-04" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/_configuration.py deleted file mode 100644 index bf6f80a700d9..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-09-04". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2022-09-04") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/operations/__init__.py deleted file mode 100644 index 6422d5c48bb1..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/operations/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import CloudServiceRoleInstancesOperations # type: ignore -from ._operations import CloudServiceRolesOperations # type: ignore -from ._operations import CloudServicesOperations # type: ignore -from ._operations import CloudServicesUpdateDomainOperations # type: ignore -from ._operations import CloudServiceOperatingSystemsOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CloudServiceRoleInstancesOperations", - "CloudServiceRolesOperations", - "CloudServicesOperations", - "CloudServicesUpdateDomainOperations", - "CloudServiceOperatingSystemsOperations", -] -__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/v2022_09_04/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/models/__init__.py deleted file mode 100644 index c38558c72df3..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/models/__init__.py +++ /dev/null @@ -1,142 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - ApiError, - ApiErrorBase, - CloudService, - CloudServiceExtensionProfile, - CloudServiceExtensionProperties, - CloudServiceInstanceView, - CloudServiceListResult, - CloudServiceNetworkProfile, - CloudServiceOsProfile, - CloudServiceProperties, - CloudServiceRole, - CloudServiceRoleListResult, - CloudServiceRoleProfile, - CloudServiceRoleProfileProperties, - CloudServiceRoleProperties, - CloudServiceRoleSku, - CloudServiceUpdate, - CloudServiceVaultAndSecretReference, - CloudServiceVaultCertificate, - CloudServiceVaultSecretGroup, - ExtendedLocation, - Extension, - InnerError, - InstanceSku, - InstanceViewStatusesSummary, - LoadBalancerConfiguration, - LoadBalancerConfigurationProperties, - LoadBalancerFrontendIpConfiguration, - LoadBalancerFrontendIpConfigurationProperties, - OSFamily, - OSFamilyListResult, - OSFamilyProperties, - OSVersion, - OSVersionListResult, - OSVersionProperties, - OSVersionPropertiesBase, - Resource, - ResourceInstanceViewStatus, - ResourceWithOptionalLocation, - RoleInstance, - RoleInstanceListResult, - RoleInstanceNetworkProfile, - RoleInstanceProperties, - RoleInstanceView, - RoleInstances, - StatusCodeCount, - SubResource, - SubResourceReadOnly, - SystemData, - UpdateDomain, - UpdateDomainListResult, - UserAssignedIdentitiesValue, -) - -from ._compute_management_client_enums import ( # type: ignore - CloudServiceSlotType, - CloudServiceUpgradeMode, - ExtendedLocationTypes, - InstanceViewTypes, - StatusLevelTypes, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ApiError", - "ApiErrorBase", - "CloudService", - "CloudServiceExtensionProfile", - "CloudServiceExtensionProperties", - "CloudServiceInstanceView", - "CloudServiceListResult", - "CloudServiceNetworkProfile", - "CloudServiceOsProfile", - "CloudServiceProperties", - "CloudServiceRole", - "CloudServiceRoleListResult", - "CloudServiceRoleProfile", - "CloudServiceRoleProfileProperties", - "CloudServiceRoleProperties", - "CloudServiceRoleSku", - "CloudServiceUpdate", - "CloudServiceVaultAndSecretReference", - "CloudServiceVaultCertificate", - "CloudServiceVaultSecretGroup", - "ExtendedLocation", - "Extension", - "InnerError", - "InstanceSku", - "InstanceViewStatusesSummary", - "LoadBalancerConfiguration", - "LoadBalancerConfigurationProperties", - "LoadBalancerFrontendIpConfiguration", - "LoadBalancerFrontendIpConfigurationProperties", - "OSFamily", - "OSFamilyListResult", - "OSFamilyProperties", - "OSVersion", - "OSVersionListResult", - "OSVersionProperties", - "OSVersionPropertiesBase", - "Resource", - "ResourceInstanceViewStatus", - "ResourceWithOptionalLocation", - "RoleInstance", - "RoleInstanceListResult", - "RoleInstanceNetworkProfile", - "RoleInstanceProperties", - "RoleInstanceView", - "RoleInstances", - "StatusCodeCount", - "SubResource", - "SubResourceReadOnly", - "SystemData", - "UpdateDomain", - "UpdateDomainListResult", - "UserAssignedIdentitiesValue", - "CloudServiceSlotType", - "CloudServiceUpgradeMode", - "ExtendedLocationTypes", - "InstanceViewTypes", - "StatusLevelTypes", -] -__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/v2022_09_04/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/models/_compute_management_client_enums.py deleted file mode 100644 index 8447b6e04823..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/models/_compute_management_client_enums.py +++ /dev/null @@ -1,59 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class CloudServiceSlotType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Slot type for the cloud service. - Possible values are :code:`
    `\\ :code:`
    `\\ **Production**\\ :code:`
    `\\ - :code:`
    `\\ **Staging**\\ :code:`
    `\\ :code:`
    ` - If not specified, the default value is Production. - """ - - PRODUCTION = "Production" - STAGING = "Staging" - - -class CloudServiceUpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Update mode for the cloud service. Role instances are allocated to update domains when the - service is deployed. Updates can be initiated manually in each update domain or initiated - automatically in all update domains. - Possible Values are :code:`
    `\\ :code:`
    `\\ **Auto**\\ :code:`
    `\\ :code:`
    `\\ **Manual** :code:`
    `\\ :code:`
    `\\ **Simultaneous**\\ :code:`
    `\\ - :code:`
    ` - If not specified, the default value is Auto. If set to Manual, PUT UpdateDomain must be called - to apply the update. If set to Auto, the update is automatically applied to each update domain - in sequence. - """ - - AUTO = "Auto" - MANUAL = "Manual" - SIMULTANEOUS = "Simultaneous" - - -class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of extendedLocation.""" - - EDGE_ZONE = "EdgeZone" - - -class InstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """InstanceViewTypes.""" - - INSTANCE_VIEW = "instanceView" - USER_DATA = "userData" - - -class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The level code.""" - - INFO = "Info" - WARNING = "Warning" - ERROR = "Error" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/models/_models_py3.py deleted file mode 100644 index 000cb95997df..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/models/_models_py3.py +++ /dev/null @@ -1,2094 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from collections.abc import MutableMapping -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models -JSON = MutableMapping[str, Any] - - -class ApiError(_serialization.Model): - """Api error. - - :ivar details: The Api error details. - :vartype details: list[~azure.mgmt.compute.v2022_09_04.models.ApiErrorBase] - :ivar innererror: The Api inner error. - :vartype innererror: ~azure.mgmt.compute.v2022_09_04.models.InnerError - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "details": {"key": "details", "type": "[ApiErrorBase]"}, - "innererror": {"key": "innererror", "type": "InnerError"}, - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - details: Optional[List["_models.ApiErrorBase"]] = None, - innererror: Optional["_models.InnerError"] = None, - code: Optional[str] = None, - target: Optional[str] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword details: The Api error details. - :paramtype details: list[~azure.mgmt.compute.v2022_09_04.models.ApiErrorBase] - :keyword innererror: The Api inner error. - :paramtype innererror: ~azure.mgmt.compute.v2022_09_04.models.InnerError - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.details = details - self.innererror = innererror - self.code = code - self.target = target - self.message = message - - -class ApiErrorBase(_serialization.Model): - """Api error base. - - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.target = target - self.message = message - - -class CloudService(_serialization.Model): - """Describes the cloud service. - - 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] - :ivar properties: Cloud service properties. - :vartype properties: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceProperties - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.compute.v2022_09_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. - :vartype zones: list[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}"}, - "properties": {"key": "properties", "type": "CloudServiceProperties"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "zones": {"key": "zones", "type": "[str]"}, - } - - def __init__( - self, - *, - 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: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword properties: Cloud service properties. - :paramtype properties: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceProperties - :keyword system_data: The system meta data relating to this resource. - :paramtype system_data: ~azure.mgmt.compute.v2022_09_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] - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - self.properties = properties - self.system_data = system_data - self.zones = zones - - -class CloudServiceExtensionProfile(_serialization.Model): - """Describes a cloud service extension profile. - - :ivar extensions: List of extensions for the cloud service. - :vartype extensions: list[~azure.mgmt.compute.v2022_09_04.models.Extension] - """ - - _attribute_map = { - "extensions": {"key": "extensions", "type": "[Extension]"}, - } - - def __init__(self, *, extensions: Optional[List["_models.Extension"]] = None, **kwargs: Any) -> None: - """ - :keyword extensions: List of extensions for the cloud service. - :paramtype extensions: list[~azure.mgmt.compute.v2022_09_04.models.Extension] - """ - super().__init__(**kwargs) - self.extensions = extensions - - -class CloudServiceExtensionProperties(_serialization.Model): - """Extension Properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type: Specifies the type of the extension. - :vartype type: str - :ivar type_handler_version: Specifies the version of the extension. Specifies the version of - the extension. If this element is not specified or an asterisk (*) is used as the value, the - latest version of the extension is used. If the value is specified with a major version number - and an asterisk as the minor version number (X.), the latest minor version of the specified - major version is selected. If a major version number and a minor version number are specified - (X.Y), the specific extension version is selected. If a version is specified, an auto-upgrade - is performed on the role instance. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Explicitly specify whether platform can automatically upgrade - typeHandlerVersion to higher minor versions when they become available. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Public settings for the extension. For JSON extensions, this is the JSON - settings for the extension. For XML Extension (like RDP), this is the XML setting for the - extension. - :vartype settings: JSON - :ivar protected_settings: Protected settings for the extension which are encrypted before sent - to the role instance. - :vartype protected_settings: JSON - :ivar protected_settings_from_key_vault: Protected settings for the extension, referenced using - KeyVault which are encrypted before sent to the role instance. - :vartype protected_settings_from_key_vault: - ~azure.mgmt.compute.v2022_09_04.models.CloudServiceVaultAndSecretReference - :ivar force_update_tag: Tag to force apply the provided public and protected settings. - Changing the tag value allows for re-running the extension without changing any of the public - or protected settings. - If forceUpdateTag is not changed, updates to public or protected settings would still be - applied by the handler. - If neither forceUpdateTag nor any of public or protected settings change, extension would flow - to the role instance with the same sequence-number, and - it is up to handler implementation whether to re-run it or not. - :vartype force_update_tag: str - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar roles_applied_to: Optional list of roles to apply this extension. If property is not - specified or '*' is specified, extension is applied to all roles in the cloud service. - :vartype roles_applied_to: list[str] - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "settings", "type": "object"}, - "protected_settings": {"key": "protectedSettings", "type": "object"}, - "protected_settings_from_key_vault": { - "key": "protectedSettingsFromKeyVault", - "type": "CloudServiceVaultAndSecretReference", - }, - "force_update_tag": {"key": "forceUpdateTag", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "roles_applied_to": {"key": "rolesAppliedTo", "type": "[str]"}, - } - - def __init__( - self, - *, - publisher: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - auto_upgrade_minor_version: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - protected_settings_from_key_vault: Optional["_models.CloudServiceVaultAndSecretReference"] = None, - force_update_tag: Optional[str] = None, - roles_applied_to: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type: Specifies the type of the extension. - :paramtype type: str - :keyword type_handler_version: Specifies the version of the extension. Specifies the version of - the extension. If this element is not specified or an asterisk (*) is used as the value, the - latest version of the extension is used. If the value is specified with a major version number - and an asterisk as the minor version number (X.), the latest minor version of the specified - major version is selected. If a major version number and a minor version number are specified - (X.Y), the specific extension version is selected. If a version is specified, an auto-upgrade - is performed on the role instance. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Explicitly specify whether platform can automatically - upgrade typeHandlerVersion to higher minor versions when they become available. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Public settings for the extension. For JSON extensions, this is the JSON - settings for the extension. For XML Extension (like RDP), this is the XML setting for the - extension. - :paramtype settings: JSON - :keyword protected_settings: Protected settings for the extension which are encrypted before - sent to the role instance. - :paramtype protected_settings: JSON - :keyword protected_settings_from_key_vault: Protected settings for the extension, referenced - using KeyVault which are encrypted before sent to the role instance. - :paramtype protected_settings_from_key_vault: - ~azure.mgmt.compute.v2022_09_04.models.CloudServiceVaultAndSecretReference - :keyword force_update_tag: Tag to force apply the provided public and protected settings. - Changing the tag value allows for re-running the extension without changing any of the public - or protected settings. - If forceUpdateTag is not changed, updates to public or protected settings would still be - applied by the handler. - If neither forceUpdateTag nor any of public or protected settings change, extension would flow - to the role instance with the same sequence-number, and - it is up to handler implementation whether to re-run it or not. - :paramtype force_update_tag: str - :keyword roles_applied_to: Optional list of roles to apply this extension. If property is not - specified or '*' is specified, extension is applied to all roles in the cloud service. - :paramtype roles_applied_to: list[str] - """ - super().__init__(**kwargs) - self.publisher = publisher - self.type = type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - self.protected_settings_from_key_vault = protected_settings_from_key_vault - self.force_update_tag = force_update_tag - self.provisioning_state: Optional[str] = None - self.roles_applied_to = roles_applied_to - - -class CloudServiceInstanceView(_serialization.Model): - """InstanceView of CloudService as a whole. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar role_instance: Instance view statuses. - :vartype role_instance: ~azure.mgmt.compute.v2022_09_04.models.InstanceViewStatusesSummary - :ivar sdk_version: The version of the SDK that was used to generate the package for the cloud - service. - :vartype sdk_version: str - :ivar private_ids: Specifies a list of unique identifiers generated internally for the cloud - service. :code:`
    `\\ :code:`
    ` NOTE: If you are using Azure Diagnostics extension, - this property can be used as 'DeploymentId' for querying details. - :vartype private_ids: list[str] - :ivar statuses: - :vartype statuses: list[~azure.mgmt.compute.v2022_09_04.models.ResourceInstanceViewStatus] - """ - - _validation = { - "sdk_version": {"readonly": True}, - "private_ids": {"readonly": True}, - "statuses": {"readonly": True}, - } - - _attribute_map = { - "role_instance": {"key": "roleInstance", "type": "InstanceViewStatusesSummary"}, - "sdk_version": {"key": "sdkVersion", "type": "str"}, - "private_ids": {"key": "privateIds", "type": "[str]"}, - "statuses": {"key": "statuses", "type": "[ResourceInstanceViewStatus]"}, - } - - def __init__(self, *, role_instance: Optional["_models.InstanceViewStatusesSummary"] = None, **kwargs: Any) -> None: - """ - :keyword role_instance: Instance view statuses. - :paramtype role_instance: ~azure.mgmt.compute.v2022_09_04.models.InstanceViewStatusesSummary - """ - super().__init__(**kwargs) - self.role_instance = role_instance - self.sdk_version: Optional[str] = None - self.private_ids: Optional[List[str]] = None - self.statuses: Optional[List["_models.ResourceInstanceViewStatus"]] = None - - -class CloudServiceListResult(_serialization.Model): - """The list operation result. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of resources. Required. - :vartype value: list[~azure.mgmt.compute.v2022_09_04.models.CloudService] - :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of - resources. Do this till nextLink is null to fetch all the resources. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[CloudService]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.CloudService"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of resources. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_09_04.models.CloudService] - :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page - of resources. Do this till nextLink is null to fetch all the resources. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class CloudServiceNetworkProfile(_serialization.Model): - """Network Profile for the cloud service. - - :ivar load_balancer_configurations: List of Load balancer configurations. Cloud service can - have up to two load balancer configurations, corresponding to a Public Load Balancer and an - Internal Load Balancer. - :vartype load_balancer_configurations: - list[~azure.mgmt.compute.v2022_09_04.models.LoadBalancerConfiguration] - :ivar slot_type: Slot type for the cloud service. - Possible values are :code:`
    `\\ :code:`
    `\\ **Production**\\ :code:`
    `\\ - :code:`
    `\\ **Staging**\\ :code:`
    `\\ :code:`
    ` - If not specified, the default value is Production. Known values are: "Production" and - "Staging". - :vartype slot_type: str or ~azure.mgmt.compute.v2022_09_04.models.CloudServiceSlotType - :ivar swappable_cloud_service: The id reference of the cloud service containing the target IP - with which the subject cloud service can perform a swap. This property cannot be updated once - it is set. The swappable cloud service referred by this id must be present otherwise an error - will be thrown. - :vartype swappable_cloud_service: ~azure.mgmt.compute.v2022_09_04.models.SubResource - """ - - _attribute_map = { - "load_balancer_configurations": {"key": "loadBalancerConfigurations", "type": "[LoadBalancerConfiguration]"}, - "slot_type": {"key": "slotType", "type": "str"}, - "swappable_cloud_service": {"key": "swappableCloudService", "type": "SubResource"}, - } - - def __init__( - self, - *, - load_balancer_configurations: Optional[List["_models.LoadBalancerConfiguration"]] = None, - slot_type: Optional[Union[str, "_models.CloudServiceSlotType"]] = None, - swappable_cloud_service: Optional["_models.SubResource"] = None, - **kwargs: Any - ) -> None: - """ - :keyword load_balancer_configurations: List of Load balancer configurations. Cloud service can - have up to two load balancer configurations, corresponding to a Public Load Balancer and an - Internal Load Balancer. - :paramtype load_balancer_configurations: - list[~azure.mgmt.compute.v2022_09_04.models.LoadBalancerConfiguration] - :keyword slot_type: Slot type for the cloud service. - Possible values are :code:`
    `\\ :code:`
    `\\ **Production**\\ :code:`
    `\\ - :code:`
    `\\ **Staging**\\ :code:`
    `\\ :code:`
    ` - If not specified, the default value is Production. Known values are: "Production" and - "Staging". - :paramtype slot_type: str or ~azure.mgmt.compute.v2022_09_04.models.CloudServiceSlotType - :keyword swappable_cloud_service: The id reference of the cloud service containing the target - IP with which the subject cloud service can perform a swap. This property cannot be updated - once it is set. The swappable cloud service referred by this id must be present otherwise an - error will be thrown. - :paramtype swappable_cloud_service: ~azure.mgmt.compute.v2022_09_04.models.SubResource - """ - super().__init__(**kwargs) - self.load_balancer_configurations = load_balancer_configurations - self.slot_type = slot_type - self.swappable_cloud_service = swappable_cloud_service - - -class CloudServiceOsProfile(_serialization.Model): - """Describes the OS profile for the cloud service. - - :ivar secrets: Specifies set of certificates that should be installed onto the role instances. - :vartype secrets: list[~azure.mgmt.compute.v2022_09_04.models.CloudServiceVaultSecretGroup] - """ - - _attribute_map = { - "secrets": {"key": "secrets", "type": "[CloudServiceVaultSecretGroup]"}, - } - - def __init__( - self, *, secrets: Optional[List["_models.CloudServiceVaultSecretGroup"]] = None, **kwargs: Any - ) -> None: - """ - :keyword secrets: Specifies set of certificates that should be installed onto the role - instances. - :paramtype secrets: list[~azure.mgmt.compute.v2022_09_04.models.CloudServiceVaultSecretGroup] - """ - super().__init__(**kwargs) - self.secrets = secrets - - -class CloudServiceProperties(_serialization.Model): - """Cloud service properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar package_url: Specifies a URL that refers to the location of the service package in the - Blob service. The service package URL can be Shared Access Signature (SAS) URI from any storage - account. - This is a write-only property and is not returned in GET calls. - :vartype package_url: str - :ivar configuration: Specifies the XML service configuration (.cscfg) for the cloud service. - :vartype configuration: str - :ivar configuration_url: Specifies a URL that refers to the location of the service - configuration in the Blob service. The service package URL can be Shared Access Signature - (SAS) URI from any storage account. - This is a write-only property and is not returned in GET calls. - :vartype configuration_url: str - :ivar start_cloud_service: (Optional) Indicates whether to start the cloud service immediately - after it is created. The default value is ``true``. - If false, the service model is still deployed, but the code is not run immediately. Instead, - the service is PoweredOff until you call Start, at which time the service will be started. A - deployed service still incurs charges, even if it is poweredoff. - :vartype start_cloud_service: bool - :ivar allow_model_override: (Optional) Indicates whether the role sku properties - (roleProfile.roles.sku) specified in the model/template should override the role instance count - and vm size specified in the .cscfg and .csdef respectively. - The default value is ``false``. - :vartype allow_model_override: bool - :ivar upgrade_mode: Update mode for the cloud service. Role instances are allocated to update - domains when the service is deployed. Updates can be initiated manually in each update domain - or initiated automatically in all update domains. - Possible Values are :code:`
    `\\ :code:`
    `\\ **Auto**\\ :code:`
    `\\ :code:`
    `\\ **Manual** :code:`
    `\\ :code:`
    `\\ **Simultaneous**\\ :code:`
    `\\ - :code:`
    ` - If not specified, the default value is Auto. If set to Manual, PUT UpdateDomain must be called - to apply the update. If set to Auto, the update is automatically applied to each update domain - in sequence. Known values are: "Auto", "Manual", and "Simultaneous". - :vartype upgrade_mode: str or ~azure.mgmt.compute.v2022_09_04.models.CloudServiceUpgradeMode - :ivar role_profile: Describes the role profile for the cloud service. - :vartype role_profile: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceRoleProfile - :ivar os_profile: Describes the OS profile for the cloud service. - :vartype os_profile: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceOsProfile - :ivar network_profile: Network Profile for the cloud service. - :vartype network_profile: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceNetworkProfile - :ivar extension_profile: Describes a cloud service extension profile. - :vartype extension_profile: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceExtensionProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar unique_id: The unique identifier for the cloud service. - :vartype unique_id: str - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "unique_id": {"readonly": True}, - } - - _attribute_map = { - "package_url": {"key": "packageUrl", "type": "str"}, - "configuration": {"key": "configuration", "type": "str"}, - "configuration_url": {"key": "configurationUrl", "type": "str"}, - "start_cloud_service": {"key": "startCloudService", "type": "bool"}, - "allow_model_override": {"key": "allowModelOverride", "type": "bool"}, - "upgrade_mode": {"key": "upgradeMode", "type": "str"}, - "role_profile": {"key": "roleProfile", "type": "CloudServiceRoleProfile"}, - "os_profile": {"key": "osProfile", "type": "CloudServiceOsProfile"}, - "network_profile": {"key": "networkProfile", "type": "CloudServiceNetworkProfile"}, - "extension_profile": {"key": "extensionProfile", "type": "CloudServiceExtensionProfile"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "unique_id": {"key": "uniqueId", "type": "str"}, - } - - def __init__( - self, - *, - package_url: Optional[str] = None, - configuration: Optional[str] = None, - configuration_url: Optional[str] = None, - start_cloud_service: Optional[bool] = None, - allow_model_override: Optional[bool] = None, - upgrade_mode: Optional[Union[str, "_models.CloudServiceUpgradeMode"]] = None, - role_profile: Optional["_models.CloudServiceRoleProfile"] = None, - os_profile: Optional["_models.CloudServiceOsProfile"] = None, - network_profile: Optional["_models.CloudServiceNetworkProfile"] = None, - extension_profile: Optional["_models.CloudServiceExtensionProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword package_url: Specifies a URL that refers to the location of the service package in the - Blob service. The service package URL can be Shared Access Signature (SAS) URI from any storage - account. - This is a write-only property and is not returned in GET calls. - :paramtype package_url: str - :keyword configuration: Specifies the XML service configuration (.cscfg) for the cloud service. - :paramtype configuration: str - :keyword configuration_url: Specifies a URL that refers to the location of the service - configuration in the Blob service. The service package URL can be Shared Access Signature - (SAS) URI from any storage account. - This is a write-only property and is not returned in GET calls. - :paramtype configuration_url: str - :keyword start_cloud_service: (Optional) Indicates whether to start the cloud service - immediately after it is created. The default value is ``true``. - If false, the service model is still deployed, but the code is not run immediately. Instead, - the service is PoweredOff until you call Start, at which time the service will be started. A - deployed service still incurs charges, even if it is poweredoff. - :paramtype start_cloud_service: bool - :keyword allow_model_override: (Optional) Indicates whether the role sku properties - (roleProfile.roles.sku) specified in the model/template should override the role instance count - and vm size specified in the .cscfg and .csdef respectively. - The default value is ``false``. - :paramtype allow_model_override: bool - :keyword upgrade_mode: Update mode for the cloud service. Role instances are allocated to - update domains when the service is deployed. Updates can be initiated manually in each update - domain or initiated automatically in all update domains. - Possible Values are :code:`
    `\\ :code:`
    `\\ **Auto**\\ :code:`
    `\\ :code:`
    `\\ **Manual** :code:`
    `\\ :code:`
    `\\ **Simultaneous**\\ :code:`
    `\\ - :code:`
    ` - If not specified, the default value is Auto. If set to Manual, PUT UpdateDomain must be called - to apply the update. If set to Auto, the update is automatically applied to each update domain - in sequence. Known values are: "Auto", "Manual", and "Simultaneous". - :paramtype upgrade_mode: str or ~azure.mgmt.compute.v2022_09_04.models.CloudServiceUpgradeMode - :keyword role_profile: Describes the role profile for the cloud service. - :paramtype role_profile: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceRoleProfile - :keyword os_profile: Describes the OS profile for the cloud service. - :paramtype os_profile: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceOsProfile - :keyword network_profile: Network Profile for the cloud service. - :paramtype network_profile: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceNetworkProfile - :keyword extension_profile: Describes a cloud service extension profile. - :paramtype extension_profile: - ~azure.mgmt.compute.v2022_09_04.models.CloudServiceExtensionProfile - """ - super().__init__(**kwargs) - self.package_url = package_url - self.configuration = configuration - self.configuration_url = configuration_url - self.start_cloud_service = start_cloud_service - self.allow_model_override = allow_model_override - self.upgrade_mode = upgrade_mode - self.role_profile = role_profile - self.os_profile = os_profile - self.network_profile = network_profile - self.extension_profile = extension_profile - self.provisioning_state: Optional[str] = None - self.unique_id: Optional[str] = None - - -class CloudServiceRole(_serialization.Model): - """Describes a role of the cloud service. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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. - :vartype location: str - :ivar sku: Describes the cloud service role sku. - :vartype sku: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceRoleSku - :ivar properties: The cloud service role properties. - :vartype properties: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceRoleProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "sku": {"key": "sku", "type": "CloudServiceRoleSku"}, - "properties": {"key": "properties", "type": "CloudServiceRoleProperties"}, - } - - def __init__( - self, - *, - sku: Optional["_models.CloudServiceRoleSku"] = None, - properties: Optional["_models.CloudServiceRoleProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword sku: Describes the cloud service role sku. - :paramtype sku: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceRoleSku - :keyword properties: The cloud service role properties. - :paramtype properties: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceRoleProperties - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location: Optional[str] = None - self.sku = sku - self.properties = properties - - -class CloudServiceRoleListResult(_serialization.Model): - """The list operation result. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of resources. Required. - :vartype value: list[~azure.mgmt.compute.v2022_09_04.models.CloudServiceRole] - :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of - resources. Do this till nextLink is null to fetch all the resources. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[CloudServiceRole]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.CloudServiceRole"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of resources. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_09_04.models.CloudServiceRole] - :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page - of resources. Do this till nextLink is null to fetch all the resources. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class CloudServiceRoleProfile(_serialization.Model): - """Describes the role profile for the cloud service. - - :ivar roles: List of roles for the cloud service. - :vartype roles: list[~azure.mgmt.compute.v2022_09_04.models.CloudServiceRoleProfileProperties] - """ - - _attribute_map = { - "roles": {"key": "roles", "type": "[CloudServiceRoleProfileProperties]"}, - } - - def __init__( - self, *, roles: Optional[List["_models.CloudServiceRoleProfileProperties"]] = None, **kwargs: Any - ) -> None: - """ - :keyword roles: List of roles for the cloud service. - :paramtype roles: - list[~azure.mgmt.compute.v2022_09_04.models.CloudServiceRoleProfileProperties] - """ - super().__init__(**kwargs) - self.roles = roles - - -class CloudServiceRoleProfileProperties(_serialization.Model): - """Describes the role properties. - - :ivar name: Resource name. - :vartype name: str - :ivar sku: Describes the cloud service role sku. - :vartype sku: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceRoleSku - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "sku": {"key": "sku", "type": "CloudServiceRoleSku"}, - } - - def __init__( - self, *, name: Optional[str] = None, sku: Optional["_models.CloudServiceRoleSku"] = None, **kwargs: Any - ) -> None: - """ - :keyword name: Resource name. - :paramtype name: str - :keyword sku: Describes the cloud service role sku. - :paramtype sku: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceRoleSku - """ - super().__init__(**kwargs) - self.name = name - self.sku = sku - - -class CloudServiceRoleProperties(_serialization.Model): - """The cloud service role properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar unique_id: Specifies the ID which uniquely identifies a cloud service role. - :vartype unique_id: str - """ - - _validation = { - "unique_id": {"readonly": True}, - } - - _attribute_map = { - "unique_id": {"key": "uniqueId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.unique_id: Optional[str] = None - - -class CloudServiceRoleSku(_serialization.Model): - """Describes the cloud service role sku. - - :ivar name: The sku name. NOTE: If the new SKU is not supported on the hardware the cloud - service is currently on, you need to delete and recreate the cloud service or move back to the - old sku. - :vartype name: str - :ivar tier: Specifies the tier of the cloud service. Possible Values are :code:`
    `\\ - :code:`
    ` **Standard** :code:`
    `\\ :code:`
    ` **Basic**. - :vartype tier: str - :ivar capacity: Specifies the number of role instances in the cloud service. - :vartype capacity: int - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "capacity": {"key": "capacity", "type": "int"}, - } - - def __init__( - self, *, name: Optional[str] = None, tier: Optional[str] = None, capacity: Optional[int] = None, **kwargs: Any - ) -> None: - """ - :keyword name: The sku name. NOTE: If the new SKU is not supported on the hardware the cloud - service is currently on, you need to delete and recreate the cloud service or move back to the - old sku. - :paramtype name: str - :keyword tier: Specifies the tier of the cloud service. Possible Values are :code:`
    `\\ - :code:`
    ` **Standard** :code:`
    `\\ :code:`
    ` **Basic**. - :paramtype tier: str - :keyword capacity: Specifies the number of role instances in the cloud service. - :paramtype capacity: int - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - self.capacity = capacity - - -class CloudServiceUpdate(_serialization.Model): - """CloudServiceUpdate. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class CloudServiceVaultAndSecretReference(_serialization.Model): - """Protected settings for the extension, referenced using KeyVault which are encrypted before sent - to the role instance. - - :ivar source_vault: The ARM Resource ID of the Key Vault. - :vartype source_vault: ~azure.mgmt.compute.v2022_09_04.models.SubResource - :ivar secret_url: Secret URL which contains the protected settings of the extension. - :vartype secret_url: str - """ - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - "secret_url": {"key": "secretUrl", "type": "str"}, - } - - def __init__( - self, *, source_vault: Optional["_models.SubResource"] = None, secret_url: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword source_vault: The ARM Resource ID of the Key Vault. - :paramtype source_vault: ~azure.mgmt.compute.v2022_09_04.models.SubResource - :keyword secret_url: Secret URL which contains the protected settings of the extension. - :paramtype secret_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.secret_url = secret_url - - -class CloudServiceVaultCertificate(_serialization.Model): - """Describes a single certificate reference in a Key Vault, and where the certificate should - reside on the role instance. - - :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as - a secret. - :vartype certificate_url: str - """ - - _attribute_map = { - "certificate_url": {"key": "certificateUrl", "type": "str"}, - } - - def __init__(self, *, certificate_url: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault - as a secret. - :paramtype certificate_url: str - """ - super().__init__(**kwargs) - self.certificate_url = certificate_url - - -class CloudServiceVaultSecretGroup(_serialization.Model): - """Describes a set of certificates which are all in the same Key Vault. - - :ivar source_vault: The relative URL of the Key Vault containing all of the certificates in - VaultCertificates. - :vartype source_vault: ~azure.mgmt.compute.v2022_09_04.models.SubResource - :ivar vault_certificates: The list of key vault references in SourceVault which contain - certificates. - :vartype vault_certificates: - list[~azure.mgmt.compute.v2022_09_04.models.CloudServiceVaultCertificate] - """ - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - "vault_certificates": {"key": "vaultCertificates", "type": "[CloudServiceVaultCertificate]"}, - } - - def __init__( - self, - *, - source_vault: Optional["_models.SubResource"] = None, - vault_certificates: Optional[List["_models.CloudServiceVaultCertificate"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source_vault: The relative URL of the Key Vault containing all of the certificates in - VaultCertificates. - :paramtype source_vault: ~azure.mgmt.compute.v2022_09_04.models.SubResource - :keyword vault_certificates: The list of key vault references in SourceVault which contain - certificates. - :paramtype vault_certificates: - list[~azure.mgmt.compute.v2022_09_04.models.CloudServiceVaultCertificate] - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.vault_certificates = vault_certificates - - -class ExtendedLocation(_serialization.Model): - """The complex type of the extended location. - - :ivar name: The name of the extended location. - :vartype name: str - :ivar type: The type of the extended location. "EdgeZone" - :vartype type: str or ~azure.mgmt.compute.v2022_09_04.models.ExtendedLocationTypes - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the extended location. - :paramtype name: str - :keyword type: The type of the extended location. "EdgeZone" - :paramtype type: str or ~azure.mgmt.compute.v2022_09_04.models.ExtendedLocationTypes - """ - super().__init__(**kwargs) - self.name = name - self.type = type - - -class Extension(_serialization.Model): - """Describes a cloud service Extension. - - :ivar name: The name of the extension. - :vartype name: str - :ivar properties: Extension Properties. - :vartype properties: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceExtensionProperties - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "properties": {"key": "properties", "type": "CloudServiceExtensionProperties"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - properties: Optional["_models.CloudServiceExtensionProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the extension. - :paramtype name: str - :keyword properties: Extension Properties. - :paramtype properties: ~azure.mgmt.compute.v2022_09_04.models.CloudServiceExtensionProperties - """ - super().__init__(**kwargs) - self.name = name - self.properties = properties - - -class InnerError(_serialization.Model): - """Inner error details. - - :ivar exceptiontype: The exception type. - :vartype exceptiontype: str - :ivar errordetail: The internal error message or exception dump. - :vartype errordetail: str - """ - - _attribute_map = { - "exceptiontype": {"key": "exceptiontype", "type": "str"}, - "errordetail": {"key": "errordetail", "type": "str"}, - } - - def __init__( - self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword exceptiontype: The exception type. - :paramtype exceptiontype: str - :keyword errordetail: The internal error message or exception dump. - :paramtype errordetail: str - """ - super().__init__(**kwargs) - self.exceptiontype = exceptiontype - self.errordetail = errordetail - - -class InstanceSku(_serialization.Model): - """The role instance SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. - :vartype name: str - :ivar tier: The tier of the cloud service role instance. - :vartype tier: str - """ - - _validation = { - "name": {"readonly": True}, - "tier": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.tier: Optional[str] = None - - -class InstanceViewStatusesSummary(_serialization.Model): - """Instance view statuses. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar statuses_summary: The summary. - :vartype statuses_summary: list[~azure.mgmt.compute.v2022_09_04.models.StatusCodeCount] - """ - - _validation = { - "statuses_summary": {"readonly": True}, - } - - _attribute_map = { - "statuses_summary": {"key": "statusesSummary", "type": "[StatusCodeCount]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.statuses_summary: Optional[List["_models.StatusCodeCount"]] = None - - -class LoadBalancerConfiguration(_serialization.Model): - """Describes the load balancer configuration. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the Load balancer. Required. - :vartype name: str - :ivar properties: Properties of the load balancer configuration. Required. - :vartype properties: ~azure.mgmt.compute.v2022_09_04.models.LoadBalancerConfigurationProperties - """ - - _validation = { - "name": {"required": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "properties": {"key": "properties", "type": "LoadBalancerConfigurationProperties"}, - } - - def __init__( - self, - *, - name: str, - properties: "_models.LoadBalancerConfigurationProperties", - id: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The name of the Load balancer. Required. - :paramtype name: str - :keyword properties: Properties of the load balancer configuration. Required. - :paramtype properties: - ~azure.mgmt.compute.v2022_09_04.models.LoadBalancerConfigurationProperties - """ - super().__init__(**kwargs) - self.id = id - self.name = name - self.properties = properties - - -class LoadBalancerConfigurationProperties(_serialization.Model): - """Describes the properties of the load balancer configuration. - - All required parameters must be populated in order to send to server. - - :ivar frontend_ip_configurations: Specifies the frontend IP to be used for the load balancer. - Only IPv4 frontend IP address is supported. Each load balancer configuration must have exactly - one frontend IP configuration. Required. - :vartype frontend_ip_configurations: - list[~azure.mgmt.compute.v2022_09_04.models.LoadBalancerFrontendIpConfiguration] - """ - - _validation = { - "frontend_ip_configurations": {"required": True}, - } - - _attribute_map = { - "frontend_ip_configurations": { - "key": "frontendIpConfigurations", - "type": "[LoadBalancerFrontendIpConfiguration]", - }, - } - - def __init__( - self, *, frontend_ip_configurations: List["_models.LoadBalancerFrontendIpConfiguration"], **kwargs: Any - ) -> None: - """ - :keyword frontend_ip_configurations: Specifies the frontend IP to be used for the load - balancer. Only IPv4 frontend IP address is supported. Each load balancer configuration must - have exactly one frontend IP configuration. Required. - :paramtype frontend_ip_configurations: - list[~azure.mgmt.compute.v2022_09_04.models.LoadBalancerFrontendIpConfiguration] - """ - super().__init__(**kwargs) - self.frontend_ip_configurations = frontend_ip_configurations - - -class LoadBalancerFrontendIpConfiguration(_serialization.Model): - """Specifies the frontend IP to be used for the load balancer. Only IPv4 frontend IP address is - supported. Each load balancer configuration must have exactly one frontend IP configuration. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the resource that is unique within the set of frontend IP - configurations used by the load balancer. This name can be used to access the resource. - Required. - :vartype name: str - :ivar properties: Properties of load balancer frontend ip configuration. Required. - :vartype properties: - ~azure.mgmt.compute.v2022_09_04.models.LoadBalancerFrontendIpConfigurationProperties - """ - - _validation = { - "name": {"required": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "properties": {"key": "properties", "type": "LoadBalancerFrontendIpConfigurationProperties"}, - } - - def __init__( - self, *, name: str, properties: "_models.LoadBalancerFrontendIpConfigurationProperties", **kwargs: Any - ) -> None: - """ - :keyword name: The name of the resource that is unique within the set of frontend IP - configurations used by the load balancer. This name can be used to access the resource. - Required. - :paramtype name: str - :keyword properties: Properties of load balancer frontend ip configuration. Required. - :paramtype properties: - ~azure.mgmt.compute.v2022_09_04.models.LoadBalancerFrontendIpConfigurationProperties - """ - super().__init__(**kwargs) - self.name = name - self.properties = properties - - -class LoadBalancerFrontendIpConfigurationProperties(_serialization.Model): # pylint: disable=name-too-long - """Describes a cloud service IP Configuration. - - :ivar public_ip_address: The reference to the public ip address resource. - :vartype public_ip_address: ~azure.mgmt.compute.v2022_09_04.models.SubResource - :ivar subnet: The reference to the virtual network subnet resource. - :vartype subnet: ~azure.mgmt.compute.v2022_09_04.models.SubResource - :ivar private_ip_address: The virtual network private IP address of the IP configuration. - :vartype private_ip_address: str - """ - - _attribute_map = { - "public_ip_address": {"key": "publicIPAddress", "type": "SubResource"}, - "subnet": {"key": "subnet", "type": "SubResource"}, - "private_ip_address": {"key": "privateIPAddress", "type": "str"}, - } - - def __init__( - self, - *, - public_ip_address: Optional["_models.SubResource"] = None, - subnet: Optional["_models.SubResource"] = None, - private_ip_address: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword public_ip_address: The reference to the public ip address resource. - :paramtype public_ip_address: ~azure.mgmt.compute.v2022_09_04.models.SubResource - :keyword subnet: The reference to the virtual network subnet resource. - :paramtype subnet: ~azure.mgmt.compute.v2022_09_04.models.SubResource - :keyword private_ip_address: The virtual network private IP address of the IP configuration. - :paramtype private_ip_address: str - """ - super().__init__(**kwargs) - self.public_ip_address = public_ip_address - self.subnet = subnet - self.private_ip_address = private_ip_address - - -class OSFamily(_serialization.Model): - """Describes a cloud service OS family. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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. - :vartype location: str - :ivar properties: OS family properties. - :vartype properties: ~azure.mgmt.compute.v2022_09_04.models.OSFamilyProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "properties": {"key": "properties", "type": "OSFamilyProperties"}, - } - - def __init__(self, *, properties: Optional["_models.OSFamilyProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: OS family properties. - :paramtype properties: ~azure.mgmt.compute.v2022_09_04.models.OSFamilyProperties - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location: Optional[str] = None - self.properties = properties - - -class OSFamilyListResult(_serialization.Model): - """The list operation result. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of resources. Required. - :vartype value: list[~azure.mgmt.compute.v2022_09_04.models.OSFamily] - :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of - resources. Do this till nextLink is null to fetch all the resources. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[OSFamily]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.OSFamily"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of resources. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_09_04.models.OSFamily] - :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page - of resources. Do this till nextLink is null to fetch all the resources. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class OSFamilyProperties(_serialization.Model): - """OS family properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The OS family name. - :vartype name: str - :ivar label: The OS family label. - :vartype label: str - :ivar versions: List of OS versions belonging to this family. - :vartype versions: list[~azure.mgmt.compute.v2022_09_04.models.OSVersionPropertiesBase] - """ - - _validation = { - "name": {"readonly": True}, - "label": {"readonly": True}, - "versions": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "versions": {"key": "versions", "type": "[OSVersionPropertiesBase]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.label: Optional[str] = None - self.versions: Optional[List["_models.OSVersionPropertiesBase"]] = None - - -class OSVersion(_serialization.Model): - """Describes a cloud service OS version. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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. - :vartype location: str - :ivar properties: OS version properties. - :vartype properties: ~azure.mgmt.compute.v2022_09_04.models.OSVersionProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "properties": {"key": "properties", "type": "OSVersionProperties"}, - } - - def __init__(self, *, properties: Optional["_models.OSVersionProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: OS version properties. - :paramtype properties: ~azure.mgmt.compute.v2022_09_04.models.OSVersionProperties - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location: Optional[str] = None - self.properties = properties - - -class OSVersionListResult(_serialization.Model): - """The list operation result. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of resources. Required. - :vartype value: list[~azure.mgmt.compute.v2022_09_04.models.OSVersion] - :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of - resources. Do this till nextLink is null to fetch all the resources. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[OSVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.OSVersion"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of resources. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_09_04.models.OSVersion] - :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page - of resources. Do this till nextLink is null to fetch all the resources. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class OSVersionProperties(_serialization.Model): - """OS version properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar family: The family of this OS version. - :vartype family: str - :ivar family_label: The family label of this OS version. - :vartype family_label: str - :ivar version: The OS version. - :vartype version: str - :ivar label: The OS version label. - :vartype label: str - :ivar is_default: Specifies whether this is the default OS version for its family. - :vartype is_default: bool - :ivar is_active: Specifies whether this OS version is active. - :vartype is_active: bool - """ - - _validation = { - "family": {"readonly": True}, - "family_label": {"readonly": True}, - "version": {"readonly": True}, - "label": {"readonly": True}, - "is_default": {"readonly": True}, - "is_active": {"readonly": True}, - } - - _attribute_map = { - "family": {"key": "family", "type": "str"}, - "family_label": {"key": "familyLabel", "type": "str"}, - "version": {"key": "version", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "is_default": {"key": "isDefault", "type": "bool"}, - "is_active": {"key": "isActive", "type": "bool"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.family: Optional[str] = None - self.family_label: Optional[str] = None - self.version: Optional[str] = None - self.label: Optional[str] = None - self.is_default: Optional[bool] = None - self.is_active: Optional[bool] = None - - -class OSVersionPropertiesBase(_serialization.Model): - """Configuration view of an OS version. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar version: The OS version. - :vartype version: str - :ivar label: The OS version label. - :vartype label: str - :ivar is_default: Specifies whether this is the default OS version for its family. - :vartype is_default: bool - :ivar is_active: Specifies whether this OS version is active. - :vartype is_active: bool - """ - - _validation = { - "version": {"readonly": True}, - "label": {"readonly": True}, - "is_default": {"readonly": True}, - "is_active": {"readonly": True}, - } - - _attribute_map = { - "version": {"key": "version", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "is_default": {"key": "isDefault", "type": "bool"}, - "is_active": {"key": "isActive", "type": "bool"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.version: Optional[str] = None - self.label: Optional[str] = None - self.is_default: Optional[bool] = None - self.is_active: Optional[bool] = None - - -class Resource(_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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - - -class ResourceInstanceViewStatus(_serialization.Model): - """Instance view status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The status code. - :vartype code: str - :ivar display_status: The short localizable label for the status. - :vartype display_status: str - :ivar message: The detailed status message, including for alerts and error messages. - :vartype message: str - :ivar time: The time of the status. - :vartype time: ~datetime.datetime - :ivar level: The level code. Known values are: "Info", "Warning", and "Error". - :vartype level: str or ~azure.mgmt.compute.v2022_09_04.models.StatusLevelTypes - """ - - _validation = { - "code": {"readonly": True}, - "display_status": {"readonly": True}, - "message": {"readonly": True}, - "time": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "display_status": {"key": "displayStatus", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "time": {"key": "time", "type": "iso-8601"}, - "level": {"key": "level", "type": "str"}, - } - - def __init__(self, *, level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, **kwargs: Any) -> None: - """ - :keyword level: The level code. Known values are: "Info", "Warning", and "Error". - :paramtype level: str or ~azure.mgmt.compute.v2022_09_04.models.StatusLevelTypes - """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.display_status: Optional[str] = None - self.message: Optional[str] = None - self.time: Optional[datetime.datetime] = None - self.level = level - - -class ResourceWithOptionalLocation(_serialization.Model): - """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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.tags = tags - - -class RoleInstance(_serialization.Model): - """Describes the cloud service role instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The role instance SKU. - :vartype sku: ~azure.mgmt.compute.v2022_09_04.models.InstanceSku - :ivar properties: Role instance properties. - :vartype properties: ~azure.mgmt.compute.v2022_09_04.models.RoleInstanceProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - "tags": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "InstanceSku"}, - "properties": {"key": "properties", "type": "RoleInstanceProperties"}, - } - - def __init__( - self, - *, - sku: Optional["_models.InstanceSku"] = None, - properties: Optional["_models.RoleInstanceProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword sku: The role instance SKU. - :paramtype sku: ~azure.mgmt.compute.v2022_09_04.models.InstanceSku - :keyword properties: Role instance properties. - :paramtype properties: ~azure.mgmt.compute.v2022_09_04.models.RoleInstanceProperties - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location: Optional[str] = None - self.tags: Optional[Dict[str, str]] = None - self.sku = sku - self.properties = properties - - -class RoleInstanceListResult(_serialization.Model): - """The list operation result. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of resources. Required. - :vartype value: list[~azure.mgmt.compute.v2022_09_04.models.RoleInstance] - :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of - resources. Do this till nextLink is null to fetch all the resources. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RoleInstance]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.RoleInstance"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of resources. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_09_04.models.RoleInstance] - :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page - of resources. Do this till nextLink is null to fetch all the resources. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleInstanceNetworkProfile(_serialization.Model): - """Describes the network profile for the role instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the role instance. - :vartype network_interfaces: list[~azure.mgmt.compute.v2022_09_04.models.SubResource] - """ - - _validation = { - "network_interfaces": {"readonly": True}, - } - - _attribute_map = { - "network_interfaces": {"key": "networkInterfaces", "type": "[SubResource]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.network_interfaces: Optional[List["_models.SubResource"]] = None - - -class RoleInstanceProperties(_serialization.Model): - """Role instance properties. - - :ivar network_profile: Describes the network profile for the role instance. - :vartype network_profile: ~azure.mgmt.compute.v2022_09_04.models.RoleInstanceNetworkProfile - :ivar instance_view: The instance view of the role instance. - :vartype instance_view: ~azure.mgmt.compute.v2022_09_04.models.RoleInstanceView - """ - - _attribute_map = { - "network_profile": {"key": "networkProfile", "type": "RoleInstanceNetworkProfile"}, - "instance_view": {"key": "instanceView", "type": "RoleInstanceView"}, - } - - def __init__( - self, - *, - network_profile: Optional["_models.RoleInstanceNetworkProfile"] = None, - instance_view: Optional["_models.RoleInstanceView"] = None, - **kwargs: Any - ) -> None: - """ - :keyword network_profile: Describes the network profile for the role instance. - :paramtype network_profile: ~azure.mgmt.compute.v2022_09_04.models.RoleInstanceNetworkProfile - :keyword instance_view: The instance view of the role instance. - :paramtype instance_view: ~azure.mgmt.compute.v2022_09_04.models.RoleInstanceView - """ - super().__init__(**kwargs) - self.network_profile = network_profile - self.instance_view = instance_view - - -class RoleInstances(_serialization.Model): - """Specifies a list of role instances from the cloud service. - - All required parameters must be populated in order to send to server. - - :ivar role_instances: List of cloud service role instance names. Value of '*' will signify all - role instances of the cloud service. Required. - :vartype role_instances: list[str] - """ - - _validation = { - "role_instances": {"required": True}, - } - - _attribute_map = { - "role_instances": {"key": "roleInstances", "type": "[str]"}, - } - - def __init__(self, *, role_instances: List[str], **kwargs: Any) -> None: - """ - :keyword role_instances: List of cloud service role instance names. Value of '*' will signify - all role instances of the cloud service. Required. - :paramtype role_instances: list[str] - """ - super().__init__(**kwargs) - self.role_instances = role_instances - - -class RoleInstanceView(_serialization.Model): - """The instance view of the role instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar platform_update_domain: The Update Domain. - :vartype platform_update_domain: int - :ivar platform_fault_domain: The Fault Domain. - :vartype platform_fault_domain: int - :ivar private_id: Specifies a unique identifier generated internally for the cloud service - associated with this role instance. :code:`
    `\\ :code:`
    ` NOTE: If you are using - Azure Diagnostics extension, this property can be used as 'DeploymentId' for querying details. - :vartype private_id: str - :ivar statuses: - :vartype statuses: list[~azure.mgmt.compute.v2022_09_04.models.ResourceInstanceViewStatus] - """ - - _validation = { - "platform_update_domain": {"readonly": True}, - "platform_fault_domain": {"readonly": True}, - "private_id": {"readonly": True}, - "statuses": {"readonly": True}, - } - - _attribute_map = { - "platform_update_domain": {"key": "platformUpdateDomain", "type": "int"}, - "platform_fault_domain": {"key": "platformFaultDomain", "type": "int"}, - "private_id": {"key": "privateId", "type": "str"}, - "statuses": {"key": "statuses", "type": "[ResourceInstanceViewStatus]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.platform_update_domain: Optional[int] = None - self.platform_fault_domain: Optional[int] = None - self.private_id: Optional[str] = None - self.statuses: Optional[List["_models.ResourceInstanceViewStatus"]] = None - - -class StatusCodeCount(_serialization.Model): - """The status code and count of the cloud service instance view statuses. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The instance view status code. - :vartype code: str - :ivar count: Number of instances having this status code. - :vartype count: int - """ - - _validation = { - "code": {"readonly": True}, - "count": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "count": {"key": "count", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.count: Optional[int] = None - - -class SubResource(_serialization.Model): - """SubResource. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class SubResourceReadOnly(_serialization.Model): - """SubResourceReadOnly. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class SystemData(_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. - - :ivar created_at: Specifies the time in UTC at which the Cloud Service (extended support) - resource was created. :code:`
    `Minimum api-version: 2022-04-04. - :vartype created_at: ~datetime.datetime - :ivar last_modified_at: Specifies the time in UTC at which the Cloud Service (extended support) - resource was last modified. :code:`
    `Minimum api-version: 2022-04-04. - :vartype last_modified_at: ~datetime.datetime - """ - - _validation = { - "created_at": {"readonly": True}, - "last_modified_at": {"readonly": True}, - } - - _attribute_map = { - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.created_at: Optional[datetime.datetime] = None - self.last_modified_at: Optional[datetime.datetime] = None - - -class UpdateDomain(_serialization.Model): - """Defines an update domain for the cloud service. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource Name. - :vartype name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - - -class UpdateDomainListResult(_serialization.Model): - """The list operation result. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of resources. Required. - :vartype value: list[~azure.mgmt.compute.v2022_09_04.models.UpdateDomain] - :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of - resources. Do this till nextLink is null to fetch all the resources. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[UpdateDomain]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.UpdateDomain"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of resources. Required. - :paramtype value: list[~azure.mgmt.compute.v2022_09_04.models.UpdateDomain] - :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page - of resources. Do this till nextLink is null to fetch all the resources. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class UserAssignedIdentitiesValue(_serialization.Model): - """UserAssignedIdentitiesValue. - - 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: Optional[str] = None - self.client_id: Optional[str] = None diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/operations/__init__.py deleted file mode 100644 index 6422d5c48bb1..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/operations/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import CloudServiceRoleInstancesOperations # type: ignore -from ._operations import CloudServiceRolesOperations # type: ignore -from ._operations import CloudServicesOperations # type: ignore -from ._operations import CloudServicesUpdateDomainOperations # type: ignore -from ._operations import CloudServiceOperatingSystemsOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CloudServiceRoleInstancesOperations", - "CloudServiceRolesOperations", - "CloudServicesOperations", - "CloudServicesUpdateDomainOperations", - "CloudServiceOperatingSystemsOperations", -] -__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/v2022_09_04/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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_04_02/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_compute_management_client.py deleted file mode 100644 index 1905c56abfb3..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_compute_management_client.py +++ /dev/null @@ -1,144 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ( - DiskAccessesOperations, - DiskEncryptionSetsOperations, - DiskRestorePointOperations, - DisksOperations, - SnapshotsOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar disks: DisksOperations operations - :vartype disks: azure.mgmt.compute.v2023_04_02.operations.DisksOperations - :ivar disk_accesses: DiskAccessesOperations operations - :vartype disk_accesses: azure.mgmt.compute.v2023_04_02.operations.DiskAccessesOperations - :ivar disk_encryption_sets: DiskEncryptionSetsOperations operations - :vartype disk_encryption_sets: - azure.mgmt.compute.v2023_04_02.operations.DiskEncryptionSetsOperations - :ivar disk_restore_point: DiskRestorePointOperations operations - :vartype disk_restore_point: - azure.mgmt.compute.v2023_04_02.operations.DiskRestorePointOperations - :ivar snapshots: SnapshotsOperations operations - :vartype snapshots: azure.mgmt.compute.v2023_04_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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-04-02". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - 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, "2023-04-02") - self.disk_accesses = DiskAccessesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-04-02" - ) - self.disk_encryption_sets = DiskEncryptionSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-04-02" - ) - self.disk_restore_point = DiskRestorePointOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-04-02" - ) - self.snapshots = SnapshotsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-04-02" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_configuration.py deleted file mode 100644 index d9bd4f03daa6..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-04-02". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-04-02") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_metadata.json deleted file mode 100644 index 87a3b96fdb70..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_metadata.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "chosen_version": "2023-04-02", - "total_api_version_list": ["2023-04-02"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "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.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "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.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node
    is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj 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 deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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_04_02/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/_compute_management_client.py deleted file mode 100644 index c988657a4974..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/_compute_management_client.py +++ /dev/null @@ -1,148 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ( - DiskAccessesOperations, - DiskEncryptionSetsOperations, - DiskRestorePointOperations, - DisksOperations, - SnapshotsOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar disks: DisksOperations operations - :vartype disks: azure.mgmt.compute.v2023_04_02.aio.operations.DisksOperations - :ivar disk_accesses: DiskAccessesOperations operations - :vartype disk_accesses: azure.mgmt.compute.v2023_04_02.aio.operations.DiskAccessesOperations - :ivar disk_encryption_sets: DiskEncryptionSetsOperations operations - :vartype disk_encryption_sets: - azure.mgmt.compute.v2023_04_02.aio.operations.DiskEncryptionSetsOperations - :ivar disk_restore_point: DiskRestorePointOperations operations - :vartype disk_restore_point: - azure.mgmt.compute.v2023_04_02.aio.operations.DiskRestorePointOperations - :ivar snapshots: SnapshotsOperations operations - :vartype snapshots: azure.mgmt.compute.v2023_04_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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-04-02". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - 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, "2023-04-02") - self.disk_accesses = DiskAccessesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-04-02" - ) - self.disk_encryption_sets = DiskEncryptionSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-04-02" - ) - self.disk_restore_point = DiskRestorePointOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-04-02" - ) - self.snapshots = SnapshotsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-04-02" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/_configuration.py deleted file mode 100644 index cfefafbd316f..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-04-02". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-04-02") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/operations/__init__.py deleted file mode 100644 index 0e0c2d8aaf8d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/operations/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -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 SnapshotsOperations # 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", - "SnapshotsOperations", -] -__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_04_02/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/operations/_operations.py deleted file mode 100644 index 644149a364ec..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/operations/_operations.py +++ /dev/null @@ -1,4727 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import ( - build_disk_accesses_create_or_update_request, - build_disk_accesses_delete_a_private_endpoint_connection_request, - build_disk_accesses_delete_request, - build_disk_accesses_get_a_private_endpoint_connection_request, - build_disk_accesses_get_private_link_resources_request, - build_disk_accesses_get_request, - build_disk_accesses_list_by_resource_group_request, - build_disk_accesses_list_private_endpoint_connections_request, - build_disk_accesses_list_request, - build_disk_accesses_update_a_private_endpoint_connection_request, - build_disk_accesses_update_request, - build_disk_encryption_sets_create_or_update_request, - build_disk_encryption_sets_delete_request, - build_disk_encryption_sets_get_request, - build_disk_encryption_sets_list_associated_resources_request, - build_disk_encryption_sets_list_by_resource_group_request, - build_disk_encryption_sets_list_request, - build_disk_encryption_sets_update_request, - build_disk_restore_point_get_request, - build_disk_restore_point_grant_access_request, - build_disk_restore_point_list_by_restore_point_request, - build_disk_restore_point_revoke_access_request, - build_disks_create_or_update_request, - build_disks_delete_request, - build_disks_get_request, - build_disks_grant_access_request, - build_disks_list_by_resource_group_request, - build_disks_list_request, - build_disks_revoke_access_request, - build_disks_update_request, - build_snapshots_create_or_update_request, - build_snapshots_delete_request, - build_snapshots_get_request, - build_snapshots_grant_access_request, - build_snapshots_list_by_resource_group_request, - build_snapshots_list_request, - build_snapshots_revoke_access_request, - build_snapshots_update_request, -) -from .._configuration import ComputeManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DisksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_04_02.aio.ComputeManagementClient`'s - :attr:`disks` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_name: str, disk: Union[_models.Disk, 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-04-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk, (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_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) - - _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_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. 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.v2023_04_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.v2023_04_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. 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.v2023_04_02.models.Disk] - :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. - - :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 - :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.v2023_04_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.v2023_04_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 "2023-04-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, 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, - 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("Disk", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Disk].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Disk]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _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, - 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-04-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk, (IOBase, bytes)): - _content = disk - else: - _json = self._serialize.body(disk, "DiskUpdate") - - _request = build_disks_update_request( - resource_group_name=resource_group_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) - - _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( - self, - resource_group_name: str, - disk_name: str, - disk: _models.DiskUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Updates (patches) a disk. - - :param resource_group_name: The name of the resource group. 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.v2023_04_02.models.DiskUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_04_02.models.Disk] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - disk_name: str, - disk: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Updates (patches) a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Patch disk operation. Required. - :type disk: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_04_02.models.Disk] - :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. - - :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 - :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.v2023_04_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.v2023_04_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 "2023-04-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, 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, - 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("Disk", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Disk].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Disk]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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.v2023_04_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 "2023-04-02")) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) - - _request = build_disks_get_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) - - _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("Disk", 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_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 "2023-04-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: - """ - _headers = kwargs.pop("headers", {}) 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-04-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, **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) -> AsyncItemPaged["_models.Disk"]: - """Lists all the disks 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 Disk or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_04_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 "2023-04-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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2023_04_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 "2023-04-02")) - cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disks_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _grant_access_initial( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, 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-04-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disks_grant_access_request( - resource_group_name=resource_group_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) - - _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_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2023_04_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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_04_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param grant_access_data: Access data object supplied in the body of the get disk access - operation. Required. - :type grant_access_data: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_04_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2023_04_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.v2023_04_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 "2023-04-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, - disk_name=disk_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, 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 "2023-04-02")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disks_revoke_access_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]: - 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_revoke_access( - self, resource_group_name: str, disk_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Revokes access to 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: - """ - _headers = kwargs.pop("headers", {}) 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-04-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) - - 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 DiskAccessesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_04_02.aio.ComputeManagementClient`'s - :attr:`disk_accesses` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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-04-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access - else: - _json = self._serialize.body(disk_access, "DiskAccess") - - _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) - - _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_create_or_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccess, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Put disk access operation. - Required. - :type disk_access: ~azure.mgmt.compute.v2023_04_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.v2023_04_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2023_04_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Put disk access operation. - Is either a DiskAccess type or a IO[bytes] type. Required. - :type disk_access: ~azure.mgmt.compute.v2023_04_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.v2023_04_02.models.DiskAccess] - :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-04-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) - - 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 - - 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 - ) - - async def _update_initial( - 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, - 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-04-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access - else: - _json = self._serialize.body(disk_access, "DiskAccessUpdate") - - _request = build_disk_accesses_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) - - _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( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccessUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Patch disk access operation. - Required. - :type disk_access: ~azure.mgmt.compute.v2023_04_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 DiskAccess or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_04_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the 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 DiskAccess or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_04_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - 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. - :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.v2023_04_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.v2023_04_02.models.DiskAccess] - :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-04-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._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) - - 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 - - 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 - ) - - @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.v2023_04_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 "2023-04-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 - ) -> 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 "2023-04-02")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disk_accesses_delete_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) - - _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_access_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes 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 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-04-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: - 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) -> AsyncItemPaged["_models.DiskAccess"]: - """Lists all the disk access resources 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 DiskAccess or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_04_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 "2023-04-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 - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2023_04_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 "2023-04-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_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. 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.v2023_04_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 "2023-04-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 - - 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, - 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-04-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.v2023_04_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.v2023_04_02.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2023_04_02.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long - self, - resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection under disk access resource, this can't be used - to create a new private endpoint connection. - - :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.v2023_04_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.v2023_04_02.models.PrivateEndpointConnection] - :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-04-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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 polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def get_a_private_endpoint_connection( - self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets information about a private endpoint connection under a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_04_02.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-04-02")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_disk_accesses_get_a_private_endpoint_connection_request( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # 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 - ) -> 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 "2023-04-02")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disk_accesses_delete_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) - - _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_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. - - :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: 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-04-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_a_private_endpoint_connection_initial( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_private_endpoint_connections( - self, resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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.v2023_04_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 "2023-04-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.v2023_04_02.aio.ComputeManagementClient`'s - :attr:`disk_encryption_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-04-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set - else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") - - _request = build_disk_encryption_sets_create_or_update_request( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2023_04_02.models.DiskEncryptionSet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_04_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_04_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Is either a DiskEncryptionSet type or a IO[bytes] type. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2023_04_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.v2023_04_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 "2023-04-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._create_or_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, **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 _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, - 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-04-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set - else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSetUpdate") - - _request = build_disk_encryption_sets_update_request( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, - 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. - :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.v2023_04_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.v2023_04_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. 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.v2023_04_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. 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.v2023_04_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.v2023_04_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 "2023-04-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, **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 - ) - - @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.v2023_04_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 "2023-04-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 - ) -> 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 "2023-04-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) - - 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_encryption_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[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 - :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-04-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 - ) -> AsyncItemPaged["_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.v2023_04_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 "2023-04-02")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2023_04_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 "2023-04-02")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_associated_resources( - self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> AsyncItemPaged[str]: - """Lists all resources that are encrypted with this 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: 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 "2023-04-02")) - cls: ClsType[_models.ResourceUriList] = 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_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, - 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("ResourceUriList", 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 DiskRestorePointOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_04_02.aio.ComputeManagementClient`'s - :attr:`disk_restore_point` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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. - - :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 - :return: DiskRestorePoint or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_04_02.models.DiskRestorePoint - :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-04-02")) - cls: ClsType[_models.DiskRestorePoint] = kwargs.pop("cls", None) - - _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) - - _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 - ) -> AsyncItemPaged["_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.v2023_04_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 "2023-04-02")) - cls: ClsType[_models.DiskRestorePointList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_restore_point_list_by_restore_point_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskRestorePointList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _grant_access_initial( - self, - resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> 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-04-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disk_restore_point_grant_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, - 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_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: _models.GrantAccessData, - *, - 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: ~azure.mgmt.compute.v2023_04_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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_04_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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: 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.v2023_04_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. - - :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.v2023_04_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.v2023_04_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 "2023-04-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 "2023-04-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 - - @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. - - :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 - :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-04-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, - 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, - 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 SnapshotsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_04_02.aio.ComputeManagementClient`'s - :attr:`snapshots` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, snapshot_name: str, snapshot: Union[_models.Snapshot, 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-04-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "Snapshot") - - _request = build_snapshots_create_or_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.Snapshot, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: ~azure.mgmt.compute.v2023_04_02.models.Snapshot - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_04_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_04_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :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.v2023_04_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.v2023_04_02.models.Snapshot] - :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-04-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, 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, - 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, **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 _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, - 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-04-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "SnapshotUpdate") - - _request = build_snapshots_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.SnapshotUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. 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.v2023_04_02.models.SnapshotUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_04_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. - Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_04_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. Is - either a SnapshotUpdate type or a IO[bytes] type. Required. - :type snapshot: ~azure.mgmt.compute.v2023_04_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.v2023_04_02.models.Snapshot] - :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-04-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, 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, **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 - ) - - @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.v2023_04_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 "2023-04-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( - 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 "2023-04-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) - - 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, snapshot_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes 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: 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-04-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, - snapshot_name=snapshot_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) -> AsyncItemPaged["_models.Snapshot"]: - """Lists snapshots 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 Snapshot or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_04_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 "2023-04-02")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - 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(self, **kwargs: Any) -> AsyncItemPaged["_models.Snapshot"]: - """Lists snapshots under a subscription. - - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_04_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 "2023-04-02")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _grant_access_initial( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, 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-04-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_snapshots_grant_access_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param grant_access_data: Access data object supplied in the body of the get snapshot access - operation. Required. - :type grant_access_data: ~azure.mgmt.compute.v2023_04_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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_04_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param 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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_04_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param 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.v2023_04_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.v2023_04_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 "2023-04-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, - snapshot_name=snapshot_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, 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 "2023-04-02")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_snapshots_revoke_access_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]: - 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_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. - :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 "2023-04-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, - snapshot_name=snapshot_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/models/__init__.py deleted file mode 100644 index 79b8cce52e88..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/models/__init__.py +++ /dev/null @@ -1,172 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - AccessUri, - ApiError, - ApiErrorBase, - CopyCompletionError, - CreationData, - Disk, - DiskAccess, - DiskAccessList, - DiskAccessUpdate, - DiskEncryptionSet, - DiskEncryptionSetList, - DiskEncryptionSetUpdate, - DiskList, - DiskRestorePoint, - DiskRestorePointList, - DiskSecurityProfile, - DiskSku, - DiskUpdate, - Encryption, - EncryptionSetIdentity, - EncryptionSettingsCollection, - EncryptionSettingsElement, - ExtendedLocation, - GrantAccessData, - ImageDiskReference, - InnerError, - KeyForDiskEncryptionSet, - KeyVaultAndKeyReference, - KeyVaultAndSecretReference, - PrivateEndpoint, - PrivateEndpointConnection, - PrivateEndpointConnectionListResult, - PrivateLinkResource, - PrivateLinkResourceListResult, - PrivateLinkServiceConnectionState, - PropertyUpdatesInProgress, - ProxyOnlyResource, - PurchasePlan, - Resource, - ResourceUriList, - ResourceWithOptionalLocation, - ShareInfoElement, - Snapshot, - SnapshotList, - SnapshotSku, - SnapshotUpdate, - SourceVault, - SubResource, - SubResourceReadOnly, - SupportedCapabilities, - SystemData, - UserAssignedIdentitiesValue, -) - -from ._compute_management_client_enums import ( # type: ignore - AccessLevel, - Architecture, - CopyCompletionErrorReason, - DataAccessAuthMode, - DiskCreateOption, - DiskEncryptionSetIdentityType, - DiskEncryptionSetType, - DiskSecurityTypes, - DiskState, - DiskStorageAccountTypes, - EncryptionType, - ExtendedLocationTypes, - FileFormat, - HyperVGeneration, - NetworkAccessPolicy, - OperatingSystemTypes, - PrivateEndpointConnectionProvisioningState, - PrivateEndpointServiceConnectionStatus, - PublicNetworkAccess, - SnapshotStorageAccountTypes, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AccessUri", - "ApiError", - "ApiErrorBase", - "CopyCompletionError", - "CreationData", - "Disk", - "DiskAccess", - "DiskAccessList", - "DiskAccessUpdate", - "DiskEncryptionSet", - "DiskEncryptionSetList", - "DiskEncryptionSetUpdate", - "DiskList", - "DiskRestorePoint", - "DiskRestorePointList", - "DiskSecurityProfile", - "DiskSku", - "DiskUpdate", - "Encryption", - "EncryptionSetIdentity", - "EncryptionSettingsCollection", - "EncryptionSettingsElement", - "ExtendedLocation", - "GrantAccessData", - "ImageDiskReference", - "InnerError", - "KeyForDiskEncryptionSet", - "KeyVaultAndKeyReference", - "KeyVaultAndSecretReference", - "PrivateEndpoint", - "PrivateEndpointConnection", - "PrivateEndpointConnectionListResult", - "PrivateLinkResource", - "PrivateLinkResourceListResult", - "PrivateLinkServiceConnectionState", - "PropertyUpdatesInProgress", - "ProxyOnlyResource", - "PurchasePlan", - "Resource", - "ResourceUriList", - "ResourceWithOptionalLocation", - "ShareInfoElement", - "Snapshot", - "SnapshotList", - "SnapshotSku", - "SnapshotUpdate", - "SourceVault", - "SubResource", - "SubResourceReadOnly", - "SupportedCapabilities", - "SystemData", - "UserAssignedIdentitiesValue", - "AccessLevel", - "Architecture", - "CopyCompletionErrorReason", - "DataAccessAuthMode", - "DiskCreateOption", - "DiskEncryptionSetIdentityType", - "DiskEncryptionSetType", - "DiskSecurityTypes", - "DiskState", - "DiskStorageAccountTypes", - "EncryptionType", - "ExtendedLocationTypes", - "FileFormat", - "HyperVGeneration", - "NetworkAccessPolicy", - "OperatingSystemTypes", - "PrivateEndpointConnectionProvisioningState", - "PrivateEndpointServiceConnectionStatus", - "PublicNetworkAccess", - "SnapshotStorageAccountTypes", -] -__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_04_02/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/models/_compute_management_client_enums.py deleted file mode 100644 index 0268329bb1d2..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/models/_compute_management_client_enums.py +++ /dev/null @@ -1,268 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AccessLevel.""" - - NONE = "None" - READ = "Read" - WRITE = "Write" - - -class Architecture(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """CPU architecture supported by an OS disk.""" - - X64 = "x64" - ARM64 = "Arm64" - - -class CopyCompletionErrorReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the error code if the background copy of a resource created via the CopyStart - operation fails. - """ - - COPY_SOURCE_NOT_FOUND = "CopySourceNotFound" - """Indicates that the source snapshot was deleted while the background copy of the resource - created via CopyStart operation was in progress.""" - - -class DataAccessAuthMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Additional authentication requirements when exporting or uploading to a disk or snapshot.""" - - AZURE_ACTIVE_DIRECTORY = "AzureActiveDirectory" - """When export/upload URL is used, the system checks if the user has an identity in Azure Active - Directory and has necessary permissions to export/upload the data. Please refer to - aka.ms/DisksAzureADAuth.""" - NONE = "None" - """No additional authentication would be performed when accessing export/upload URL.""" - - -class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This enumerates the possible sources of a disk's creation.""" - - EMPTY = "Empty" - """Create an empty data disk of a size given by diskSizeGB.""" - ATTACH = "Attach" - """Disk will be attached to a VM.""" - FROM_IMAGE = "FromImage" - """Create a new disk from a platform image specified by the given imageReference or - galleryImageReference.""" - IMPORT = "Import" - """Create a disk by importing from a blob specified by a sourceUri in a storage account specified - by storageAccountId.""" - COPY = "Copy" - """Create a new disk or snapshot by copying from a disk or snapshot specified by the given - sourceResourceId.""" - RESTORE = "Restore" - """Create a new disk by copying from a backup recovery point.""" - UPLOAD = "Upload" - """Create a new disk by obtaining a write token and using it to directly upload the contents of - the disk.""" - COPY_START = "CopyStart" - """Create a new disk by using a deep copy process, where the resource creation is considered - complete only after all data has been copied from the source.""" - IMPORT_SECURE = "ImportSecure" - """Similar to Import create option. Create a new Trusted Launch VM or Confidential VM supported - disk by importing additional blob for VM guest state specified by securityDataUri in storage - account specified by storageAccountId""" - UPLOAD_PREPARED_SECURE = "UploadPreparedSecure" - """Similar to Upload create option. Create a new Trusted Launch VM or Confidential VM supported - disk and upload using write token in both disk and VM guest state""" - COPY_FROM_SAN_SNAPSHOT = "CopyFromSanSnapshot" - """Create a new disk by exporting from elastic san volume snapshot""" - IMPORT_ENUM = "Import" - """Create a disk by importing from a blob specified by a sourceUri in a storage account specified - by storageAccountId.""" - - -class DiskEncryptionSetIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported - for new creations. Disk Encryption Sets can be updated with Identity type None during migration - of subscription to a new Azure Active Directory tenant; it will cause the encrypted resources - to lose access to the keys. - """ - - SYSTEM_ASSIGNED = "SystemAssigned" - USER_ASSIGNED = "UserAssigned" - SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" - NONE = "None" - - -class DiskEncryptionSetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of key used to encrypt the data of the disk.""" - - ENCRYPTION_AT_REST_WITH_CUSTOMER_KEY = "EncryptionAtRestWithCustomerKey" - """Resource using diskEncryptionSet would be encrypted at rest with Customer managed key that can - be changed and revoked by a customer.""" - ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" - """Resource using diskEncryptionSet would be encrypted at rest with two layers of encryption. One - of the keys is Customer managed and the other key is Platform managed.""" - CONFIDENTIAL_VM_ENCRYPTED_WITH_CUSTOMER_KEY = "ConfidentialVmEncryptedWithCustomerKey" - """Confidential VM supported disk and VM guest state would be encrypted with customer managed key.""" - - -class DiskSecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the SecurityType of the VM. Applicable for OS disks only.""" - - TRUSTED_LAUNCH = "TrustedLaunch" - """Trusted Launch provides security features such as secure boot and virtual Trusted Platform - Module (vTPM)""" - CONFIDENTIAL_VM_VMGUEST_STATE_ONLY_ENCRYPTED_WITH_PLATFORM_KEY = ( - "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey" - ) - """Indicates Confidential VM disk with only VM guest state encrypted""" - CONFIDENTIAL_VM_DISK_ENCRYPTED_WITH_PLATFORM_KEY = "ConfidentialVM_DiskEncryptedWithPlatformKey" - """Indicates Confidential VM disk with both OS disk and VM guest state encrypted with a platform - managed key""" - CONFIDENTIAL_VM_DISK_ENCRYPTED_WITH_CUSTOMER_KEY = "ConfidentialVM_DiskEncryptedWithCustomerKey" - """Indicates Confidential VM disk with both OS disk and VM guest state encrypted with a customer - managed key""" - - -class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This enumerates the possible state of the disk.""" - - UNATTACHED = "Unattached" - """The disk is not being used and can be attached to a VM.""" - ATTACHED = "Attached" - """The disk is currently attached to a running VM.""" - RESERVED = "Reserved" - """The disk is attached to a stopped-deallocated VM.""" - FROZEN = "Frozen" - """The disk is attached to a VM which is in hibernated state.""" - ACTIVE_SAS = "ActiveSAS" - """The disk currently has an Active SAS Uri associated with it.""" - ACTIVE_SAS_FROZEN = "ActiveSASFrozen" - """The disk is attached to a VM in hibernated state and has an active SAS URI associated with it.""" - READY_TO_UPLOAD = "ReadyToUpload" - """A disk is ready to be created by upload by requesting a write token.""" - ACTIVE_UPLOAD = "ActiveUpload" - """A disk is created for upload and a write token has been issued for uploading to it.""" - - -class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The sku name.""" - - STANDARD_LRS = "Standard_LRS" - """Standard HDD locally redundant storage. Best for backup, non-critical, and infrequent access.""" - PREMIUM_LRS = "Premium_LRS" - """Premium SSD locally redundant storage. Best for production and performance sensitive workloads.""" - STANDARD_SSD_LRS = "StandardSSD_LRS" - """Standard SSD locally redundant storage. Best for web servers, lightly used enterprise - applications and dev/test.""" - ULTRA_SSD_LRS = "UltraSSD_LRS" - """Ultra SSD locally redundant storage. Best for IO-intensive workloads such as SAP HANA, top tier - databases (for example, SQL, Oracle), and other transaction-heavy workloads.""" - PREMIUM_ZRS = "Premium_ZRS" - """Premium SSD zone redundant storage. Best for the production workloads that need storage - resiliency against zone failures.""" - STANDARD_SSD_ZRS = "StandardSSD_ZRS" - """Standard SSD zone redundant storage. Best for web servers, lightly used enterprise applications - and dev/test that need storage resiliency against zone failures.""" - PREMIUM_V2_LRS = "PremiumV2_LRS" - """Premium SSD v2 locally redundant storage. Best for production and performance-sensitive - workloads that consistently require low latency and high IOPS and throughput.""" - - -class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of key used to encrypt the data of the disk.""" - - ENCRYPTION_AT_REST_WITH_PLATFORM_KEY = "EncryptionAtRestWithPlatformKey" - """Disk is encrypted at rest with Platform managed key. It is the default encryption type. This is - not a valid encryption type for disk encryption sets.""" - ENCRYPTION_AT_REST_WITH_CUSTOMER_KEY = "EncryptionAtRestWithCustomerKey" - """Disk is encrypted at rest with Customer managed key that can be changed and revoked by a - customer.""" - ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" - """Disk is encrypted at rest with 2 layers of encryption. One of the keys is Customer managed and - the other key is Platform managed.""" - - -class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of extendedLocation.""" - - EDGE_ZONE = "EdgeZone" - - -class FileFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Used to specify the file format when making request for SAS on a VHDX file format snapshot.""" - - VHD = "VHD" - """A VHD file is a disk image file in the Virtual Hard Disk file format.""" - VHDX = "VHDX" - """A VHDX file is a disk image file in the Virtual Hard Disk v2 file format.""" - - -class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The hypervisor generation of the Virtual Machine. Applicable to OS disks only.""" - - V1 = "V1" - V2 = "V2" - - -class NetworkAccessPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Policy for accessing the disk via network.""" - - ALLOW_ALL = "AllowAll" - """The disk can be exported or uploaded to from any network.""" - ALLOW_PRIVATE = "AllowPrivate" - """The disk can be exported or uploaded to using a DiskAccess resource's private endpoints.""" - DENY_ALL = "DenyAll" - """The disk cannot be exported.""" - - -class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The Operating System type.""" - - WINDOWS = "Windows" - LINUX = "Linux" - - -class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current provisioning state.""" - - SUCCEEDED = "Succeeded" - CREATING = "Creating" - DELETING = "Deleting" - FAILED = "Failed" - - -class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The private endpoint connection status.""" - - PENDING = "Pending" - APPROVED = "Approved" - REJECTED = "Rejected" - - -class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Policy for controlling export on the disk.""" - - ENABLED = "Enabled" - """You can generate a SAS URI to access the underlying data of the disk publicly on the internet - when NetworkAccessPolicy is set to AllowAll. You can access the data via the SAS URI only from - your trusted Azure VNET when NetworkAccessPolicy is set to AllowPrivate.""" - DISABLED = "Disabled" - """You cannot access the underlying data of the disk publicly on the internet even when - NetworkAccessPolicy is set to AllowAll. You can access the data via the SAS URI only from your - trusted Azure VNET when NetworkAccessPolicy is set to AllowPrivate.""" - - -class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The sku name.""" - - STANDARD_LRS = "Standard_LRS" - """Standard HDD locally redundant storage""" - PREMIUM_LRS = "Premium_LRS" - """Premium SSD locally redundant storage""" - STANDARD_ZRS = "Standard_ZRS" - """Standard zone redundant storage""" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/models/_models_py3.py deleted file mode 100644 index 2ced228156e5..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/models/_models_py3.py +++ /dev/null @@ -1,3191 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -class AccessUri(_serialization.Model): - """A disk access SAS uri. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar access_sas: A SAS uri for accessing a disk. - :vartype access_sas: str - :ivar security_data_access_sas: A SAS uri for accessing a VM guest state. - :vartype security_data_access_sas: str - """ - - _validation = { - "access_sas": {"readonly": True}, - "security_data_access_sas": {"readonly": True}, - } - - _attribute_map = { - "access_sas": {"key": "accessSAS", "type": "str"}, - "security_data_access_sas": {"key": "securityDataAccessSAS", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.access_sas: Optional[str] = None - self.security_data_access_sas: Optional[str] = None - - -class ApiError(_serialization.Model): - """Api error. - - :ivar details: The Api error details. - :vartype details: list[~azure.mgmt.compute.v2023_04_02.models.ApiErrorBase] - :ivar innererror: The Api inner error. - :vartype innererror: ~azure.mgmt.compute.v2023_04_02.models.InnerError - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "details": {"key": "details", "type": "[ApiErrorBase]"}, - "innererror": {"key": "innererror", "type": "InnerError"}, - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - details: Optional[List["_models.ApiErrorBase"]] = None, - innererror: Optional["_models.InnerError"] = None, - code: Optional[str] = None, - target: Optional[str] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword details: The Api error details. - :paramtype details: list[~azure.mgmt.compute.v2023_04_02.models.ApiErrorBase] - :keyword innererror: The Api inner error. - :paramtype innererror: ~azure.mgmt.compute.v2023_04_02.models.InnerError - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.details = details - self.innererror = innererror - self.code = code - self.target = target - self.message = message - - -class ApiErrorBase(_serialization.Model): - """Api error base. - - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.target = target - self.message = message - - -class CopyCompletionError(_serialization.Model): - """Indicates the error details if the background copy of a resource created via the CopyStart - operation fails. - - All required parameters must be populated in order to send to server. - - :ivar error_code: Indicates the error code if the background copy of a resource created via the - CopyStart operation fails. Required. "CopySourceNotFound" - :vartype error_code: str or ~azure.mgmt.compute.v2023_04_02.models.CopyCompletionErrorReason - :ivar error_message: Indicates the error message if the background copy of a resource created - via the CopyStart operation fails. Required. - :vartype error_message: str - """ - - _validation = { - "error_code": {"required": True}, - "error_message": {"required": True}, - } - - _attribute_map = { - "error_code": {"key": "errorCode", "type": "str"}, - "error_message": {"key": "errorMessage", "type": "str"}, - } - - def __init__( - self, *, error_code: Union[str, "_models.CopyCompletionErrorReason"], error_message: str, **kwargs: Any - ) -> None: - """ - :keyword error_code: Indicates the error code if the background copy of a resource created via - the CopyStart operation fails. Required. "CopySourceNotFound" - :paramtype error_code: str or ~azure.mgmt.compute.v2023_04_02.models.CopyCompletionErrorReason - :keyword error_message: Indicates the error message if the background copy of a resource - created via the CopyStart operation fails. Required. - :paramtype error_message: str - """ - super().__init__(**kwargs) - self.error_code = error_code - self.error_message = error_message - - -class CreationData(_serialization.Model): - """Data used when creating a disk. - - 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 create_option: This enumerates the possible sources of a disk's creation. Required. Known - values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", "CopyStart", - "ImportSecure", "UploadPreparedSecure", "CopyFromSanSnapshot", and "Import". - :vartype create_option: str or ~azure.mgmt.compute.v2023_04_02.models.DiskCreateOption - :ivar storage_account_id: Required if createOption is Import. The Azure Resource Manager - identifier of the storage account containing the blob to import as a disk. - :vartype storage_account_id: str - :ivar image_reference: Disk source information for PIR or user images. - :vartype image_reference: ~azure.mgmt.compute.v2023_04_02.models.ImageDiskReference - :ivar gallery_image_reference: Required if creating from a Gallery Image. The - id/sharedGalleryImageId/communityGalleryImageId of the ImageDiskReference will be the ARM id of - the shared galley image version from which to create a disk. - :vartype gallery_image_reference: ~azure.mgmt.compute.v2023_04_02.models.ImageDiskReference - :ivar source_uri: If createOption is Import, this is the URI of a blob to be imported into a - managed disk. - :vartype source_uri: str - :ivar source_resource_id: If createOption is Copy, this is the ARM id of the source snapshot or - disk. - :vartype source_resource_id: str - :ivar source_unique_id: If this field is set, this is the unique id identifying the source of - this resource. - :vartype source_unique_id: str - :ivar upload_size_bytes: If createOption is Upload, this is the size of the contents of the - upload including the VHD footer. This value should be between 20972032 (20 MiB + 512 bytes for - the VHD footer) and 35183298347520 bytes (32 TiB + 512 bytes for the VHD footer). - :vartype upload_size_bytes: int - :ivar logical_sector_size: Logical sector size in bytes for Ultra disks. Supported values are - 512 ad 4096. 4096 is the default. - :vartype logical_sector_size: int - :ivar security_data_uri: If createOption is ImportSecure, this is the URI of a blob to be - imported into VM guest state. - :vartype security_data_uri: str - :ivar performance_plus: Set this flag to true to get a boost on the performance target of the - disk deployed, see here on the respective performance target. This flag can only be set on disk - creation time and cannot be disabled after enabled. - :vartype performance_plus: bool - :ivar elastic_san_resource_id: Required if createOption is CopyFromSanSnapshot. This is the ARM - id of the source elastic san volume snapshot. - :vartype elastic_san_resource_id: str - """ - - _validation = { - "create_option": {"required": True}, - "source_unique_id": {"readonly": True}, - } - - _attribute_map = { - "create_option": {"key": "createOption", "type": "str"}, - "storage_account_id": {"key": "storageAccountId", "type": "str"}, - "image_reference": {"key": "imageReference", "type": "ImageDiskReference"}, - "gallery_image_reference": {"key": "galleryImageReference", "type": "ImageDiskReference"}, - "source_uri": {"key": "sourceUri", "type": "str"}, - "source_resource_id": {"key": "sourceResourceId", "type": "str"}, - "source_unique_id": {"key": "sourceUniqueId", "type": "str"}, - "upload_size_bytes": {"key": "uploadSizeBytes", "type": "int"}, - "logical_sector_size": {"key": "logicalSectorSize", "type": "int"}, - "security_data_uri": {"key": "securityDataUri", "type": "str"}, - "performance_plus": {"key": "performancePlus", "type": "bool"}, - "elastic_san_resource_id": {"key": "elasticSanResourceId", "type": "str"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOption"], - storage_account_id: Optional[str] = None, - image_reference: Optional["_models.ImageDiskReference"] = None, - gallery_image_reference: Optional["_models.ImageDiskReference"] = None, - source_uri: Optional[str] = None, - source_resource_id: Optional[str] = None, - upload_size_bytes: Optional[int] = None, - logical_sector_size: Optional[int] = None, - security_data_uri: Optional[str] = None, - performance_plus: Optional[bool] = None, - elastic_san_resource_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword create_option: This enumerates the possible sources of a disk's creation. Required. - Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", - "CopyStart", "ImportSecure", "UploadPreparedSecure", "CopyFromSanSnapshot", and "Import". - :paramtype create_option: str or ~azure.mgmt.compute.v2023_04_02.models.DiskCreateOption - :keyword storage_account_id: Required if createOption is Import. The Azure Resource Manager - identifier of the storage account containing the blob to import as a disk. - :paramtype storage_account_id: str - :keyword image_reference: Disk source information for PIR or user images. - :paramtype image_reference: ~azure.mgmt.compute.v2023_04_02.models.ImageDiskReference - :keyword gallery_image_reference: Required if creating from a Gallery Image. The - id/sharedGalleryImageId/communityGalleryImageId of the ImageDiskReference will be the ARM id of - the shared galley image version from which to create a disk. - :paramtype gallery_image_reference: ~azure.mgmt.compute.v2023_04_02.models.ImageDiskReference - :keyword source_uri: If createOption is Import, this is the URI of a blob to be imported into a - managed disk. - :paramtype source_uri: str - :keyword source_resource_id: If createOption is Copy, this is the ARM id of the source snapshot - or disk. - :paramtype source_resource_id: str - :keyword upload_size_bytes: If createOption is Upload, this is the size of the contents of the - upload including the VHD footer. This value should be between 20972032 (20 MiB + 512 bytes for - the VHD footer) and 35183298347520 bytes (32 TiB + 512 bytes for the VHD footer). - :paramtype upload_size_bytes: int - :keyword logical_sector_size: Logical sector size in bytes for Ultra disks. Supported values - are 512 ad 4096. 4096 is the default. - :paramtype logical_sector_size: int - :keyword security_data_uri: If createOption is ImportSecure, this is the URI of a blob to be - imported into VM guest state. - :paramtype security_data_uri: str - :keyword performance_plus: Set this flag to true to get a boost on the performance target of - the disk deployed, see here on the respective performance target. This flag can only be set on - disk creation time and cannot be disabled after enabled. - :paramtype performance_plus: bool - :keyword elastic_san_resource_id: Required if createOption is CopyFromSanSnapshot. This is the - ARM id of the source elastic san volume snapshot. - :paramtype elastic_san_resource_id: str - """ - super().__init__(**kwargs) - self.create_option = create_option - self.storage_account_id = storage_account_id - self.image_reference = image_reference - self.gallery_image_reference = gallery_image_reference - self.source_uri = source_uri - self.source_resource_id = source_resource_id - self.source_unique_id: Optional[str] = None - self.upload_size_bytes = upload_size_bytes - self.logical_sector_size = logical_sector_size - self.security_data_uri = security_data_uri - self.performance_plus = performance_plus - self.elastic_san_resource_id = elastic_san_resource_id - - -class Resource(_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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - - -class Disk(Resource): - """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. - :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] - :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 - disk attached. maxShares should be set to a value greater than one for disks to allow attaching - them to multiple VMs. - :vartype managed_by_extended: list[str] - :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, - Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS. - :vartype sku: ~azure.mgmt.compute.v2023_04_02.models.DiskSku - :ivar zones: The Logical zone list for Disk. - :vartype zones: list[str] - :ivar extended_location: The extended location where the disk will be created. Extended - location cannot be changed. - :vartype extended_location: ~azure.mgmt.compute.v2023_04_02.models.ExtendedLocation - :ivar time_created: The time when the disk was created. - :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2023_04_02.models.OperatingSystemTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2023_04_02.models.HyperVGeneration - :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.v2023_04_02.models.PurchasePlan - :ivar supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :vartype supported_capabilities: ~azure.mgmt.compute.v2023_04_02.models.SupportedCapabilities - :ivar creation_data: Disk source information. CreationData information cannot be changed after - the disk has been created. - :vartype creation_data: ~azure.mgmt.compute.v2023_04_02.models.CreationData - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. - :vartype disk_size_bytes: int - :ivar unique_id: Unique Guid identifying the resource. - :vartype unique_id: str - :ivar encryption_settings_collection: Encryption settings collection used for Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2023_04_02.models.EncryptionSettingsCollection - :ivar provisioning_state: The disk provisioning state. - :vartype provisioning_state: str - :ivar disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :vartype disk_m_bps_read_write: int - :ivar disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_only: int - :ivar disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :vartype disk_m_bps_read_only: int - :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", - "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", and "ActiveUpload". - :vartype disk_state: str or ~azure.mgmt.compute.v2023_04_02.models.DiskState - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2023_04_02.models.Encryption - :ivar max_shares: The maximum number of VMs that can attach to the disk at the same time. Value - greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :vartype max_shares: int - :ivar share_info: Details of the list of all VMs that have the disk attached. maxShares should - be set to a value greater than one for disks to allow attaching them to multiple VMs. - :vartype share_info: list[~azure.mgmt.compute.v2023_04_02.models.ShareInfoElement] - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2023_04_02.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar bursting_enabled_time: Latest time when bursting was last enabled on a disk. - :vartype bursting_enabled_time: ~datetime.datetime - :ivar tier: Performance tier of the disk (e.g, P4, S10) as described here: - https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra - disks. - :vartype tier: str - :ivar bursting_enabled: Set to true to enable bursting beyond the provisioned performance - target of the disk. Bursting is disabled by default. Does not apply to Ultra disks. - :vartype bursting_enabled: bool - :ivar property_updates_in_progress: Properties of the disk for which update is pending. - :vartype property_updates_in_progress: - ~azure.mgmt.compute.v2023_04_02.models.PropertyUpdatesInProgress - :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. - :vartype supports_hibernation: bool - :ivar security_profile: Contains the security related information for the resource. - :vartype security_profile: ~azure.mgmt.compute.v2023_04_02.models.DiskSecurityProfile - :ivar completion_percent: Percentage complete for the background copy when a resource is - created via the CopyStart operation. - :vartype completion_percent: float - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2023_04_02.models.PublicNetworkAccess - :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :vartype data_access_auth_mode: str or - ~azure.mgmt.compute.v2023_04_02.models.DataAccessAuthMode - :ivar optimized_for_frequent_attach: Setting this property to true improves reliability and - performance of data disks that are frequently (more than 5 times a day) by detached from one - virtual machine and attached to another. This property should not be set for disks that are not - detached and attached frequently as it causes the disks to not align with the fault domain of - the virtual machine. - :vartype optimized_for_frequent_attach: bool - :ivar last_ownership_update_time: The UTC time when the ownership state of the disk was last - changed i.e., the time the disk was last attached or detached from a VM or the time when the VM - to which the disk was attached was deallocated or started. - :vartype last_ownership_update_time: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "managed_by": {"readonly": True}, - "managed_by_extended": {"readonly": True}, - "time_created": {"readonly": True}, - "disk_size_bytes": {"readonly": True}, - "unique_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "disk_state": {"readonly": True}, - "share_info": {"readonly": True}, - "bursting_enabled_time": {"readonly": True}, - "property_updates_in_progress": {"readonly": True}, - "last_ownership_update_time": {"readonly": 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}"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "managed_by_extended": {"key": "managedByExtended", "type": "[str]"}, - "sku": {"key": "sku", "type": "DiskSku"}, - "zones": {"key": "zones", "type": "[str]"}, - "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"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - "creation_data": {"key": "properties.creationData", "type": "CreationData"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "disk_size_bytes": {"key": "properties.diskSizeBytes", "type": "int"}, - "unique_id": {"key": "properties.uniqueId", "type": "str"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "disk_iops_read_write": {"key": "properties.diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "properties.diskMBpsReadWrite", "type": "int"}, - "disk_iops_read_only": {"key": "properties.diskIOPSReadOnly", "type": "int"}, - "disk_m_bps_read_only": {"key": "properties.diskMBpsReadOnly", "type": "int"}, - "disk_state": {"key": "properties.diskState", "type": "str"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "max_shares": {"key": "properties.maxShares", "type": "int"}, - "share_info": {"key": "properties.shareInfo", "type": "[ShareInfoElement]"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - "bursting_enabled_time": {"key": "properties.burstingEnabledTime", "type": "iso-8601"}, - "tier": {"key": "properties.tier", "type": "str"}, - "bursting_enabled": {"key": "properties.burstingEnabled", "type": "bool"}, - "property_updates_in_progress": { - "key": "properties.propertyUpdatesInProgress", - "type": "PropertyUpdatesInProgress", - }, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "security_profile": {"key": "properties.securityProfile", "type": "DiskSecurityProfile"}, - "completion_percent": {"key": "properties.completionPercent", "type": "float"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, - "optimized_for_frequent_attach": {"key": "properties.optimizedForFrequentAttach", "type": "bool"}, - "last_ownership_update_time": {"key": "properties.LastOwnershipUpdateTime", "type": "iso-8601"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.DiskSku"] = None, - zones: Optional[List[str]] = None, - 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, - supported_capabilities: Optional["_models.SupportedCapabilities"] = None, - creation_data: Optional["_models.CreationData"] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - disk_iops_read_write: Optional[int] = None, - disk_m_bps_read_write: Optional[int] = None, - disk_iops_read_only: Optional[int] = None, - disk_m_bps_read_only: Optional[int] = None, - encryption: Optional["_models.Encryption"] = None, - max_shares: Optional[int] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - tier: Optional[str] = None, - bursting_enabled: Optional[bool] = None, - supports_hibernation: Optional[bool] = None, - security_profile: Optional["_models.DiskSecurityProfile"] = None, - completion_percent: Optional[float] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, - optimized_for_frequent_attach: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2023_04_02.models.DiskSku - :keyword zones: The Logical zone list for Disk. - :paramtype zones: list[str] - :keyword extended_location: The extended location where the disk will be created. Extended - location cannot be changed. - :paramtype extended_location: ~azure.mgmt.compute.v2023_04_02.models.ExtendedLocation - :keyword os_type: The Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2023_04_02.models.OperatingSystemTypes - :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_04_02.models.HyperVGeneration - :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.v2023_04_02.models.PurchasePlan - :keyword supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :paramtype supported_capabilities: ~azure.mgmt.compute.v2023_04_02.models.SupportedCapabilities - :keyword creation_data: Disk source information. CreationData information cannot be changed - after the disk has been created. - :paramtype creation_data: ~azure.mgmt.compute.v2023_04_02.models.CreationData - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used for Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2023_04_02.models.EncryptionSettingsCollection - :keyword disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_write: int - :keyword disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :paramtype disk_m_bps_read_write: int - :keyword disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_only: int - :keyword disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :paramtype disk_m_bps_read_only: int - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2023_04_02.models.Encryption - :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. - Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :paramtype max_shares: int - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2023_04_02.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword tier: Performance tier of the disk (e.g, P4, S10) as described here: - https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra - disks. - :paramtype tier: str - :keyword bursting_enabled: Set to true to enable bursting beyond the provisioned performance - target of the disk. Bursting is disabled by default. Does not apply to Ultra disks. - :paramtype bursting_enabled: bool - :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. - :paramtype supports_hibernation: bool - :keyword security_profile: Contains the security related information for the resource. - :paramtype security_profile: ~azure.mgmt.compute.v2023_04_02.models.DiskSecurityProfile - :keyword completion_percent: Percentage complete for the background copy when a resource is - created via the CopyStart operation. - :paramtype completion_percent: float - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2023_04_02.models.PublicNetworkAccess - :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :paramtype data_access_auth_mode: str or - ~azure.mgmt.compute.v2023_04_02.models.DataAccessAuthMode - :keyword optimized_for_frequent_attach: Setting this property to true improves reliability and - performance of data disks that are frequently (more than 5 times a day) by detached from one - virtual machine and attached to another. This property should not be set for disks that are not - detached and attached frequently as it causes the disks to not align with the fault domain of - the virtual machine. - :paramtype optimized_for_frequent_attach: bool - """ - super().__init__(location=location, tags=tags, **kwargs) - self.managed_by: Optional[str] = None - self.managed_by_extended: Optional[List[str]] = None - self.sku = sku - self.zones = zones - self.extended_location = extended_location - self.time_created: Optional[datetime.datetime] = None - self.os_type = os_type - self.hyper_v_generation = hyper_v_generation - self.purchase_plan = purchase_plan - self.supported_capabilities = supported_capabilities - self.creation_data = creation_data - self.disk_size_gb = disk_size_gb - self.disk_size_bytes: Optional[int] = None - self.unique_id: Optional[str] = None - self.encryption_settings_collection = encryption_settings_collection - self.provisioning_state: Optional[str] = None - self.disk_iops_read_write = disk_iops_read_write - self.disk_m_bps_read_write = disk_m_bps_read_write - self.disk_iops_read_only = disk_iops_read_only - self.disk_m_bps_read_only = disk_m_bps_read_only - self.disk_state: Optional[Union[str, "_models.DiskState"]] = None - self.encryption = encryption - self.max_shares = max_shares - self.share_info: Optional[List["_models.ShareInfoElement"]] = None - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - self.bursting_enabled_time: Optional[datetime.datetime] = None - self.tier = tier - self.bursting_enabled = bursting_enabled - self.property_updates_in_progress: Optional["_models.PropertyUpdatesInProgress"] = None - self.supports_hibernation = supports_hibernation - self.security_profile = security_profile - self.completion_percent = completion_percent - self.public_network_access = public_network_access - self.data_access_auth_mode = data_access_auth_mode - self.optimized_for_frequent_attach = optimized_for_frequent_attach - self.last_ownership_update_time: Optional[datetime.datetime] = None - - -class DiskAccess(Resource): - """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. - :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] - :ivar extended_location: The extended location where the disk access will be created. Extended - location cannot be changed. - :vartype extended_location: ~azure.mgmt.compute.v2023_04_02.models.ExtendedLocation - :ivar private_endpoint_connections: A readonly collection of private endpoint connections - created on the disk. Currently only one endpoint connection is supported. - :vartype private_endpoint_connections: - list[~azure.mgmt.compute.v2023_04_02.models.PrivateEndpointConnection] - :ivar provisioning_state: The disk access resource provisioning state. - :vartype provisioning_state: str - :ivar time_created: The time when the disk access was created. - :vartype time_created: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "private_endpoint_connections": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "time_created": {"readonly": 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}"}, - "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - "private_endpoint_connections": { - "key": "properties.privateEndpointConnections", - "type": "[PrivateEndpointConnection]", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - extended_location: Optional["_models.ExtendedLocation"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2023_04_02.models.ExtendedLocation - """ - super().__init__(location=location, tags=tags, **kwargs) - self.extended_location = extended_location - self.private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None - self.provisioning_state: Optional[str] = None - self.time_created: Optional[datetime.datetime] = None - - -class DiskAccessList(_serialization.Model): - """The List disk access operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of disk access resources. Required. - :vartype value: list[~azure.mgmt.compute.v2023_04_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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DiskAccess]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.DiskAccess"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of disk access resources. Required. - :paramtype value: list[~azure.mgmt.compute.v2023_04_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DiskAccessUpdate(_serialization.Model): - """Used for updating a disk access resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class DiskEncryptionSet(Resource): - """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. - :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] - :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.v2023_04_02.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and - "ConfidentialVmEncryptedWithCustomerKey". - :vartype encryption_type: str or ~azure.mgmt.compute.v2023_04_02.models.DiskEncryptionSetType - :ivar active_key: The key vault key which is currently used by this disk encryption set. - :vartype active_key: ~azure.mgmt.compute.v2023_04_02.models.KeyForDiskEncryptionSet - :ivar previous_keys: A readonly collection of key vault keys previously used by this disk - encryption set while a key rotation is in progress. It will be empty if there is no ongoing key - rotation. - :vartype previous_keys: list[~azure.mgmt.compute.v2023_04_02.models.KeyForDiskEncryptionSet] - :ivar provisioning_state: The disk encryption set provisioning state. - :vartype provisioning_state: str - :ivar rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating of - this disk encryption set to the latest key version. - :vartype rotation_to_latest_key_version_enabled: bool - :ivar last_key_rotation_timestamp: The time when the active key of this disk encryption set was - updated. - :vartype last_key_rotation_timestamp: ~datetime.datetime - :ivar auto_key_rotation_error: The error that was encountered during auto-key rotation. If an - error is present, then auto-key rotation will not be attempted until the error on this disk - encryption set is fixed. - :vartype auto_key_rotation_error: ~azure.mgmt.compute.v2023_04_02.models.ApiError - :ivar federated_client_id: Multi-tenant application client id to access key vault in a - different tenant. Setting the value to 'None' will clear the property. - :vartype federated_client_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "previous_keys": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "last_key_rotation_timestamp": {"readonly": True}, - "auto_key_rotation_error": {"readonly": 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}"}, - "identity": {"key": "identity", "type": "EncryptionSetIdentity"}, - "encryption_type": {"key": "properties.encryptionType", "type": "str"}, - "active_key": {"key": "properties.activeKey", "type": "KeyForDiskEncryptionSet"}, - "previous_keys": {"key": "properties.previousKeys", "type": "[KeyForDiskEncryptionSet]"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "rotation_to_latest_key_version_enabled": { - "key": "properties.rotationToLatestKeyVersionEnabled", - "type": "bool", - }, - "last_key_rotation_timestamp": {"key": "properties.lastKeyRotationTimestamp", "type": "iso-8601"}, - "auto_key_rotation_error": {"key": "properties.autoKeyRotationError", "type": "ApiError"}, - "federated_client_id": {"key": "properties.federatedClientId", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, - active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, - rotation_to_latest_key_version_enabled: Optional[bool] = None, - federated_client_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2023_04_02.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values - are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and - "ConfidentialVmEncryptedWithCustomerKey". - :paramtype encryption_type: str or ~azure.mgmt.compute.v2023_04_02.models.DiskEncryptionSetType - :keyword active_key: The key vault key which is currently used by this disk encryption set. - :paramtype active_key: ~azure.mgmt.compute.v2023_04_02.models.KeyForDiskEncryptionSet - :keyword rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating - of this disk encryption set to the latest key version. - :paramtype rotation_to_latest_key_version_enabled: bool - :keyword federated_client_id: Multi-tenant application client id to access key vault in a - different tenant. Setting the value to 'None' will clear the property. - :paramtype federated_client_id: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.identity = identity - self.encryption_type = encryption_type - self.active_key = active_key - self.previous_keys: Optional[List["_models.KeyForDiskEncryptionSet"]] = None - self.provisioning_state: Optional[str] = None - self.rotation_to_latest_key_version_enabled = rotation_to_latest_key_version_enabled - self.last_key_rotation_timestamp: Optional[datetime.datetime] = None - self.auto_key_rotation_error: Optional["_models.ApiError"] = None - self.federated_client_id = federated_client_id - - -class DiskEncryptionSetList(_serialization.Model): - """The List disk encryption set operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of disk encryption sets. Required. - :vartype value: list[~azure.mgmt.compute.v2023_04_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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DiskEncryptionSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DiskEncryptionSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of disk encryption sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2023_04_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DiskEncryptionSetUpdate(_serialization.Model): - """disk encryption set update resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, 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.v2023_04_02.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and - "ConfidentialVmEncryptedWithCustomerKey". - :vartype encryption_type: str or ~azure.mgmt.compute.v2023_04_02.models.DiskEncryptionSetType - :ivar active_key: Key Vault Key Url to be used for server side encryption of Managed Disks and - Snapshots. - :vartype active_key: ~azure.mgmt.compute.v2023_04_02.models.KeyForDiskEncryptionSet - :ivar rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating of - this disk encryption set to the latest key version. - :vartype rotation_to_latest_key_version_enabled: bool - :ivar federated_client_id: Multi-tenant application client id to access key vault in a - different tenant. Setting the value to 'None' will clear the property. - :vartype federated_client_id: str - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "identity": {"key": "identity", "type": "EncryptionSetIdentity"}, - "encryption_type": {"key": "properties.encryptionType", "type": "str"}, - "active_key": {"key": "properties.activeKey", "type": "KeyForDiskEncryptionSet"}, - "rotation_to_latest_key_version_enabled": { - "key": "properties.rotationToLatestKeyVersionEnabled", - "type": "bool", - }, - "federated_client_id": {"key": "properties.federatedClientId", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, - active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, - rotation_to_latest_key_version_enabled: Optional[bool] = None, - federated_client_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2023_04_02.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values - are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and - "ConfidentialVmEncryptedWithCustomerKey". - :paramtype encryption_type: str or ~azure.mgmt.compute.v2023_04_02.models.DiskEncryptionSetType - :keyword active_key: Key Vault Key Url to be used for server side encryption of Managed Disks - and Snapshots. - :paramtype active_key: ~azure.mgmt.compute.v2023_04_02.models.KeyForDiskEncryptionSet - :keyword rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating - of this disk encryption set to the latest key version. - :paramtype rotation_to_latest_key_version_enabled: bool - :keyword federated_client_id: Multi-tenant application client id to access key vault in a - different tenant. Setting the value to 'None' will clear the property. - :paramtype federated_client_id: str - """ - super().__init__(**kwargs) - self.tags = tags - self.identity = identity - self.encryption_type = encryption_type - self.active_key = active_key - self.rotation_to_latest_key_version_enabled = rotation_to_latest_key_version_enabled - self.federated_client_id = federated_client_id - - -class DiskList(_serialization.Model): - """The List Disks operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of disks. Required. - :vartype value: list[~azure.mgmt.compute.v2023_04_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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Disk]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of disks. Required. - :paramtype value: list[~azure.mgmt.compute.v2023_04_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ProxyOnlyResource(_serialization.Model): - """The ProxyOnly Resource model definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - - -class DiskRestorePoint(ProxyOnlyResource): - """Properties of disk restore point. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :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. - :vartype source_resource_id: str - :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2023_04_02.models.OperatingSystemTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2023_04_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.v2023_04_02.models.PurchasePlan - :ivar supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :vartype supported_capabilities: ~azure.mgmt.compute.v2023_04_02.models.SupportedCapabilities - :ivar family_id: id of the backing snapshot's MIS family. - :vartype family_id: str - :ivar source_unique_id: unique incarnation id of the source disk. - :vartype source_unique_id: str - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2023_04_02.models.Encryption - :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. - :vartype supports_hibernation: bool - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2023_04_02.models.NetworkAccessPolicy - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2023_04_02.models.PublicNetworkAccess - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar completion_percent: Percentage complete for the background copy of disk restore point - when source resource is from a different region. - :vartype completion_percent: float - :ivar replication_state: Replication state of disk restore point when source resource is from a - different region. - :vartype replication_state: str - :ivar source_resource_location: Location of source disk or source disk restore point when - source resource is from a different region. - :vartype source_resource_location: str - :ivar security_profile: Contains the security related information for the resource. - :vartype security_profile: ~azure.mgmt.compute.v2023_04_02.models.DiskSecurityProfile - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "time_created": {"readonly": True}, - "source_resource_id": {"readonly": True}, - "os_type": {"readonly": True}, - "family_id": {"readonly": True}, - "source_unique_id": {"readonly": True}, - "encryption": {"readonly": True}, - "replication_state": {"readonly": True}, - "source_resource_location": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "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"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - "family_id": {"key": "properties.familyId", "type": "str"}, - "source_unique_id": {"key": "properties.sourceUniqueId", "type": "str"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - "completion_percent": {"key": "properties.completionPercent", "type": "float"}, - "replication_state": {"key": "properties.replicationState", "type": "str"}, - "source_resource_location": {"key": "properties.sourceResourceLocation", "type": "str"}, - "security_profile": {"key": "properties.securityProfile", "type": "DiskSecurityProfile"}, - } - - def __init__( - self, - *, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - purchase_plan: Optional["_models.PurchasePlan"] = None, - supported_capabilities: Optional["_models.SupportedCapabilities"] = None, - supports_hibernation: Optional[bool] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - disk_access_id: Optional[str] = None, - completion_percent: Optional[float] = None, - security_profile: Optional["_models.DiskSecurityProfile"] = None, - **kwargs: Any - ) -> None: - """ - :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_04_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.v2023_04_02.models.PurchasePlan - :keyword supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :paramtype supported_capabilities: ~azure.mgmt.compute.v2023_04_02.models.SupportedCapabilities - :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. - :paramtype supports_hibernation: bool - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2023_04_02.models.NetworkAccessPolicy - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2023_04_02.models.PublicNetworkAccess - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword completion_percent: Percentage complete for the background copy of disk restore point - when source resource is from a different region. - :paramtype completion_percent: float - :keyword security_profile: Contains the security related information for the resource. - :paramtype security_profile: ~azure.mgmt.compute.v2023_04_02.models.DiskSecurityProfile - """ - super().__init__(**kwargs) - self.time_created: Optional[datetime.datetime] = None - self.source_resource_id: Optional[str] = None - self.os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None - self.hyper_v_generation = hyper_v_generation - self.purchase_plan = purchase_plan - self.supported_capabilities = supported_capabilities - self.family_id: Optional[str] = None - self.source_unique_id: Optional[str] = None - self.encryption: Optional["_models.Encryption"] = None - self.supports_hibernation = supports_hibernation - self.network_access_policy = network_access_policy - self.public_network_access = public_network_access - self.disk_access_id = disk_access_id - self.completion_percent = completion_percent - self.replication_state: Optional[str] = None - self.source_resource_location: Optional[str] = None - self.security_profile = security_profile - - -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.v2023_04_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.v2023_04_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. - - :ivar security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. Known - values are: "TrustedLaunch", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", - "ConfidentialVM_DiskEncryptedWithPlatformKey", and - "ConfidentialVM_DiskEncryptedWithCustomerKey". - :vartype security_type: str or ~azure.mgmt.compute.v2023_04_02.models.DiskSecurityTypes - :ivar secure_vm_disk_encryption_set_id: ResourceId of the disk encryption set associated to - Confidential VM supported disk encrypted with customer managed key. - :vartype secure_vm_disk_encryption_set_id: str - """ - - _attribute_map = { - "security_type": {"key": "securityType", "type": "str"}, - "secure_vm_disk_encryption_set_id": {"key": "secureVMDiskEncryptionSetId", "type": "str"}, - } - - def __init__( - self, - *, - security_type: Optional[Union[str, "_models.DiskSecurityTypes"]] = None, - secure_vm_disk_encryption_set_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. - Known values are: "TrustedLaunch", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", - "ConfidentialVM_DiskEncryptedWithPlatformKey", and - "ConfidentialVM_DiskEncryptedWithCustomerKey". - :paramtype security_type: str or ~azure.mgmt.compute.v2023_04_02.models.DiskSecurityTypes - :keyword secure_vm_disk_encryption_set_id: ResourceId of the disk encryption set associated to - Confidential VM supported disk encrypted with customer managed key. - :paramtype secure_vm_disk_encryption_set_id: str - """ - super().__init__(**kwargs) - self.security_type = security_type - self.secure_vm_disk_encryption_set_id = secure_vm_disk_encryption_set_id - - -class DiskSku(_serialization.Model): - """The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, - Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", - "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", and "PremiumV2_LRS". - :vartype name: str or ~azure.mgmt.compute.v2023_04_02.models.DiskStorageAccountTypes - :ivar tier: The sku tier. - :vartype tier: str - """ - - _validation = { - "tier": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__(self, *, name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs: Any) -> None: - """ - :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", and "PremiumV2_LRS". - :paramtype name: str or ~azure.mgmt.compute.v2023_04_02.models.DiskStorageAccountTypes - """ - super().__init__(**kwargs) - self.name = name - self.tier: Optional[str] = None - - -class DiskUpdate(_serialization.Model): - """Disk update resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, - Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS. - :vartype sku: ~azure.mgmt.compute.v2023_04_02.models.DiskSku - :ivar os_type: the Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2023_04_02.models.OperatingSystemTypes - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2023_04_02.models.EncryptionSettingsCollection - :ivar disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :vartype disk_m_bps_read_write: int - :ivar disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_only: int - :ivar disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :vartype disk_m_bps_read_only: int - :ivar max_shares: The maximum number of VMs that can attach to the disk at the same time. Value - greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :vartype max_shares: int - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2023_04_02.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2023_04_02.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar tier: Performance tier of the disk (e.g, P4, S10) as described here: - https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra - disks. - :vartype tier: str - :ivar bursting_enabled: Set to true to enable bursting beyond the provisioned performance - 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.v2023_04_02.models.PurchasePlan - :ivar supported_capabilities: List of supported capabilities to be added on the OS disk. - :vartype supported_capabilities: ~azure.mgmt.compute.v2023_04_02.models.SupportedCapabilities - :ivar property_updates_in_progress: Properties of the disk for which update is pending. - :vartype property_updates_in_progress: - ~azure.mgmt.compute.v2023_04_02.models.PropertyUpdatesInProgress - :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. - :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2023_04_02.models.PublicNetworkAccess - :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :vartype data_access_auth_mode: str or - ~azure.mgmt.compute.v2023_04_02.models.DataAccessAuthMode - :ivar optimized_for_frequent_attach: Setting this property to true improves reliability and - performance of data disks that are frequently (more than 5 times a day) by detached from one - virtual machine and attached to another. This property should not be set for disks that are not - detached and attached frequently as it causes the disks to not align with the fault domain of - the virtual machine. - :vartype optimized_for_frequent_attach: bool - """ - - _validation = { - "property_updates_in_progress": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "DiskSku"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "disk_iops_read_write": {"key": "properties.diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "properties.diskMBpsReadWrite", "type": "int"}, - "disk_iops_read_only": {"key": "properties.diskIOPSReadOnly", "type": "int"}, - "disk_m_bps_read_only": {"key": "properties.diskMBpsReadOnly", "type": "int"}, - "max_shares": {"key": "properties.maxShares", "type": "int"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "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"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - "property_updates_in_progress": { - "key": "properties.propertyUpdatesInProgress", - "type": "PropertyUpdatesInProgress", - }, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, - "optimized_for_frequent_attach": {"key": "properties.optimizedForFrequentAttach", "type": "bool"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.DiskSku"] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - disk_iops_read_write: Optional[int] = None, - disk_m_bps_read_write: Optional[int] = None, - disk_iops_read_only: Optional[int] = None, - disk_m_bps_read_only: Optional[int] = None, - max_shares: Optional[int] = None, - encryption: Optional["_models.Encryption"] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - tier: Optional[str] = None, - bursting_enabled: Optional[bool] = None, - purchase_plan: Optional["_models.PurchasePlan"] = None, - supported_capabilities: Optional["_models.SupportedCapabilities"] = None, - supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, - optimized_for_frequent_attach: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2023_04_02.models.DiskSku - :keyword os_type: the Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2023_04_02.models.OperatingSystemTypes - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2023_04_02.models.EncryptionSettingsCollection - :keyword disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_write: int - :keyword disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :paramtype disk_m_bps_read_write: int - :keyword disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_only: int - :keyword disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :paramtype disk_m_bps_read_only: int - :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. - Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :paramtype max_shares: int - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2023_04_02.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2023_04_02.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword tier: Performance tier of the disk (e.g, P4, S10) as described here: - https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra - disks. - :paramtype tier: str - :keyword bursting_enabled: Set to true to enable bursting beyond the provisioned performance - 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.v2023_04_02.models.PurchasePlan - :keyword supported_capabilities: List of supported capabilities to be added on the OS disk. - :paramtype supported_capabilities: ~azure.mgmt.compute.v2023_04_02.models.SupportedCapabilities - :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. - :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2023_04_02.models.PublicNetworkAccess - :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :paramtype data_access_auth_mode: str or - ~azure.mgmt.compute.v2023_04_02.models.DataAccessAuthMode - :keyword optimized_for_frequent_attach: Setting this property to true improves reliability and - performance of data disks that are frequently (more than 5 times a day) by detached from one - virtual machine and attached to another. This property should not be set for disks that are not - detached and attached frequently as it causes the disks to not align with the fault domain of - the virtual machine. - :paramtype optimized_for_frequent_attach: bool - """ - super().__init__(**kwargs) - self.tags = tags - self.sku = sku - self.os_type = os_type - self.disk_size_gb = disk_size_gb - self.encryption_settings_collection = encryption_settings_collection - self.disk_iops_read_write = disk_iops_read_write - self.disk_m_bps_read_write = disk_m_bps_read_write - self.disk_iops_read_only = disk_iops_read_only - self.disk_m_bps_read_only = disk_m_bps_read_only - self.max_shares = max_shares - self.encryption = encryption - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - self.tier = tier - self.bursting_enabled = bursting_enabled - self.purchase_plan = purchase_plan - self.supported_capabilities = supported_capabilities - self.property_updates_in_progress: Optional["_models.PropertyUpdatesInProgress"] = None - self.supports_hibernation = supports_hibernation - self.public_network_access = public_network_access - self.data_access_auth_mode = data_access_auth_mode - self.optimized_for_frequent_attach = optimized_for_frequent_attach - - -class Encryption(_serialization.Model): - """Encryption at rest settings for disk or snapshot. - - :ivar disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling - encryption at rest. - :vartype disk_encryption_set_id: str - :ivar type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and - "EncryptionAtRestWithPlatformAndCustomerKeys". - :vartype type: str or ~azure.mgmt.compute.v2023_04_02.models.EncryptionType - """ - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - disk_encryption_set_id: Optional[str] = None, - type: Optional[Union[str, "_models.EncryptionType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling - encryption at rest. - :paramtype disk_encryption_set_id: str - :keyword type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and - "EncryptionAtRestWithPlatformAndCustomerKeys". - :paramtype type: str or ~azure.mgmt.compute.v2023_04_02.models.EncryptionType - """ - super().__init__(**kwargs) - self.disk_encryption_set_id = disk_encryption_set_id - self.type = type - - -class EncryptionSetIdentity(_serialization.Model): - """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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is - supported for new creations. Disk Encryption Sets can be updated with Identity type None during - migration of subscription to a new Azure Active Directory tenant; it will cause the encrypted - resources to lose access to the keys. Known values are: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", and "None". - :vartype type: str or ~azure.mgmt.compute.v2023_04_02.models.DiskEncryptionSetIdentityType - :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-client-tenant-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype tenant_id: str - :ivar user_assigned_identities: The list of user identities associated with the disk encryption - set. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2023_04_02.models.UserAssignedIdentitiesValue] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentitiesValue}"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.DiskEncryptionSetIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned - is supported for new creations. Disk Encryption Sets can be updated with Identity type None - during migration of subscription to a new Azure Active Directory tenant; it will cause the - encrypted resources to lose access to the keys. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :paramtype type: str or ~azure.mgmt.compute.v2023_04_02.models.DiskEncryptionSetIdentityType - :keyword user_assigned_identities: The list of user identities associated with the disk - encryption set. The user identity dictionary key references will be ARM resource ids in the - form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2023_04_02.models.UserAssignedIdentitiesValue] - """ - super().__init__(**kwargs) - self.type = type - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.user_assigned_identities = user_assigned_identities - - -class EncryptionSettingsCollection(_serialization.Model): - """Encryption settings for disk or snapshot. - - All required parameters must be populated in order to send to server. - - :ivar enabled: Set this flag to true and provide DiskEncryptionKey and optional - KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and - KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, - the existing settings remain unchanged. Required. - :vartype enabled: bool - :ivar encryption_settings: A collection of encryption settings, one for each disk volume. - :vartype encryption_settings: - list[~azure.mgmt.compute.v2023_04_02.models.EncryptionSettingsElement] - :ivar encryption_settings_version: Describes what type of encryption is used for the disks. - Once this field is set, it cannot be overwritten. '1.0' corresponds to Azure Disk Encryption - with AAD app.'1.1' corresponds to Azure Disk Encryption. - :vartype encryption_settings_version: str - """ - - _validation = { - "enabled": {"required": True}, - } - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "encryption_settings": {"key": "encryptionSettings", "type": "[EncryptionSettingsElement]"}, - "encryption_settings_version": {"key": "encryptionSettingsVersion", "type": "str"}, - } - - def __init__( - self, - *, - enabled: bool, - encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, - encryption_settings_version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Set this flag to true and provide DiskEncryptionKey and optional - KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and - KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, - the existing settings remain unchanged. Required. - :paramtype enabled: bool - :keyword encryption_settings: A collection of encryption settings, one for each disk volume. - :paramtype encryption_settings: - list[~azure.mgmt.compute.v2023_04_02.models.EncryptionSettingsElement] - :keyword encryption_settings_version: Describes what type of encryption is used for the disks. - Once this field is set, it cannot be overwritten. '1.0' corresponds to Azure Disk Encryption - with AAD app.'1.1' corresponds to Azure Disk Encryption. - :paramtype encryption_settings_version: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.encryption_settings = encryption_settings - self.encryption_settings_version = encryption_settings_version - - -class EncryptionSettingsElement(_serialization.Model): - """Encryption settings for one disk volume. - - :ivar disk_encryption_key: Key Vault Secret Url and vault id of the disk encryption key. - :vartype disk_encryption_key: ~azure.mgmt.compute.v2023_04_02.models.KeyVaultAndSecretReference - :ivar key_encryption_key: Key Vault Key Url and vault id of the key encryption key. - KeyEncryptionKey is optional and when provided is used to unwrap the disk encryption key. - :vartype key_encryption_key: ~azure.mgmt.compute.v2023_04_02.models.KeyVaultAndKeyReference - """ - - _attribute_map = { - "disk_encryption_key": {"key": "diskEncryptionKey", "type": "KeyVaultAndSecretReference"}, - "key_encryption_key": {"key": "keyEncryptionKey", "type": "KeyVaultAndKeyReference"}, - } - - def __init__( - self, - *, - disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_key: Key Vault Secret Url and vault id of the disk encryption key. - :paramtype disk_encryption_key: - ~azure.mgmt.compute.v2023_04_02.models.KeyVaultAndSecretReference - :keyword key_encryption_key: Key Vault Key Url and vault id of the key encryption key. - KeyEncryptionKey is optional and when provided is used to unwrap the disk encryption key. - :paramtype key_encryption_key: ~azure.mgmt.compute.v2023_04_02.models.KeyVaultAndKeyReference - """ - super().__init__(**kwargs) - self.disk_encryption_key = disk_encryption_key - self.key_encryption_key = key_encryption_key - - -class ExtendedLocation(_serialization.Model): - """The complex type of the extended location. - - :ivar name: The name of the extended location. - :vartype name: str - :ivar type: The type of the extended location. "EdgeZone" - :vartype type: str or ~azure.mgmt.compute.v2023_04_02.models.ExtendedLocationTypes - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the extended location. - :paramtype name: str - :keyword type: The type of the extended location. "EdgeZone" - :paramtype type: str or ~azure.mgmt.compute.v2023_04_02.models.ExtendedLocationTypes - """ - super().__init__(**kwargs) - self.name = name - self.type = type - - -class GrantAccessData(_serialization.Model): - """Data used for requesting a SAS. - - All required parameters must be populated in order to send to server. - - :ivar access: Required. Known values are: "None", "Read", and "Write". - :vartype access: str or ~azure.mgmt.compute.v2023_04_02.models.AccessLevel - :ivar duration_in_seconds: Time duration in seconds until the SAS access expires. Required. - :vartype duration_in_seconds: int - :ivar get_secure_vm_guest_state_sas: Set this flag to true to get additional SAS for VM guest - state. - :vartype get_secure_vm_guest_state_sas: bool - :ivar file_format: Used to specify the file format when making request for SAS on a VHDX file - format snapshot. Known values are: "VHD" and "VHDX". - :vartype file_format: str or ~azure.mgmt.compute.v2023_04_02.models.FileFormat - """ - - _validation = { - "access": {"required": True}, - "duration_in_seconds": {"required": True}, - } - - _attribute_map = { - "access": {"key": "access", "type": "str"}, - "duration_in_seconds": {"key": "durationInSeconds", "type": "int"}, - "get_secure_vm_guest_state_sas": {"key": "getSecureVMGuestStateSAS", "type": "bool"}, - "file_format": {"key": "fileFormat", "type": "str"}, - } - - def __init__( - self, - *, - access: Union[str, "_models.AccessLevel"], - duration_in_seconds: int, - get_secure_vm_guest_state_sas: Optional[bool] = None, - file_format: Optional[Union[str, "_models.FileFormat"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword access: Required. Known values are: "None", "Read", and "Write". - :paramtype access: str or ~azure.mgmt.compute.v2023_04_02.models.AccessLevel - :keyword duration_in_seconds: Time duration in seconds until the SAS access expires. Required. - :paramtype duration_in_seconds: int - :keyword get_secure_vm_guest_state_sas: Set this flag to true to get additional SAS for VM - guest state. - :paramtype get_secure_vm_guest_state_sas: bool - :keyword file_format: Used to specify the file format when making request for SAS on a VHDX - file format snapshot. Known values are: "VHD" and "VHDX". - :paramtype file_format: str or ~azure.mgmt.compute.v2023_04_02.models.FileFormat - """ - super().__init__(**kwargs) - self.access = access - self.duration_in_seconds = duration_in_seconds - self.get_secure_vm_guest_state_sas = get_secure_vm_guest_state_sas - self.file_format = file_format - - -class ImageDiskReference(_serialization.Model): - """The source image used for creating the disk. - - :ivar id: A relative uri containing either a Platform Image Repository, user image, or Azure - Compute Gallery image reference. - :vartype id: str - :ivar shared_gallery_image_id: A relative uri containing a direct shared Azure Compute Gallery - image reference. - :vartype shared_gallery_image_id: str - :ivar community_gallery_image_id: A relative uri containing a community Azure Compute Gallery - image reference. - :vartype community_gallery_image_id: str - :ivar lun: If the disk is created from an image's data disk, this is an index that indicates - which of the data disks in the image to use. For OS disks, this field is null. - :vartype lun: int - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "shared_gallery_image_id": {"key": "sharedGalleryImageId", "type": "str"}, - "community_gallery_image_id": {"key": "communityGalleryImageId", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - shared_gallery_image_id: Optional[str] = None, - community_gallery_image_id: Optional[str] = None, - lun: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: A relative uri containing either a Platform Image Repository, user image, or Azure - Compute Gallery image reference. - :paramtype id: str - :keyword shared_gallery_image_id: A relative uri containing a direct shared Azure Compute - Gallery image reference. - :paramtype shared_gallery_image_id: str - :keyword community_gallery_image_id: A relative uri containing a community Azure Compute - Gallery image reference. - :paramtype community_gallery_image_id: str - :keyword lun: If the disk is created from an image's data disk, this is an index that indicates - which of the data disks in the image to use. For OS disks, this field is null. - :paramtype lun: int - """ - super().__init__(**kwargs) - self.id = id - self.shared_gallery_image_id = shared_gallery_image_id - self.community_gallery_image_id = community_gallery_image_id - self.lun = lun - - -class InnerError(_serialization.Model): - """Inner error details. - - :ivar exceptiontype: The exception type. - :vartype exceptiontype: str - :ivar errordetail: The internal error message or exception dump. - :vartype errordetail: str - """ - - _attribute_map = { - "exceptiontype": {"key": "exceptiontype", "type": "str"}, - "errordetail": {"key": "errordetail", "type": "str"}, - } - - def __init__( - self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword exceptiontype: The exception type. - :paramtype exceptiontype: str - :keyword errordetail: The internal error message or exception dump. - :paramtype errordetail: str - """ - super().__init__(**kwargs) - self.exceptiontype = exceptiontype - self.errordetail = errordetail - - -class KeyForDiskEncryptionSet(_serialization.Model): - """Key Vault Key Url to be used for server side encryption of Managed Disks and Snapshots. - - All required parameters must be populated in order to send to server. - - :ivar source_vault: Resource id of the KeyVault containing the key or secret. This property is - optional and cannot be used if the KeyVault subscription is not the same as the Disk Encryption - Set subscription. - :vartype source_vault: ~azure.mgmt.compute.v2023_04_02.models.SourceVault - :ivar key_url: Fully versioned Key Url pointing to a key in KeyVault. Version segment of the - Url is required regardless of rotationToLatestKeyVersionEnabled value. Required. - :vartype key_url: str - """ - - _validation = { - "key_url": {"required": True}, - } - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SourceVault"}, - "key_url": {"key": "keyUrl", "type": "str"}, - } - - def __init__(self, *, key_url: str, source_vault: Optional["_models.SourceVault"] = None, **kwargs: Any) -> None: - """ - :keyword source_vault: Resource id of the KeyVault containing the key or secret. This property - is optional and cannot be used if the KeyVault subscription is not the same as the Disk - Encryption Set subscription. - :paramtype source_vault: ~azure.mgmt.compute.v2023_04_02.models.SourceVault - :keyword key_url: Fully versioned Key Url pointing to a key in KeyVault. Version segment of the - Url is required regardless of rotationToLatestKeyVersionEnabled value. Required. - :paramtype key_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.key_url = key_url - - -class KeyVaultAndKeyReference(_serialization.Model): - """Key Vault Key Url and vault id of KeK, KeK is optional and when provided is used to unwrap the - encryptionKey. - - All required parameters must be populated in order to send to server. - - :ivar source_vault: Resource id of the KeyVault containing the key or secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2023_04_02.models.SourceVault - :ivar key_url: Url pointing to a key or secret in KeyVault. Required. - :vartype key_url: str - """ - - _validation = { - "source_vault": {"required": True}, - "key_url": {"required": True}, - } - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SourceVault"}, - "key_url": {"key": "keyUrl", "type": "str"}, - } - - def __init__(self, *, source_vault: "_models.SourceVault", key_url: str, **kwargs: Any) -> None: - """ - :keyword source_vault: Resource id of the KeyVault containing the key or secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2023_04_02.models.SourceVault - :keyword key_url: Url pointing to a key or secret in KeyVault. Required. - :paramtype key_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.key_url = key_url - - -class KeyVaultAndSecretReference(_serialization.Model): - """Key Vault Secret Url and vault id of the encryption key. - - All required parameters must be populated in order to send to server. - - :ivar source_vault: Resource id of the KeyVault containing the key or secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2023_04_02.models.SourceVault - :ivar secret_url: Url pointing to a key or secret in KeyVault. Required. - :vartype secret_url: str - """ - - _validation = { - "source_vault": {"required": True}, - "secret_url": {"required": True}, - } - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SourceVault"}, - "secret_url": {"key": "secretUrl", "type": "str"}, - } - - def __init__(self, *, source_vault: "_models.SourceVault", secret_url: str, **kwargs: Any) -> None: - """ - :keyword source_vault: Resource id of the KeyVault containing the key or secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2023_04_02.models.SourceVault - :keyword secret_url: Url pointing to a key or secret in KeyVault. Required. - :paramtype secret_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.secret_url = secret_url - - -class PrivateEndpoint(_serialization.Model): - """The Private Endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ARM identifier for Private Endpoint. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class PrivateEndpointConnection(_serialization.Model): - """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. - :vartype id: str - :ivar name: private endpoint connection name. - :vartype name: str - :ivar type: private endpoint connection type. - :vartype type: str - :ivar private_endpoint: The resource of private end point. - :vartype private_endpoint: ~azure.mgmt.compute.v2023_04_02.models.PrivateEndpoint - :ivar private_link_service_connection_state: A collection of information about the state of the - connection between DiskAccess and Virtual Network. - :vartype private_link_service_connection_state: - ~azure.mgmt.compute.v2023_04_02.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2023_04_02.models.PrivateEndpointConnectionProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "private_endpoint": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionState", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_link_service_connection_state: A collection of information about the state of - the connection between DiskAccess and Virtual Network. - :paramtype private_link_service_connection_state: - ~azure.mgmt.compute.v2023_04_02.models.PrivateLinkServiceConnectionState - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.private_endpoint: Optional["_models.PrivateEndpoint"] = None - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = None - - -class PrivateEndpointConnectionListResult(_serialization.Model): - """A list of private link resources. - - :ivar value: Array of private endpoint connections. - :vartype value: list[~azure.mgmt.compute.v2023_04_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. - :vartype next_link: str - """ - - _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 - ) -> None: - """ - :keyword value: Array of private endpoint connections. - :paramtype value: list[~azure.mgmt.compute.v2023_04_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class PrivateLinkResource(_serialization.Model): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: private link resource Id. - :vartype id: str - :ivar name: private link resource name. - :vartype name: str - :ivar type: private link resource type. - :vartype type: str - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - :ivar required_zone_names: The private link resource DNS zone name. - :vartype required_zone_names: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "group_id": {"readonly": True}, - "required_members": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "group_id": {"key": "properties.groupId", "type": "str"}, - "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, - } - - def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword required_zone_names: The private link resource DNS zone name. - :paramtype required_zone_names: list[str] - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.group_id: Optional[str] = None - self.required_members: Optional[List[str]] = None - self.required_zone_names = required_zone_names - - -class PrivateLinkResourceListResult(_serialization.Model): - """A list of private link resources. - - :ivar value: Array of private link resources. - :vartype value: list[~azure.mgmt.compute.v2023_04_02.models.PrivateLinkResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateLinkResource]"}, - } - - def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Array of private link resources. - :paramtype value: list[~azure.mgmt.compute.v2023_04_02.models.PrivateLinkResource] - """ - super().__init__(**kwargs) - self.value = value - - -class PrivateLinkServiceConnectionState(_serialization.Model): - """A collection of information about the state of the connection between service consumer and - provider. - - :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", and "Rejected". - :vartype status: str or - ~azure.mgmt.compute.v2023_04_02.models.PrivateEndpointServiceConnectionStatus - :ivar description: The reason for approval/rejection of the connection. - :vartype description: str - :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :vartype actions_required: str - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", and "Rejected". - :paramtype status: str or - ~azure.mgmt.compute.v2023_04_02.models.PrivateEndpointServiceConnectionStatus - :keyword description: The reason for approval/rejection of the connection. - :paramtype description: str - :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :paramtype actions_required: str - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required = actions_required - - -class PropertyUpdatesInProgress(_serialization.Model): - """Properties of the disk for which update is pending. - - :ivar target_tier: The target performance tier of the disk if a tier change operation is in - progress. - :vartype target_tier: str - """ - - _attribute_map = { - "target_tier": {"key": "targetTier", "type": "str"}, - } - - def __init__(self, *, target_tier: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword target_tier: The target performance tier of the disk if a tier change operation is in - progress. - :paramtype target_tier: str - """ - super().__init__(**kwargs) - self.target_tier = target_tier - - -class PurchasePlan(_serialization.Model): - """Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. - - All required parameters must be populated in order to send to server. - - :ivar name: The plan ID. Required. - :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 - """ - - _validation = { - "name": {"required": True}, - "publisher": {"required": True}, - "product": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - "promotion_code": {"key": "promotionCode", "type": "str"}, - } - - 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.name = name - self.publisher = publisher - self.product = product - self.promotion_code = promotion_code - - -class ResourceUriList(_serialization.Model): - """The List resources which are encrypted with the disk encryption set. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of IDs or Owner IDs of resources which are encrypted with the disk - encryption set. Required. - :vartype value: list[str] - :ivar next_link: The uri to fetch the next page of encrypted resources. Call ListNext() with - this to fetch the next page of encrypted resources. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[str]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List[str], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of IDs or Owner IDs of resources which are encrypted with the disk - encryption set. Required. - :paramtype value: list[str] - :keyword next_link: The uri to fetch the next page of encrypted resources. Call ListNext() with - this to fetch the next page of encrypted resources. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ResourceWithOptionalLocation(_serialization.Model): - """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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.tags = tags - - -class ShareInfoElement(_serialization.Model): - """ShareInfoElement. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar vm_uri: A relative URI containing the ID of the VM that has the disk attached. - :vartype vm_uri: str - """ - - _validation = { - "vm_uri": {"readonly": True}, - } - - _attribute_map = { - "vm_uri": {"key": "vmUri", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.vm_uri: Optional[str] = None - - -class Snapshot(Resource): - """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. - :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] - :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 - an optional parameter for incremental snapshot and the default behavior is the SKU will be set - to the same sku as the previous snapshot. - :vartype sku: ~azure.mgmt.compute.v2023_04_02.models.SnapshotSku - :ivar extended_location: The extended location where the snapshot will be created. Extended - location cannot be changed. - :vartype extended_location: ~azure.mgmt.compute.v2023_04_02.models.ExtendedLocation - :ivar time_created: The time when the snapshot was created. - :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2023_04_02.models.OperatingSystemTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2023_04_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.v2023_04_02.models.PurchasePlan - :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.v2023_04_02.models.SupportedCapabilities - :ivar creation_data: Disk source information. CreationData information cannot be changed after - the disk has been created. - :vartype creation_data: ~azure.mgmt.compute.v2023_04_02.models.CreationData - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. - :vartype disk_size_bytes: int - :ivar disk_state: The state of the snapshot. Known values are: "Unattached", "Attached", - "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", and "ActiveUpload". - :vartype disk_state: str or ~azure.mgmt.compute.v2023_04_02.models.DiskState - :ivar unique_id: Unique Guid identifying the resource. - :vartype unique_id: str - :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2023_04_02.models.EncryptionSettingsCollection - :ivar provisioning_state: The disk provisioning state. - :vartype provisioning_state: str - :ivar incremental: Whether a snapshot is incremental. Incremental snapshots on the same disk - occupy less space than full snapshots and can be diffed. - :vartype incremental: bool - :ivar incremental_snapshot_family_id: Incremental snapshots for a disk share an incremental - snapshot family id. The Get Page Range Diff API can only be called on incremental snapshots - with the same family id. - :vartype incremental_snapshot_family_id: str - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2023_04_02.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2023_04_02.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar security_profile: Contains the security related information for the resource. - :vartype security_profile: ~azure.mgmt.compute.v2023_04_02.models.DiskSecurityProfile - :ivar supports_hibernation: Indicates the OS on a snapshot supports hibernation. - :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2023_04_02.models.PublicNetworkAccess - :ivar completion_percent: Percentage complete for the background copy when a resource is - created via the CopyStart operation. - :vartype completion_percent: float - :ivar copy_completion_error: Indicates the error details if the background copy of a resource - created via the CopyStart operation fails. - :vartype copy_completion_error: ~azure.mgmt.compute.v2023_04_02.models.CopyCompletionError - :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :vartype data_access_auth_mode: str or - ~azure.mgmt.compute.v2023_04_02.models.DataAccessAuthMode - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "managed_by": {"readonly": True}, - "time_created": {"readonly": True}, - "disk_size_bytes": {"readonly": True}, - "disk_state": {"readonly": True}, - "unique_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "incremental_snapshot_family_id": {"readonly": 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}"}, - "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"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - "creation_data": {"key": "properties.creationData", "type": "CreationData"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "disk_size_bytes": {"key": "properties.diskSizeBytes", "type": "int"}, - "disk_state": {"key": "properties.diskState", "type": "str"}, - "unique_id": {"key": "properties.uniqueId", "type": "str"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "incremental": {"key": "properties.incremental", "type": "bool"}, - "incremental_snapshot_family_id": {"key": "properties.incrementalSnapshotFamilyId", "type": "str"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - "security_profile": {"key": "properties.securityProfile", "type": "DiskSecurityProfile"}, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "completion_percent": {"key": "properties.completionPercent", "type": "float"}, - "copy_completion_error": {"key": "properties.copyCompletionError", "type": "CopyCompletionError"}, - "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.SnapshotSku"] = None, - 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, - supported_capabilities: Optional["_models.SupportedCapabilities"] = None, - creation_data: Optional["_models.CreationData"] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - incremental: Optional[bool] = None, - encryption: Optional["_models.Encryption"] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - security_profile: Optional["_models.DiskSecurityProfile"] = None, - supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - completion_percent: Optional[float] = None, - copy_completion_error: Optional["_models.CopyCompletionError"] = None, - data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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. - :paramtype sku: ~azure.mgmt.compute.v2023_04_02.models.SnapshotSku - :keyword extended_location: The extended location where the snapshot will be created. Extended - location cannot be changed. - :paramtype extended_location: ~azure.mgmt.compute.v2023_04_02.models.ExtendedLocation - :keyword os_type: The Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2023_04_02.models.OperatingSystemTypes - :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_04_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.v2023_04_02.models.PurchasePlan - :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.v2023_04_02.models.SupportedCapabilities - :keyword creation_data: Disk source information. CreationData information cannot be changed - after the disk has been created. - :paramtype creation_data: ~azure.mgmt.compute.v2023_04_02.models.CreationData - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2023_04_02.models.EncryptionSettingsCollection - :keyword incremental: Whether a snapshot is incremental. Incremental snapshots on the same disk - occupy less space than full snapshots and can be diffed. - :paramtype incremental: bool - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2023_04_02.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2023_04_02.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword security_profile: Contains the security related information for the resource. - :paramtype security_profile: ~azure.mgmt.compute.v2023_04_02.models.DiskSecurityProfile - :keyword supports_hibernation: Indicates the OS on a snapshot supports hibernation. - :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2023_04_02.models.PublicNetworkAccess - :keyword completion_percent: Percentage complete for the background copy when a resource is - created via the CopyStart operation. - :paramtype completion_percent: float - :keyword copy_completion_error: Indicates the error details if the background copy of a - resource created via the CopyStart operation fails. - :paramtype copy_completion_error: ~azure.mgmt.compute.v2023_04_02.models.CopyCompletionError - :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :paramtype data_access_auth_mode: str or - ~azure.mgmt.compute.v2023_04_02.models.DataAccessAuthMode - """ - super().__init__(location=location, tags=tags, **kwargs) - self.managed_by: Optional[str] = None - self.sku = sku - self.extended_location = extended_location - self.time_created: Optional[datetime.datetime] = None - self.os_type = os_type - self.hyper_v_generation = hyper_v_generation - self.purchase_plan = purchase_plan - self.supported_capabilities = supported_capabilities - self.creation_data = creation_data - self.disk_size_gb = disk_size_gb - self.disk_size_bytes: Optional[int] = None - self.disk_state: Optional[Union[str, "_models.DiskState"]] = None - self.unique_id: Optional[str] = None - self.encryption_settings_collection = encryption_settings_collection - self.provisioning_state: Optional[str] = None - self.incremental = incremental - self.incremental_snapshot_family_id: Optional[str] = None - self.encryption = encryption - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - self.security_profile = security_profile - self.supports_hibernation = supports_hibernation - self.public_network_access = public_network_access - self.completion_percent = completion_percent - self.copy_completion_error = copy_completion_error - self.data_access_auth_mode = data_access_auth_mode - - -class SnapshotList(_serialization.Model): - """The List Snapshots operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of snapshots. Required. - :vartype value: list[~azure.mgmt.compute.v2023_04_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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Snapshot]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of snapshots. Required. - :paramtype value: list[~azure.mgmt.compute.v2023_04_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SnapshotSku(_serialization.Model): - """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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", and "Standard_ZRS". - :vartype name: str or ~azure.mgmt.compute.v2023_04_02.models.SnapshotStorageAccountTypes - :ivar tier: The sku tier. - :vartype tier: str - """ - - _validation = { - "tier": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__( - self, *, name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs: Any - ) -> None: - """ - :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", and - "Standard_ZRS". - :paramtype name: str or ~azure.mgmt.compute.v2023_04_02.models.SnapshotStorageAccountTypes - """ - super().__init__(**kwargs) - self.name = name - self.tier: Optional[str] = None - - -class SnapshotUpdate(_serialization.Model): - """Snapshot update resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar 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. - :vartype sku: ~azure.mgmt.compute.v2023_04_02.models.SnapshotSku - :ivar os_type: the Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2023_04_02.models.OperatingSystemTypes - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2023_04_02.models.EncryptionSettingsCollection - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2023_04_02.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2023_04_02.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar supports_hibernation: Indicates the OS on a snapshot supports hibernation. - :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2023_04_02.models.PublicNetworkAccess - :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :vartype data_access_auth_mode: str or - ~azure.mgmt.compute.v2023_04_02.models.DataAccessAuthMode - :ivar supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :vartype supported_capabilities: ~azure.mgmt.compute.v2023_04_02.models.SupportedCapabilities - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "SnapshotSku"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.SnapshotSku"] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - encryption: Optional["_models.Encryption"] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, - supported_capabilities: Optional["_models.SupportedCapabilities"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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. - :paramtype sku: ~azure.mgmt.compute.v2023_04_02.models.SnapshotSku - :keyword os_type: the Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2023_04_02.models.OperatingSystemTypes - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2023_04_02.models.EncryptionSettingsCollection - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2023_04_02.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2023_04_02.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword supports_hibernation: Indicates the OS on a snapshot supports hibernation. - :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2023_04_02.models.PublicNetworkAccess - :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :paramtype data_access_auth_mode: str or - ~azure.mgmt.compute.v2023_04_02.models.DataAccessAuthMode - :keyword supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :paramtype supported_capabilities: ~azure.mgmt.compute.v2023_04_02.models.SupportedCapabilities - """ - super().__init__(**kwargs) - self.tags = tags - self.sku = sku - self.os_type = os_type - self.disk_size_gb = disk_size_gb - self.encryption_settings_collection = encryption_settings_collection - self.encryption = encryption - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - self.supports_hibernation = supports_hibernation - self.public_network_access = public_network_access - self.data_access_auth_mode = data_access_auth_mode - self.supported_capabilities = supported_capabilities - - -class SourceVault(_serialization.Model): - """The vault id is an Azure Resource Manager Resource id in the form - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class SubResource(_serialization.Model): - """SubResource. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class SubResourceReadOnly(_serialization.Model): - """SubResourceReadOnly. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class SupportedCapabilities(_serialization.Model): - """List of supported capabilities persisted on the disk resource for VM use. - - :ivar disk_controller_types: The disk controllers that an OS disk supports. If set it can be - SCSI or SCSI, NVME or NVME, SCSI. - :vartype disk_controller_types: str - :ivar accelerated_network: True if the image from which the OS disk is created supports - accelerated networking. - :vartype accelerated_network: bool - :ivar architecture: CPU architecture supported by an OS disk. Known values are: "x64" and - "Arm64". - :vartype architecture: str or ~azure.mgmt.compute.v2023_04_02.models.Architecture - """ - - _attribute_map = { - "disk_controller_types": {"key": "diskControllerTypes", "type": "str"}, - "accelerated_network": {"key": "acceleratedNetwork", "type": "bool"}, - "architecture": {"key": "architecture", "type": "str"}, - } - - def __init__( - self, - *, - disk_controller_types: Optional[str] = None, - accelerated_network: Optional[bool] = None, - architecture: Optional[Union[str, "_models.Architecture"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_controller_types: The disk controllers that an OS disk supports. If set it can be - SCSI or SCSI, NVME or NVME, SCSI. - :paramtype disk_controller_types: str - :keyword accelerated_network: True if the image from which the OS disk is created supports - accelerated networking. - :paramtype accelerated_network: bool - :keyword architecture: CPU architecture supported by an OS disk. Known values are: "x64" and - "Arm64". - :paramtype architecture: str or ~azure.mgmt.compute.v2023_04_02.models.Architecture - """ - super().__init__(**kwargs) - self.disk_controller_types = disk_controller_types - self.accelerated_network = accelerated_network - self.architecture = architecture - - -class SystemData(_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. - - :ivar created_at: Specifies the time in UTC at which the Cloud Service (extended support) - resource was created. :code:`
    `Minimum api-version: 2022-04-04. - :vartype created_at: ~datetime.datetime - :ivar last_modified_at: Specifies the time in UTC at which the Cloud Service (extended support) - resource was last modified. :code:`
    `Minimum api-version: 2022-04-04. - :vartype last_modified_at: ~datetime.datetime - """ - - _validation = { - "created_at": {"readonly": True}, - "last_modified_at": {"readonly": True}, - } - - _attribute_map = { - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.created_at: Optional[datetime.datetime] = None - self.last_modified_at: Optional[datetime.datetime] = None - - -class UserAssignedIdentitiesValue(_serialization.Model): - """UserAssignedIdentitiesValue. - - 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: Optional[str] = None - self.client_id: Optional[str] = None diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/operations/__init__.py deleted file mode 100644 index 0e0c2d8aaf8d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/operations/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -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 SnapshotsOperations # 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", - "SnapshotsOperations", -] -__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_04_02/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/operations/_operations.py deleted file mode 100644 index e21a1b0a8ff3..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/operations/_operations.py +++ /dev/null @@ -1,5848 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import ComputeManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_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: - _headers = case_insensitive_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-04-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}", - ) - 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"), - } - - _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_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", "2023-04-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}", - ) - 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"), - } - - _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_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", "2023-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", - ) - 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"), - } - - _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_disks_delete_request( - resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-02")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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", "2023-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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-04-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", - ) - 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"), - } - - _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_disks_revoke_access_request( - resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-02")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> 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-04-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}", - ) - 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"), - } - - _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_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", "2023-04-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", - ) - 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"), - } - - _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) - - -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", "2023-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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", "2023-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateLinkResources", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-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}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - 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" - ), - } - - _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_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", "2023-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - 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" - ), - } - - _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_disk_accesses_delete_a_private_endpoint_connection_request( # pylint: disable=name-too-long - resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - 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" - ), - } - - _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) - - -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", "2023-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections", - ) - 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"), - } - - _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_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", "2023-04-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", - ) - 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"), - } - - _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) - - -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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}/associatedResources", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-02")) - 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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-02")) - 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", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-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", - ) - 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"), - } - - _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_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", "2023-04-02")) - 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", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2023-04-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}", - ) - 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"), - } - - _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_snapshots_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", "2023-04-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}", - ) - 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"), - } - - _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_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", "2023-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", - ) - 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"), - } - - _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_snapshots_delete_request( - resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-02")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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-04-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}/beginGetAccess", - ) - 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"), - } - - _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_snapshots_revoke_access_request( - resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-02")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -class DisksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_04_02.ComputeManagementClient`'s - :attr:`disks` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_name: str, disk: Union[_models.Disk, 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-04-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, (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_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) - - _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_create_or_update( - self, - resource_group_name: str, - disk_name: str, - disk: _models.Disk, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Creates or updates 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 - :param disk: Disk object supplied in the body of the Put disk operation. Required. - :type disk: ~azure.mgmt.compute.v2023_04_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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_04_02.models.Disk] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_name: str, - disk: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Creates or updates 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 - :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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_04_02.models.Disk] - :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. - - :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 - :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.v2023_04_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.v2023_04_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 "2023-04-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._create_or_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, **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 _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, - 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-04-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, (IOBase, bytes)): - _content = disk - else: - _json = self._serialize.body(disk, "DiskUpdate") - - _request = build_disks_update_request( - resource_group_name=resource_group_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) - - _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, - disk_name: str, - disk: _models.DiskUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Updates (patches) a disk. - - :param resource_group_name: The name of the resource group. Required. - :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.v2023_04_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.v2023_04_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. 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.v2023_04_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. 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.v2023_04_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.v2023_04_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 "2023-04-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, **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 - ) - - @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.v2023_04_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 "2023-04-02")) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) - - _request = build_disks_get_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) - - _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("Disk", 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_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-04-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. - :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 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-04-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_name=disk_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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Disk"]: - """Lists all the disks 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 Disk or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_04_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 "2023-04-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 list(self, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2023_04_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 "2023-04-02")) - cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disks_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) - - 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, - 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-04-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disks_grant_access_request( - resource_group_name=resource_group_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) - - _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_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_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.v2023_04_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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_04_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_04_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_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.v2023_04_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.v2023_04_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 "2023-04-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, - disk_name=disk_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, 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-04-02")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disks_revoke_access_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]: - 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_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. - :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 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-04-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._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 - ) - 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 DiskAccessesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_04_02.ComputeManagementClient`'s - :attr:`disk_accesses` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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-04-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access - else: - _json = self._serialize.body(disk_access, "DiskAccess") - - _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) - - _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_create_or_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccess, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Put disk access operation. - Required. - :type disk_access: ~azure.mgmt.compute.v2023_04_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.v2023_04_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2023_04_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Put disk access operation. - Is either a DiskAccess type or a IO[bytes] type. Required. - :type disk_access: ~azure.mgmt.compute.v2023_04_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.v2023_04_02.models.DiskAccess] - :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-04-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) - - 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 - - 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 - ) - - def _update_initial( - 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, - 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-04-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access - else: - _json = self._serialize.body(disk_access, "DiskAccessUpdate") - - _request = build_disk_accesses_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) - - _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, - disk_access_name: str, - disk_access: _models.DiskAccessUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Patch disk access operation. - Required. - :type disk_access: ~azure.mgmt.compute.v2023_04_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 DiskAccess or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_04_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the 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 DiskAccess or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_04_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - 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. - :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.v2023_04_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.v2023_04_02.models.DiskAccess] - :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-04-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._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) - - 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 - - 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 - ) - - @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.v2023_04_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 "2023-04-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]: - 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-04-02")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disk_accesses_delete_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) - - _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_access_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes 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 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-04-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 - - 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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.DiskAccess"]: - """Lists all the disk access resources 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 DiskAccess or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_04_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 "2023-04-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 list(self, **kwargs: Any) -> ItemPaged["_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.v2023_04_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 "2023-04-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 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. - :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.v2023_04_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 "2023-04-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 = 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 - - 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 - ) -> 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-04-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(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 = 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_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 - ) -> 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. - :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.v2023_04_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 PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_04_02.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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 - ) -> 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. - :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 LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_04_02.models.PrivateEndpointConnection] - :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. - - :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.v2023_04_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.v2023_04_02.models.PrivateEndpointConnection] - :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-04-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, 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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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 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.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - 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.v2023_04_02.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-04-02")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_disk_accesses_get_a_private_endpoint_connection_request( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _delete_a_private_endpoint_connection_initial( # pylint: disable=name-too-long - self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> 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-04-02")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disk_accesses_delete_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) - - _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_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. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) 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-04-02")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_a_private_endpoint_connection_initial( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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_private_endpoint_connections( - self, resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> ItemPaged["_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.v2023_04_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 "2023-04-02")) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_accesses_list_private_endpoint_connections_request( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class DiskEncryptionSetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_04_02.ComputeManagementClient`'s - :attr:`disk_encryption_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 "2023-04-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set - else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") - - _request = build_disk_encryption_sets_create_or_update_request( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2023_04_02.models.DiskEncryptionSet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_04_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_04_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Is either a DiskEncryptionSet type or a IO[bytes] type. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2023_04_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.v2023_04_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 "2023-04-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._create_or_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 - ) - - 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, - 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-04-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( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, - 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. - :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.v2023_04_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.v2023_04_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.v2023_04_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.v2023_04_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.v2023_04_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 "2023-04-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.v2023_04_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 "2023-04-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 "2023-04-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 - :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-04-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, **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) -> ItemPaged["_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.v2023_04_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 "2023-04-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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_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.v2023_04_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 "2023-04-02")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 list_associated_resources( - self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> ItemPaged[str]: - """Lists all resources that are encrypted with this 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: 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 "2023-04-02")) - cls: ClsType[_models.ResourceUriList] = 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_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, - 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("ResourceUriList", 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 DiskRestorePointOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_04_02.ComputeManagementClient`'s - :attr:`disk_restore_point` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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. - - :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 - :return: DiskRestorePoint or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_04_02.models.DiskRestorePoint - :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-04-02")) - cls: ClsType[_models.DiskRestorePoint] = kwargs.pop("cls", None) - - _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) - - _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 - ) -> ItemPaged["_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.v2023_04_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 "2023-04-02")) - cls: ClsType[_models.DiskRestorePointList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_restore_point_list_by_restore_point_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DiskRestorePointList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _grant_access_initial( - self, - resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> 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-04-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disk_restore_point_grant_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, - 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_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: _models.GrantAccessData, - *, - 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: ~azure.mgmt.compute.v2023_04_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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_04_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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: 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.v2023_04_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.v2023_04_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.v2023_04_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 "2023-04-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 "2023-04-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 - - return deserialized # type: ignore - - @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. - - :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 - :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-04-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._revoke_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, - 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 SnapshotsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_04_02.ComputeManagementClient`'s - :attr:`snapshots` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, snapshot_name: str, snapshot: Union[_models.Snapshot, 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-04-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "Snapshot") - - _request = build_snapshots_create_or_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.Snapshot, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: ~azure.mgmt.compute.v2023_04_02.models.Snapshot - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_04_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_04_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :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.v2023_04_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.v2023_04_02.models.Snapshot] - :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-04-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._create_or_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, **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 _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, - 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-04-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "SnapshotUpdate") - - _request = build_snapshots_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, - snapshot_name: str, - snapshot: _models.SnapshotUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. 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.v2023_04_02.models.SnapshotUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_04_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. - Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_04_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. Is - either a SnapshotUpdate type or a IO[bytes] type. Required. - :type snapshot: ~azure.mgmt.compute.v2023_04_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.v2023_04_02.models.Snapshot] - :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-04-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, **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 - ) - - @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.v2023_04_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 "2023-04-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]: - 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-04-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) - - 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, snapshot_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes 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: 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-04-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, - snapshot_name=snapshot_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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Snapshot"]: - """Lists snapshots 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 Snapshot or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_04_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 "2023-04-02")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.Snapshot"]: - """Lists snapshots under a subscription. - - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_04_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 "2023-04-02")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _grant_access_initial( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, 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-04-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_snapshots_grant_access_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param grant_access_data: Access data object supplied in the body of the get snapshot access - operation. Required. - :type grant_access_data: ~azure.mgmt.compute.v2023_04_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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_04_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param 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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_04_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param 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.v2023_04_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.v2023_04_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 "2023-04-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, - snapshot_name=snapshot_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, 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 "2023-04-02")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_snapshots_revoke_access_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]: - 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_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. - :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 "2023-04-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._revoke_access_initial( - resource_group_name=resource_group_name, - snapshot_name=snapshot_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_compute_management_client.py deleted file mode 100644 index f8f44d1a266c..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_compute_management_client.py +++ /dev/null @@ -1,195 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ( - CommunityGalleriesOperations, - CommunityGalleryImageVersionsOperations, - CommunityGalleryImagesOperations, - GalleriesOperations, - GalleryApplicationVersionsOperations, - GalleryApplicationsOperations, - GalleryImageVersionsOperations, - GalleryImagesOperations, - GallerySharingProfileOperations, - SharedGalleriesOperations, - SharedGalleryImageVersionsOperations, - SharedGalleryImagesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :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 - :ivar community_gallery_images: CommunityGalleryImagesOperations operations - :vartype community_gallery_images: - azure.mgmt.compute.v2023_07_03.operations.CommunityGalleryImagesOperations - :ivar community_gallery_image_versions: CommunityGalleryImageVersionsOperations operations - :vartype community_gallery_image_versions: - azure.mgmt.compute.v2023_07_03.operations.CommunityGalleryImageVersionsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-07-03". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.galleries = GalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.gallery_images = GalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.gallery_image_versions = GalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.gallery_applications = GalleryApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.gallery_application_versions = GalleryApplicationVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.gallery_sharing_profile = GallerySharingProfileOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.shared_galleries = SharedGalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.shared_gallery_images = SharedGalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.community_galleries = CommunityGalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.community_gallery_images = CommunityGalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) 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 deleted file mode 100644 index 943bc0daf2a2..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :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. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-07-03") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) 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 deleted file mode 100644 index c34db13db3ac..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_metadata.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "chosen_version": "2023-07-03", - "total_api_version_list": ["2023-07-03"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "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.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "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.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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": { - "galleries": "GalleriesOperations", - "gallery_images": "GalleryImagesOperations", - "gallery_image_versions": "GalleryImageVersionsOperations", - "gallery_applications": "GalleryApplicationsOperations", - "gallery_application_versions": "GalleryApplicationVersionsOperations", - "gallery_sharing_profile": "GallerySharingProfileOperations", - "shared_galleries": "SharedGalleriesOperations", - "shared_gallery_images": "SharedGalleryImagesOperations", - "shared_gallery_image_versions": "SharedGalleryImageVersionsOperations", - "community_galleries": "CommunityGalleriesOperations", - "community_gallery_images": "CommunityGalleryImagesOperations", - "community_gallery_image_versions": "CommunityGalleryImageVersionsOperations" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node
    is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj 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 deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/_compute_management_client.py deleted file mode 100644 index 49e1d242fdbb..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/_compute_management_client.py +++ /dev/null @@ -1,200 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ( - CommunityGalleriesOperations, - CommunityGalleryImageVersionsOperations, - CommunityGalleryImagesOperations, - GalleriesOperations, - GalleryApplicationVersionsOperations, - GalleryApplicationsOperations, - GalleryImageVersionsOperations, - GalleryImagesOperations, - GallerySharingProfileOperations, - SharedGalleriesOperations, - SharedGalleryImageVersionsOperations, - SharedGalleryImagesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :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 - :ivar community_gallery_images: CommunityGalleryImagesOperations operations - :vartype community_gallery_images: - azure.mgmt.compute.v2023_07_03.aio.operations.CommunityGalleryImagesOperations - :ivar community_gallery_image_versions: CommunityGalleryImageVersionsOperations operations - :vartype community_gallery_image_versions: - azure.mgmt.compute.v2023_07_03.aio.operations.CommunityGalleryImageVersionsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-07-03". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.galleries = GalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.gallery_images = GalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.gallery_image_versions = GalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.gallery_applications = GalleryApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.gallery_application_versions = GalleryApplicationVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.gallery_sharing_profile = GallerySharingProfileOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.shared_galleries = SharedGalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.shared_gallery_images = SharedGalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.community_galleries = CommunityGalleriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.community_gallery_images = CommunityGalleryImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-03" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) 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 deleted file mode 100644 index 1a3262717545..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :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. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-07-03") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ 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 deleted file mode 100644 index 139d983a5840..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/operations/__init__.py +++ /dev/null @@ -1,47 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - 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 ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "GalleriesOperations", - "GalleryImagesOperations", - "GalleryImageVersionsOperations", - "GalleryApplicationsOperations", - "GalleryApplicationVersionsOperations", - "GallerySharingProfileOperations", - "SharedGalleriesOperations", - "SharedGalleryImagesOperations", - "SharedGalleryImageVersionsOperations", - "CommunityGalleriesOperations", - "CommunityGalleryImagesOperations", - "CommunityGalleryImageVersionsOperations", -] -__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 deleted file mode 100644 index 39163b4efd3a..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/operations/_operations.py +++ /dev/null @@ -1,4923 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import ( - build_community_galleries_get_request, - build_community_gallery_image_versions_get_request, - build_community_gallery_image_versions_list_request, - build_community_gallery_images_get_request, - build_community_gallery_images_list_request, - build_galleries_create_or_update_request, - build_galleries_delete_request, - build_galleries_get_request, - build_galleries_list_by_resource_group_request, - build_galleries_list_request, - build_galleries_update_request, - build_gallery_application_versions_create_or_update_request, - build_gallery_application_versions_delete_request, - build_gallery_application_versions_get_request, - build_gallery_application_versions_list_by_gallery_application_request, - build_gallery_application_versions_update_request, - build_gallery_applications_create_or_update_request, - build_gallery_applications_delete_request, - build_gallery_applications_get_request, - build_gallery_applications_list_by_gallery_request, - build_gallery_applications_update_request, - build_gallery_image_versions_create_or_update_request, - build_gallery_image_versions_delete_request, - build_gallery_image_versions_get_request, - build_gallery_image_versions_list_by_gallery_image_request, - build_gallery_image_versions_update_request, - build_gallery_images_create_or_update_request, - build_gallery_images_delete_request, - build_gallery_images_get_request, - build_gallery_images_list_by_gallery_request, - build_gallery_images_update_request, - build_gallery_sharing_profile_update_request, - build_shared_galleries_get_request, - build_shared_galleries_list_request, - build_shared_gallery_image_versions_get_request, - build_shared_gallery_image_versions_list_request, - build_shared_gallery_images_get_request, - build_shared_gallery_images_list_request, -) -from .._configuration import ComputeManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GalleriesOperations: - """ - .. 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:`galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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: Union[_models.Gallery, 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, (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 = 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: _models.Gallery, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - 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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - 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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, gallery_name: str, gallery: Union[_models.Gallery, IO[bytes]], **kwargs: Any - ) -> 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. - 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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~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, 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=gallery, - 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("Gallery", 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.Gallery].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Gallery]( - 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: Union[_models.GalleryUpdate, 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, (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) - - _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: _models.GalleryUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - 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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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. - 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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: Union[_models.GalleryUpdate, IO[bytes]], - **kwargs: Any - ) -> 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. - 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 AsyncLROPoller that returns either Gallery or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~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, 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=gallery, - 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("Gallery", 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.Gallery].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Gallery]( - 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, - 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_galleries_delete_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) - - _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, gallery_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Delete 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 to be deleted. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) 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, - 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) -> AsyncItemPaged["_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 {}) - - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - 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 = 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("GalleryImage", 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]: - 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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) - - _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, 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 {}) - - 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, **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_gallery( - self, resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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.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.GalleryImageList] = 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_images_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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryImageList", 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 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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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, "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) - - _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_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: - """ - - @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 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: - """ - - @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. 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) - :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._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 - ) - - @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. - - :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 = 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("GalleryImageVersion", 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, - gallery_image_version_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 "2023-07-03")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - 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 {}) - - 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) - - 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_gallery_image( - self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.GalleryImageVersion"]: - """List gallery image versions in 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 - resides. 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) - :rtype: - ~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.GalleryImageVersionList] = 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_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, - 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("GalleryImageVersionList", 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 GalleryApplicationsOperations: - """ - .. 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_applications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application: Union[_models.GalleryApplication, 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_application, (IOBase, bytes)): - _content = gallery_application - else: - _json = self._serialize.body(gallery_application, "GalleryApplication") - - _request = build_gallery_applications_create_or_update_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, - 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_application_name: str, - gallery_application: _models.GalleryApplication, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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 - :keyword content_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 GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the create or 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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplication, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~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, 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_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 - ) - await 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: 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.GalleryApplication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GalleryApplication]( - 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_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, 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_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_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, - ) - _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_application_name: str, - gallery_application: _models.GalleryApplicationUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :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 - :keyword content_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 GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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 - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :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 AsyncLROPoller that returns either GalleryApplication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~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, 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=gallery_application, - 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("GalleryApplication", 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.GalleryApplication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GalleryApplication]( - 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]: - 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[AsyncIterator[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 = 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, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete a gallery Application. - - :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 is to be deleted. Required. - :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be deleted. - 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) 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_application_name=gallery_application_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_gallery( - self, resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.GalleryApplication"]: - """List gallery Application 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 Application Gallery from which Application - Definitions are to be listed. Required. - :type gallery_name: str - :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.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.GalleryApplicationList] = 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_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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryApplicationList", 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 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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: Union[_models.GalleryApplicationVersion, 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_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersion") - - _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, - 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersion, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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 - :keyword content_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 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: - """ - - @overload - async 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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] - :keyword content_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 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: - """ - - @distributed_trace_async - async 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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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 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._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, - 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 - ) - - async 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]], - **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_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersionUpdate") - - _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, - 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Update 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 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 - :keyword content_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 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: - """ - - @overload - async 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Update 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 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] - :keyword content_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 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: - """ - - @distributed_trace_async - async 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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: - """Update 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 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 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) - - deserialized = self._deserialize("GalleryApplicationVersion", 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, - gallery_application_version_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 "2023-07-03")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - 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, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete 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 - deleted. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) 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_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, - 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_gallery_application( - self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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.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.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 - - async 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, 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 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:`gallery_sharing_profile` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _update_initial( - self, - resource_group_name: str, - gallery_name: str, - sharing_update: Union[_models.SharingUpdate, 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(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 = 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( - 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 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 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: - """ - - @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. - - :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 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: - """ - - @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. - - :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 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 {}) - - 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) - - 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: 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.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 - ) - - -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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_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: - """ - 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 = 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("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.aio.ComputeManagementClient`'s - :attr:`shared_gallery_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~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 - - async 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, 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, 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 = 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("SharedGalleryImage", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.SharedGalleryImageVersion"]: - """List shared gallery image versions 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 - :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) - 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, - gallery_image_version_name: str, - **kwargs: Any - ) -> _models.SharedGalleryImageVersion: - """Get a shared gallery image version 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 - :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, - 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.SharedGalleryImageVersion] = kwargs.pop("cls", None) - - _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, - 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("SharedGalleryImageVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # 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.aio.ComputeManagementClient`'s - :attr:`community_galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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: 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 - :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.CommunityGallery] = kwargs.pop("cls", 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) - - _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("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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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: - """ - 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 = 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("CommunityGalleryImage", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, location: str, public_gallery_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.CommunityGalleryImage"]: - """List community gallery images inside 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 - :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.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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CommunityGalleryImageList", 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 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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - gallery_image_version_name: str, - **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: - """ - 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.CommunityGalleryImageVersion] = 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, - 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("CommunityGalleryImageVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, location: str, public_gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.CommunityGalleryImageVersion"]: - """List community gallery image versions inside an 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: 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) - 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/v2023_07_03/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ 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 deleted file mode 100644 index e97c8bf11e64..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/__init__.py +++ /dev/null @@ -1,274 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - ApiError, - ApiErrorBase, - CommunityGallery, - CommunityGalleryImage, - CommunityGalleryImageIdentifier, - CommunityGalleryImageList, - CommunityGalleryImageVersion, - CommunityGalleryImageVersionList, - CommunityGalleryInfo, - CommunityGalleryMetadata, - DataDiskImageEncryption, - Disallowed, - DiskImageEncryption, - EncryptionImages, - ExtendedLocation, - Gallery, - GalleryApplication, - GalleryApplicationCustomAction, - GalleryApplicationCustomActionParameter, - GalleryApplicationList, - GalleryApplicationUpdate, - GalleryApplicationVersion, - GalleryApplicationVersionList, - GalleryApplicationVersionPublishingProfile, - GalleryApplicationVersionSafetyProfile, - GalleryApplicationVersionUpdate, - GalleryArtifactPublishingProfileBase, - GalleryArtifactSafetyProfileBase, - GalleryArtifactSource, - GalleryArtifactVersionFullSource, - GalleryArtifactVersionSource, - GalleryDataDiskImage, - GalleryDiskImage, - GalleryDiskImageSource, - GalleryExtendedLocation, - GalleryIdentifier, - GalleryImage, - GalleryImageFeature, - GalleryImageIdentifier, - GalleryImageList, - GalleryImageUpdate, - GalleryImageVersion, - GalleryImageVersionList, - GalleryImageVersionPublishingProfile, - GalleryImageVersionSafetyProfile, - GalleryImageVersionStorageProfile, - GalleryImageVersionUefiSettings, - GalleryImageVersionUpdate, - GalleryList, - GalleryOSDiskImage, - GalleryTargetExtendedLocation, - GalleryUpdate, - ImagePurchasePlan, - ImageVersionSecurityProfile, - InnerError, - LatestGalleryImageVersion, - ManagedArtifact, - OSDiskImageEncryption, - OSDiskImageSecurityProfile, - PirCommunityGalleryResource, - PirResource, - PirSharedGalleryResource, - PolicyViolation, - RecommendedMachineConfiguration, - RegionalReplicationStatus, - RegionalSharingStatus, - ReplicationStatus, - Resource, - ResourceRange, - ResourceWithOptionalLocation, - SharedGallery, - SharedGalleryDataDiskImage, - SharedGalleryDiskImage, - SharedGalleryImage, - SharedGalleryImageList, - SharedGalleryImageVersion, - SharedGalleryImageVersionList, - SharedGalleryImageVersionStorageProfile, - SharedGalleryList, - SharedGalleryOSDiskImage, - SharingProfile, - SharingProfileGroup, - SharingStatus, - SharingUpdate, - SoftDeletePolicy, - SubResource, - SubResourceReadOnly, - SystemData, - TargetRegion, - UefiKey, - UefiKeySignatures, - UpdateResourceDefinition, - UserArtifactManage, - UserArtifactSettings, - UserArtifactSource, - UserAssignedIdentitiesValue, -) - -from ._compute_management_client_enums import ( # type: ignore - AggregatedReplicationState, - Architecture, - ConfidentialVMEncryptionType, - EdgeZoneStorageAccountType, - ExtendedLocationTypes, - GalleryApplicationCustomActionParameterType, - GalleryExpandParams, - GalleryExtendedLocationType, - GalleryProvisioningState, - GallerySharingPermissionTypes, - HostCaching, - HyperVGeneration, - OperatingSystemStateTypes, - OperatingSystemTypes, - PolicyViolationCategory, - ReplicationMode, - ReplicationState, - ReplicationStatusTypes, - SelectPermissions, - SharedGalleryHostCaching, - SharedToValues, - SharingProfileGroupTypes, - SharingState, - SharingUpdateOperationTypes, - StorageAccountType, - UefiKeyType, - UefiSignatureTemplateName, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ApiError", - "ApiErrorBase", - "CommunityGallery", - "CommunityGalleryImage", - "CommunityGalleryImageIdentifier", - "CommunityGalleryImageList", - "CommunityGalleryImageVersion", - "CommunityGalleryImageVersionList", - "CommunityGalleryInfo", - "CommunityGalleryMetadata", - "DataDiskImageEncryption", - "Disallowed", - "DiskImageEncryption", - "EncryptionImages", - "ExtendedLocation", - "Gallery", - "GalleryApplication", - "GalleryApplicationCustomAction", - "GalleryApplicationCustomActionParameter", - "GalleryApplicationList", - "GalleryApplicationUpdate", - "GalleryApplicationVersion", - "GalleryApplicationVersionList", - "GalleryApplicationVersionPublishingProfile", - "GalleryApplicationVersionSafetyProfile", - "GalleryApplicationVersionUpdate", - "GalleryArtifactPublishingProfileBase", - "GalleryArtifactSafetyProfileBase", - "GalleryArtifactSource", - "GalleryArtifactVersionFullSource", - "GalleryArtifactVersionSource", - "GalleryDataDiskImage", - "GalleryDiskImage", - "GalleryDiskImageSource", - "GalleryExtendedLocation", - "GalleryIdentifier", - "GalleryImage", - "GalleryImageFeature", - "GalleryImageIdentifier", - "GalleryImageList", - "GalleryImageUpdate", - "GalleryImageVersion", - "GalleryImageVersionList", - "GalleryImageVersionPublishingProfile", - "GalleryImageVersionSafetyProfile", - "GalleryImageVersionStorageProfile", - "GalleryImageVersionUefiSettings", - "GalleryImageVersionUpdate", - "GalleryList", - "GalleryOSDiskImage", - "GalleryTargetExtendedLocation", - "GalleryUpdate", - "ImagePurchasePlan", - "ImageVersionSecurityProfile", - "InnerError", - "LatestGalleryImageVersion", - "ManagedArtifact", - "OSDiskImageEncryption", - "OSDiskImageSecurityProfile", - "PirCommunityGalleryResource", - "PirResource", - "PirSharedGalleryResource", - "PolicyViolation", - "RecommendedMachineConfiguration", - "RegionalReplicationStatus", - "RegionalSharingStatus", - "ReplicationStatus", - "Resource", - "ResourceRange", - "ResourceWithOptionalLocation", - "SharedGallery", - "SharedGalleryDataDiskImage", - "SharedGalleryDiskImage", - "SharedGalleryImage", - "SharedGalleryImageList", - "SharedGalleryImageVersion", - "SharedGalleryImageVersionList", - "SharedGalleryImageVersionStorageProfile", - "SharedGalleryList", - "SharedGalleryOSDiskImage", - "SharingProfile", - "SharingProfileGroup", - "SharingStatus", - "SharingUpdate", - "SoftDeletePolicy", - "SubResource", - "SubResourceReadOnly", - "SystemData", - "TargetRegion", - "UefiKey", - "UefiKeySignatures", - "UpdateResourceDefinition", - "UserArtifactManage", - "UserArtifactSettings", - "UserArtifactSource", - "UserAssignedIdentitiesValue", - "AggregatedReplicationState", - "Architecture", - "ConfidentialVMEncryptionType", - "EdgeZoneStorageAccountType", - "ExtendedLocationTypes", - "GalleryApplicationCustomActionParameterType", - "GalleryExpandParams", - "GalleryExtendedLocationType", - "GalleryProvisioningState", - "GallerySharingPermissionTypes", - "HostCaching", - "HyperVGeneration", - "OperatingSystemStateTypes", - "OperatingSystemTypes", - "PolicyViolationCategory", - "ReplicationMode", - "ReplicationState", - "ReplicationStatusTypes", - "SelectPermissions", - "SharedGalleryHostCaching", - "SharedToValues", - "SharingProfileGroupTypes", - "SharingState", - "SharingUpdateOperationTypes", - "StorageAccountType", - "UefiKeyType", - "UefiSignatureTemplateName", -] -__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/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/_compute_management_client_enums.py deleted file mode 100644 index 09be37bb0487..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/_compute_management_client_enums.py +++ /dev/null @@ -1,237 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AggregatedReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is the aggregated replication status based on all the regional replication status flags.""" - - UNKNOWN = "Unknown" - IN_PROGRESS = "InProgress" - COMPLETED = "Completed" - FAILED = "Failed" - - -class Architecture(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The architecture of the image. Applicable to OS disks only.""" - - X64 = "x64" - ARM64 = "Arm64" - - -class ConfidentialVMEncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """confidential VM encryption types.""" - - ENCRYPTED_VM_GUEST_STATE_ONLY_WITH_PMK = "EncryptedVMGuestStateOnlyWithPmk" - ENCRYPTED_WITH_PMK = "EncryptedWithPmk" - ENCRYPTED_WITH_CMK = "EncryptedWithCmk" - NON_PERSISTED_TPM = "NonPersistedTPM" - - -class EdgeZoneStorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the storage account type to be used to store the image. This property is not - updatable. - """ - - STANDARD_LRS = "Standard_LRS" - STANDARD_ZRS = "Standard_ZRS" - STANDARD_SSD_LRS = "StandardSSD_LRS" - PREMIUM_LRS = "Premium_LRS" - - -class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of extendedLocation.""" - - EDGE_ZONE = "EdgeZone" - - -class GalleryApplicationCustomActionParameterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the type of the custom action parameter. Possible values are: String, - ConfigurationDataBlob or LogOutputBlob. - """ - - STRING = "String" - CONFIGURATION_DATA_BLOB = "ConfigurationDataBlob" - LOG_OUTPUT_BLOB = "LogOutputBlob" - - -class GalleryExpandParams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """GalleryExpandParams.""" - - SHARING_PROFILE_GROUPS = "SharingProfile/Groups" - - -class GalleryExtendedLocationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """It is type of the extended location.""" - - EDGE_ZONE = "EdgeZone" - UNKNOWN = "Unknown" - - -class GalleryProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state, which only appears in the response.""" - - CREATING = "Creating" - UPDATING = "Updating" - FAILED = "Failed" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - MIGRATING = "Migrating" - - -class GallerySharingPermissionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows you to specify the permission of sharing gallery. Possible values are: - **Private,** **Groups,** **Community.**. - """ - - PRIVATE = "Private" - GROUPS = "Groups" - COMMUNITY = "Community" - - -class HostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'.""" - - NONE = "None" - READ_ONLY = "ReadOnly" - READ_WRITE = "ReadWrite" - - -class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The hypervisor generation of the Virtual Machine. Applicable to OS disks only.""" - - V1 = "V1" - V2 = "V2" - - -class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows the user to specify whether the virtual machines created under this image - are 'Generalized' or 'Specialized'. - """ - - GENERALIZED = "Generalized" - SPECIALIZED = "Specialized" - - -class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows you to specify the supported type of the OS that application is built for. - Possible values are: **Windows,** **Linux.**. - """ - - WINDOWS = "Windows" - LINUX = "Linux" - - -class PolicyViolationCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Describes the nature of the policy violation.""" - - OTHER = "Other" - IMAGE_FLAGGED_UNSAFE = "ImageFlaggedUnsafe" - COPYRIGHT_VALIDATION = "CopyrightValidation" - IP_THEFT = "IpTheft" - - -class ReplicationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Optional parameter which specifies the mode to be used for replication. This property is not - updatable. - """ - - FULL = "Full" - SHALLOW = "Shallow" - - -class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is the regional replication state.""" - - UNKNOWN = "Unknown" - REPLICATING = "Replicating" - COMPLETED = "Completed" - FAILED = "Failed" - - -class ReplicationStatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ReplicationStatusTypes.""" - - REPLICATION_STATUS = "ReplicationStatus" - UEFI_SETTINGS = "UefiSettings" - - -class SelectPermissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SelectPermissions.""" - - PERMISSIONS = "Permissions" - - -class SharedGalleryHostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'.""" - - NONE = "None" - READ_ONLY = "ReadOnly" - READ_WRITE = "ReadWrite" - - -class SharedToValues(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SharedToValues.""" - - TENANT = "tenant" - - -class SharingProfileGroupTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows you to specify the type of sharing group. Possible values are: - **Subscriptions,** **AADTenants.**. - """ - - SUBSCRIPTIONS = "Subscriptions" - AAD_TENANTS = "AADTenants" - - -class SharingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The sharing state of the gallery, which only appears in the response.""" - - SUCCEEDED = "Succeeded" - IN_PROGRESS = "InProgress" - FAILED = "Failed" - UNKNOWN = "Unknown" - - -class SharingUpdateOperationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property allows you to specify the operation type of gallery sharing update. Possible - values are: **Add,** **Remove,** **Reset.**. - """ - - ADD = "Add" - REMOVE = "Remove" - RESET = "Reset" - ENABLE_COMMUNITY = "EnableCommunity" - - -class StorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the storage account type to be used to store the image. This property is not - updatable. - """ - - STANDARD_LRS = "Standard_LRS" - STANDARD_ZRS = "Standard_ZRS" - PREMIUM_LRS = "Premium_LRS" - - -class UefiKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of key signature.""" - - SHA256 = "sha256" - X509 = "x509" - - -class UefiSignatureTemplateName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The name of the signature template that contains default UEFI keys.""" - - NO_SIGNATURE_TEMPLATE = "NoSignatureTemplate" - MICROSOFT_UEFI_CERTIFICATE_AUTHORITY_TEMPLATE = "MicrosoftUefiCertificateAuthorityTemplate" - MICROSOFT_WINDOWS_TEMPLATE = "MicrosoftWindowsTemplate" 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 deleted file mode 100644 index b792030c1ae3..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/_models_py3.py +++ /dev/null @@ -1,4731 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# 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 .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -class ApiError(_serialization.Model): - """Api error. - - :ivar details: The Api error details. - :vartype details: list[~azure.mgmt.compute.v2023_07_03.models.ApiErrorBase] - :ivar innererror: The Api inner error. - :vartype innererror: ~azure.mgmt.compute.v2023_07_03.models.InnerError - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "details": {"key": "details", "type": "[ApiErrorBase]"}, - "innererror": {"key": "innererror", "type": "InnerError"}, - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - details: Optional[List["_models.ApiErrorBase"]] = None, - innererror: Optional["_models.InnerError"] = None, - code: Optional[str] = None, - target: Optional[str] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword details: The Api error details. - :paramtype details: list[~azure.mgmt.compute.v2023_07_03.models.ApiErrorBase] - :keyword innererror: The Api inner error. - :paramtype innererror: ~azure.mgmt.compute.v2023_07_03.models.InnerError - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.details = details - self.innererror = innererror - self.code = code - self.target = target - self.message = message - - -class ApiErrorBase(_serialization.Model): - """Api error base. - - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.target = target - self.message = message - - -class PirCommunityGalleryResource(_serialization.Model): - """Base information about the community gallery resource in azure compute gallery. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar type: Resource type. - :vartype type: str - :ivar unique_id: The unique id of this community gallery. - :vartype unique_id: str - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - } - - 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 - """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.location: Optional[str] = None - self.type: Optional[str] = None - self.unique_id = unique_id - - -class CommunityGallery(PirCommunityGalleryResource): - """Specifies information about the Community Gallery that you want to create or update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar type: Resource type. - :vartype type: str - :ivar unique_id: The unique id of this community gallery. - :vartype unique_id: str - :ivar disclaimer: The disclaimer for a community gallery resource. - :vartype disclaimer: str - :ivar artifact_tags: The artifact tags of a community gallery resource. - :vartype artifact_tags: dict[str, str] - :ivar community_metadata: The metadata of community gallery. - :vartype community_metadata: ~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryMetadata - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - "disclaimer": {"key": "properties.disclaimer", "type": "str"}, - "artifact_tags": {"key": "properties.artifactTags", "type": "{str}"}, - "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: - """ - :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 - - -class CommunityGalleryImage(PirCommunityGalleryResource): - """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. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar type: Resource type. - :vartype type: str - :ivar unique_id: The unique id of this community gallery. - :vartype unique_id: str - :ivar 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". - :vartype os_type: str or ~azure.mgmt.compute.v2023_07_03.models.OperatingSystemTypes - :ivar 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". - :vartype os_state: str or ~azure.mgmt.compute.v2023_07_03.models.OperatingSystemStateTypes - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar identifier: This is the community gallery image definition identifier. - :vartype identifier: ~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImageIdentifier - :ivar recommended: The properties describe the recommended machine configuration for this Image - Definition. These properties are updatable. - :vartype recommended: ~azure.mgmt.compute.v2023_07_03.models.RecommendedMachineConfiguration - :ivar disallowed: Describes the disallowed disk types. - :vartype disallowed: ~azure.mgmt.compute.v2023_07_03.models.Disallowed - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2023_07_03.models.HyperVGeneration - :ivar features: A list of gallery image features. - :vartype features: list[~azure.mgmt.compute.v2023_07_03.models.GalleryImageFeature] - :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :vartype purchase_plan: ~azure.mgmt.compute.v2023_07_03.models.ImagePurchasePlan - :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values - are: "x64" and "Arm64". - :vartype architecture: str or ~azure.mgmt.compute.v2023_07_03.models.Architecture - :ivar privacy_statement_uri: Privacy statement URI for the current community gallery image. - :vartype privacy_statement_uri: str - :ivar eula: The end-user license agreement for the current community gallery image. - :vartype eula: str - :ivar disclaimer: The disclaimer for a community gallery resource. - :vartype disclaimer: str - :ivar artifact_tags: The artifact tags of a community gallery resource. - :vartype artifact_tags: dict[str, str] - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "os_state": {"key": "properties.osState", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "identifier": {"key": "properties.identifier", "type": "CommunityGalleryImageIdentifier"}, - "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, - "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "features": {"key": "properties.features", "type": "[GalleryImageFeature]"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, - "architecture": {"key": "properties.architecture", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "disclaimer": {"key": "properties.disclaimer", "type": "str"}, - "artifact_tags": {"key": "properties.artifactTags", "type": "{str}"}, - } - - 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 - ) -> 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.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 - - -class CommunityGalleryImageIdentifier(_serialization.Model): - """This is the community gallery image definition identifier. - - :ivar publisher: The name of the gallery image definition publisher. - :vartype publisher: str - :ivar offer: The name of the gallery image definition offer. - :vartype offer: str - :ivar sku: The name of the gallery image definition SKU. - :vartype sku: str - """ - - _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 - """ - super().__init__(**kwargs) - self.publisher = publisher - self.offer = offer - self.sku = sku - - -class CommunityGalleryImageList(_serialization.Model): - """The List Community Gallery Images operation response. - - All required parameters must be populated in order to send to server. - - :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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[CommunityGalleryImage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.CommunityGalleryImage"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class CommunityGalleryImageVersion(PirCommunityGalleryResource): - """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. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar type: Resource type. - :vartype type: str - :ivar unique_id: The unique id of this community gallery. - :vartype unique_id: str - :ivar published_date: The published date of the gallery image version Definition. This property - can be used for decommissioning purposes. This property is updatable. - :vartype published_date: ~datetime.datetime - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar storage_profile: Describes the storage profile of the image version. - :vartype storage_profile: - ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImageVersionStorageProfile - :ivar disclaimer: The disclaimer for a community gallery resource. - :vartype disclaimer: str - :ivar artifact_tags: The artifact tags of a community gallery resource. - :vartype artifact_tags: dict[str, str] - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - "published_date": {"key": "properties.publishedDate", "type": "iso-8601"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "exclude_from_latest": {"key": "properties.excludeFromLatest", "type": "bool"}, - "storage_profile": {"key": "properties.storageProfile", "type": "SharedGalleryImageVersionStorageProfile"}, - "disclaimer": {"key": "properties.disclaimer", "type": "str"}, - "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: - """ - :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 - - -class CommunityGalleryImageVersionList(_serialization.Model): - """The List Community Gallery Image versions operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of community gallery image versions. Required. - :vartype value: list[~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImageVersion] - :ivar next_link: The URI to fetch the next page of community gallery image versions. Call - ListNext() with this to fetch the next page of community gallery image versions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[CommunityGalleryImageVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.CommunityGalleryImageVersion"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of community gallery image versions. Required. - :paramtype value: list[~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImageVersion] - :keyword next_link: The URI to fetch the next page of community gallery image versions. Call - ListNext() with this to fetch the next page of community gallery image versions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class CommunityGalleryInfo(_serialization.Model): - """Information of community gallery if current gallery is shared to community. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar publisher_uri: The link to the publisher website. Visible to all users. - :vartype publisher_uri: str - :ivar publisher_contact: Community gallery publisher support email. The email address of the - publisher. Visible to all users. - :vartype publisher_contact: str - :ivar eula: End-user license agreement for community gallery image. - :vartype eula: str - :ivar public_name_prefix: The prefix of the gallery name that will be displayed publicly. - Visible to all users. - :vartype public_name_prefix: str - :ivar community_gallery_enabled: Contains info about whether community gallery sharing is - enabled. - :vartype community_gallery_enabled: bool - :ivar public_names: Community gallery public name list. - :vartype public_names: list[str] - """ - - _validation = { - "community_gallery_enabled": {"readonly": True}, - "public_names": {"readonly": True}, - } - - _attribute_map = { - "publisher_uri": {"key": "publisherUri", "type": "str"}, - "publisher_contact": {"key": "publisherContact", "type": "str"}, - "eula": {"key": "eula", "type": "str"}, - "public_name_prefix": {"key": "publicNamePrefix", "type": "str"}, - "community_gallery_enabled": {"key": "communityGalleryEnabled", "type": "bool"}, - "public_names": {"key": "publicNames", "type": "[str]"}, - } - - def __init__( - self, - *, - publisher_uri: Optional[str] = None, - publisher_contact: Optional[str] = None, - eula: Optional[str] = None, - public_name_prefix: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword publisher_uri: The link to the publisher website. Visible to all users. - :paramtype publisher_uri: str - :keyword publisher_contact: Community gallery publisher support email. The email address of the - publisher. Visible to all users. - :paramtype publisher_contact: str - :keyword eula: End-user license agreement for community gallery image. - :paramtype eula: str - :keyword public_name_prefix: The prefix of the gallery name that will be displayed publicly. - Visible to all users. - :paramtype public_name_prefix: str - """ - super().__init__(**kwargs) - self.publisher_uri = publisher_uri - self.publisher_contact = publisher_contact - self.eula = eula - self.public_name_prefix = public_name_prefix - self.community_gallery_enabled: Optional[bool] = None - self.public_names: Optional[List[str]] = None - - -class CommunityGalleryMetadata(_serialization.Model): - """The metadata of community gallery. - - All required parameters must be populated in order to send to server. - - :ivar publisher_uri: The publisher URI of this community gallery. - :vartype publisher_uri: str - :ivar publisher_contact: The publisher email id of this community gallery. Required. - :vartype publisher_contact: str - :ivar eula: The end-user license agreement for this community gallery. - :vartype eula: str - :ivar public_names: A list of public names the gallery has. Required. - :vartype public_names: list[str] - :ivar privacy_statement_uri: The link for the privacy statement of this community gallery from - the gallery publisher. - :vartype privacy_statement_uri: str - """ - - _validation = { - "publisher_contact": {"required": True}, - "public_names": {"required": True}, - } - - _attribute_map = { - "publisher_uri": {"key": "publisherUri", "type": "str"}, - "publisher_contact": {"key": "publisherContact", "type": "str"}, - "eula": {"key": "eula", "type": "str"}, - "public_names": {"key": "publicNames", "type": "[str]"}, - "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 - """ - 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 - - -class DiskImageEncryption(_serialization.Model): - """This is the disk image encryption base class. - - :ivar disk_encryption_set_id: A relative URI containing the resource ID of the disk encryption - set. - :vartype disk_encryption_set_id: str - """ - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - } - - def __init__(self, *, disk_encryption_set_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword disk_encryption_set_id: A relative URI containing the resource ID of the disk - encryption set. - :paramtype disk_encryption_set_id: str - """ - super().__init__(**kwargs) - self.disk_encryption_set_id = disk_encryption_set_id - - -class DataDiskImageEncryption(DiskImageEncryption): - """Contains encryption settings for a data disk image. - - All required parameters must be populated in order to send to server. - - :ivar disk_encryption_set_id: A relative URI containing the resource ID of the disk encryption - set. - :vartype disk_encryption_set_id: str - :ivar 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. - :vartype lun: int - """ - - _validation = { - "lun": {"required": True}, - } - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__(self, *, lun: int, disk_encryption_set_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword disk_encryption_set_id: A relative URI containing the resource ID of the disk - encryption set. - :paramtype disk_encryption_set_id: str - :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__(disk_encryption_set_id=disk_encryption_set_id, **kwargs) - self.lun = lun - - -class Disallowed(_serialization.Model): - """Describes the disallowed disk types. - - :ivar disk_types: A list of disk types. - :vartype disk_types: list[str] - """ - - _attribute_map = { - "disk_types": {"key": "diskTypes", "type": "[str]"}, - } - - def __init__(self, *, disk_types: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword disk_types: A list of disk types. - :paramtype disk_types: list[str] - """ - super().__init__(**kwargs) - self.disk_types = disk_types - - -class EncryptionImages(_serialization.Model): - """Optional. Allows users to provide customer managed keys for encrypting the OS and data disks in - the gallery artifact. - - :ivar os_disk_image: Contains encryption settings for an OS disk image. - :vartype os_disk_image: ~azure.mgmt.compute.v2023_07_03.models.OSDiskImageEncryption - :ivar data_disk_images: A list of encryption specifications for data disk images. - :vartype data_disk_images: list[~azure.mgmt.compute.v2023_07_03.models.DataDiskImageEncryption] - """ - - _attribute_map = { - "os_disk_image": {"key": "osDiskImage", "type": "OSDiskImageEncryption"}, - "data_disk_images": {"key": "dataDiskImages", "type": "[DataDiskImageEncryption]"}, - } - - def __init__( - self, - *, - os_disk_image: Optional["_models.OSDiskImageEncryption"] = None, - data_disk_images: Optional[List["_models.DataDiskImageEncryption"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_disk_image: Contains encryption settings for an OS disk image. - :paramtype os_disk_image: ~azure.mgmt.compute.v2023_07_03.models.OSDiskImageEncryption - :keyword data_disk_images: A list of encryption specifications for data disk images. - :paramtype data_disk_images: - list[~azure.mgmt.compute.v2023_07_03.models.DataDiskImageEncryption] - """ - super().__init__(**kwargs) - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - - -class ExtendedLocation(_serialization.Model): - """The complex type of the extended location. - - :ivar name: The name of the extended location. - :vartype name: str - :ivar type: The type of the extended location. "EdgeZone" - :vartype type: str or ~azure.mgmt.compute.v2023_07_03.models.ExtendedLocationTypes - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the extended location. - :paramtype name: str - :keyword type: The type of the extended location. "EdgeZone" - :paramtype type: str or ~azure.mgmt.compute.v2023_07_03.models.ExtendedLocationTypes - """ - super().__init__(**kwargs) - self.name = name - self.type = type - - -class Resource(_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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - - -class Gallery(Resource): - """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. - :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] - :ivar description: The description of this Shared Image Gallery resource. This property is - updatable. - :vartype description: str - :ivar identifier: Describes the gallery unique name. - :vartype identifier: ~azure.mgmt.compute.v2023_07_03.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2023_07_03.models.GalleryProvisioningState - :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. - :vartype sharing_profile: ~azure.mgmt.compute.v2023_07_03.models.SharingProfile - :ivar soft_delete_policy: Contains information about the soft deletion policy of the gallery. - :vartype soft_delete_policy: ~azure.mgmt.compute.v2023_07_03.models.SoftDeletePolicy - :ivar sharing_status: Sharing status of current gallery. - :vartype sharing_status: ~azure.mgmt.compute.v2023_07_03.models.SharingStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "sharing_status": {"readonly": 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}"}, - "description": {"key": "properties.description", "type": "str"}, - "identifier": {"key": "properties.identifier", "type": "GalleryIdentifier"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "sharing_profile": {"key": "properties.sharingProfile", "type": "SharingProfile"}, - "soft_delete_policy": {"key": "properties.softDeletePolicy", "type": "SoftDeletePolicy"}, - "sharing_status": {"key": "properties.sharingStatus", "type": "SharingStatus"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - identifier: Optional["_models.GalleryIdentifier"] = None, - sharing_profile: Optional["_models.SharingProfile"] = None, - soft_delete_policy: Optional["_models.SoftDeletePolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this Shared Image Gallery resource. This property is - updatable. - :paramtype description: str - :keyword identifier: Describes the gallery unique name. - :paramtype identifier: ~azure.mgmt.compute.v2023_07_03.models.GalleryIdentifier - :keyword sharing_profile: Profile for gallery sharing to subscription or tenant. - :paramtype sharing_profile: ~azure.mgmt.compute.v2023_07_03.models.SharingProfile - :keyword soft_delete_policy: Contains information about the soft deletion policy of the - gallery. - :paramtype soft_delete_policy: ~azure.mgmt.compute.v2023_07_03.models.SoftDeletePolicy - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.identifier = identifier - self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None - self.sharing_profile = sharing_profile - self.soft_delete_policy = soft_delete_policy - self.sharing_status: Optional["_models.SharingStatus"] = None - - -class GalleryApplication(Resource): - """Specifies information about the gallery Application 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. - :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] - :ivar description: The description of this gallery Application Definition resource. This - property is updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery Application Definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar supported_os_type: This property allows you to specify the supported type of the OS that - application is built for. Possible values are: **Windows,** **Linux.**. Known values are: - "Windows" and "Linux". - :vartype supported_os_type: str or ~azure.mgmt.compute.v2023_07_03.models.OperatingSystemTypes - :ivar custom_actions: A list of custom actions that can be performed with all of the Gallery - Application Versions within this Gallery Application. - :vartype custom_actions: - list[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationCustomAction] - """ - - _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}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "supported_os_type": {"key": "properties.supportedOSType", "type": "str"}, - "custom_actions": {"key": "properties.customActions", "type": "[GalleryApplicationCustomAction]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - custom_actions: Optional[List["_models.GalleryApplicationCustomAction"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery Application Definition resource. This - property is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery Application Definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: str - :keyword end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword supported_os_type: This property allows you to specify the supported type of the OS - that application is built for. Possible values are: **Windows,** **Linux.**. Known values are: - "Windows" and "Linux". - :paramtype supported_os_type: str or - ~azure.mgmt.compute.v2023_07_03.models.OperatingSystemTypes - :keyword custom_actions: A list of custom actions that can be performed with all of the Gallery - Application Versions within this Gallery Application. - :paramtype custom_actions: - list[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationCustomAction] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.end_of_life_date = end_of_life_date - self.supported_os_type = supported_os_type - self.custom_actions = custom_actions - - -class GalleryApplicationCustomAction(_serialization.Model): - """A custom action that can be performed with a Gallery Application Version. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the custom action. Must be unique within the Gallery Application - Version. Required. - :vartype name: str - :ivar script: The script to run when executing this custom action. Required. - :vartype script: str - :ivar description: Description to help the users understand what this custom action does. - :vartype description: str - :ivar parameters: The parameters that this custom action uses. - :vartype parameters: - list[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationCustomActionParameter] - """ - - _validation = { - "name": {"required": True}, - "script": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "script": {"key": "script", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "parameters": {"key": "parameters", "type": "[GalleryApplicationCustomActionParameter]"}, - } - - def __init__( - self, - *, - name: str, - script: str, - description: Optional[str] = None, - parameters: Optional[List["_models.GalleryApplicationCustomActionParameter"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the custom action. Must be unique within the Gallery Application - Version. Required. - :paramtype name: str - :keyword script: The script to run when executing this custom action. Required. - :paramtype script: str - :keyword description: Description to help the users understand what this custom action does. - :paramtype description: str - :keyword parameters: The parameters that this custom action uses. - :paramtype parameters: - list[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationCustomActionParameter] - """ - super().__init__(**kwargs) - self.name = name - self.script = script - self.description = description - self.parameters = parameters - - -class GalleryApplicationCustomActionParameter(_serialization.Model): - """The definition of a parameter that can be passed to a custom action of a Gallery Application - Version. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the custom action. Must be unique within the Gallery Application - Version. Required. - :vartype name: str - :ivar required: Indicates whether this parameter must be passed when running the custom action. - :vartype required: bool - :ivar type: Specifies the type of the custom action parameter. Possible values are: String, - ConfigurationDataBlob or LogOutputBlob. Known values are: "String", "ConfigurationDataBlob", - and "LogOutputBlob". - :vartype type: str or - ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationCustomActionParameterType - :ivar default_value: The default value of the parameter. Only applies to string types. - :vartype default_value: str - :ivar description: A description to help users understand what this parameter means. - :vartype description: str - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "required": {"key": "required", "type": "bool"}, - "type": {"key": "type", "type": "str"}, - "default_value": {"key": "defaultValue", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - required: Optional[bool] = None, - type: Optional[Union[str, "_models.GalleryApplicationCustomActionParameterType"]] = None, - default_value: Optional[str] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the custom action. Must be unique within the Gallery Application - Version. Required. - :paramtype name: str - :keyword required: Indicates whether this parameter must be passed when running the custom - action. - :paramtype required: bool - :keyword type: Specifies the type of the custom action parameter. Possible values are: String, - ConfigurationDataBlob or LogOutputBlob. Known values are: "String", "ConfigurationDataBlob", - and "LogOutputBlob". - :paramtype type: str or - ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationCustomActionParameterType - :keyword default_value: The default value of the parameter. Only applies to string types. - :paramtype default_value: str - :keyword description: A description to help users understand what this parameter means. - :paramtype description: str - """ - super().__init__(**kwargs) - self.name = name - self.required = required - self.type = type - self.default_value = default_value - self.description = description - - -class GalleryApplicationList(_serialization.Model): - """The List Gallery Applications operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of Gallery Applications. 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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryApplication]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.GalleryApplication"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of Gallery Applications. 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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class UpdateResourceDefinition(_serialization.Model): - """The Update Resource model definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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 = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.tags = tags - - -class GalleryApplicationUpdate(UpdateResourceDefinition): - """Specifies information about the gallery Application Definition that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar description: The description of this gallery Application Definition resource. This - property is updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery Application Definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar supported_os_type: This property allows you to specify the supported type of the OS that - application is built for. Possible values are: **Windows,** **Linux.**. Known values are: - "Windows" and "Linux". - :vartype supported_os_type: str or ~azure.mgmt.compute.v2023_07_03.models.OperatingSystemTypes - :ivar custom_actions: A list of custom actions that can be performed with all of the Gallery - Application Versions within this Gallery Application. - :vartype custom_actions: - list[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationCustomAction] - """ - - _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"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "supported_os_type": {"key": "properties.supportedOSType", "type": "str"}, - "custom_actions": {"key": "properties.customActions", "type": "[GalleryApplicationCustomAction]"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - custom_actions: Optional[List["_models.GalleryApplicationCustomAction"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery Application Definition resource. This - property is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery Application Definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: str - :keyword end_of_life_date: The end of life date of the gallery Application Definition. This - property can be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword supported_os_type: This property allows you to specify the supported type of the OS - that application is built for. Possible values are: **Windows,** **Linux.**. Known values are: - "Windows" and "Linux". - :paramtype supported_os_type: str or - ~azure.mgmt.compute.v2023_07_03.models.OperatingSystemTypes - :keyword custom_actions: A list of custom actions that can be performed with all of the Gallery - Application Versions within this Gallery Application. - :paramtype custom_actions: - list[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationCustomAction] - """ - super().__init__(tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.end_of_life_date = end_of_life_date - self.supported_os_type = supported_os_type - self.custom_actions = custom_actions - - -class GalleryApplicationVersion(Resource): - """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. - :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] - :ivar publishing_profile: The publishing profile of a gallery image version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersionPublishingProfile - :ivar safety_profile: The safety profile of the Gallery Application Version. - :vartype safety_profile: - ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersionSafetyProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2023_07_03.models.GalleryProvisioningState - :ivar replication_status: This is the replication status of the gallery image version. - :vartype replication_status: ~azure.mgmt.compute.v2023_07_03.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": 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}"}, - "publishing_profile": { - "key": "properties.publishingProfile", - "type": "GalleryApplicationVersionPublishingProfile", - }, - "safety_profile": {"key": "properties.safetyProfile", "type": "GalleryApplicationVersionSafetyProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, - safety_profile: Optional["_models.GalleryApplicationVersionSafetyProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image version. - :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__(location=location, tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.safety_profile = safety_profile - self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None - self.replication_status: Optional["_models.ReplicationStatus"] = None - - -class GalleryApplicationVersionList(_serialization.Model): - """The List Gallery Application version operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of gallery Application Versions. Required. - :vartype value: list[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] - :ivar next_link: The uri to fetch the next page of gallery Application Versions. Call - ListNext() with this to fetch the next page of gallery Application Versions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryApplicationVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.GalleryApplicationVersion"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of gallery Application Versions. Required. - :paramtype value: list[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] - :keyword next_link: The uri to fetch the next page of gallery Application Versions. Call - ListNext() with this to fetch the next page of gallery Application Versions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryArtifactPublishingProfileBase(_serialization.Model): - """Describes the basic gallery artifact publishing profile. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar target_regions: The target regions where the Image Version is going to be replicated to. - This property is updatable. - :vartype target_regions: list[~azure.mgmt.compute.v2023_07_03.models.TargetRegion] - :ivar replica_count: The number of replicas of the Image Version to be created per region. This - property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :vartype replica_count: int - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar published_date: The timestamp for when the gallery image version is published. - :vartype published_date: ~datetime.datetime - :ivar end_of_life_date: The end of life date of the gallery image version. This property can be - used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2023_07_03.models.StorageAccountType - :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Known values are: "Full" and "Shallow". - :vartype replication_mode: str or ~azure.mgmt.compute.v2023_07_03.models.ReplicationMode - :ivar target_extended_locations: The target extended locations where the Image Version is going - to be replicated to. This property is updatable. - :vartype target_extended_locations: - list[~azure.mgmt.compute.v2023_07_03.models.GalleryTargetExtendedLocation] - """ - - _validation = { - "published_date": {"readonly": True}, - } - - _attribute_map = { - "target_regions": {"key": "targetRegions", "type": "[TargetRegion]"}, - "replica_count": {"key": "replicaCount", "type": "int"}, - "exclude_from_latest": {"key": "excludeFromLatest", "type": "bool"}, - "published_date": {"key": "publishedDate", "type": "iso-8601"}, - "end_of_life_date": {"key": "endOfLifeDate", "type": "iso-8601"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "replication_mode": {"key": "replicationMode", "type": "str"}, - "target_extended_locations": {"key": "targetExtendedLocations", "type": "[GalleryTargetExtendedLocation]"}, - } - - def __init__( - self, - *, - target_regions: Optional[List["_models.TargetRegion"]] = None, - replica_count: Optional[int] = None, - exclude_from_latest: Optional[bool] = None, - end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, - target_extended_locations: Optional[List["_models.GalleryTargetExtendedLocation"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword target_regions: The target regions where the Image Version is going to be replicated - to. This property is updatable. - :paramtype target_regions: list[~azure.mgmt.compute.v2023_07_03.models.TargetRegion] - :keyword replica_count: The number of replicas of the Image Version to be created per region. - This property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :paramtype replica_count: int - :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 end_of_life_date: The end of life date of the gallery image version. This property can - be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2023_07_03.models.StorageAccountType - :keyword replication_mode: Optional parameter which specifies the mode to be used for - replication. This property is not updatable. Known values are: "Full" and "Shallow". - :paramtype replication_mode: str or ~azure.mgmt.compute.v2023_07_03.models.ReplicationMode - :keyword target_extended_locations: The target extended locations where the Image Version is - going to be replicated to. This property is updatable. - :paramtype target_extended_locations: - list[~azure.mgmt.compute.v2023_07_03.models.GalleryTargetExtendedLocation] - """ - super().__init__(**kwargs) - self.target_regions = target_regions - self.replica_count = replica_count - self.exclude_from_latest = exclude_from_latest - self.published_date: Optional[datetime.datetime] = None - self.end_of_life_date = end_of_life_date - self.storage_account_type = storage_account_type - self.replication_mode = replication_mode - self.target_extended_locations = target_extended_locations - - -class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfileBase): # pylint: disable=name-too-long - """The publishing profile of a gallery image version. - - 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 target_regions: The target regions where the Image Version is going to be replicated to. - This property is updatable. - :vartype target_regions: list[~azure.mgmt.compute.v2023_07_03.models.TargetRegion] - :ivar replica_count: The number of replicas of the Image Version to be created per region. This - property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :vartype replica_count: int - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar published_date: The timestamp for when the gallery image version is published. - :vartype published_date: ~datetime.datetime - :ivar end_of_life_date: The end of life date of the gallery image version. This property can be - used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2023_07_03.models.StorageAccountType - :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Known values are: "Full" and "Shallow". - :vartype replication_mode: str or ~azure.mgmt.compute.v2023_07_03.models.ReplicationMode - :ivar target_extended_locations: The target extended locations where the Image Version is going - to be replicated to. This property is updatable. - :vartype target_extended_locations: - list[~azure.mgmt.compute.v2023_07_03.models.GalleryTargetExtendedLocation] - :ivar source: The source image from which the Image Version is going to be created. Required. - :vartype source: ~azure.mgmt.compute.v2023_07_03.models.UserArtifactSource - :ivar manage_actions: - :vartype manage_actions: ~azure.mgmt.compute.v2023_07_03.models.UserArtifactManage - :ivar settings: Additional settings for the VM app that contains the target package and config - file name when it is deployed to target VM or VM scale set. - :vartype settings: ~azure.mgmt.compute.v2023_07_03.models.UserArtifactSettings - :ivar advanced_settings: Optional. Additional settings to pass to the vm-application-manager - extension. For advanced use only. - :vartype advanced_settings: dict[str, str] - :ivar enable_health_check: Optional. Whether or not this application reports health. - :vartype enable_health_check: bool - :ivar custom_actions: A list of custom actions that can be performed with this Gallery - Application Version. - :vartype custom_actions: - list[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationCustomAction] - """ - - _validation = { - "published_date": {"readonly": True}, - "source": {"required": True}, - } - - _attribute_map = { - "target_regions": {"key": "targetRegions", "type": "[TargetRegion]"}, - "replica_count": {"key": "replicaCount", "type": "int"}, - "exclude_from_latest": {"key": "excludeFromLatest", "type": "bool"}, - "published_date": {"key": "publishedDate", "type": "iso-8601"}, - "end_of_life_date": {"key": "endOfLifeDate", "type": "iso-8601"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "replication_mode": {"key": "replicationMode", "type": "str"}, - "target_extended_locations": {"key": "targetExtendedLocations", "type": "[GalleryTargetExtendedLocation]"}, - "source": {"key": "source", "type": "UserArtifactSource"}, - "manage_actions": {"key": "manageActions", "type": "UserArtifactManage"}, - "settings": {"key": "settings", "type": "UserArtifactSettings"}, - "advanced_settings": {"key": "advancedSettings", "type": "{str}"}, - "enable_health_check": {"key": "enableHealthCheck", "type": "bool"}, - "custom_actions": {"key": "customActions", "type": "[GalleryApplicationCustomAction]"}, - } - - def __init__( - self, - *, - source: "_models.UserArtifactSource", - target_regions: Optional[List["_models.TargetRegion"]] = None, - replica_count: Optional[int] = None, - exclude_from_latest: Optional[bool] = None, - end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, - target_extended_locations: Optional[List["_models.GalleryTargetExtendedLocation"]] = None, - manage_actions: Optional["_models.UserArtifactManage"] = None, - settings: Optional["_models.UserArtifactSettings"] = None, - advanced_settings: Optional[Dict[str, str]] = None, - enable_health_check: Optional[bool] = None, - custom_actions: Optional[List["_models.GalleryApplicationCustomAction"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword target_regions: The target regions where the Image Version is going to be replicated - to. This property is updatable. - :paramtype target_regions: list[~azure.mgmt.compute.v2023_07_03.models.TargetRegion] - :keyword replica_count: The number of replicas of the Image Version to be created per region. - This property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :paramtype replica_count: int - :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 end_of_life_date: The end of life date of the gallery image version. This property can - be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2023_07_03.models.StorageAccountType - :keyword replication_mode: Optional parameter which specifies the mode to be used for - replication. This property is not updatable. Known values are: "Full" and "Shallow". - :paramtype replication_mode: str or ~azure.mgmt.compute.v2023_07_03.models.ReplicationMode - :keyword target_extended_locations: The target extended locations where the Image Version is - going to be replicated to. This property is updatable. - :paramtype target_extended_locations: - list[~azure.mgmt.compute.v2023_07_03.models.GalleryTargetExtendedLocation] - :keyword source: The source image from which the Image Version is going to be created. - Required. - :paramtype source: ~azure.mgmt.compute.v2023_07_03.models.UserArtifactSource - :keyword manage_actions: - :paramtype manage_actions: ~azure.mgmt.compute.v2023_07_03.models.UserArtifactManage - :keyword settings: Additional settings for the VM app that contains the target package and - config file name when it is deployed to target VM or VM scale set. - :paramtype settings: ~azure.mgmt.compute.v2023_07_03.models.UserArtifactSettings - :keyword advanced_settings: Optional. Additional settings to pass to the vm-application-manager - extension. For advanced use only. - :paramtype advanced_settings: dict[str, str] - :keyword enable_health_check: Optional. Whether or not this application reports health. - :paramtype enable_health_check: bool - :keyword custom_actions: A list of custom actions that can be performed with this Gallery - Application Version. - :paramtype custom_actions: - list[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationCustomAction] - """ - super().__init__( - target_regions=target_regions, - replica_count=replica_count, - exclude_from_latest=exclude_from_latest, - end_of_life_date=end_of_life_date, - storage_account_type=storage_account_type, - replication_mode=replication_mode, - target_extended_locations=target_extended_locations, - **kwargs - ) - self.source = source - self.manage_actions = manage_actions - self.settings = settings - self.advanced_settings = advanced_settings - self.enable_health_check = enable_health_check - self.custom_actions = custom_actions - - -class GalleryArtifactSafetyProfileBase(_serialization.Model): - """This is the safety profile of the Gallery Artifact Version. - - :ivar allow_deletion_of_replicated_locations: Indicates whether or not removing this Gallery - Image Version from replicated regions is allowed. - :vartype allow_deletion_of_replicated_locations: bool - """ - - _attribute_map = { - "allow_deletion_of_replicated_locations": {"key": "allowDeletionOfReplicatedLocations", "type": "bool"}, - } - - def __init__(self, *, allow_deletion_of_replicated_locations: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword allow_deletion_of_replicated_locations: Indicates whether or not removing this Gallery - Image Version from replicated regions is allowed. - :paramtype allow_deletion_of_replicated_locations: bool - """ - super().__init__(**kwargs) - self.allow_deletion_of_replicated_locations = allow_deletion_of_replicated_locations - - -class GalleryApplicationVersionSafetyProfile(GalleryArtifactSafetyProfileBase): - """The safety profile of the Gallery Application Version. - - :ivar allow_deletion_of_replicated_locations: Indicates whether or not removing this Gallery - Image Version from replicated regions is allowed. - :vartype allow_deletion_of_replicated_locations: bool - """ - - -class GalleryApplicationVersionUpdate(UpdateResourceDefinition): - """Specifies information about the gallery Application Version that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar publishing_profile: The publishing profile of a gallery image version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersionPublishingProfile - :ivar safety_profile: The safety profile of the Gallery Application Version. - :vartype safety_profile: - ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersionSafetyProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2023_07_03.models.GalleryProvisioningState - :ivar replication_status: This is the replication status of the gallery image version. - :vartype replication_status: ~azure.mgmt.compute.v2023_07_03.models.ReplicationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "publishing_profile": { - "key": "properties.publishingProfile", - "type": "GalleryApplicationVersionPublishingProfile", - }, - "safety_profile": {"key": "properties.safetyProfile", "type": "GalleryApplicationVersionSafetyProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, - safety_profile: Optional["_models.GalleryApplicationVersionSafetyProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image version. - :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: Optional[Union[str, "_models.GalleryProvisioningState"]] = None - self.replication_status: Optional["_models.ReplicationStatus"] = 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 - """ - super().__init__(**kwargs) - self.managed_image = managed_image - - -class GalleryArtifactVersionSource(_serialization.Model): - """The gallery artifact version source. - - :ivar id: The id of the gallery artifact version source. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: The id of the gallery artifact version source. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class GalleryArtifactVersionFullSource(GalleryArtifactVersionSource): - """The source of the gallery artifact version. - - :ivar id: The id of the gallery artifact version source. - :vartype id: str - :ivar community_gallery_image_id: The resource Id of the source Community Gallery Image. Only - required when using Community Gallery Image as a source. - :vartype community_gallery_image_id: str - :ivar virtual_machine_id: The resource Id of the source virtual machine. Only required when - capturing a virtual machine to source this Gallery Image Version. - :vartype virtual_machine_id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "community_gallery_image_id": {"key": "communityGalleryImageId", "type": "str"}, - "virtual_machine_id": {"key": "virtualMachineId", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - community_gallery_image_id: Optional[str] = None, - virtual_machine_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the gallery artifact version source. - :paramtype id: str - :keyword community_gallery_image_id: The resource Id of the source Community Gallery Image. - Only required when using Community Gallery Image as a source. - :paramtype community_gallery_image_id: str - :keyword virtual_machine_id: The resource Id of the source virtual machine. Only required when - capturing a virtual machine to source this Gallery Image Version. - :paramtype virtual_machine_id: str - """ - super().__init__(id=id, **kwargs) - self.community_gallery_image_id = community_gallery_image_id - self.virtual_machine_id = virtual_machine_id - - -class GalleryDiskImage(_serialization.Model): - """This is the disk image base class. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar size_in_gb: This property indicates the size of the VHD to be created. - :vartype size_in_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2023_07_03.models.HostCaching - :ivar source: The source for the disk image. - :vartype source: ~azure.mgmt.compute.v2023_07_03.models.GalleryDiskImageSource - """ - - _validation = { - "size_in_gb": {"readonly": True}, - } - - _attribute_map = { - "size_in_gb": {"key": "sizeInGB", "type": "int"}, - "host_caching": {"key": "hostCaching", "type": "str"}, - "source": {"key": "source", "type": "GalleryDiskImageSource"}, - } - - def __init__( - self, - *, - host_caching: Optional[Union[str, "_models.HostCaching"]] = None, - source: Optional["_models.GalleryDiskImageSource"] = 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.HostCaching - :keyword source: The source for the disk image. - :paramtype source: ~azure.mgmt.compute.v2023_07_03.models.GalleryDiskImageSource - """ - super().__init__(**kwargs) - self.size_in_gb: Optional[int] = None - self.host_caching = host_caching - self.source = source - - -class GalleryDataDiskImage(GalleryDiskImage): - """This is the data disk 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 size_in_gb: This property indicates the size of the VHD to be created. - :vartype size_in_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2023_07_03.models.HostCaching - :ivar source: The source for the disk image. - :vartype source: ~azure.mgmt.compute.v2023_07_03.models.GalleryDiskImageSource - :ivar 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. - :vartype lun: int - """ - - _validation = { - "size_in_gb": {"readonly": True}, - "lun": {"required": True}, - } - - _attribute_map = { - "size_in_gb": {"key": "sizeInGB", "type": "int"}, - "host_caching": {"key": "hostCaching", "type": "str"}, - "source": {"key": "source", "type": "GalleryDiskImageSource"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__( - self, - *, - lun: int, - host_caching: Optional[Union[str, "_models.HostCaching"]] = None, - source: Optional["_models.GalleryDiskImageSource"] = 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.HostCaching - :keyword source: The source for the disk image. - :paramtype source: ~azure.mgmt.compute.v2023_07_03.models.GalleryDiskImageSource - :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, source=source, **kwargs) - self.lun = lun - - -class GalleryDiskImageSource(GalleryArtifactVersionSource): - """The source for the disk image. - - :ivar id: The id of the gallery artifact version source. - :vartype id: str - :ivar uri: The uri of the gallery artifact version source. Currently used to specify vhd/blob - source. - :vartype uri: str - :ivar storage_account_id: The Storage Account Id that contains the vhd blob being used as a - source for this artifact version. - :vartype storage_account_id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "uri": {"key": "uri", "type": "str"}, - "storage_account_id": {"key": "storageAccountId", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - uri: Optional[str] = None, - storage_account_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the gallery artifact version source. - :paramtype id: str - :keyword uri: The uri of the gallery artifact version source. Currently used to specify - vhd/blob source. - :paramtype uri: str - :keyword storage_account_id: The Storage Account Id that contains the vhd blob being used as a - source for this artifact version. - :paramtype storage_account_id: str - """ - super().__init__(id=id, **kwargs) - self.uri = uri - self.storage_account_id = storage_account_id - - -class GalleryExtendedLocation(_serialization.Model): - """The name of the extended location. - - :ivar name: - :vartype name: str - :ivar type: It is type of the extended location. Known values are: "EdgeZone" and "Unknown". - :vartype type: str or ~azure.mgmt.compute.v2023_07_03.models.GalleryExtendedLocationType - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[Union[str, "_models.GalleryExtendedLocationType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: - :paramtype name: str - :keyword type: It is type of the extended location. Known values are: "EdgeZone" and "Unknown". - :paramtype type: str or ~azure.mgmt.compute.v2023_07_03.models.GalleryExtendedLocationType - """ - super().__init__(**kwargs) - self.name = name - self.type = type - - -class GalleryIdentifier(_serialization.Model): - """Describes the gallery unique name. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar unique_name: The unique name of the Shared Image Gallery. This name is generated - automatically by Azure. - :vartype unique_name: str - """ - - _validation = { - "unique_name": {"readonly": True}, - } - - _attribute_map = { - "unique_name": {"key": "uniqueName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.unique_name: Optional[str] = None - - -class GalleryImage(Resource): - """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. - :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] - :ivar description: The description of this gallery image definition resource. This property is - updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery image definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar 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". - :vartype os_type: str or ~azure.mgmt.compute.v2023_07_03.models.OperatingSystemTypes - :ivar 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". - :vartype os_state: str or ~azure.mgmt.compute.v2023_07_03.models.OperatingSystemStateTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2023_07_03.models.HyperVGeneration - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar identifier: This is the gallery image definition identifier. - :vartype identifier: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageIdentifier - :ivar recommended: The properties describe the recommended machine configuration for this Image - Definition. These properties are updatable. - :vartype recommended: ~azure.mgmt.compute.v2023_07_03.models.RecommendedMachineConfiguration - :ivar disallowed: Describes the disallowed disk types. - :vartype disallowed: ~azure.mgmt.compute.v2023_07_03.models.Disallowed - :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :vartype purchase_plan: ~azure.mgmt.compute.v2023_07_03.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2023_07_03.models.GalleryProvisioningState - :ivar features: A list of gallery image features. - :vartype features: list[~azure.mgmt.compute.v2023_07_03.models.GalleryImageFeature] - :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values - are: "x64" and "Arm64". - :vartype architecture: str or ~azure.mgmt.compute.v2023_07_03.models.Architecture - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "os_state": {"key": "properties.osState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, - "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "features": {"key": "properties.features", "type": "[GalleryImageFeature]"}, - "architecture": {"key": "properties.architecture", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["_models.GalleryImageIdentifier"] = None, - recommended: Optional["_models.RecommendedMachineConfiguration"] = None, - disallowed: Optional["_models.Disallowed"] = None, - purchase_plan: Optional["_models.ImagePurchasePlan"] = None, - features: Optional[List["_models.GalleryImageFeature"]] = None, - architecture: Optional[Union[str, "_models.Architecture"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery image definition resource. This property - is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery image definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: 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 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 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 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 features: A list of gallery image features. - :paramtype features: list[~azure.mgmt.compute.v2023_07_03.models.GalleryImageFeature] - :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 - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.os_type = os_type - self.os_state = os_state - self.hyper_v_generation = hyper_v_generation - self.end_of_life_date = end_of_life_date - self.identifier = identifier - self.recommended = recommended - self.disallowed = disallowed - self.purchase_plan = purchase_plan - self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None - self.features = features - self.architecture = architecture - - -class GalleryImageFeature(_serialization.Model): - """A feature for gallery image. - - :ivar name: The name of the gallery image feature. - :vartype name: str - :ivar value: The value of the gallery image feature. - :vartype value: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: The name of the gallery image feature. - :paramtype name: str - :keyword value: The value of the gallery image feature. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class GalleryImageIdentifier(_serialization.Model): - """This is the gallery image definition identifier. - - All required parameters must be populated in order to send to server. - - :ivar publisher: The name of the gallery image definition publisher. Required. - :vartype publisher: str - :ivar offer: The name of the gallery image definition offer. Required. - :vartype offer: str - :ivar sku: The name of the gallery image definition SKU. Required. - :vartype sku: str - """ - - _validation = { - "publisher": {"required": True}, - "offer": {"required": True}, - "sku": {"required": True}, - } - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "offer": {"key": "offer", "type": "str"}, - "sku": {"key": "sku", "type": "str"}, - } - - def __init__(self, *, publisher: str, offer: str, sku: str, **kwargs: Any) -> None: - """ - :keyword publisher: The name of the gallery image definition publisher. Required. - :paramtype publisher: str - :keyword offer: The name of the gallery image definition offer. Required. - :paramtype offer: str - :keyword sku: The name of the gallery image definition SKU. Required. - :paramtype sku: str - """ - super().__init__(**kwargs) - self.publisher = publisher - self.offer = offer - self.sku = sku - - -class GalleryImageList(_serialization.Model): - """The List Gallery Images operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of Shared Image Gallery images. Required. - :vartype value: list[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] - :ivar next_link: The uri to fetch the next page of Image Definitions in the Shared Image - Gallery. Call ListNext() with this to fetch the next page of gallery image definitions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryImage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.GalleryImage"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of Shared Image Gallery images. Required. - :paramtype value: list[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] - :keyword next_link: The uri to fetch the next page of Image Definitions in the Shared Image - Gallery. Call ListNext() with this to fetch the next page of gallery image definitions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryImageUpdate(UpdateResourceDefinition): - """Specifies information about the gallery image definition that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar description: The description of this gallery image definition resource. This property is - updatable. - :vartype description: str - :ivar eula: The Eula agreement for the gallery image definition. - :vartype eula: str - :ivar privacy_statement_uri: The privacy statement uri. - :vartype privacy_statement_uri: str - :ivar release_note_uri: The release note uri. - :vartype release_note_uri: str - :ivar 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". - :vartype os_type: str or ~azure.mgmt.compute.v2023_07_03.models.OperatingSystemTypes - :ivar 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". - :vartype os_state: str or ~azure.mgmt.compute.v2023_07_03.models.OperatingSystemStateTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2023_07_03.models.HyperVGeneration - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar identifier: This is the gallery image definition identifier. - :vartype identifier: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageIdentifier - :ivar recommended: The properties describe the recommended machine configuration for this Image - Definition. These properties are updatable. - :vartype recommended: ~azure.mgmt.compute.v2023_07_03.models.RecommendedMachineConfiguration - :ivar disallowed: Describes the disallowed disk types. - :vartype disallowed: ~azure.mgmt.compute.v2023_07_03.models.Disallowed - :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :vartype purchase_plan: ~azure.mgmt.compute.v2023_07_03.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2023_07_03.models.GalleryProvisioningState - :ivar features: A list of gallery image features. - :vartype features: list[~azure.mgmt.compute.v2023_07_03.models.GalleryImageFeature] - :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values - are: "x64" and "Arm64". - :vartype architecture: str or ~azure.mgmt.compute.v2023_07_03.models.Architecture - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "release_note_uri": {"key": "properties.releaseNoteUri", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "os_state": {"key": "properties.osState", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, - "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "features": {"key": "properties.features", "type": "[GalleryImageFeature]"}, - "architecture": {"key": "properties.architecture", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["_models.GalleryImageIdentifier"] = None, - recommended: Optional["_models.RecommendedMachineConfiguration"] = None, - disallowed: Optional["_models.Disallowed"] = None, - purchase_plan: Optional["_models.ImagePurchasePlan"] = None, - features: Optional[List["_models.GalleryImageFeature"]] = None, - architecture: Optional[Union[str, "_models.Architecture"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this gallery image definition resource. This property - is updatable. - :paramtype description: str - :keyword eula: The Eula agreement for the gallery image definition. - :paramtype eula: str - :keyword privacy_statement_uri: The privacy statement uri. - :paramtype privacy_statement_uri: str - :keyword release_note_uri: The release note uri. - :paramtype release_note_uri: 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 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 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 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 features: A list of gallery image features. - :paramtype features: list[~azure.mgmt.compute.v2023_07_03.models.GalleryImageFeature] - :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 - """ - super().__init__(tags=tags, **kwargs) - self.description = description - self.eula = eula - self.privacy_statement_uri = privacy_statement_uri - self.release_note_uri = release_note_uri - self.os_type = os_type - self.os_state = os_state - self.hyper_v_generation = hyper_v_generation - self.end_of_life_date = end_of_life_date - self.identifier = identifier - self.recommended = recommended - self.disallowed = disallowed - self.purchase_plan = purchase_plan - self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None - self.features = features - self.architecture = architecture - - -class GalleryImageVersion(Resource): - """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. - :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] - :ivar publishing_profile: The publishing profile of a gallery image Version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2023_07_03.models.GalleryProvisioningState - :ivar storage_profile: This is the storage profile of a Gallery Image Version. - :vartype storage_profile: - ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionStorageProfile - :ivar safety_profile: This is the safety profile of the Gallery Image Version. - :vartype safety_profile: - ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionSafetyProfile - :ivar replication_status: This is the replication status of the gallery image version. - :vartype replication_status: ~azure.mgmt.compute.v2023_07_03.models.ReplicationStatus - :ivar security_profile: The security profile of a gallery image version. - :vartype security_profile: ~azure.mgmt.compute.v2023_07_03.models.ImageVersionSecurityProfile - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": 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}"}, - "publishing_profile": {"key": "properties.publishingProfile", "type": "GalleryImageVersionPublishingProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"}, - "safety_profile": {"key": "properties.safetyProfile", "type": "GalleryImageVersionSafetyProfile"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - "security_profile": {"key": "properties.securityProfile", "type": "ImageVersionSecurityProfile"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, - safety_profile: Optional["_models.GalleryImageVersionSafetyProfile"] = None, - security_profile: Optional["_models.ImageVersionSecurityProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image Version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionPublishingProfile - :keyword storage_profile: This is the storage profile of a Gallery Image Version. - :paramtype storage_profile: - ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionStorageProfile - :keyword safety_profile: This is the safety profile of the Gallery Image Version. - :paramtype safety_profile: - ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionSafetyProfile - :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) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None - self.storage_profile = storage_profile - self.safety_profile = safety_profile - self.replication_status: Optional["_models.ReplicationStatus"] = None - self.security_profile = security_profile - - -class GalleryImageVersionList(_serialization.Model): - """The List Gallery Image version operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of gallery image versions. Required. - :vartype value: list[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] - :ivar next_link: The uri to fetch the next page of gallery image versions. Call ListNext() with - this to fetch the next page of gallery image versions. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GalleryImageVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.GalleryImageVersion"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of gallery image versions. Required. - :paramtype value: list[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] - :keyword next_link: The uri to fetch the next page of gallery image versions. Call ListNext() - with this to fetch the next page of gallery image versions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase): - """The publishing profile of a gallery image Version. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar target_regions: The target regions where the Image Version is going to be replicated to. - This property is updatable. - :vartype target_regions: list[~azure.mgmt.compute.v2023_07_03.models.TargetRegion] - :ivar replica_count: The number of replicas of the Image Version to be created per region. This - property would take effect for a region when regionalReplicaCount is not specified. This - property is updatable. - :vartype replica_count: int - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar published_date: The timestamp for when the gallery image version is published. - :vartype published_date: ~datetime.datetime - :ivar end_of_life_date: The end of life date of the gallery image version. This property can be - used for decommissioning purposes. This property is updatable. - :vartype end_of_life_date: ~datetime.datetime - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2023_07_03.models.StorageAccountType - :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Known values are: "Full" and "Shallow". - :vartype replication_mode: str or ~azure.mgmt.compute.v2023_07_03.models.ReplicationMode - :ivar target_extended_locations: The target extended locations where the Image Version is going - to be replicated to. This property is updatable. - :vartype target_extended_locations: - list[~azure.mgmt.compute.v2023_07_03.models.GalleryTargetExtendedLocation] - """ - - -class GalleryImageVersionSafetyProfile(GalleryArtifactSafetyProfileBase): - """This is the safety profile of the Gallery Image Version. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar allow_deletion_of_replicated_locations: Indicates whether or not removing this Gallery - Image Version from replicated regions is allowed. - :vartype allow_deletion_of_replicated_locations: bool - :ivar reported_for_policy_violation: Indicates whether this image has been reported as - violating Microsoft's policies. - :vartype reported_for_policy_violation: bool - :ivar policy_violations: A list of Policy Violations that have been reported for this Gallery - Image Version. - :vartype policy_violations: list[~azure.mgmt.compute.v2023_07_03.models.PolicyViolation] - """ - - _validation = { - "reported_for_policy_violation": {"readonly": True}, - "policy_violations": {"readonly": True}, - } - - _attribute_map = { - "allow_deletion_of_replicated_locations": {"key": "allowDeletionOfReplicatedLocations", "type": "bool"}, - "reported_for_policy_violation": {"key": "reportedForPolicyViolation", "type": "bool"}, - "policy_violations": {"key": "policyViolations", "type": "[PolicyViolation]"}, - } - - def __init__(self, *, allow_deletion_of_replicated_locations: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword allow_deletion_of_replicated_locations: Indicates whether or not removing this Gallery - Image Version from replicated regions is allowed. - :paramtype allow_deletion_of_replicated_locations: bool - """ - super().__init__(allow_deletion_of_replicated_locations=allow_deletion_of_replicated_locations, **kwargs) - self.reported_for_policy_violation: Optional[bool] = None - self.policy_violations: Optional[List["_models.PolicyViolation"]] = None - - -class GalleryImageVersionStorageProfile(_serialization.Model): - """This is the storage profile of a Gallery Image Version. - - :ivar source: The source of the gallery artifact version. - :vartype source: ~azure.mgmt.compute.v2023_07_03.models.GalleryArtifactVersionFullSource - :ivar os_disk_image: This is the OS disk image. - :vartype os_disk_image: ~azure.mgmt.compute.v2023_07_03.models.GalleryOSDiskImage - :ivar data_disk_images: A list of data disk images. - :vartype data_disk_images: list[~azure.mgmt.compute.v2023_07_03.models.GalleryDataDiskImage] - """ - - _attribute_map = { - "source": {"key": "source", "type": "GalleryArtifactVersionFullSource"}, - "os_disk_image": {"key": "osDiskImage", "type": "GalleryOSDiskImage"}, - "data_disk_images": {"key": "dataDiskImages", "type": "[GalleryDataDiskImage]"}, - } - - def __init__( - self, - *, - source: Optional["_models.GalleryArtifactVersionFullSource"] = None, - os_disk_image: Optional["_models.GalleryOSDiskImage"] = None, - data_disk_images: Optional[List["_models.GalleryDataDiskImage"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source: The source of the gallery artifact version. - :paramtype source: ~azure.mgmt.compute.v2023_07_03.models.GalleryArtifactVersionFullSource - :keyword os_disk_image: This is the OS disk image. - :paramtype os_disk_image: ~azure.mgmt.compute.v2023_07_03.models.GalleryOSDiskImage - :keyword data_disk_images: A list of data disk images. - :paramtype data_disk_images: list[~azure.mgmt.compute.v2023_07_03.models.GalleryDataDiskImage] - """ - super().__init__(**kwargs) - self.source = source - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - - -class GalleryImageVersionUefiSettings(_serialization.Model): - """Contains UEFI settings for the image version. - - :ivar signature_template_names: The name of the template(s) that contains default UEFI key - signatures that will be added to the image. - :vartype signature_template_names: list[str or - ~azure.mgmt.compute.v2023_07_03.models.UefiSignatureTemplateName] - :ivar additional_signatures: Additional UEFI key signatures that will be added to the image in - addition to the signature templates. - :vartype additional_signatures: ~azure.mgmt.compute.v2023_07_03.models.UefiKeySignatures - """ - - _attribute_map = { - "signature_template_names": {"key": "signatureTemplateNames", "type": "[str]"}, - "additional_signatures": {"key": "additionalSignatures", "type": "UefiKeySignatures"}, - } - - def __init__( - self, - *, - signature_template_names: Optional[List[Union[str, "_models.UefiSignatureTemplateName"]]] = None, - additional_signatures: Optional["_models.UefiKeySignatures"] = None, - **kwargs: Any - ) -> None: - """ - :keyword signature_template_names: The name of the template(s) that contains default UEFI key - signatures that will be added to the image. - :paramtype signature_template_names: list[str or - ~azure.mgmt.compute.v2023_07_03.models.UefiSignatureTemplateName] - :keyword additional_signatures: Additional UEFI key signatures that will be added to the image - in addition to the signature templates. - :paramtype additional_signatures: ~azure.mgmt.compute.v2023_07_03.models.UefiKeySignatures - """ - super().__init__(**kwargs) - self.signature_template_names = signature_template_names - self.additional_signatures = additional_signatures - - -class GalleryImageVersionUpdate(UpdateResourceDefinition): - """Specifies information about the gallery image version that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar publishing_profile: The publishing profile of a gallery image Version. - :vartype publishing_profile: - ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2023_07_03.models.GalleryProvisioningState - :ivar storage_profile: This is the storage profile of a Gallery Image Version. - :vartype storage_profile: - ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionStorageProfile - :ivar safety_profile: This is the safety profile of the Gallery Image Version. - :vartype safety_profile: - ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionSafetyProfile - :ivar replication_status: This is the replication status of the gallery image version. - :vartype replication_status: ~azure.mgmt.compute.v2023_07_03.models.ReplicationStatus - :ivar security_profile: The security profile of a gallery image version. - :vartype security_profile: ~azure.mgmt.compute.v2023_07_03.models.ImageVersionSecurityProfile - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "replication_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "publishing_profile": {"key": "properties.publishingProfile", "type": "GalleryImageVersionPublishingProfile"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"}, - "safety_profile": {"key": "properties.safetyProfile", "type": "GalleryImageVersionSafetyProfile"}, - "replication_status": {"key": "properties.replicationStatus", "type": "ReplicationStatus"}, - "security_profile": {"key": "properties.securityProfile", "type": "ImageVersionSecurityProfile"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, - safety_profile: Optional["_models.GalleryImageVersionSafetyProfile"] = None, - security_profile: Optional["_models.ImageVersionSecurityProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword publishing_profile: The publishing profile of a gallery image Version. - :paramtype publishing_profile: - ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionPublishingProfile - :keyword storage_profile: This is the storage profile of a Gallery Image Version. - :paramtype storage_profile: - ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionStorageProfile - :keyword safety_profile: This is the safety profile of the Gallery Image Version. - :paramtype safety_profile: - ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionSafetyProfile - :keyword security_profile: The security profile of a gallery image version. - :paramtype security_profile: ~azure.mgmt.compute.v2023_07_03.models.ImageVersionSecurityProfile - """ - super().__init__(tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None - self.storage_profile = storage_profile - self.safety_profile = safety_profile - self.replication_status: Optional["_models.ReplicationStatus"] = None - self.security_profile = security_profile - - -class GalleryList(_serialization.Model): - """The List Galleries operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of galleries. Required. - :vartype value: list[~azure.mgmt.compute.v2023_07_03.models.Gallery] - :ivar next_link: The uri to fetch the next page of galleries. Call ListNext() with this to - fetch the next page of galleries. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Gallery]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Gallery"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of galleries. Required. - :paramtype value: list[~azure.mgmt.compute.v2023_07_03.models.Gallery] - :keyword next_link: The uri to fetch the next page of galleries. Call ListNext() with this to - fetch the next page of galleries. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GalleryOSDiskImage(GalleryDiskImage): - """This is the OS disk image. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar size_in_gb: This property indicates the size of the VHD to be created. - :vartype size_in_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2023_07_03.models.HostCaching - :ivar source: The source for the disk image. - :vartype source: ~azure.mgmt.compute.v2023_07_03.models.GalleryDiskImageSource - """ - - -class GalleryTargetExtendedLocation(_serialization.Model): - """GalleryTargetExtendedLocation. - - :ivar name: The name of the region. - :vartype name: str - :ivar extended_location: The name of the extended location. - :vartype extended_location: ~azure.mgmt.compute.v2023_07_03.models.GalleryExtendedLocation - :ivar extended_location_replica_count: The number of replicas of the Image Version to be - created per extended location. This property is updatable. - :vartype extended_location_replica_count: int - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "StandardSSD_LRS", and "Premium_LRS". - :vartype storage_account_type: str or - ~azure.mgmt.compute.v2023_07_03.models.EdgeZoneStorageAccountType - :ivar encryption: Optional. Allows users to provide customer managed keys for encrypting the OS - and data disks in the gallery artifact. - :vartype encryption: ~azure.mgmt.compute.v2023_07_03.models.EncryptionImages - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "extended_location": {"key": "extendedLocation", "type": "GalleryExtendedLocation"}, - "extended_location_replica_count": {"key": "extendedLocationReplicaCount", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "encryption": {"key": "encryption", "type": "EncryptionImages"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - extended_location: Optional["_models.GalleryExtendedLocation"] = None, - extended_location_replica_count: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.EdgeZoneStorageAccountType"]] = None, - encryption: Optional["_models.EncryptionImages"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the region. - :paramtype name: str - :keyword extended_location: The name of the extended location. - :paramtype extended_location: ~azure.mgmt.compute.v2023_07_03.models.GalleryExtendedLocation - :keyword extended_location_replica_count: The number of replicas of the Image Version to be - created per extended location. This property is updatable. - :paramtype extended_location_replica_count: int - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", - "StandardSSD_LRS", and "Premium_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2023_07_03.models.EdgeZoneStorageAccountType - :keyword encryption: Optional. Allows users to provide customer managed keys for encrypting the - OS and data disks in the gallery artifact. - :paramtype encryption: ~azure.mgmt.compute.v2023_07_03.models.EncryptionImages - """ - super().__init__(**kwargs) - self.name = name - self.extended_location = extended_location - self.extended_location_replica_count = extended_location_replica_count - self.storage_account_type = storage_account_type - self.encryption = encryption - - -class GalleryUpdate(UpdateResourceDefinition): - """Specifies information about the Shared Image Gallery that you want to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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] - :ivar description: The description of this Shared Image Gallery resource. This property is - updatable. - :vartype description: str - :ivar identifier: Describes the gallery unique name. - :vartype identifier: ~azure.mgmt.compute.v2023_07_03.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Known - values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", and "Migrating". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2023_07_03.models.GalleryProvisioningState - :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. - :vartype sharing_profile: ~azure.mgmt.compute.v2023_07_03.models.SharingProfile - :ivar soft_delete_policy: Contains information about the soft deletion policy of the gallery. - :vartype soft_delete_policy: ~azure.mgmt.compute.v2023_07_03.models.SoftDeletePolicy - :ivar sharing_status: Sharing status of current gallery. - :vartype sharing_status: ~azure.mgmt.compute.v2023_07_03.models.SharingStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "sharing_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "identifier": {"key": "properties.identifier", "type": "GalleryIdentifier"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "sharing_profile": {"key": "properties.sharingProfile", "type": "SharingProfile"}, - "soft_delete_policy": {"key": "properties.softDeletePolicy", "type": "SoftDeletePolicy"}, - "sharing_status": {"key": "properties.sharingStatus", "type": "SharingStatus"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - identifier: Optional["_models.GalleryIdentifier"] = None, - sharing_profile: Optional["_models.SharingProfile"] = None, - soft_delete_policy: Optional["_models.SoftDeletePolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of this Shared Image Gallery resource. This property is - updatable. - :paramtype description: str - :keyword identifier: Describes the gallery unique name. - :paramtype identifier: ~azure.mgmt.compute.v2023_07_03.models.GalleryIdentifier - :keyword sharing_profile: Profile for gallery sharing to subscription or tenant. - :paramtype sharing_profile: ~azure.mgmt.compute.v2023_07_03.models.SharingProfile - :keyword soft_delete_policy: Contains information about the soft deletion policy of the - gallery. - :paramtype soft_delete_policy: ~azure.mgmt.compute.v2023_07_03.models.SoftDeletePolicy - """ - super().__init__(tags=tags, **kwargs) - self.description = description - self.identifier = identifier - self.provisioning_state: Optional[Union[str, "_models.GalleryProvisioningState"]] = None - self.sharing_profile = sharing_profile - self.soft_delete_policy = soft_delete_policy - self.sharing_status: Optional["_models.SharingStatus"] = None - - -class ImagePurchasePlan(_serialization.Model): - """Describes the gallery image definition purchase plan. This is used by marketplace images. - - :ivar name: The plan ID. - :vartype name: str - :ivar publisher: The publisher ID. - :vartype publisher: str - :ivar product: The product ID. - :vartype product: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - publisher: Optional[str] = None, - product: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The plan ID. - :paramtype name: str - :keyword publisher: The publisher ID. - :paramtype publisher: str - :keyword product: The product ID. - :paramtype product: str - """ - super().__init__(**kwargs) - self.name = name - self.publisher = publisher - self.product = product - - -class ImageVersionSecurityProfile(_serialization.Model): - """The security profile of a gallery image version. - - :ivar uefi_settings: Contains UEFI settings for the image version. - :vartype uefi_settings: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionUefiSettings - """ - - _attribute_map = { - "uefi_settings": {"key": "uefiSettings", "type": "GalleryImageVersionUefiSettings"}, - } - - def __init__( - self, *, uefi_settings: Optional["_models.GalleryImageVersionUefiSettings"] = None, **kwargs: Any - ) -> None: - """ - :keyword uefi_settings: Contains UEFI settings for the image version. - :paramtype uefi_settings: - ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionUefiSettings - """ - super().__init__(**kwargs) - self.uefi_settings = uefi_settings - - -class InnerError(_serialization.Model): - """Inner error details. - - :ivar exceptiontype: The exception type. - :vartype exceptiontype: str - :ivar errordetail: The internal error message or exception dump. - :vartype errordetail: str - """ - - _attribute_map = { - "exceptiontype": {"key": "exceptiontype", "type": "str"}, - "errordetail": {"key": "errordetail", "type": "str"}, - } - - def __init__( - self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword exceptiontype: The exception type. - :paramtype exceptiontype: str - :keyword errordetail: The internal error message or exception dump. - :paramtype errordetail: str - """ - super().__init__(**kwargs) - self.exceptiontype = exceptiontype - 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. - - :ivar disk_encryption_set_id: A relative URI containing the resource ID of the disk encryption - set. - :vartype disk_encryption_set_id: str - :ivar security_profile: This property specifies the security profile of an OS disk image. - :vartype security_profile: ~azure.mgmt.compute.v2023_07_03.models.OSDiskImageSecurityProfile - """ - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - "security_profile": {"key": "securityProfile", "type": "OSDiskImageSecurityProfile"}, - } - - def __init__( - self, - *, - disk_encryption_set_id: Optional[str] = None, - security_profile: Optional["_models.OSDiskImageSecurityProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_set_id: A relative URI containing the resource ID of the disk - encryption set. - :paramtype disk_encryption_set_id: str - :keyword security_profile: This property specifies the security profile of an OS disk image. - :paramtype security_profile: ~azure.mgmt.compute.v2023_07_03.models.OSDiskImageSecurityProfile - """ - super().__init__(disk_encryption_set_id=disk_encryption_set_id, **kwargs) - self.security_profile = security_profile - - -class OSDiskImageSecurityProfile(_serialization.Model): - """Contains security profile for an OS disk image. - - :ivar confidential_vm_encryption_type: confidential VM encryption types. Known values are: - "EncryptedVMGuestStateOnlyWithPmk", "EncryptedWithPmk", "EncryptedWithCmk", and - "NonPersistedTPM". - :vartype confidential_vm_encryption_type: str or - ~azure.mgmt.compute.v2023_07_03.models.ConfidentialVMEncryptionType - :ivar secure_vm_disk_encryption_set_id: secure VM disk encryption set id. - :vartype secure_vm_disk_encryption_set_id: str - """ - - _attribute_map = { - "confidential_vm_encryption_type": {"key": "confidentialVMEncryptionType", "type": "str"}, - "secure_vm_disk_encryption_set_id": {"key": "secureVMDiskEncryptionSetId", "type": "str"}, - } - - def __init__( - self, - *, - confidential_vm_encryption_type: Optional[Union[str, "_models.ConfidentialVMEncryptionType"]] = None, - secure_vm_disk_encryption_set_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword confidential_vm_encryption_type: confidential VM encryption types. Known values are: - "EncryptedVMGuestStateOnlyWithPmk", "EncryptedWithPmk", "EncryptedWithCmk", and - "NonPersistedTPM". - :paramtype confidential_vm_encryption_type: str or - ~azure.mgmt.compute.v2023_07_03.models.ConfidentialVMEncryptionType - :keyword secure_vm_disk_encryption_set_id: secure VM disk encryption set id. - :paramtype secure_vm_disk_encryption_set_id: str - """ - super().__init__(**kwargs) - self.confidential_vm_encryption_type = confidential_vm_encryption_type - self.secure_vm_disk_encryption_set_id = secure_vm_disk_encryption_set_id - - -class PirResource(_serialization.Model): - """The Resource model definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.location: Optional[str] = None - - -class PirSharedGalleryResource(PirResource): - """Base information about the shared gallery resource in pir. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar unique_id: The unique id of this shared gallery. - :vartype unique_id: str - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - } - - 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 - """ - super().__init__(**kwargs) - self.unique_id = unique_id - - -class PolicyViolation(_serialization.Model): - """A policy violation reported against a gallery artifact. - - :ivar category: Describes the nature of the policy violation. Known values are: "Other", - "ImageFlaggedUnsafe", "CopyrightValidation", and "IpTheft". - :vartype category: str or ~azure.mgmt.compute.v2023_07_03.models.PolicyViolationCategory - :ivar details: Describes specific details about why this policy violation was reported. - :vartype details: str - """ - - _attribute_map = { - "category": {"key": "category", "type": "str"}, - "details": {"key": "details", "type": "str"}, - } - - def __init__( - self, - *, - category: Optional[Union[str, "_models.PolicyViolationCategory"]] = None, - details: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword category: Describes the nature of the policy violation. Known values are: "Other", - "ImageFlaggedUnsafe", "CopyrightValidation", and "IpTheft". - :paramtype category: str or ~azure.mgmt.compute.v2023_07_03.models.PolicyViolationCategory - :keyword details: Describes specific details about why this policy violation was reported. - :paramtype details: str - """ - super().__init__(**kwargs) - self.category = category - self.details = details - - -class RecommendedMachineConfiguration(_serialization.Model): - """The properties describe the recommended machine configuration for this Image Definition. These - properties are updatable. - - :ivar v_cp_us: Describes the resource range. - :vartype v_cp_us: ~azure.mgmt.compute.v2023_07_03.models.ResourceRange - :ivar memory: Describes the resource range. - :vartype memory: ~azure.mgmt.compute.v2023_07_03.models.ResourceRange - """ - - _attribute_map = { - "v_cp_us": {"key": "vCPUs", "type": "ResourceRange"}, - "memory": {"key": "memory", "type": "ResourceRange"}, - } - - def __init__( - self, - *, - v_cp_us: Optional["_models.ResourceRange"] = None, - memory: Optional["_models.ResourceRange"] = None, - **kwargs: Any - ) -> None: - """ - :keyword v_cp_us: Describes the resource range. - :paramtype v_cp_us: ~azure.mgmt.compute.v2023_07_03.models.ResourceRange - :keyword memory: Describes the resource range. - :paramtype memory: ~azure.mgmt.compute.v2023_07_03.models.ResourceRange - """ - super().__init__(**kwargs) - self.v_cp_us = v_cp_us - self.memory = memory - - -class RegionalReplicationStatus(_serialization.Model): - """This is the regional replication status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar region: The region to which the gallery image version is being replicated to. - :vartype region: str - :ivar state: This is the regional replication state. Known values are: "Unknown", - "Replicating", "Completed", and "Failed". - :vartype state: str or ~azure.mgmt.compute.v2023_07_03.models.ReplicationState - :ivar details: The details of the replication status. - :vartype details: str - :ivar progress: It indicates progress of the replication job. - :vartype progress: int - """ - - _validation = { - "region": {"readonly": True}, - "state": {"readonly": True}, - "details": {"readonly": True}, - "progress": {"readonly": True}, - } - - _attribute_map = { - "region": {"key": "region", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "details": {"key": "details", "type": "str"}, - "progress": {"key": "progress", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.region: Optional[str] = None - self.state: Optional[Union[str, "_models.ReplicationState"]] = None - self.details: Optional[str] = None - self.progress: Optional[int] = None - - -class RegionalSharingStatus(_serialization.Model): - """Gallery regional sharing status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar region: Region name. - :vartype region: str - :ivar state: Gallery sharing state in current region. Known values are: "Succeeded", - "InProgress", "Failed", and "Unknown". - :vartype state: str or ~azure.mgmt.compute.v2023_07_03.models.SharingState - :ivar details: Details of gallery regional sharing failure. - :vartype details: str - """ - - _validation = { - "state": {"readonly": True}, - } - - _attribute_map = { - "region": {"key": "region", "type": "str"}, - "state": {"key": "state", "type": "str"}, - "details": {"key": "details", "type": "str"}, - } - - def __init__(self, *, region: Optional[str] = None, details: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword region: Region name. - :paramtype region: str - :keyword details: Details of gallery regional sharing failure. - :paramtype details: str - """ - super().__init__(**kwargs) - self.region = region - self.state: Optional[Union[str, "_models.SharingState"]] = None - self.details = details - - -class ReplicationStatus(_serialization.Model): - """This is the replication status of the gallery image version. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar aggregated_state: This is the aggregated replication status based on all the regional - replication status flags. Known values are: "Unknown", "InProgress", "Completed", and "Failed". - :vartype aggregated_state: str or - ~azure.mgmt.compute.v2023_07_03.models.AggregatedReplicationState - :ivar summary: This is a summary of replication status for each region. - :vartype summary: list[~azure.mgmt.compute.v2023_07_03.models.RegionalReplicationStatus] - """ - - _validation = { - "aggregated_state": {"readonly": True}, - "summary": {"readonly": True}, - } - - _attribute_map = { - "aggregated_state": {"key": "aggregatedState", "type": "str"}, - "summary": {"key": "summary", "type": "[RegionalReplicationStatus]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.aggregated_state: Optional[Union[str, "_models.AggregatedReplicationState"]] = None - self.summary: Optional[List["_models.RegionalReplicationStatus"]] = None - - -class ResourceRange(_serialization.Model): - """Describes the resource range. - - :ivar min: The minimum number of the resource. - :vartype min: int - :ivar max: The maximum number of the resource. - :vartype max: int - """ - - _attribute_map = { - "min": {"key": "min", "type": "int"}, - "max": {"key": "max", "type": "int"}, - } - - def __init__( - self, - *, - min: Optional[int] = None, # pylint: disable=redefined-builtin - max: Optional[int] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword min: The minimum number of the resource. - :paramtype min: int - :keyword max: The maximum number of the resource. - :paramtype max: int - """ - super().__init__(**kwargs) - self.min = min - self.max = max - - -class ResourceWithOptionalLocation(_serialization.Model): - """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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.tags = tags - - -class SharedGallery(PirSharedGalleryResource): - """Specifies information about the Shared Gallery that you want to create or update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar unique_id: The unique id of this shared gallery. - :vartype unique_id: str - :ivar artifact_tags: The artifact tags of a shared gallery resource. - :vartype artifact_tags: dict[str, str] - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - "artifact_tags": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - "artifact_tags": {"key": "properties.artifactTags", "type": "{str}"}, - } - - 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 - """ - super().__init__(unique_id=unique_id, **kwargs) - self.artifact_tags: Optional[Dict[str, str]] = None - - -class SharedGalleryDiskImage(_serialization.Model): - """This is the disk image base class. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar disk_size_gb: This property indicates the size of the VHD to be created. - :vartype disk_size_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryHostCaching - """ - - _validation = { - "disk_size_gb": {"readonly": True}, - } - - _attribute_map = { - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "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 - """ - super().__init__(**kwargs) - self.disk_size_gb: Optional[int] = None - self.host_caching = host_caching - - -class SharedGalleryDataDiskImage(SharedGalleryDiskImage): - """This is the data disk 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 disk_size_gb: This property indicates the size of the VHD to be created. - :vartype disk_size_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryHostCaching - :ivar 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. - :vartype lun: int - """ - - _validation = { - "disk_size_gb": {"readonly": True}, - "lun": {"required": True}, - } - - _attribute_map = { - "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, - "host_caching": {"key": "hostCaching", "type": "str"}, - "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 - - -class SharedGalleryImage(PirSharedGalleryResource): - """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. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar unique_id: The unique id of this shared gallery. - :vartype unique_id: str - :ivar 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". - :vartype os_type: str or ~azure.mgmt.compute.v2023_07_03.models.OperatingSystemTypes - :ivar 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". - :vartype os_state: str or ~azure.mgmt.compute.v2023_07_03.models.OperatingSystemStateTypes - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar identifier: This is the gallery image definition identifier. - :vartype identifier: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageIdentifier - :ivar recommended: The properties describe the recommended machine configuration for this Image - Definition. These properties are updatable. - :vartype recommended: ~azure.mgmt.compute.v2023_07_03.models.RecommendedMachineConfiguration - :ivar disallowed: Describes the disallowed disk types. - :vartype disallowed: ~azure.mgmt.compute.v2023_07_03.models.Disallowed - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2023_07_03.models.HyperVGeneration - :ivar features: A list of gallery image features. - :vartype features: list[~azure.mgmt.compute.v2023_07_03.models.GalleryImageFeature] - :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :vartype purchase_plan: ~azure.mgmt.compute.v2023_07_03.models.ImagePurchasePlan - :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values - are: "x64" and "Arm64". - :vartype architecture: str or ~azure.mgmt.compute.v2023_07_03.models.Architecture - :ivar privacy_statement_uri: Privacy statement uri for the current community gallery image. - :vartype privacy_statement_uri: str - :ivar eula: End-user license agreement for the current community gallery image. - :vartype eula: str - :ivar artifact_tags: The artifact tags of a shared gallery resource. - :vartype artifact_tags: dict[str, str] - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "os_state": {"key": "properties.osState", "type": "str"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "recommended": {"key": "properties.recommended", "type": "RecommendedMachineConfiguration"}, - "disallowed": {"key": "properties.disallowed", "type": "Disallowed"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "features": {"key": "properties.features", "type": "[GalleryImageFeature]"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "ImagePurchasePlan"}, - "architecture": {"key": "properties.architecture", "type": "str"}, - "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, - "eula": {"key": "properties.eula", "type": "str"}, - "artifact_tags": {"key": "properties.artifactTags", "type": "{str}"}, - } - - 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 - ) -> 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.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 - - -class SharedGalleryImageList(_serialization.Model): - """The List Shared Gallery Images operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of shared gallery images. Required. - :vartype value: list[~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImage] - :ivar next_link: The uri to fetch the next page of shared gallery images. Call ListNext() with - this to fetch the next page of shared gallery images. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SharedGalleryImage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.SharedGalleryImage"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of shared gallery images. Required. - :paramtype value: list[~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImage] - :keyword next_link: The uri to fetch the next page of shared gallery images. Call ListNext() - with this to fetch the next page of shared gallery images. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SharedGalleryImageVersion(PirSharedGalleryResource): - """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. - - :ivar name: Resource name. - :vartype name: str - :ivar location: Resource location. - :vartype location: str - :ivar unique_id: The unique id of this shared gallery. - :vartype unique_id: str - :ivar published_date: The published date of the gallery image version Definition. This property - can be used for decommissioning purposes. This property is updatable. - :vartype published_date: ~datetime.datetime - :ivar 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. - :vartype end_of_life_date: ~datetime.datetime - :ivar exclude_from_latest: If set to true, Virtual Machines deployed from the latest version of - the Image Definition won't use this Image Version. - :vartype exclude_from_latest: bool - :ivar storage_profile: Describes the storage profile of the image version. - :vartype storage_profile: - ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImageVersionStorageProfile - :ivar artifact_tags: The artifact tags of a shared gallery resource. - :vartype artifact_tags: dict[str, str] - """ - - _validation = { - "name": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "unique_id": {"key": "identifier.uniqueId", "type": "str"}, - "published_date": {"key": "properties.publishedDate", "type": "iso-8601"}, - "end_of_life_date": {"key": "properties.endOfLifeDate", "type": "iso-8601"}, - "exclude_from_latest": {"key": "properties.excludeFromLatest", "type": "bool"}, - "storage_profile": {"key": "properties.storageProfile", "type": "SharedGalleryImageVersionStorageProfile"}, - "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: - """ - :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 - - -class SharedGalleryImageVersionList(_serialization.Model): - """The List Shared Gallery Image versions operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of shared gallery images versions. 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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SharedGalleryImageVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - 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. - :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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SharedGalleryImageVersionStorageProfile(_serialization.Model): - """This is the storage profile of a Gallery Image Version. - - :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. - :vartype data_disk_images: - list[~azure.mgmt.compute.v2023_07_03.models.SharedGalleryDataDiskImage] - """ - - _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] - """ - super().__init__(**kwargs) - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images - - -class SharedGalleryList(_serialization.Model): - """The List Shared Galleries operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of shared galleries. Required. - :vartype value: list[~azure.mgmt.compute.v2023_07_03.models.SharedGallery] - :ivar next_link: The uri to fetch the next page of shared galleries. Call ListNext() with this - to fetch the next page of shared galleries. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SharedGallery]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.SharedGallery"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of shared galleries. Required. - :paramtype value: list[~azure.mgmt.compute.v2023_07_03.models.SharedGallery] - :keyword next_link: The uri to fetch the next page of shared galleries. Call ListNext() with - this to fetch the next page of shared galleries. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SharedGalleryOSDiskImage(SharedGalleryDiskImage): - """This is the OS disk image. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar disk_size_gb: This property indicates the size of the VHD to be created. - :vartype disk_size_gb: int - :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :vartype host_caching: str or ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryHostCaching - """ - - -class SharingProfile(_serialization.Model): - """Profile for gallery sharing to subscription or tenant. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar permissions: This property allows you to specify the permission of sharing gallery. - Possible values are: **Private,** **Groups,** **Community.**. Known values are: "Private", - "Groups", and "Community". - :vartype permissions: str or - ~azure.mgmt.compute.v2023_07_03.models.GallerySharingPermissionTypes - :ivar groups: A list of sharing profile groups. - :vartype groups: list[~azure.mgmt.compute.v2023_07_03.models.SharingProfileGroup] - :ivar community_gallery_info: Information of community gallery if current gallery is shared to - community. - :vartype community_gallery_info: ~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryInfo - """ - - _validation = { - "groups": {"readonly": True}, - } - - _attribute_map = { - "permissions": {"key": "permissions", "type": "str"}, - "groups": {"key": "groups", "type": "[SharingProfileGroup]"}, - "community_gallery_info": {"key": "communityGalleryInfo", "type": "CommunityGalleryInfo"}, - } - - def __init__( - self, - *, - permissions: Optional[Union[str, "_models.GallerySharingPermissionTypes"]] = None, - community_gallery_info: Optional["_models.CommunityGalleryInfo"] = None, - **kwargs: Any - ) -> None: - """ - :keyword permissions: This property allows you to specify the permission of sharing gallery. - Possible values are: **Private,** **Groups,** **Community.**. Known values are: "Private", - "Groups", and "Community". - :paramtype permissions: str or - ~azure.mgmt.compute.v2023_07_03.models.GallerySharingPermissionTypes - :keyword community_gallery_info: Information of community gallery if current gallery is shared - to community. - :paramtype community_gallery_info: ~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryInfo - """ - super().__init__(**kwargs) - self.permissions = permissions - self.groups: Optional[List["_models.SharingProfileGroup"]] = None - self.community_gallery_info = community_gallery_info - - -class SharingProfileGroup(_serialization.Model): - """Group of the gallery sharing profile. - - :ivar type: This property allows you to specify the type of sharing group. Possible values are: - **Subscriptions,** **AADTenants.**. Known values are: "Subscriptions" and "AADTenants". - :vartype type: str or ~azure.mgmt.compute.v2023_07_03.models.SharingProfileGroupTypes - :ivar ids: A list of subscription/tenant ids the gallery is aimed to be shared to. - :vartype ids: list[str] - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "ids": {"key": "ids", "type": "[str]"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.SharingProfileGroupTypes"]] = None, - ids: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: This property allows you to specify the type of sharing group. Possible values - are: **Subscriptions,** **AADTenants.**. Known values are: "Subscriptions" and "AADTenants". - :paramtype type: str or ~azure.mgmt.compute.v2023_07_03.models.SharingProfileGroupTypes - :keyword ids: A list of subscription/tenant ids the gallery is aimed to be shared to. - :paramtype ids: list[str] - """ - super().__init__(**kwargs) - self.type = type - self.ids = ids - - -class SharingStatus(_serialization.Model): - """Sharing status of current gallery. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar aggregated_state: Aggregated sharing state of current gallery. Known values are: - "Succeeded", "InProgress", "Failed", and "Unknown". - :vartype aggregated_state: str or ~azure.mgmt.compute.v2023_07_03.models.SharingState - :ivar summary: Summary of all regional sharing status. - :vartype summary: list[~azure.mgmt.compute.v2023_07_03.models.RegionalSharingStatus] - """ - - _validation = { - "aggregated_state": {"readonly": True}, - } - - _attribute_map = { - "aggregated_state": {"key": "aggregatedState", "type": "str"}, - "summary": {"key": "summary", "type": "[RegionalSharingStatus]"}, - } - - def __init__(self, *, summary: Optional[List["_models.RegionalSharingStatus"]] = None, **kwargs: Any) -> None: - """ - :keyword summary: Summary of all regional sharing status. - :paramtype summary: list[~azure.mgmt.compute.v2023_07_03.models.RegionalSharingStatus] - """ - super().__init__(**kwargs) - self.aggregated_state: Optional[Union[str, "_models.SharingState"]] = None - self.summary = summary - - -class SharingUpdate(_serialization.Model): - """Specifies information about the gallery sharing profile update. - - All required parameters must be populated in order to send to server. - - :ivar operation_type: This property allows you to specify the operation type of gallery sharing - update. Possible values are: **Add,** **Remove,** **Reset.**. Required. Known values are: - "Add", "Remove", "Reset", and "EnableCommunity". - :vartype operation_type: str or - ~azure.mgmt.compute.v2023_07_03.models.SharingUpdateOperationTypes - :ivar groups: A list of sharing profile groups. - :vartype groups: list[~azure.mgmt.compute.v2023_07_03.models.SharingProfileGroup] - """ - - _validation = { - "operation_type": {"required": True}, - } - - _attribute_map = { - "operation_type": {"key": "operationType", "type": "str"}, - "groups": {"key": "groups", "type": "[SharingProfileGroup]"}, - } - - def __init__( - self, - *, - operation_type: Union[str, "_models.SharingUpdateOperationTypes"], - groups: Optional[List["_models.SharingProfileGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword operation_type: This property allows you to specify the operation type of gallery - sharing update. Possible values are: **Add,** **Remove,** **Reset.**. Required. Known values - are: "Add", "Remove", "Reset", and "EnableCommunity". - :paramtype operation_type: str or - ~azure.mgmt.compute.v2023_07_03.models.SharingUpdateOperationTypes - :keyword groups: A list of sharing profile groups. - :paramtype groups: list[~azure.mgmt.compute.v2023_07_03.models.SharingProfileGroup] - """ - super().__init__(**kwargs) - self.operation_type = operation_type - self.groups = groups - - -class SoftDeletePolicy(_serialization.Model): - """Contains information about the soft deletion policy of the gallery. - - :ivar is_soft_delete_enabled: Enables soft-deletion for resources in this gallery, allowing - them to be recovered within retention time. - :vartype is_soft_delete_enabled: bool - """ - - _attribute_map = { - "is_soft_delete_enabled": {"key": "isSoftDeleteEnabled", "type": "bool"}, - } - - def __init__(self, *, is_soft_delete_enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword is_soft_delete_enabled: Enables soft-deletion for resources in this gallery, allowing - them to be recovered within retention time. - :paramtype is_soft_delete_enabled: bool - """ - super().__init__(**kwargs) - self.is_soft_delete_enabled = is_soft_delete_enabled - - -class SubResource(_serialization.Model): - """SubResource. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class SubResourceReadOnly(_serialization.Model): - """SubResourceReadOnly. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class SystemData(_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. - - :ivar created_at: Specifies the time in UTC at which the Cloud Service (extended support) - resource was created. :code:`
    `Minimum api-version: 2022-04-04. - :vartype created_at: ~datetime.datetime - :ivar last_modified_at: Specifies the time in UTC at which the Cloud Service (extended support) - resource was last modified. :code:`
    `Minimum api-version: 2022-04-04. - :vartype last_modified_at: ~datetime.datetime - """ - - _validation = { - "created_at": {"readonly": True}, - "last_modified_at": {"readonly": True}, - } - - _attribute_map = { - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.created_at: Optional[datetime.datetime] = None - self.last_modified_at: Optional[datetime.datetime] = None - - -class TargetRegion(_serialization.Model): - """Describes the target region information. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the region. Required. - :vartype name: str - :ivar regional_replica_count: The number of replicas of the Image Version to be created per - region. This property is updatable. - :vartype regional_replica_count: int - :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :vartype storage_account_type: str or ~azure.mgmt.compute.v2023_07_03.models.StorageAccountType - :ivar encryption: Optional. Allows users to provide customer managed keys for encrypting the OS - and data disks in the gallery artifact. - :vartype encryption: ~azure.mgmt.compute.v2023_07_03.models.EncryptionImages - :ivar exclude_from_latest: Contains the flag setting to hide an image when users specify - version='latest'. - :vartype exclude_from_latest: bool - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "regional_replica_count": {"key": "regionalReplicaCount", "type": "int"}, - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "encryption": {"key": "encryption", "type": "EncryptionImages"}, - "exclude_from_latest": {"key": "excludeFromLatest", "type": "bool"}, - } - - def __init__( - self, - *, - name: str, - regional_replica_count: Optional[int] = None, - storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, - encryption: Optional["_models.EncryptionImages"] = None, - exclude_from_latest: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the region. Required. - :paramtype name: str - :keyword regional_replica_count: The number of replicas of the Image Version to be created per - region. This property is updatable. - :paramtype regional_replica_count: int - :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", and - "Premium_LRS". - :paramtype storage_account_type: str or - ~azure.mgmt.compute.v2023_07_03.models.StorageAccountType - :keyword encryption: Optional. Allows users to provide customer managed keys for encrypting the - OS and data disks in the gallery artifact. - :paramtype encryption: ~azure.mgmt.compute.v2023_07_03.models.EncryptionImages - :keyword exclude_from_latest: Contains the flag setting to hide an image when users specify - version='latest'. - :paramtype exclude_from_latest: bool - """ - super().__init__(**kwargs) - self.name = name - self.regional_replica_count = regional_replica_count - self.storage_account_type = storage_account_type - self.encryption = encryption - self.exclude_from_latest = exclude_from_latest - - -class UefiKey(_serialization.Model): - """A UEFI key signature. - - :ivar type: The type of key signature. Known values are: "sha256" and "x509". - :vartype type: str or ~azure.mgmt.compute.v2023_07_03.models.UefiKeyType - :ivar value: The value of the key signature. - :vartype value: list[str] - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "value": {"key": "value", "type": "[str]"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.UefiKeyType"]] = None, - value: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of key signature. Known values are: "sha256" and "x509". - :paramtype type: str or ~azure.mgmt.compute.v2023_07_03.models.UefiKeyType - :keyword value: The value of the key signature. - :paramtype value: list[str] - """ - super().__init__(**kwargs) - self.type = type - self.value = value - - -class UefiKeySignatures(_serialization.Model): - """Additional UEFI key signatures that will be added to the image in addition to the signature - templates. - - :ivar pk: The Platform Key of this image version. - :vartype pk: ~azure.mgmt.compute.v2023_07_03.models.UefiKey - :ivar kek: The Key Encryption Keys of this image version. - :vartype kek: list[~azure.mgmt.compute.v2023_07_03.models.UefiKey] - :ivar db: The database of UEFI keys for this image version. - :vartype db: list[~azure.mgmt.compute.v2023_07_03.models.UefiKey] - :ivar dbx: The database of revoked UEFI keys for this image version. - :vartype dbx: list[~azure.mgmt.compute.v2023_07_03.models.UefiKey] - """ - - _attribute_map = { - "pk": {"key": "pk", "type": "UefiKey"}, - "kek": {"key": "kek", "type": "[UefiKey]"}, - "db": {"key": "db", "type": "[UefiKey]"}, - "dbx": {"key": "dbx", "type": "[UefiKey]"}, - } - - def __init__( - self, - *, - pk: Optional["_models.UefiKey"] = None, - kek: Optional[List["_models.UefiKey"]] = None, - db: Optional[List["_models.UefiKey"]] = None, - dbx: Optional[List["_models.UefiKey"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword pk: The Platform Key of this image version. - :paramtype pk: ~azure.mgmt.compute.v2023_07_03.models.UefiKey - :keyword kek: The Key Encryption Keys of this image version. - :paramtype kek: list[~azure.mgmt.compute.v2023_07_03.models.UefiKey] - :keyword db: The database of UEFI keys for this image version. - :paramtype db: list[~azure.mgmt.compute.v2023_07_03.models.UefiKey] - :keyword dbx: The database of revoked UEFI keys for this image version. - :paramtype dbx: list[~azure.mgmt.compute.v2023_07_03.models.UefiKey] - """ - super().__init__(**kwargs) - self.pk = pk - self.kek = kek - self.db = db - self.dbx = dbx - - -class UserArtifactManage(_serialization.Model): - """UserArtifactManage. - - All required parameters must be populated in order to send to server. - - :ivar install: Required. The path and arguments to install the gallery application. This is - limited to 4096 characters. Required. - :vartype install: str - :ivar remove: Required. The path and arguments to remove the gallery application. This is - limited to 4096 characters. Required. - :vartype remove: str - :ivar update: Optional. The path and arguments to update the gallery application. If not - present, then update operation will invoke remove command on the previous version and install - command on the current version of the gallery application. This is limited to 4096 characters. - :vartype update: str - """ - - _validation = { - "install": {"required": True}, - "remove": {"required": True}, - } - - _attribute_map = { - "install": {"key": "install", "type": "str"}, - "remove": {"key": "remove", "type": "str"}, - "update": {"key": "update", "type": "str"}, - } - - def __init__(self, *, install: str, remove: str, update: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword install: Required. The path and arguments to install the gallery application. This is - limited to 4096 characters. Required. - :paramtype install: str - :keyword remove: Required. The path and arguments to remove the gallery application. This is - limited to 4096 characters. Required. - :paramtype remove: str - :keyword update: Optional. The path and arguments to update the gallery application. If not - present, then update operation will invoke remove command on the previous version and install - command on the current version of the gallery application. This is limited to 4096 characters. - :paramtype update: str - """ - super().__init__(**kwargs) - self.install = install - self.remove = remove - self.update = update - - -class UserArtifactSettings(_serialization.Model): - """Additional settings for the VM app that contains the target package and config file name when - it is deployed to target VM or VM scale set. - - :ivar package_file_name: Optional. The name to assign the downloaded package file on the VM. - This is limited to 4096 characters. If not specified, the package file will be named the same - as the Gallery Application name. - :vartype package_file_name: str - :ivar config_file_name: Optional. The name to assign the downloaded config file on the VM. This - is limited to 4096 characters. If not specified, the config file will be named the Gallery - Application name appended with "_config". - :vartype config_file_name: str - """ - - _attribute_map = { - "package_file_name": {"key": "packageFileName", "type": "str"}, - "config_file_name": {"key": "configFileName", "type": "str"}, - } - - def __init__( - self, *, package_file_name: Optional[str] = None, config_file_name: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword package_file_name: Optional. The name to assign the downloaded package file on the VM. - This is limited to 4096 characters. If not specified, the package file will be named the same - as the Gallery Application name. - :paramtype package_file_name: str - :keyword config_file_name: Optional. The name to assign the downloaded config file on the VM. - This is limited to 4096 characters. If not specified, the config file will be named the Gallery - Application name appended with "_config". - :paramtype config_file_name: str - """ - super().__init__(**kwargs) - self.package_file_name = package_file_name - self.config_file_name = config_file_name - - -class UserArtifactSource(_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 media_link: Required. The mediaLink of the artifact, must be a readable storage page - blob. Required. - :vartype media_link: str - :ivar default_configuration_link: Optional. The defaultConfigurationLink of the artifact, must - be a readable storage page blob. - :vartype default_configuration_link: str - """ - - _validation = { - "media_link": {"required": True}, - } - - _attribute_map = { - "media_link": {"key": "mediaLink", "type": "str"}, - "default_configuration_link": {"key": "defaultConfigurationLink", "type": "str"}, - } - - def __init__(self, *, media_link: str, default_configuration_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword media_link: Required. The mediaLink of the artifact, must be a readable storage page - blob. Required. - :paramtype media_link: str - :keyword default_configuration_link: Optional. The defaultConfigurationLink of the artifact, - must be a readable storage page blob. - :paramtype default_configuration_link: str - """ - super().__init__(**kwargs) - self.media_link = media_link - self.default_configuration_link = default_configuration_link - - -class UserAssignedIdentitiesValue(_serialization.Model): - """UserAssignedIdentitiesValue. - - 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: Optional[str] = None - self.client_id: Optional[str] = None diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ 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 deleted file mode 100644 index 139d983a5840..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/operations/__init__.py +++ /dev/null @@ -1,47 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - 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 ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "GalleriesOperations", - "GalleryImagesOperations", - "GalleryImageVersionsOperations", - "GalleryApplicationsOperations", - "GalleryApplicationVersionsOperations", - "GallerySharingProfileOperations", - "SharedGalleriesOperations", - "SharedGalleryImagesOperations", - "SharedGalleryImageVersionsOperations", - "CommunityGalleriesOperations", - "CommunityGalleryImagesOperations", - "CommunityGalleryImageVersionsOperations", -] -__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 deleted file mode 100644 index 93fe774d48d0..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/operations/_operations.py +++ /dev/null @@ -1,6205 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import ComputeManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_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: - _headers = case_insensitive_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}", - ) - 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"), - } - - _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_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/{galleryName}", - ) - 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"), - } - - _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_galleries_get_request( - resource_group_name: str, - gallery_name: str, - subscription_id: str, - *, - select: Optional[Union[str, _models.SelectPermissions]] = None, - expand: Optional[Union[str, _models.GalleryExpandParams]] = 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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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 {}) - - 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}", - ) - 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"), - } - - _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) - - -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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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}", - ) - 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"), - } - - _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_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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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_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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", - ) - 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"), - } - - _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_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 {}) - - 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}/images/{galleryImageName}", - ) - 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"), - } - - _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) - - -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 {}) - - 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}/images", - ) - 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"), - } - - _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_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, - **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}", - ) - 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"), - } - - _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_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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", - ) - 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"), - } - - _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_image_versions_get_request( - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image_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")) - 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}", - ) - 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"), - } - - _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) - - -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 {}) - - 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}/images/{galleryImageName}/versions/{galleryImageVersionName}", - ) - 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"), - } - - _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) - - -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 {}) - - 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}/images/{galleryImageName}/versions", - ) - 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"), - } - - _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_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 - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", - ) - 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"), - } - - _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}", - ) - 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"), - } - - _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_get_request( - 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}", - ) - 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"), - } - - _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_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}", - ) - 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"), - } - - _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) - - -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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications", - ) - 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"), - } - - _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_gallery_application_versions_create_or_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, - **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}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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_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, - **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}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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_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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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) - - -def build_gallery_application_versions_delete_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, - **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}/versions/{galleryApplicationVersionName}", - ) - 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"), - "galleryApplicationVersionName": _SERIALIZER.url( - "gallery_application_version_name", gallery_application_version_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) - - -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 {}) - - 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}/versions", - ) - 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"), - } - - _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_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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/share", - ) - 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"), - } - - _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_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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "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) - - -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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}", - ) - 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"), - } - - _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_shared_gallery_images_list_request( - location: str, - gallery_unique_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 {}) - - 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}/sharedGalleries/{galleryUniqueName}/images", - ) - 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"), - } - - _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) - - -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 {}) - - 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}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}", - ) - 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"), - "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_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 {}) - - 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}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}/versions", - ) - 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"), - "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) - - -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")) - 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}", - ) - 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"), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}", - ) - 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_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 {}) - - 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}", - ) - 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", - ) - 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}", - ) - 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"), - "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") - - # 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_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 {}) - - 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", - ) - 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) - - -class GalleriesOperations: - """ - .. 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:`galleries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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, (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 - - 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) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: _models.Gallery, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_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. - 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: - """ - - @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. - - :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: - """ - - @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. - - :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. 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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) 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) - - 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, **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 _update_initial( - self, - resource_group_name: str, - gallery_name: str, - gallery: Union[_models.GalleryUpdate, 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, (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) - - _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]: - 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, - 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. 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 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. 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 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. 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 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, **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 - ) - - @distributed_trace - 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 = 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 - - def _delete_initial(self, resource_group_name: str, gallery_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_galleries_delete_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) - - _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, gallery_name: str, **kwargs: Any) -> LROPoller[None]: - """Delete 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 to be deleted. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) 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, - 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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_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.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, - 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: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_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, - 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 - - 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) - - 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 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) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_image_name: str, - gallery_image: Union[_models.GalleryImage, 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, (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 = 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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: - """ - - @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. - - :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: - """ - - @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. - - :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] - :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, 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) - - 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: 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, - ) - return LROPoller[_models.GalleryImage]( - 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: Union[_models.GalleryImageUpdate, 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, (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 = 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: - 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, - 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: - """ - - @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. - - :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: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image: Union[_models.GalleryImageUpdate, IO[bytes]], - **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. 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 {}) - _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) - - 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: 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, - ) - 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_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, - 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("GalleryImage", 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) - - _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) - - _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, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> LROPoller[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 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 - ) -> ItemPaged["_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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) 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) - - 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_images_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("GalleryImageList", 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 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) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - 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: - """ - - @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. 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: - """ - - @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. - - :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 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, **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, - 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, "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) - - _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]: - 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, - 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. - - :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 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_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. - - :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 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_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 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 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._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, **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 - ) - - @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( - 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, - 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_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, - 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, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - **kwargs: Any - ) -> LROPoller[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 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, - 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 - - 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_image( - self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> ItemPaged["_models.GalleryImageVersion"]: - """List gallery image versions in 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 - resides. 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) - :rtype: - ~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.GalleryImageVersionList] = 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_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, - 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("GalleryImageVersionList", 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 GalleryApplicationsOperations: - """ - .. 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_applications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application: Union[_models.GalleryApplication, 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_application, (IOBase, bytes)): - _content = gallery_application - else: - _json = self._serialize.body(gallery_application, "GalleryApplication") - - _request = build_gallery_applications_create_or_update_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, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: _models.GalleryApplication, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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 - :keyword content_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: - """ - - @overload - def begin_create_or_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]: - """Create or update 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 is to be created. 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. - :type gallery_application_name: str - :param gallery_application: Parameters supplied to the create or 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_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplication, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Create or update 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 is to be created. 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. - :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.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._create_or_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, **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 _update_initial( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, 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_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_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, - ) - _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]: - 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, - gallery_application_name: str, - gallery_application: _models.GalleryApplicationUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Update 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 is to be updated. 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. - :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 - :keyword content_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: - """ - - @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. - - :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 is to be updated. 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. - :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. 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. - :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. - :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, **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 - ) - - @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 - ) -> 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) - 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, 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. 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. - :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be deleted. - 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, **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 - ) -> ItemPaged["_models.GalleryApplication"]: - """List gallery Application 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 Application Gallery from which Application - Definitions are to be listed. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) 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) - - 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: - 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 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) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_application_name: str, - gallery_application_version_name: str, - gallery_application_version: Union[_models.GalleryApplicationVersion, 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_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersion") - - _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, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersion, - *, - 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. - :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 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 - :keyword content_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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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], - *, - 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. - :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 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] - :keyword content_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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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]], - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Create or update 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 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] - :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, 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_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 - ) - 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: 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.GalleryApplicationVersion].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.GalleryApplicationVersion]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - 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]], - **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_application_version, (IOBase, bytes)): - _content = gallery_application_version - else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersionUpdate") - - _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, - 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]: - 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, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update 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 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 - :keyword content_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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update 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 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] - :keyword content_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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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]], - **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update 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 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] - :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, 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_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 - ) - 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: 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.GalleryApplicationVersion].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - 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, - 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 {}) - - _headers = kwargs.pop("headers", {}) 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_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, - 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, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Delete 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 - deleted. 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: - """ - _headers = kwargs.pop("headers", {}) 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, - gallery_application_version_name=gallery_application_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 - - 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_application( - self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> ItemPaged["_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) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_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) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_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 - - -class SharedGalleryImageVersionsOperations: - """ - .. 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. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.SharedGalleryImageVersion"]: - """List shared gallery image versions 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 - :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.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 - - 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, 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, - gallery_image_version_name: str, - **kwargs: Any - ) -> _models.SharedGalleryImageVersion: - """Get a shared gallery image version 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 - :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, - 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.SharedGalleryImageVersion] = kwargs.pop("cls", None) - - _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, - 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("SharedGalleryImageVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # 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) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, **kwargs: Any) -> _models.CommunityGallery: - """Get a community gallery by gallery public name. - - :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 - :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.CommunityGallery] = kwargs.pop("cls", 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) - - _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("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) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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: - """ - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CommunityGalleryImage", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, location: str, public_gallery_name: str, **kwargs: Any - ) -> ItemPaged["_models.CommunityGalleryImage"]: - """List community gallery images inside 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 - :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.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 - - def extract_data(pipeline_response): - deserialized = self._deserialize("CommunityGalleryImageList", 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 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:`community_gallery_image_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - gallery_image_version_name: str, - **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: - """ - 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.CommunityGalleryImageVersion] = 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, - 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("CommunityGalleryImageVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, location: str, public_gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> ItemPaged["_models.CommunityGalleryImageVersion"]: - """List community gallery image versions inside an 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: 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) - 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/v2023_07_03/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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_10_02/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_compute_management_client.py deleted file mode 100644 index f4067e561989..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_compute_management_client.py +++ /dev/null @@ -1,144 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ( - DiskAccessesOperations, - DiskEncryptionSetsOperations, - DiskRestorePointOperations, - DisksOperations, - SnapshotsOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar disks: DisksOperations operations - :vartype disks: azure.mgmt.compute.v2023_10_02.operations.DisksOperations - :ivar disk_accesses: DiskAccessesOperations operations - :vartype disk_accesses: azure.mgmt.compute.v2023_10_02.operations.DiskAccessesOperations - :ivar disk_encryption_sets: DiskEncryptionSetsOperations operations - :vartype disk_encryption_sets: - azure.mgmt.compute.v2023_10_02.operations.DiskEncryptionSetsOperations - :ivar disk_restore_point: DiskRestorePointOperations operations - :vartype disk_restore_point: - azure.mgmt.compute.v2023_10_02.operations.DiskRestorePointOperations - :ivar snapshots: SnapshotsOperations operations - :vartype snapshots: azure.mgmt.compute.v2023_10_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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-10-02". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - 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, "2023-10-02") - self.disk_accesses = DiskAccessesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-10-02" - ) - self.disk_encryption_sets = DiskEncryptionSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-10-02" - ) - self.disk_restore_point = DiskRestorePointOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-10-02" - ) - self.snapshots = SnapshotsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-10-02" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_configuration.py deleted file mode 100644 index 7d39c5d9e1ea..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-10-02". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-10-02") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_metadata.json deleted file mode 100644 index 4b70f0035826..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_metadata.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "chosen_version": "2023-10-02", - "total_api_version_list": ["2023-10-02"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "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.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "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.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node
    is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj 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 deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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_10_02/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/_compute_management_client.py deleted file mode 100644 index 4850f56a1b40..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/_compute_management_client.py +++ /dev/null @@ -1,148 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ( - DiskAccessesOperations, - DiskEncryptionSetsOperations, - DiskRestorePointOperations, - DisksOperations, - SnapshotsOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar disks: DisksOperations operations - :vartype disks: azure.mgmt.compute.v2023_10_02.aio.operations.DisksOperations - :ivar disk_accesses: DiskAccessesOperations operations - :vartype disk_accesses: azure.mgmt.compute.v2023_10_02.aio.operations.DiskAccessesOperations - :ivar disk_encryption_sets: DiskEncryptionSetsOperations operations - :vartype disk_encryption_sets: - azure.mgmt.compute.v2023_10_02.aio.operations.DiskEncryptionSetsOperations - :ivar disk_restore_point: DiskRestorePointOperations operations - :vartype disk_restore_point: - azure.mgmt.compute.v2023_10_02.aio.operations.DiskRestorePointOperations - :ivar snapshots: SnapshotsOperations operations - :vartype snapshots: azure.mgmt.compute.v2023_10_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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-10-02". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - 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, "2023-10-02") - self.disk_accesses = DiskAccessesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-10-02" - ) - self.disk_encryption_sets = DiskEncryptionSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-10-02" - ) - self.disk_restore_point = DiskRestorePointOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-10-02" - ) - self.snapshots = SnapshotsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-10-02" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/_configuration.py deleted file mode 100644 index 8e33564d19bf..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-10-02". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-10-02") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/operations/__init__.py deleted file mode 100644 index 0e0c2d8aaf8d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/operations/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -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 SnapshotsOperations # 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", - "SnapshotsOperations", -] -__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_10_02/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/operations/_operations.py deleted file mode 100644 index 6c535ec116d2..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/operations/_operations.py +++ /dev/null @@ -1,4727 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import ( - build_disk_accesses_create_or_update_request, - build_disk_accesses_delete_a_private_endpoint_connection_request, - build_disk_accesses_delete_request, - build_disk_accesses_get_a_private_endpoint_connection_request, - build_disk_accesses_get_private_link_resources_request, - build_disk_accesses_get_request, - build_disk_accesses_list_by_resource_group_request, - build_disk_accesses_list_private_endpoint_connections_request, - build_disk_accesses_list_request, - build_disk_accesses_update_a_private_endpoint_connection_request, - build_disk_accesses_update_request, - build_disk_encryption_sets_create_or_update_request, - build_disk_encryption_sets_delete_request, - build_disk_encryption_sets_get_request, - build_disk_encryption_sets_list_associated_resources_request, - build_disk_encryption_sets_list_by_resource_group_request, - build_disk_encryption_sets_list_request, - build_disk_encryption_sets_update_request, - build_disk_restore_point_get_request, - build_disk_restore_point_grant_access_request, - build_disk_restore_point_list_by_restore_point_request, - build_disk_restore_point_revoke_access_request, - build_disks_create_or_update_request, - build_disks_delete_request, - build_disks_get_request, - build_disks_grant_access_request, - build_disks_list_by_resource_group_request, - build_disks_list_request, - build_disks_revoke_access_request, - build_disks_update_request, - build_snapshots_create_or_update_request, - build_snapshots_delete_request, - build_snapshots_get_request, - build_snapshots_grant_access_request, - build_snapshots_list_by_resource_group_request, - build_snapshots_list_request, - build_snapshots_revoke_access_request, - build_snapshots_update_request, -) -from .._configuration import ComputeManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DisksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_10_02.aio.ComputeManagementClient`'s - :attr:`disks` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_name: str, disk: Union[_models.Disk, 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-10-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk, (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_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) - - _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_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. 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.v2023_10_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.v2023_10_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. 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.v2023_10_02.models.Disk] - :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. - - :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 - :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.v2023_10_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.v2023_10_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 "2023-10-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, 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, - 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("Disk", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Disk].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Disk]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _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, - 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-10-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk, (IOBase, bytes)): - _content = disk - else: - _json = self._serialize.body(disk, "DiskUpdate") - - _request = build_disks_update_request( - resource_group_name=resource_group_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) - - _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( - self, - resource_group_name: str, - disk_name: str, - disk: _models.DiskUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Updates (patches) a disk. - - :param resource_group_name: The name of the resource group. 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.v2023_10_02.models.DiskUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_10_02.models.Disk] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - disk_name: str, - disk: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Updates (patches) a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Patch disk operation. Required. - :type disk: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_10_02.models.Disk] - :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. - - :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 - :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.v2023_10_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.v2023_10_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 "2023-10-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, 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, - 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("Disk", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Disk].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Disk]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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.v2023_10_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 "2023-10-02")) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) - - _request = build_disks_get_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) - - _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("Disk", 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_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 "2023-10-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: - """ - _headers = kwargs.pop("headers", {}) 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-10-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, **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) -> AsyncItemPaged["_models.Disk"]: - """Lists all the disks 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 Disk or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_10_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 "2023-10-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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2023_10_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 "2023-10-02")) - cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disks_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _grant_access_initial( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, 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-10-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disks_grant_access_request( - resource_group_name=resource_group_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) - - _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_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_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.v2023_10_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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_10_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param grant_access_data: Access data object supplied in the body of the get disk access - operation. Required. - :type grant_access_data: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_10_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> 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_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.v2023_10_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.v2023_10_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 "2023-10-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, - disk_name=disk_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, 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 "2023-10-02")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disks_revoke_access_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]: - 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_revoke_access( - self, resource_group_name: str, disk_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Revokes access to 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: - """ - _headers = kwargs.pop("headers", {}) 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-10-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) - - 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 DiskAccessesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_10_02.aio.ComputeManagementClient`'s - :attr:`disk_accesses` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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-10-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access - else: - _json = self._serialize.body(disk_access, "DiskAccess") - - _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) - - _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_create_or_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccess, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Put disk access operation. - Required. - :type disk_access: ~azure.mgmt.compute.v2023_10_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.v2023_10_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2023_10_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Put disk access operation. - Is either a DiskAccess type or a IO[bytes] type. Required. - :type disk_access: ~azure.mgmt.compute.v2023_10_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.v2023_10_02.models.DiskAccess] - :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-10-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) - - 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 - - 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 - ) - - async def _update_initial( - 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, - 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-10-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access - else: - _json = self._serialize.body(disk_access, "DiskAccessUpdate") - - _request = build_disk_accesses_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) - - _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( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccessUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Patch disk access operation. - Required. - :type disk_access: ~azure.mgmt.compute.v2023_10_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 DiskAccess or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_10_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the 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 DiskAccess or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_10_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - 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. - :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.v2023_10_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.v2023_10_02.models.DiskAccess] - :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-10-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._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) - - 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 - - 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 - ) - - @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.v2023_10_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 "2023-10-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 - ) -> 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 "2023-10-02")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disk_accesses_delete_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) - - _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_access_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes 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 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-10-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: - 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) -> AsyncItemPaged["_models.DiskAccess"]: - """Lists all the disk access resources 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 DiskAccess or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_10_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 "2023-10-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 - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2023_10_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 "2023-10-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_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. 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.v2023_10_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 "2023-10-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 - - 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, - 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-10-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.v2023_10_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.v2023_10_02.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2023_10_02.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long - self, - resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection under disk access resource, this can't be used - to create a new private endpoint connection. - - :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.v2023_10_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.v2023_10_02.models.PrivateEndpointConnection] - :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-10-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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 polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def get_a_private_endpoint_connection( - self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets information about a private endpoint connection under a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_10_02.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-10-02")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_disk_accesses_get_a_private_endpoint_connection_request( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # 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 - ) -> 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 "2023-10-02")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disk_accesses_delete_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) - - _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_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. - - :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: 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-10-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_a_private_endpoint_connection_initial( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_private_endpoint_connections( - self, resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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.v2023_10_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 "2023-10-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.v2023_10_02.aio.ComputeManagementClient`'s - :attr:`disk_encryption_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-10-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set - else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") - - _request = build_disk_encryption_sets_create_or_update_request( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2023_10_02.models.DiskEncryptionSet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_10_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_10_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Is either a DiskEncryptionSet type or a IO[bytes] type. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2023_10_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.v2023_10_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 "2023-10-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._create_or_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, **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 _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, - 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-10-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set - else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSetUpdate") - - _request = build_disk_encryption_sets_update_request( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, - 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. - :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.v2023_10_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.v2023_10_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. 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.v2023_10_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. 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.v2023_10_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.v2023_10_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 "2023-10-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, **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 - ) - - @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.v2023_10_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 "2023-10-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 - ) -> 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 "2023-10-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) - - 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_encryption_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[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 - :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-10-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 - ) -> AsyncItemPaged["_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.v2023_10_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 "2023-10-02")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_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.v2023_10_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 "2023-10-02")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_associated_resources( - self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> AsyncItemPaged[str]: - """Lists all resources that are encrypted with this 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: 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 "2023-10-02")) - cls: ClsType[_models.ResourceUriList] = 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_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, - 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("ResourceUriList", 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 DiskRestorePointOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_10_02.aio.ComputeManagementClient`'s - :attr:`disk_restore_point` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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. - - :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 - :return: DiskRestorePoint or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_10_02.models.DiskRestorePoint - :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-10-02")) - cls: ClsType[_models.DiskRestorePoint] = kwargs.pop("cls", None) - - _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) - - _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 - ) -> AsyncItemPaged["_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.v2023_10_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 "2023-10-02")) - cls: ClsType[_models.DiskRestorePointList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_restore_point_list_by_restore_point_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskRestorePointList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _grant_access_initial( - self, - resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> 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-10-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disk_restore_point_grant_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, - 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_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: _models.GrantAccessData, - *, - 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: ~azure.mgmt.compute.v2023_10_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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_10_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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: 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.v2023_10_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. - - :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.v2023_10_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.v2023_10_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 "2023-10-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 "2023-10-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 - - @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. - - :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 - :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-10-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, - 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, - 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 SnapshotsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_10_02.aio.ComputeManagementClient`'s - :attr:`snapshots` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, snapshot_name: str, snapshot: Union[_models.Snapshot, 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-10-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "Snapshot") - - _request = build_snapshots_create_or_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.Snapshot, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: ~azure.mgmt.compute.v2023_10_02.models.Snapshot - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_10_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_10_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :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.v2023_10_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.v2023_10_02.models.Snapshot] - :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-10-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, 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, - 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, **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 _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, - 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-10-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "SnapshotUpdate") - - _request = build_snapshots_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.SnapshotUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. 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.v2023_10_02.models.SnapshotUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_10_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. - Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_10_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. Is - either a SnapshotUpdate type or a IO[bytes] type. Required. - :type snapshot: ~azure.mgmt.compute.v2023_10_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.v2023_10_02.models.Snapshot] - :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-10-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, 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, **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 - ) - - @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.v2023_10_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 "2023-10-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( - 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 "2023-10-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) - - 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, snapshot_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes 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: 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-10-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, - snapshot_name=snapshot_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) -> AsyncItemPaged["_models.Snapshot"]: - """Lists snapshots 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 Snapshot or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_10_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 "2023-10-02")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - 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(self, **kwargs: Any) -> AsyncItemPaged["_models.Snapshot"]: - """Lists snapshots under a subscription. - - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_10_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 "2023-10-02")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _grant_access_initial( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, 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-10-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_snapshots_grant_access_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param grant_access_data: Access data object supplied in the body of the get snapshot access - operation. Required. - :type grant_access_data: ~azure.mgmt.compute.v2023_10_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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_10_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param 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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_10_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param 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.v2023_10_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.v2023_10_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 "2023-10-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, - snapshot_name=snapshot_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, 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 "2023-10-02")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_snapshots_revoke_access_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]: - 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_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. - :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 "2023-10-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, - snapshot_name=snapshot_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/models/__init__.py deleted file mode 100644 index 087321a1aa15..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/models/__init__.py +++ /dev/null @@ -1,174 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - AccessUri, - ApiError, - ApiErrorBase, - CopyCompletionError, - CreationData, - Disk, - DiskAccess, - DiskAccessList, - DiskAccessUpdate, - DiskEncryptionSet, - DiskEncryptionSetList, - DiskEncryptionSetUpdate, - DiskList, - DiskRestorePoint, - DiskRestorePointList, - DiskSecurityProfile, - DiskSku, - DiskUpdate, - Encryption, - EncryptionSetIdentity, - EncryptionSettingsCollection, - EncryptionSettingsElement, - ExtendedLocation, - GrantAccessData, - ImageDiskReference, - InnerError, - KeyForDiskEncryptionSet, - KeyVaultAndKeyReference, - KeyVaultAndSecretReference, - PrivateEndpoint, - PrivateEndpointConnection, - PrivateEndpointConnectionListResult, - PrivateLinkResource, - PrivateLinkResourceListResult, - PrivateLinkServiceConnectionState, - PropertyUpdatesInProgress, - ProxyOnlyResource, - PurchasePlan, - Resource, - ResourceUriList, - ResourceWithOptionalLocation, - ShareInfoElement, - Snapshot, - SnapshotList, - SnapshotSku, - SnapshotUpdate, - SourceVault, - SubResource, - SubResourceReadOnly, - SupportedCapabilities, - SystemData, - UserAssignedIdentitiesValue, -) - -from ._compute_management_client_enums import ( # type: ignore - AccessLevel, - Architecture, - CopyCompletionErrorReason, - DataAccessAuthMode, - DiskCreateOption, - DiskEncryptionSetIdentityType, - DiskEncryptionSetType, - DiskSecurityTypes, - DiskState, - DiskStorageAccountTypes, - EncryptionType, - ExtendedLocationTypes, - FileFormat, - HyperVGeneration, - NetworkAccessPolicy, - OperatingSystemTypes, - PrivateEndpointConnectionProvisioningState, - PrivateEndpointServiceConnectionStatus, - ProvisionedBandwidthCopyOption, - PublicNetworkAccess, - SnapshotStorageAccountTypes, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AccessUri", - "ApiError", - "ApiErrorBase", - "CopyCompletionError", - "CreationData", - "Disk", - "DiskAccess", - "DiskAccessList", - "DiskAccessUpdate", - "DiskEncryptionSet", - "DiskEncryptionSetList", - "DiskEncryptionSetUpdate", - "DiskList", - "DiskRestorePoint", - "DiskRestorePointList", - "DiskSecurityProfile", - "DiskSku", - "DiskUpdate", - "Encryption", - "EncryptionSetIdentity", - "EncryptionSettingsCollection", - "EncryptionSettingsElement", - "ExtendedLocation", - "GrantAccessData", - "ImageDiskReference", - "InnerError", - "KeyForDiskEncryptionSet", - "KeyVaultAndKeyReference", - "KeyVaultAndSecretReference", - "PrivateEndpoint", - "PrivateEndpointConnection", - "PrivateEndpointConnectionListResult", - "PrivateLinkResource", - "PrivateLinkResourceListResult", - "PrivateLinkServiceConnectionState", - "PropertyUpdatesInProgress", - "ProxyOnlyResource", - "PurchasePlan", - "Resource", - "ResourceUriList", - "ResourceWithOptionalLocation", - "ShareInfoElement", - "Snapshot", - "SnapshotList", - "SnapshotSku", - "SnapshotUpdate", - "SourceVault", - "SubResource", - "SubResourceReadOnly", - "SupportedCapabilities", - "SystemData", - "UserAssignedIdentitiesValue", - "AccessLevel", - "Architecture", - "CopyCompletionErrorReason", - "DataAccessAuthMode", - "DiskCreateOption", - "DiskEncryptionSetIdentityType", - "DiskEncryptionSetType", - "DiskSecurityTypes", - "DiskState", - "DiskStorageAccountTypes", - "EncryptionType", - "ExtendedLocationTypes", - "FileFormat", - "HyperVGeneration", - "NetworkAccessPolicy", - "OperatingSystemTypes", - "PrivateEndpointConnectionProvisioningState", - "PrivateEndpointServiceConnectionStatus", - "ProvisionedBandwidthCopyOption", - "PublicNetworkAccess", - "SnapshotStorageAccountTypes", -] -__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_10_02/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/models/_compute_management_client_enums.py deleted file mode 100644 index 4a70d0b63b49..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/models/_compute_management_client_enums.py +++ /dev/null @@ -1,280 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AccessLevel.""" - - NONE = "None" - READ = "Read" - WRITE = "Write" - - -class Architecture(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """CPU architecture supported by an OS disk.""" - - X64 = "x64" - ARM64 = "Arm64" - - -class CopyCompletionErrorReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the error code if the background copy of a resource created via the CopyStart - operation fails. - """ - - COPY_SOURCE_NOT_FOUND = "CopySourceNotFound" - """Indicates that the source snapshot was deleted while the background copy of the resource - created via CopyStart operation was in progress.""" - - -class DataAccessAuthMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Additional authentication requirements when exporting or uploading to a disk or snapshot.""" - - AZURE_ACTIVE_DIRECTORY = "AzureActiveDirectory" - """When export/upload URL is used, the system checks if the user has an identity in Azure Active - Directory and has necessary permissions to export/upload the data. Please refer to - aka.ms/DisksAzureADAuth.""" - NONE = "None" - """No additional authentication would be performed when accessing export/upload URL.""" - - -class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This enumerates the possible sources of a disk's creation.""" - - EMPTY = "Empty" - """Create an empty data disk of a size given by diskSizeGB.""" - ATTACH = "Attach" - """Disk will be attached to a VM.""" - FROM_IMAGE = "FromImage" - """Create a new disk from a platform image specified by the given imageReference or - galleryImageReference.""" - IMPORT = "Import" - """Create a disk by importing from a blob specified by a sourceUri in a storage account specified - by storageAccountId.""" - COPY = "Copy" - """Create a new disk or snapshot by copying from a disk or snapshot specified by the given - sourceResourceId.""" - RESTORE = "Restore" - """Create a new disk by copying from a backup recovery point.""" - UPLOAD = "Upload" - """Create a new disk by obtaining a write token and using it to directly upload the contents of - the disk.""" - COPY_START = "CopyStart" - """Create a new disk by using a deep copy process, where the resource creation is considered - complete only after all data has been copied from the source.""" - IMPORT_SECURE = "ImportSecure" - """Similar to Import create option. Create a new Trusted Launch VM or Confidential VM supported - disk by importing additional blob for VM guest state specified by securityDataUri in storage - account specified by storageAccountId""" - UPLOAD_PREPARED_SECURE = "UploadPreparedSecure" - """Similar to Upload create option. Create a new Trusted Launch VM or Confidential VM supported - disk and upload using write token in both disk and VM guest state""" - COPY_FROM_SAN_SNAPSHOT = "CopyFromSanSnapshot" - """Create a new disk by exporting from elastic san volume snapshot""" - IMPORT_ENUM = "Import" - """Create a disk by importing from a blob specified by a sourceUri in a storage account specified - by storageAccountId.""" - - -class DiskEncryptionSetIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported - for new creations. Disk Encryption Sets can be updated with Identity type None during migration - of subscription to a new Azure Active Directory tenant; it will cause the encrypted resources - to lose access to the keys. - """ - - SYSTEM_ASSIGNED = "SystemAssigned" - USER_ASSIGNED = "UserAssigned" - SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" - NONE = "None" - - -class DiskEncryptionSetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of key used to encrypt the data of the disk.""" - - ENCRYPTION_AT_REST_WITH_CUSTOMER_KEY = "EncryptionAtRestWithCustomerKey" - """Resource using diskEncryptionSet would be encrypted at rest with Customer managed key that can - be changed and revoked by a customer.""" - ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" - """Resource using diskEncryptionSet would be encrypted at rest with two layers of encryption. One - of the keys is Customer managed and the other key is Platform managed.""" - CONFIDENTIAL_VM_ENCRYPTED_WITH_CUSTOMER_KEY = "ConfidentialVmEncryptedWithCustomerKey" - """Confidential VM supported disk and VM guest state would be encrypted with customer managed key.""" - - -class DiskSecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the SecurityType of the VM. Applicable for OS disks only.""" - - TRUSTED_LAUNCH = "TrustedLaunch" - """Trusted Launch provides security features such as secure boot and virtual Trusted Platform - Module (vTPM)""" - CONFIDENTIAL_VM_VMGUEST_STATE_ONLY_ENCRYPTED_WITH_PLATFORM_KEY = ( - "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey" - ) - """Indicates Confidential VM disk with only VM guest state encrypted""" - CONFIDENTIAL_VM_DISK_ENCRYPTED_WITH_PLATFORM_KEY = "ConfidentialVM_DiskEncryptedWithPlatformKey" - """Indicates Confidential VM disk with both OS disk and VM guest state encrypted with a platform - managed key""" - CONFIDENTIAL_VM_DISK_ENCRYPTED_WITH_CUSTOMER_KEY = "ConfidentialVM_DiskEncryptedWithCustomerKey" - """Indicates Confidential VM disk with both OS disk and VM guest state encrypted with a customer - managed key""" - CONFIDENTIAL_VM_NON_PERSISTED_TPM = "ConfidentialVM_NonPersistedTPM" - """Indicates Confidential VM disk with a ephemeral vTPM. vTPM state is not persisted across VM - reboots.""" - - -class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This enumerates the possible state of the disk.""" - - UNATTACHED = "Unattached" - """The disk is not being used and can be attached to a VM.""" - ATTACHED = "Attached" - """The disk is currently attached to a running VM.""" - RESERVED = "Reserved" - """The disk is attached to a stopped-deallocated VM.""" - FROZEN = "Frozen" - """The disk is attached to a VM which is in hibernated state.""" - ACTIVE_SAS = "ActiveSAS" - """The disk currently has an Active SAS Uri associated with it.""" - ACTIVE_SAS_FROZEN = "ActiveSASFrozen" - """The disk is attached to a VM in hibernated state and has an active SAS URI associated with it.""" - READY_TO_UPLOAD = "ReadyToUpload" - """A disk is ready to be created by upload by requesting a write token.""" - ACTIVE_UPLOAD = "ActiveUpload" - """A disk is created for upload and a write token has been issued for uploading to it.""" - - -class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The sku name.""" - - STANDARD_LRS = "Standard_LRS" - """Standard HDD locally redundant storage. Best for backup, non-critical, and infrequent access.""" - PREMIUM_LRS = "Premium_LRS" - """Premium SSD locally redundant storage. Best for production and performance sensitive workloads.""" - STANDARD_SSD_LRS = "StandardSSD_LRS" - """Standard SSD locally redundant storage. Best for web servers, lightly used enterprise - applications and dev/test.""" - ULTRA_SSD_LRS = "UltraSSD_LRS" - """Ultra SSD locally redundant storage. Best for IO-intensive workloads such as SAP HANA, top tier - databases (for example, SQL, Oracle), and other transaction-heavy workloads.""" - PREMIUM_ZRS = "Premium_ZRS" - """Premium SSD zone redundant storage. Best for the production workloads that need storage - resiliency against zone failures.""" - STANDARD_SSD_ZRS = "StandardSSD_ZRS" - """Standard SSD zone redundant storage. Best for web servers, lightly used enterprise applications - and dev/test that need storage resiliency against zone failures.""" - PREMIUM_V2_LRS = "PremiumV2_LRS" - """Premium SSD v2 locally redundant storage. Best for production and performance-sensitive - workloads that consistently require low latency and high IOPS and throughput.""" - - -class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of key used to encrypt the data of the disk.""" - - ENCRYPTION_AT_REST_WITH_PLATFORM_KEY = "EncryptionAtRestWithPlatformKey" - """Disk is encrypted at rest with Platform managed key. It is the default encryption type. This is - not a valid encryption type for disk encryption sets.""" - ENCRYPTION_AT_REST_WITH_CUSTOMER_KEY = "EncryptionAtRestWithCustomerKey" - """Disk is encrypted at rest with Customer managed key that can be changed and revoked by a - customer.""" - ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" - """Disk is encrypted at rest with 2 layers of encryption. One of the keys is Customer managed and - the other key is Platform managed.""" - - -class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of extendedLocation.""" - - EDGE_ZONE = "EdgeZone" - - -class FileFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Used to specify the file format when making request for SAS on a VHDX file format snapshot.""" - - VHD = "VHD" - """A VHD file is a disk image file in the Virtual Hard Disk file format.""" - VHDX = "VHDX" - """A VHDX file is a disk image file in the Virtual Hard Disk v2 file format.""" - - -class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The hypervisor generation of the Virtual Machine. Applicable to OS disks only.""" - - V1 = "V1" - V2 = "V2" - - -class NetworkAccessPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Policy for accessing the disk via network.""" - - ALLOW_ALL = "AllowAll" - """The disk can be exported or uploaded to from any network.""" - ALLOW_PRIVATE = "AllowPrivate" - """The disk can be exported or uploaded to using a DiskAccess resource's private endpoints.""" - DENY_ALL = "DenyAll" - """The disk cannot be exported.""" - - -class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The Operating System type.""" - - WINDOWS = "Windows" - LINUX = "Linux" - - -class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current provisioning state.""" - - SUCCEEDED = "Succeeded" - CREATING = "Creating" - DELETING = "Deleting" - FAILED = "Failed" - - -class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The private endpoint connection status.""" - - PENDING = "Pending" - APPROVED = "Approved" - REJECTED = "Rejected" - - -class ProvisionedBandwidthCopyOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """If this field is set on a snapshot and createOption is CopyStart, the snapshot will be copied - at a quicker speed. - """ - - NONE = "None" - ENHANCED = "Enhanced" - - -class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Policy for controlling export on the disk.""" - - ENABLED = "Enabled" - """You can generate a SAS URI to access the underlying data of the disk publicly on the internet - when NetworkAccessPolicy is set to AllowAll. You can access the data via the SAS URI only from - your trusted Azure VNET when NetworkAccessPolicy is set to AllowPrivate.""" - DISABLED = "Disabled" - """You cannot access the underlying data of the disk publicly on the internet even when - NetworkAccessPolicy is set to AllowAll. You can access the data via the SAS URI only from your - trusted Azure VNET when NetworkAccessPolicy is set to AllowPrivate.""" - - -class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The sku name.""" - - STANDARD_LRS = "Standard_LRS" - """Standard HDD locally redundant storage""" - PREMIUM_LRS = "Premium_LRS" - """Premium SSD locally redundant storage""" - STANDARD_ZRS = "Standard_ZRS" - """Standard zone redundant storage""" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/models/_models_py3.py deleted file mode 100644 index a6c3a2cb0fdc..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/models/_models_py3.py +++ /dev/null @@ -1,3204 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -class AccessUri(_serialization.Model): - """A disk access SAS uri. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar access_sas: A SAS uri for accessing a disk. - :vartype access_sas: str - :ivar security_data_access_sas: A SAS uri for accessing a VM guest state. - :vartype security_data_access_sas: str - """ - - _validation = { - "access_sas": {"readonly": True}, - "security_data_access_sas": {"readonly": True}, - } - - _attribute_map = { - "access_sas": {"key": "accessSAS", "type": "str"}, - "security_data_access_sas": {"key": "securityDataAccessSAS", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.access_sas: Optional[str] = None - self.security_data_access_sas: Optional[str] = None - - -class ApiError(_serialization.Model): - """Api error. - - :ivar details: The Api error details. - :vartype details: list[~azure.mgmt.compute.v2023_10_02.models.ApiErrorBase] - :ivar innererror: The Api inner error. - :vartype innererror: ~azure.mgmt.compute.v2023_10_02.models.InnerError - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "details": {"key": "details", "type": "[ApiErrorBase]"}, - "innererror": {"key": "innererror", "type": "InnerError"}, - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - details: Optional[List["_models.ApiErrorBase"]] = None, - innererror: Optional["_models.InnerError"] = None, - code: Optional[str] = None, - target: Optional[str] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword details: The Api error details. - :paramtype details: list[~azure.mgmt.compute.v2023_10_02.models.ApiErrorBase] - :keyword innererror: The Api inner error. - :paramtype innererror: ~azure.mgmt.compute.v2023_10_02.models.InnerError - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.details = details - self.innererror = innererror - self.code = code - self.target = target - self.message = message - - -class ApiErrorBase(_serialization.Model): - """Api error base. - - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.target = target - self.message = message - - -class CopyCompletionError(_serialization.Model): - """Indicates the error details if the background copy of a resource created via the CopyStart - operation fails. - - All required parameters must be populated in order to send to server. - - :ivar error_code: Indicates the error code if the background copy of a resource created via the - CopyStart operation fails. Required. "CopySourceNotFound" - :vartype error_code: str or ~azure.mgmt.compute.v2023_10_02.models.CopyCompletionErrorReason - :ivar error_message: Indicates the error message if the background copy of a resource created - via the CopyStart operation fails. Required. - :vartype error_message: str - """ - - _validation = { - "error_code": {"required": True}, - "error_message": {"required": True}, - } - - _attribute_map = { - "error_code": {"key": "errorCode", "type": "str"}, - "error_message": {"key": "errorMessage", "type": "str"}, - } - - def __init__( - self, *, error_code: Union[str, "_models.CopyCompletionErrorReason"], error_message: str, **kwargs: Any - ) -> None: - """ - :keyword error_code: Indicates the error code if the background copy of a resource created via - the CopyStart operation fails. Required. "CopySourceNotFound" - :paramtype error_code: str or ~azure.mgmt.compute.v2023_10_02.models.CopyCompletionErrorReason - :keyword error_message: Indicates the error message if the background copy of a resource - created via the CopyStart operation fails. Required. - :paramtype error_message: str - """ - super().__init__(**kwargs) - self.error_code = error_code - self.error_message = error_message - - -class CreationData(_serialization.Model): - """Data used when creating a disk. - - 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 create_option: This enumerates the possible sources of a disk's creation. Required. Known - values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", "CopyStart", - "ImportSecure", "UploadPreparedSecure", "CopyFromSanSnapshot", and "Import". - :vartype create_option: str or ~azure.mgmt.compute.v2023_10_02.models.DiskCreateOption - :ivar storage_account_id: Required if createOption is Import. The Azure Resource Manager - identifier of the storage account containing the blob to import as a disk. - :vartype storage_account_id: str - :ivar image_reference: Disk source information for PIR or user images. - :vartype image_reference: ~azure.mgmt.compute.v2023_10_02.models.ImageDiskReference - :ivar gallery_image_reference: Required if creating from a Gallery Image. The - id/sharedGalleryImageId/communityGalleryImageId of the ImageDiskReference will be the ARM id of - the shared galley image version from which to create a disk. - :vartype gallery_image_reference: ~azure.mgmt.compute.v2023_10_02.models.ImageDiskReference - :ivar source_uri: If createOption is Import, this is the URI of a blob to be imported into a - managed disk. - :vartype source_uri: str - :ivar source_resource_id: If createOption is Copy, this is the ARM id of the source snapshot or - disk. - :vartype source_resource_id: str - :ivar source_unique_id: If this field is set, this is the unique id identifying the source of - this resource. - :vartype source_unique_id: str - :ivar upload_size_bytes: If createOption is Upload, this is the size of the contents of the - upload including the VHD footer. This value should be between 20972032 (20 MiB + 512 bytes for - the VHD footer) and 35183298347520 bytes (32 TiB + 512 bytes for the VHD footer). - :vartype upload_size_bytes: int - :ivar logical_sector_size: Logical sector size in bytes for Ultra disks. Supported values are - 512 ad 4096. 4096 is the default. - :vartype logical_sector_size: int - :ivar security_data_uri: If createOption is ImportSecure, this is the URI of a blob to be - imported into VM guest state. - :vartype security_data_uri: str - :ivar performance_plus: Set this flag to true to get a boost on the performance target of the - disk deployed, see here on the respective performance target. This flag can only be set on disk - creation time and cannot be disabled after enabled. - :vartype performance_plus: bool - :ivar elastic_san_resource_id: Required if createOption is CopyFromSanSnapshot. This is the ARM - id of the source elastic san volume snapshot. - :vartype elastic_san_resource_id: str - :ivar provisioned_bandwidth_copy_speed: If this field is set on a snapshot and createOption is - CopyStart, the snapshot will be copied at a quicker speed. Known values are: "None" and - "Enhanced". - :vartype provisioned_bandwidth_copy_speed: str or - ~azure.mgmt.compute.v2023_10_02.models.ProvisionedBandwidthCopyOption - """ - - _validation = { - "create_option": {"required": True}, - "source_unique_id": {"readonly": True}, - } - - _attribute_map = { - "create_option": {"key": "createOption", "type": "str"}, - "storage_account_id": {"key": "storageAccountId", "type": "str"}, - "image_reference": {"key": "imageReference", "type": "ImageDiskReference"}, - "gallery_image_reference": {"key": "galleryImageReference", "type": "ImageDiskReference"}, - "source_uri": {"key": "sourceUri", "type": "str"}, - "source_resource_id": {"key": "sourceResourceId", "type": "str"}, - "source_unique_id": {"key": "sourceUniqueId", "type": "str"}, - "upload_size_bytes": {"key": "uploadSizeBytes", "type": "int"}, - "logical_sector_size": {"key": "logicalSectorSize", "type": "int"}, - "security_data_uri": {"key": "securityDataUri", "type": "str"}, - "performance_plus": {"key": "performancePlus", "type": "bool"}, - "elastic_san_resource_id": {"key": "elasticSanResourceId", "type": "str"}, - "provisioned_bandwidth_copy_speed": {"key": "provisionedBandwidthCopySpeed", "type": "str"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOption"], - storage_account_id: Optional[str] = None, - image_reference: Optional["_models.ImageDiskReference"] = None, - gallery_image_reference: Optional["_models.ImageDiskReference"] = None, - source_uri: Optional[str] = None, - source_resource_id: Optional[str] = None, - upload_size_bytes: Optional[int] = None, - logical_sector_size: Optional[int] = None, - security_data_uri: Optional[str] = None, - performance_plus: Optional[bool] = None, - elastic_san_resource_id: Optional[str] = None, - provisioned_bandwidth_copy_speed: Optional[Union[str, "_models.ProvisionedBandwidthCopyOption"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword create_option: This enumerates the possible sources of a disk's creation. Required. - Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", - "CopyStart", "ImportSecure", "UploadPreparedSecure", "CopyFromSanSnapshot", and "Import". - :paramtype create_option: str or ~azure.mgmt.compute.v2023_10_02.models.DiskCreateOption - :keyword storage_account_id: Required if createOption is Import. The Azure Resource Manager - identifier of the storage account containing the blob to import as a disk. - :paramtype storage_account_id: str - :keyword image_reference: Disk source information for PIR or user images. - :paramtype image_reference: ~azure.mgmt.compute.v2023_10_02.models.ImageDiskReference - :keyword gallery_image_reference: Required if creating from a Gallery Image. The - id/sharedGalleryImageId/communityGalleryImageId of the ImageDiskReference will be the ARM id of - the shared galley image version from which to create a disk. - :paramtype gallery_image_reference: ~azure.mgmt.compute.v2023_10_02.models.ImageDiskReference - :keyword source_uri: If createOption is Import, this is the URI of a blob to be imported into a - managed disk. - :paramtype source_uri: str - :keyword source_resource_id: If createOption is Copy, this is the ARM id of the source snapshot - or disk. - :paramtype source_resource_id: str - :keyword upload_size_bytes: If createOption is Upload, this is the size of the contents of the - upload including the VHD footer. This value should be between 20972032 (20 MiB + 512 bytes for - the VHD footer) and 35183298347520 bytes (32 TiB + 512 bytes for the VHD footer). - :paramtype upload_size_bytes: int - :keyword logical_sector_size: Logical sector size in bytes for Ultra disks. Supported values - are 512 ad 4096. 4096 is the default. - :paramtype logical_sector_size: int - :keyword security_data_uri: If createOption is ImportSecure, this is the URI of a blob to be - imported into VM guest state. - :paramtype security_data_uri: str - :keyword performance_plus: Set this flag to true to get a boost on the performance target of - the disk deployed, see here on the respective performance target. This flag can only be set on - disk creation time and cannot be disabled after enabled. - :paramtype performance_plus: bool - :keyword elastic_san_resource_id: Required if createOption is CopyFromSanSnapshot. This is the - ARM id of the source elastic san volume snapshot. - :paramtype elastic_san_resource_id: str - :keyword provisioned_bandwidth_copy_speed: If this field is set on a snapshot and createOption - is CopyStart, the snapshot will be copied at a quicker speed. Known values are: "None" and - "Enhanced". - :paramtype provisioned_bandwidth_copy_speed: str or - ~azure.mgmt.compute.v2023_10_02.models.ProvisionedBandwidthCopyOption - """ - super().__init__(**kwargs) - self.create_option = create_option - self.storage_account_id = storage_account_id - self.image_reference = image_reference - self.gallery_image_reference = gallery_image_reference - self.source_uri = source_uri - self.source_resource_id = source_resource_id - self.source_unique_id: Optional[str] = None - self.upload_size_bytes = upload_size_bytes - self.logical_sector_size = logical_sector_size - self.security_data_uri = security_data_uri - self.performance_plus = performance_plus - self.elastic_san_resource_id = elastic_san_resource_id - self.provisioned_bandwidth_copy_speed = provisioned_bandwidth_copy_speed - - -class Resource(_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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - - -class Disk(Resource): - """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. - :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] - :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 - disk attached. maxShares should be set to a value greater than one for disks to allow attaching - them to multiple VMs. - :vartype managed_by_extended: list[str] - :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, - Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS. - :vartype sku: ~azure.mgmt.compute.v2023_10_02.models.DiskSku - :ivar zones: The Logical zone list for Disk. - :vartype zones: list[str] - :ivar extended_location: The extended location where the disk will be created. Extended - location cannot be changed. - :vartype extended_location: ~azure.mgmt.compute.v2023_10_02.models.ExtendedLocation - :ivar time_created: The time when the disk was created. - :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2023_10_02.models.OperatingSystemTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2023_10_02.models.HyperVGeneration - :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.v2023_10_02.models.PurchasePlan - :ivar supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :vartype supported_capabilities: ~azure.mgmt.compute.v2023_10_02.models.SupportedCapabilities - :ivar creation_data: Disk source information. CreationData information cannot be changed after - the disk has been created. - :vartype creation_data: ~azure.mgmt.compute.v2023_10_02.models.CreationData - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. - :vartype disk_size_bytes: int - :ivar unique_id: Unique Guid identifying the resource. - :vartype unique_id: str - :ivar encryption_settings_collection: Encryption settings collection used for Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2023_10_02.models.EncryptionSettingsCollection - :ivar provisioning_state: The disk provisioning state. - :vartype provisioning_state: str - :ivar disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :vartype disk_m_bps_read_write: int - :ivar disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_only: int - :ivar disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :vartype disk_m_bps_read_only: int - :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", - "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", and "ActiveUpload". - :vartype disk_state: str or ~azure.mgmt.compute.v2023_10_02.models.DiskState - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2023_10_02.models.Encryption - :ivar max_shares: The maximum number of VMs that can attach to the disk at the same time. Value - greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :vartype max_shares: int - :ivar share_info: Details of the list of all VMs that have the disk attached. maxShares should - be set to a value greater than one for disks to allow attaching them to multiple VMs. - :vartype share_info: list[~azure.mgmt.compute.v2023_10_02.models.ShareInfoElement] - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2023_10_02.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar bursting_enabled_time: Latest time when bursting was last enabled on a disk. - :vartype bursting_enabled_time: ~datetime.datetime - :ivar tier: Performance tier of the disk (e.g, P4, S10) as described here: - https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra - disks. - :vartype tier: str - :ivar bursting_enabled: Set to true to enable bursting beyond the provisioned performance - target of the disk. Bursting is disabled by default. Does not apply to Ultra disks. - :vartype bursting_enabled: bool - :ivar property_updates_in_progress: Properties of the disk for which update is pending. - :vartype property_updates_in_progress: - ~azure.mgmt.compute.v2023_10_02.models.PropertyUpdatesInProgress - :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. - :vartype supports_hibernation: bool - :ivar security_profile: Contains the security related information for the resource. - :vartype security_profile: ~azure.mgmt.compute.v2023_10_02.models.DiskSecurityProfile - :ivar completion_percent: Percentage complete for the background copy when a resource is - created via the CopyStart operation. - :vartype completion_percent: float - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2023_10_02.models.PublicNetworkAccess - :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :vartype data_access_auth_mode: str or - ~azure.mgmt.compute.v2023_10_02.models.DataAccessAuthMode - :ivar optimized_for_frequent_attach: Setting this property to true improves reliability and - performance of data disks that are frequently (more than 5 times a day) by detached from one - virtual machine and attached to another. This property should not be set for disks that are not - detached and attached frequently as it causes the disks to not align with the fault domain of - the virtual machine. - :vartype optimized_for_frequent_attach: bool - :ivar last_ownership_update_time: The UTC time when the ownership state of the disk was last - changed i.e., the time the disk was last attached or detached from a VM or the time when the VM - to which the disk was attached was deallocated or started. - :vartype last_ownership_update_time: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "managed_by": {"readonly": True}, - "managed_by_extended": {"readonly": True}, - "time_created": {"readonly": True}, - "disk_size_bytes": {"readonly": True}, - "unique_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "disk_state": {"readonly": True}, - "share_info": {"readonly": True}, - "bursting_enabled_time": {"readonly": True}, - "property_updates_in_progress": {"readonly": True}, - "last_ownership_update_time": {"readonly": 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}"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "managed_by_extended": {"key": "managedByExtended", "type": "[str]"}, - "sku": {"key": "sku", "type": "DiskSku"}, - "zones": {"key": "zones", "type": "[str]"}, - "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"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - "creation_data": {"key": "properties.creationData", "type": "CreationData"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "disk_size_bytes": {"key": "properties.diskSizeBytes", "type": "int"}, - "unique_id": {"key": "properties.uniqueId", "type": "str"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "disk_iops_read_write": {"key": "properties.diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "properties.diskMBpsReadWrite", "type": "int"}, - "disk_iops_read_only": {"key": "properties.diskIOPSReadOnly", "type": "int"}, - "disk_m_bps_read_only": {"key": "properties.diskMBpsReadOnly", "type": "int"}, - "disk_state": {"key": "properties.diskState", "type": "str"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "max_shares": {"key": "properties.maxShares", "type": "int"}, - "share_info": {"key": "properties.shareInfo", "type": "[ShareInfoElement]"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - "bursting_enabled_time": {"key": "properties.burstingEnabledTime", "type": "iso-8601"}, - "tier": {"key": "properties.tier", "type": "str"}, - "bursting_enabled": {"key": "properties.burstingEnabled", "type": "bool"}, - "property_updates_in_progress": { - "key": "properties.propertyUpdatesInProgress", - "type": "PropertyUpdatesInProgress", - }, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "security_profile": {"key": "properties.securityProfile", "type": "DiskSecurityProfile"}, - "completion_percent": {"key": "properties.completionPercent", "type": "float"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, - "optimized_for_frequent_attach": {"key": "properties.optimizedForFrequentAttach", "type": "bool"}, - "last_ownership_update_time": {"key": "properties.LastOwnershipUpdateTime", "type": "iso-8601"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.DiskSku"] = None, - zones: Optional[List[str]] = None, - 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, - supported_capabilities: Optional["_models.SupportedCapabilities"] = None, - creation_data: Optional["_models.CreationData"] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - disk_iops_read_write: Optional[int] = None, - disk_m_bps_read_write: Optional[int] = None, - disk_iops_read_only: Optional[int] = None, - disk_m_bps_read_only: Optional[int] = None, - encryption: Optional["_models.Encryption"] = None, - max_shares: Optional[int] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - tier: Optional[str] = None, - bursting_enabled: Optional[bool] = None, - supports_hibernation: Optional[bool] = None, - security_profile: Optional["_models.DiskSecurityProfile"] = None, - completion_percent: Optional[float] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, - optimized_for_frequent_attach: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2023_10_02.models.DiskSku - :keyword zones: The Logical zone list for Disk. - :paramtype zones: list[str] - :keyword extended_location: The extended location where the disk will be created. Extended - location cannot be changed. - :paramtype extended_location: ~azure.mgmt.compute.v2023_10_02.models.ExtendedLocation - :keyword os_type: The Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2023_10_02.models.OperatingSystemTypes - :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_10_02.models.HyperVGeneration - :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.v2023_10_02.models.PurchasePlan - :keyword supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :paramtype supported_capabilities: ~azure.mgmt.compute.v2023_10_02.models.SupportedCapabilities - :keyword creation_data: Disk source information. CreationData information cannot be changed - after the disk has been created. - :paramtype creation_data: ~azure.mgmt.compute.v2023_10_02.models.CreationData - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used for Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2023_10_02.models.EncryptionSettingsCollection - :keyword disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_write: int - :keyword disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :paramtype disk_m_bps_read_write: int - :keyword disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_only: int - :keyword disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :paramtype disk_m_bps_read_only: int - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2023_10_02.models.Encryption - :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. - Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :paramtype max_shares: int - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2023_10_02.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword tier: Performance tier of the disk (e.g, P4, S10) as described here: - https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra - disks. - :paramtype tier: str - :keyword bursting_enabled: Set to true to enable bursting beyond the provisioned performance - target of the disk. Bursting is disabled by default. Does not apply to Ultra disks. - :paramtype bursting_enabled: bool - :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. - :paramtype supports_hibernation: bool - :keyword security_profile: Contains the security related information for the resource. - :paramtype security_profile: ~azure.mgmt.compute.v2023_10_02.models.DiskSecurityProfile - :keyword completion_percent: Percentage complete for the background copy when a resource is - created via the CopyStart operation. - :paramtype completion_percent: float - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2023_10_02.models.PublicNetworkAccess - :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :paramtype data_access_auth_mode: str or - ~azure.mgmt.compute.v2023_10_02.models.DataAccessAuthMode - :keyword optimized_for_frequent_attach: Setting this property to true improves reliability and - performance of data disks that are frequently (more than 5 times a day) by detached from one - virtual machine and attached to another. This property should not be set for disks that are not - detached and attached frequently as it causes the disks to not align with the fault domain of - the virtual machine. - :paramtype optimized_for_frequent_attach: bool - """ - super().__init__(location=location, tags=tags, **kwargs) - self.managed_by: Optional[str] = None - self.managed_by_extended: Optional[List[str]] = None - self.sku = sku - self.zones = zones - self.extended_location = extended_location - self.time_created: Optional[datetime.datetime] = None - self.os_type = os_type - self.hyper_v_generation = hyper_v_generation - self.purchase_plan = purchase_plan - self.supported_capabilities = supported_capabilities - self.creation_data = creation_data - self.disk_size_gb = disk_size_gb - self.disk_size_bytes: Optional[int] = None - self.unique_id: Optional[str] = None - self.encryption_settings_collection = encryption_settings_collection - self.provisioning_state: Optional[str] = None - self.disk_iops_read_write = disk_iops_read_write - self.disk_m_bps_read_write = disk_m_bps_read_write - self.disk_iops_read_only = disk_iops_read_only - self.disk_m_bps_read_only = disk_m_bps_read_only - self.disk_state: Optional[Union[str, "_models.DiskState"]] = None - self.encryption = encryption - self.max_shares = max_shares - self.share_info: Optional[List["_models.ShareInfoElement"]] = None - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - self.bursting_enabled_time: Optional[datetime.datetime] = None - self.tier = tier - self.bursting_enabled = bursting_enabled - self.property_updates_in_progress: Optional["_models.PropertyUpdatesInProgress"] = None - self.supports_hibernation = supports_hibernation - self.security_profile = security_profile - self.completion_percent = completion_percent - self.public_network_access = public_network_access - self.data_access_auth_mode = data_access_auth_mode - self.optimized_for_frequent_attach = optimized_for_frequent_attach - self.last_ownership_update_time: Optional[datetime.datetime] = None - - -class DiskAccess(Resource): - """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. - :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] - :ivar extended_location: The extended location where the disk access will be created. Extended - location cannot be changed. - :vartype extended_location: ~azure.mgmt.compute.v2023_10_02.models.ExtendedLocation - :ivar private_endpoint_connections: A readonly collection of private endpoint connections - created on the disk. Currently only one endpoint connection is supported. - :vartype private_endpoint_connections: - list[~azure.mgmt.compute.v2023_10_02.models.PrivateEndpointConnection] - :ivar provisioning_state: The disk access resource provisioning state. - :vartype provisioning_state: str - :ivar time_created: The time when the disk access was created. - :vartype time_created: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "private_endpoint_connections": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "time_created": {"readonly": 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}"}, - "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - "private_endpoint_connections": { - "key": "properties.privateEndpointConnections", - "type": "[PrivateEndpointConnection]", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - extended_location: Optional["_models.ExtendedLocation"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2023_10_02.models.ExtendedLocation - """ - super().__init__(location=location, tags=tags, **kwargs) - self.extended_location = extended_location - self.private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None - self.provisioning_state: Optional[str] = None - self.time_created: Optional[datetime.datetime] = None - - -class DiskAccessList(_serialization.Model): - """The List disk access operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of disk access resources. Required. - :vartype value: list[~azure.mgmt.compute.v2023_10_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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DiskAccess]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.DiskAccess"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of disk access resources. Required. - :paramtype value: list[~azure.mgmt.compute.v2023_10_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DiskAccessUpdate(_serialization.Model): - """Used for updating a disk access resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class DiskEncryptionSet(Resource): - """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. - :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] - :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.v2023_10_02.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and - "ConfidentialVmEncryptedWithCustomerKey". - :vartype encryption_type: str or ~azure.mgmt.compute.v2023_10_02.models.DiskEncryptionSetType - :ivar active_key: The key vault key which is currently used by this disk encryption set. - :vartype active_key: ~azure.mgmt.compute.v2023_10_02.models.KeyForDiskEncryptionSet - :ivar previous_keys: A readonly collection of key vault keys previously used by this disk - encryption set while a key rotation is in progress. It will be empty if there is no ongoing key - rotation. - :vartype previous_keys: list[~azure.mgmt.compute.v2023_10_02.models.KeyForDiskEncryptionSet] - :ivar provisioning_state: The disk encryption set provisioning state. - :vartype provisioning_state: str - :ivar rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating of - this disk encryption set to the latest key version. - :vartype rotation_to_latest_key_version_enabled: bool - :ivar last_key_rotation_timestamp: The time when the active key of this disk encryption set was - updated. - :vartype last_key_rotation_timestamp: ~datetime.datetime - :ivar auto_key_rotation_error: The error that was encountered during auto-key rotation. If an - error is present, then auto-key rotation will not be attempted until the error on this disk - encryption set is fixed. - :vartype auto_key_rotation_error: ~azure.mgmt.compute.v2023_10_02.models.ApiError - :ivar federated_client_id: Multi-tenant application client id to access key vault in a - different tenant. Setting the value to 'None' will clear the property. - :vartype federated_client_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "previous_keys": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "last_key_rotation_timestamp": {"readonly": True}, - "auto_key_rotation_error": {"readonly": 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}"}, - "identity": {"key": "identity", "type": "EncryptionSetIdentity"}, - "encryption_type": {"key": "properties.encryptionType", "type": "str"}, - "active_key": {"key": "properties.activeKey", "type": "KeyForDiskEncryptionSet"}, - "previous_keys": {"key": "properties.previousKeys", "type": "[KeyForDiskEncryptionSet]"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "rotation_to_latest_key_version_enabled": { - "key": "properties.rotationToLatestKeyVersionEnabled", - "type": "bool", - }, - "last_key_rotation_timestamp": {"key": "properties.lastKeyRotationTimestamp", "type": "iso-8601"}, - "auto_key_rotation_error": {"key": "properties.autoKeyRotationError", "type": "ApiError"}, - "federated_client_id": {"key": "properties.federatedClientId", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, - active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, - rotation_to_latest_key_version_enabled: Optional[bool] = None, - federated_client_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2023_10_02.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values - are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and - "ConfidentialVmEncryptedWithCustomerKey". - :paramtype encryption_type: str or ~azure.mgmt.compute.v2023_10_02.models.DiskEncryptionSetType - :keyword active_key: The key vault key which is currently used by this disk encryption set. - :paramtype active_key: ~azure.mgmt.compute.v2023_10_02.models.KeyForDiskEncryptionSet - :keyword rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating - of this disk encryption set to the latest key version. - :paramtype rotation_to_latest_key_version_enabled: bool - :keyword federated_client_id: Multi-tenant application client id to access key vault in a - different tenant. Setting the value to 'None' will clear the property. - :paramtype federated_client_id: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.identity = identity - self.encryption_type = encryption_type - self.active_key = active_key - self.previous_keys: Optional[List["_models.KeyForDiskEncryptionSet"]] = None - self.provisioning_state: Optional[str] = None - self.rotation_to_latest_key_version_enabled = rotation_to_latest_key_version_enabled - self.last_key_rotation_timestamp: Optional[datetime.datetime] = None - self.auto_key_rotation_error: Optional["_models.ApiError"] = None - self.federated_client_id = federated_client_id - - -class DiskEncryptionSetList(_serialization.Model): - """The List disk encryption set operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of disk encryption sets. Required. - :vartype value: list[~azure.mgmt.compute.v2023_10_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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DiskEncryptionSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DiskEncryptionSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of disk encryption sets. Required. - :paramtype value: list[~azure.mgmt.compute.v2023_10_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DiskEncryptionSetUpdate(_serialization.Model): - """disk encryption set update resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, 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.v2023_10_02.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and - "ConfidentialVmEncryptedWithCustomerKey". - :vartype encryption_type: str or ~azure.mgmt.compute.v2023_10_02.models.DiskEncryptionSetType - :ivar active_key: Key Vault Key Url to be used for server side encryption of Managed Disks and - Snapshots. - :vartype active_key: ~azure.mgmt.compute.v2023_10_02.models.KeyForDiskEncryptionSet - :ivar rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating of - this disk encryption set to the latest key version. - :vartype rotation_to_latest_key_version_enabled: bool - :ivar federated_client_id: Multi-tenant application client id to access key vault in a - different tenant. Setting the value to 'None' will clear the property. - :vartype federated_client_id: str - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "identity": {"key": "identity", "type": "EncryptionSetIdentity"}, - "encryption_type": {"key": "properties.encryptionType", "type": "str"}, - "active_key": {"key": "properties.activeKey", "type": "KeyForDiskEncryptionSet"}, - "rotation_to_latest_key_version_enabled": { - "key": "properties.rotationToLatestKeyVersionEnabled", - "type": "bool", - }, - "federated_client_id": {"key": "properties.federatedClientId", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, - active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, - rotation_to_latest_key_version_enabled: Optional[bool] = None, - federated_client_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2023_10_02.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values - are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and - "ConfidentialVmEncryptedWithCustomerKey". - :paramtype encryption_type: str or ~azure.mgmt.compute.v2023_10_02.models.DiskEncryptionSetType - :keyword active_key: Key Vault Key Url to be used for server side encryption of Managed Disks - and Snapshots. - :paramtype active_key: ~azure.mgmt.compute.v2023_10_02.models.KeyForDiskEncryptionSet - :keyword rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating - of this disk encryption set to the latest key version. - :paramtype rotation_to_latest_key_version_enabled: bool - :keyword federated_client_id: Multi-tenant application client id to access key vault in a - different tenant. Setting the value to 'None' will clear the property. - :paramtype federated_client_id: str - """ - super().__init__(**kwargs) - self.tags = tags - self.identity = identity - self.encryption_type = encryption_type - self.active_key = active_key - self.rotation_to_latest_key_version_enabled = rotation_to_latest_key_version_enabled - self.federated_client_id = federated_client_id - - -class DiskList(_serialization.Model): - """The List Disks operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of disks. Required. - :vartype value: list[~azure.mgmt.compute.v2023_10_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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Disk]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of disks. Required. - :paramtype value: list[~azure.mgmt.compute.v2023_10_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ProxyOnlyResource(_serialization.Model): - """The ProxyOnly Resource model definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - - -class DiskRestorePoint(ProxyOnlyResource): - """Properties of disk restore point. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :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. - :vartype source_resource_id: str - :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2023_10_02.models.OperatingSystemTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2023_10_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.v2023_10_02.models.PurchasePlan - :ivar supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :vartype supported_capabilities: ~azure.mgmt.compute.v2023_10_02.models.SupportedCapabilities - :ivar family_id: id of the backing snapshot's MIS family. - :vartype family_id: str - :ivar source_unique_id: unique incarnation id of the source disk. - :vartype source_unique_id: str - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2023_10_02.models.Encryption - :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. - :vartype supports_hibernation: bool - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2023_10_02.models.NetworkAccessPolicy - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2023_10_02.models.PublicNetworkAccess - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar completion_percent: Percentage complete for the background copy of disk restore point - when source resource is from a different region. - :vartype completion_percent: float - :ivar replication_state: Replication state of disk restore point when source resource is from a - different region. - :vartype replication_state: str - :ivar source_resource_location: Location of source disk or source disk restore point when - source resource is from a different region. - :vartype source_resource_location: str - :ivar security_profile: Contains the security related information for the resource. - :vartype security_profile: ~azure.mgmt.compute.v2023_10_02.models.DiskSecurityProfile - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "time_created": {"readonly": True}, - "source_resource_id": {"readonly": True}, - "os_type": {"readonly": True}, - "family_id": {"readonly": True}, - "source_unique_id": {"readonly": True}, - "encryption": {"readonly": True}, - "replication_state": {"readonly": True}, - "source_resource_location": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "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"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - "family_id": {"key": "properties.familyId", "type": "str"}, - "source_unique_id": {"key": "properties.sourceUniqueId", "type": "str"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - "completion_percent": {"key": "properties.completionPercent", "type": "float"}, - "replication_state": {"key": "properties.replicationState", "type": "str"}, - "source_resource_location": {"key": "properties.sourceResourceLocation", "type": "str"}, - "security_profile": {"key": "properties.securityProfile", "type": "DiskSecurityProfile"}, - } - - def __init__( - self, - *, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - purchase_plan: Optional["_models.PurchasePlan"] = None, - supported_capabilities: Optional["_models.SupportedCapabilities"] = None, - supports_hibernation: Optional[bool] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - disk_access_id: Optional[str] = None, - completion_percent: Optional[float] = None, - security_profile: Optional["_models.DiskSecurityProfile"] = None, - **kwargs: Any - ) -> None: - """ - :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_10_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.v2023_10_02.models.PurchasePlan - :keyword supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :paramtype supported_capabilities: ~azure.mgmt.compute.v2023_10_02.models.SupportedCapabilities - :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. - :paramtype supports_hibernation: bool - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2023_10_02.models.NetworkAccessPolicy - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2023_10_02.models.PublicNetworkAccess - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword completion_percent: Percentage complete for the background copy of disk restore point - when source resource is from a different region. - :paramtype completion_percent: float - :keyword security_profile: Contains the security related information for the resource. - :paramtype security_profile: ~azure.mgmt.compute.v2023_10_02.models.DiskSecurityProfile - """ - super().__init__(**kwargs) - self.time_created: Optional[datetime.datetime] = None - self.source_resource_id: Optional[str] = None - self.os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None - self.hyper_v_generation = hyper_v_generation - self.purchase_plan = purchase_plan - self.supported_capabilities = supported_capabilities - self.family_id: Optional[str] = None - self.source_unique_id: Optional[str] = None - self.encryption: Optional["_models.Encryption"] = None - self.supports_hibernation = supports_hibernation - self.network_access_policy = network_access_policy - self.public_network_access = public_network_access - self.disk_access_id = disk_access_id - self.completion_percent = completion_percent - self.replication_state: Optional[str] = None - self.source_resource_location: Optional[str] = None - self.security_profile = security_profile - - -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.v2023_10_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.v2023_10_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. - - :ivar security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. Known - values are: "TrustedLaunch", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", - "ConfidentialVM_DiskEncryptedWithPlatformKey", "ConfidentialVM_DiskEncryptedWithCustomerKey", - and "ConfidentialVM_NonPersistedTPM". - :vartype security_type: str or ~azure.mgmt.compute.v2023_10_02.models.DiskSecurityTypes - :ivar secure_vm_disk_encryption_set_id: ResourceId of the disk encryption set associated to - Confidential VM supported disk encrypted with customer managed key. - :vartype secure_vm_disk_encryption_set_id: str - """ - - _attribute_map = { - "security_type": {"key": "securityType", "type": "str"}, - "secure_vm_disk_encryption_set_id": {"key": "secureVMDiskEncryptionSetId", "type": "str"}, - } - - def __init__( - self, - *, - security_type: Optional[Union[str, "_models.DiskSecurityTypes"]] = None, - secure_vm_disk_encryption_set_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. - Known values are: "TrustedLaunch", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", - "ConfidentialVM_DiskEncryptedWithPlatformKey", "ConfidentialVM_DiskEncryptedWithCustomerKey", - and "ConfidentialVM_NonPersistedTPM". - :paramtype security_type: str or ~azure.mgmt.compute.v2023_10_02.models.DiskSecurityTypes - :keyword secure_vm_disk_encryption_set_id: ResourceId of the disk encryption set associated to - Confidential VM supported disk encrypted with customer managed key. - :paramtype secure_vm_disk_encryption_set_id: str - """ - super().__init__(**kwargs) - self.security_type = security_type - self.secure_vm_disk_encryption_set_id = secure_vm_disk_encryption_set_id - - -class DiskSku(_serialization.Model): - """The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, - Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", - "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", and "PremiumV2_LRS". - :vartype name: str or ~azure.mgmt.compute.v2023_10_02.models.DiskStorageAccountTypes - :ivar tier: The sku tier. - :vartype tier: str - """ - - _validation = { - "tier": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__(self, *, name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs: Any) -> None: - """ - :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", and "PremiumV2_LRS". - :paramtype name: str or ~azure.mgmt.compute.v2023_10_02.models.DiskStorageAccountTypes - """ - super().__init__(**kwargs) - self.name = name - self.tier: Optional[str] = None - - -class DiskUpdate(_serialization.Model): - """Disk update resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, - Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS. - :vartype sku: ~azure.mgmt.compute.v2023_10_02.models.DiskSku - :ivar os_type: the Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2023_10_02.models.OperatingSystemTypes - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2023_10_02.models.EncryptionSettingsCollection - :ivar disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :vartype disk_m_bps_read_write: int - :ivar disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_only: int - :ivar disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :vartype disk_m_bps_read_only: int - :ivar max_shares: The maximum number of VMs that can attach to the disk at the same time. Value - greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :vartype max_shares: int - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2023_10_02.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2023_10_02.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar tier: Performance tier of the disk (e.g, P4, S10) as described here: - https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra - disks. - :vartype tier: str - :ivar bursting_enabled: Set to true to enable bursting beyond the provisioned performance - 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.v2023_10_02.models.PurchasePlan - :ivar supported_capabilities: List of supported capabilities to be added on the OS disk. - :vartype supported_capabilities: ~azure.mgmt.compute.v2023_10_02.models.SupportedCapabilities - :ivar property_updates_in_progress: Properties of the disk for which update is pending. - :vartype property_updates_in_progress: - ~azure.mgmt.compute.v2023_10_02.models.PropertyUpdatesInProgress - :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. - :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2023_10_02.models.PublicNetworkAccess - :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :vartype data_access_auth_mode: str or - ~azure.mgmt.compute.v2023_10_02.models.DataAccessAuthMode - :ivar optimized_for_frequent_attach: Setting this property to true improves reliability and - performance of data disks that are frequently (more than 5 times a day) by detached from one - virtual machine and attached to another. This property should not be set for disks that are not - detached and attached frequently as it causes the disks to not align with the fault domain of - the virtual machine. - :vartype optimized_for_frequent_attach: bool - """ - - _validation = { - "property_updates_in_progress": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "DiskSku"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "disk_iops_read_write": {"key": "properties.diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "properties.diskMBpsReadWrite", "type": "int"}, - "disk_iops_read_only": {"key": "properties.diskIOPSReadOnly", "type": "int"}, - "disk_m_bps_read_only": {"key": "properties.diskMBpsReadOnly", "type": "int"}, - "max_shares": {"key": "properties.maxShares", "type": "int"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "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"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - "property_updates_in_progress": { - "key": "properties.propertyUpdatesInProgress", - "type": "PropertyUpdatesInProgress", - }, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, - "optimized_for_frequent_attach": {"key": "properties.optimizedForFrequentAttach", "type": "bool"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.DiskSku"] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - disk_iops_read_write: Optional[int] = None, - disk_m_bps_read_write: Optional[int] = None, - disk_iops_read_only: Optional[int] = None, - disk_m_bps_read_only: Optional[int] = None, - max_shares: Optional[int] = None, - encryption: Optional["_models.Encryption"] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - tier: Optional[str] = None, - bursting_enabled: Optional[bool] = None, - purchase_plan: Optional["_models.PurchasePlan"] = None, - supported_capabilities: Optional["_models.SupportedCapabilities"] = None, - supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, - optimized_for_frequent_attach: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2023_10_02.models.DiskSku - :keyword os_type: the Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2023_10_02.models.OperatingSystemTypes - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2023_10_02.models.EncryptionSettingsCollection - :keyword disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_write: int - :keyword disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :paramtype disk_m_bps_read_write: int - :keyword disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_only: int - :keyword disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :paramtype disk_m_bps_read_only: int - :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. - Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :paramtype max_shares: int - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2023_10_02.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2023_10_02.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword tier: Performance tier of the disk (e.g, P4, S10) as described here: - https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra - disks. - :paramtype tier: str - :keyword bursting_enabled: Set to true to enable bursting beyond the provisioned performance - 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.v2023_10_02.models.PurchasePlan - :keyword supported_capabilities: List of supported capabilities to be added on the OS disk. - :paramtype supported_capabilities: ~azure.mgmt.compute.v2023_10_02.models.SupportedCapabilities - :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. - :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2023_10_02.models.PublicNetworkAccess - :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :paramtype data_access_auth_mode: str or - ~azure.mgmt.compute.v2023_10_02.models.DataAccessAuthMode - :keyword optimized_for_frequent_attach: Setting this property to true improves reliability and - performance of data disks that are frequently (more than 5 times a day) by detached from one - virtual machine and attached to another. This property should not be set for disks that are not - detached and attached frequently as it causes the disks to not align with the fault domain of - the virtual machine. - :paramtype optimized_for_frequent_attach: bool - """ - super().__init__(**kwargs) - self.tags = tags - self.sku = sku - self.os_type = os_type - self.disk_size_gb = disk_size_gb - self.encryption_settings_collection = encryption_settings_collection - self.disk_iops_read_write = disk_iops_read_write - self.disk_m_bps_read_write = disk_m_bps_read_write - self.disk_iops_read_only = disk_iops_read_only - self.disk_m_bps_read_only = disk_m_bps_read_only - self.max_shares = max_shares - self.encryption = encryption - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - self.tier = tier - self.bursting_enabled = bursting_enabled - self.purchase_plan = purchase_plan - self.supported_capabilities = supported_capabilities - self.property_updates_in_progress: Optional["_models.PropertyUpdatesInProgress"] = None - self.supports_hibernation = supports_hibernation - self.public_network_access = public_network_access - self.data_access_auth_mode = data_access_auth_mode - self.optimized_for_frequent_attach = optimized_for_frequent_attach - - -class Encryption(_serialization.Model): - """Encryption at rest settings for disk or snapshot. - - :ivar disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling - encryption at rest. - :vartype disk_encryption_set_id: str - :ivar type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and - "EncryptionAtRestWithPlatformAndCustomerKeys". - :vartype type: str or ~azure.mgmt.compute.v2023_10_02.models.EncryptionType - """ - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - disk_encryption_set_id: Optional[str] = None, - type: Optional[Union[str, "_models.EncryptionType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling - encryption at rest. - :paramtype disk_encryption_set_id: str - :keyword type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and - "EncryptionAtRestWithPlatformAndCustomerKeys". - :paramtype type: str or ~azure.mgmt.compute.v2023_10_02.models.EncryptionType - """ - super().__init__(**kwargs) - self.disk_encryption_set_id = disk_encryption_set_id - self.type = type - - -class EncryptionSetIdentity(_serialization.Model): - """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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is - supported for new creations. Disk Encryption Sets can be updated with Identity type None during - migration of subscription to a new Azure Active Directory tenant; it will cause the encrypted - resources to lose access to the keys. Known values are: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", and "None". - :vartype type: str or ~azure.mgmt.compute.v2023_10_02.models.DiskEncryptionSetIdentityType - :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-client-tenant-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype tenant_id: str - :ivar user_assigned_identities: The list of user identities associated with the disk encryption - set. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2023_10_02.models.UserAssignedIdentitiesValue] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentitiesValue}"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.DiskEncryptionSetIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned - is supported for new creations. Disk Encryption Sets can be updated with Identity type None - during migration of subscription to a new Azure Active Directory tenant; it will cause the - encrypted resources to lose access to the keys. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :paramtype type: str or ~azure.mgmt.compute.v2023_10_02.models.DiskEncryptionSetIdentityType - :keyword user_assigned_identities: The list of user identities associated with the disk - encryption set. The user identity dictionary key references will be ARM resource ids in the - form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2023_10_02.models.UserAssignedIdentitiesValue] - """ - super().__init__(**kwargs) - self.type = type - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.user_assigned_identities = user_assigned_identities - - -class EncryptionSettingsCollection(_serialization.Model): - """Encryption settings for disk or snapshot. - - All required parameters must be populated in order to send to server. - - :ivar enabled: Set this flag to true and provide DiskEncryptionKey and optional - KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and - KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, - the existing settings remain unchanged. Required. - :vartype enabled: bool - :ivar encryption_settings: A collection of encryption settings, one for each disk volume. - :vartype encryption_settings: - list[~azure.mgmt.compute.v2023_10_02.models.EncryptionSettingsElement] - :ivar encryption_settings_version: Describes what type of encryption is used for the disks. - Once this field is set, it cannot be overwritten. '1.0' corresponds to Azure Disk Encryption - with AAD app.'1.1' corresponds to Azure Disk Encryption. - :vartype encryption_settings_version: str - """ - - _validation = { - "enabled": {"required": True}, - } - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "encryption_settings": {"key": "encryptionSettings", "type": "[EncryptionSettingsElement]"}, - "encryption_settings_version": {"key": "encryptionSettingsVersion", "type": "str"}, - } - - def __init__( - self, - *, - enabled: bool, - encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, - encryption_settings_version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Set this flag to true and provide DiskEncryptionKey and optional - KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and - KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, - the existing settings remain unchanged. Required. - :paramtype enabled: bool - :keyword encryption_settings: A collection of encryption settings, one for each disk volume. - :paramtype encryption_settings: - list[~azure.mgmt.compute.v2023_10_02.models.EncryptionSettingsElement] - :keyword encryption_settings_version: Describes what type of encryption is used for the disks. - Once this field is set, it cannot be overwritten. '1.0' corresponds to Azure Disk Encryption - with AAD app.'1.1' corresponds to Azure Disk Encryption. - :paramtype encryption_settings_version: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.encryption_settings = encryption_settings - self.encryption_settings_version = encryption_settings_version - - -class EncryptionSettingsElement(_serialization.Model): - """Encryption settings for one disk volume. - - :ivar disk_encryption_key: Key Vault Secret Url and vault id of the disk encryption key. - :vartype disk_encryption_key: ~azure.mgmt.compute.v2023_10_02.models.KeyVaultAndSecretReference - :ivar key_encryption_key: Key Vault Key Url and vault id of the key encryption key. - KeyEncryptionKey is optional and when provided is used to unwrap the disk encryption key. - :vartype key_encryption_key: ~azure.mgmt.compute.v2023_10_02.models.KeyVaultAndKeyReference - """ - - _attribute_map = { - "disk_encryption_key": {"key": "diskEncryptionKey", "type": "KeyVaultAndSecretReference"}, - "key_encryption_key": {"key": "keyEncryptionKey", "type": "KeyVaultAndKeyReference"}, - } - - def __init__( - self, - *, - disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_key: Key Vault Secret Url and vault id of the disk encryption key. - :paramtype disk_encryption_key: - ~azure.mgmt.compute.v2023_10_02.models.KeyVaultAndSecretReference - :keyword key_encryption_key: Key Vault Key Url and vault id of the key encryption key. - KeyEncryptionKey is optional and when provided is used to unwrap the disk encryption key. - :paramtype key_encryption_key: ~azure.mgmt.compute.v2023_10_02.models.KeyVaultAndKeyReference - """ - super().__init__(**kwargs) - self.disk_encryption_key = disk_encryption_key - self.key_encryption_key = key_encryption_key - - -class ExtendedLocation(_serialization.Model): - """The complex type of the extended location. - - :ivar name: The name of the extended location. - :vartype name: str - :ivar type: The type of the extended location. "EdgeZone" - :vartype type: str or ~azure.mgmt.compute.v2023_10_02.models.ExtendedLocationTypes - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the extended location. - :paramtype name: str - :keyword type: The type of the extended location. "EdgeZone" - :paramtype type: str or ~azure.mgmt.compute.v2023_10_02.models.ExtendedLocationTypes - """ - super().__init__(**kwargs) - self.name = name - self.type = type - - -class GrantAccessData(_serialization.Model): - """Data used for requesting a SAS. - - All required parameters must be populated in order to send to server. - - :ivar access: Required. Known values are: "None", "Read", and "Write". - :vartype access: str or ~azure.mgmt.compute.v2023_10_02.models.AccessLevel - :ivar duration_in_seconds: Time duration in seconds until the SAS access expires. Required. - :vartype duration_in_seconds: int - :ivar get_secure_vm_guest_state_sas: Set this flag to true to get additional SAS for VM guest - state. - :vartype get_secure_vm_guest_state_sas: bool - :ivar file_format: Used to specify the file format when making request for SAS on a VHDX file - format snapshot. Known values are: "VHD" and "VHDX". - :vartype file_format: str or ~azure.mgmt.compute.v2023_10_02.models.FileFormat - """ - - _validation = { - "access": {"required": True}, - "duration_in_seconds": {"required": True}, - } - - _attribute_map = { - "access": {"key": "access", "type": "str"}, - "duration_in_seconds": {"key": "durationInSeconds", "type": "int"}, - "get_secure_vm_guest_state_sas": {"key": "getSecureVMGuestStateSAS", "type": "bool"}, - "file_format": {"key": "fileFormat", "type": "str"}, - } - - def __init__( - self, - *, - access: Union[str, "_models.AccessLevel"], - duration_in_seconds: int, - get_secure_vm_guest_state_sas: Optional[bool] = None, - file_format: Optional[Union[str, "_models.FileFormat"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword access: Required. Known values are: "None", "Read", and "Write". - :paramtype access: str or ~azure.mgmt.compute.v2023_10_02.models.AccessLevel - :keyword duration_in_seconds: Time duration in seconds until the SAS access expires. Required. - :paramtype duration_in_seconds: int - :keyword get_secure_vm_guest_state_sas: Set this flag to true to get additional SAS for VM - guest state. - :paramtype get_secure_vm_guest_state_sas: bool - :keyword file_format: Used to specify the file format when making request for SAS on a VHDX - file format snapshot. Known values are: "VHD" and "VHDX". - :paramtype file_format: str or ~azure.mgmt.compute.v2023_10_02.models.FileFormat - """ - super().__init__(**kwargs) - self.access = access - self.duration_in_seconds = duration_in_seconds - self.get_secure_vm_guest_state_sas = get_secure_vm_guest_state_sas - self.file_format = file_format - - -class ImageDiskReference(_serialization.Model): - """The source image used for creating the disk. - - :ivar id: A relative uri containing either a Platform Image Repository, user image, or Azure - Compute Gallery image reference. - :vartype id: str - :ivar shared_gallery_image_id: A relative uri containing a direct shared Azure Compute Gallery - image reference. - :vartype shared_gallery_image_id: str - :ivar community_gallery_image_id: A relative uri containing a community Azure Compute Gallery - image reference. - :vartype community_gallery_image_id: str - :ivar lun: If the disk is created from an image's data disk, this is an index that indicates - which of the data disks in the image to use. For OS disks, this field is null. - :vartype lun: int - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "shared_gallery_image_id": {"key": "sharedGalleryImageId", "type": "str"}, - "community_gallery_image_id": {"key": "communityGalleryImageId", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - shared_gallery_image_id: Optional[str] = None, - community_gallery_image_id: Optional[str] = None, - lun: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: A relative uri containing either a Platform Image Repository, user image, or Azure - Compute Gallery image reference. - :paramtype id: str - :keyword shared_gallery_image_id: A relative uri containing a direct shared Azure Compute - Gallery image reference. - :paramtype shared_gallery_image_id: str - :keyword community_gallery_image_id: A relative uri containing a community Azure Compute - Gallery image reference. - :paramtype community_gallery_image_id: str - :keyword lun: If the disk is created from an image's data disk, this is an index that indicates - which of the data disks in the image to use. For OS disks, this field is null. - :paramtype lun: int - """ - super().__init__(**kwargs) - self.id = id - self.shared_gallery_image_id = shared_gallery_image_id - self.community_gallery_image_id = community_gallery_image_id - self.lun = lun - - -class InnerError(_serialization.Model): - """Inner error details. - - :ivar exceptiontype: The exception type. - :vartype exceptiontype: str - :ivar errordetail: The internal error message or exception dump. - :vartype errordetail: str - """ - - _attribute_map = { - "exceptiontype": {"key": "exceptiontype", "type": "str"}, - "errordetail": {"key": "errordetail", "type": "str"}, - } - - def __init__( - self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword exceptiontype: The exception type. - :paramtype exceptiontype: str - :keyword errordetail: The internal error message or exception dump. - :paramtype errordetail: str - """ - super().__init__(**kwargs) - self.exceptiontype = exceptiontype - self.errordetail = errordetail - - -class KeyForDiskEncryptionSet(_serialization.Model): - """Key Vault Key Url to be used for server side encryption of Managed Disks and Snapshots. - - All required parameters must be populated in order to send to server. - - :ivar source_vault: Resource id of the KeyVault containing the key or secret. This property is - optional and cannot be used if the KeyVault subscription is not the same as the Disk Encryption - Set subscription. - :vartype source_vault: ~azure.mgmt.compute.v2023_10_02.models.SourceVault - :ivar key_url: Fully versioned Key Url pointing to a key in KeyVault. Version segment of the - Url is required regardless of rotationToLatestKeyVersionEnabled value. Required. - :vartype key_url: str - """ - - _validation = { - "key_url": {"required": True}, - } - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SourceVault"}, - "key_url": {"key": "keyUrl", "type": "str"}, - } - - def __init__(self, *, key_url: str, source_vault: Optional["_models.SourceVault"] = None, **kwargs: Any) -> None: - """ - :keyword source_vault: Resource id of the KeyVault containing the key or secret. This property - is optional and cannot be used if the KeyVault subscription is not the same as the Disk - Encryption Set subscription. - :paramtype source_vault: ~azure.mgmt.compute.v2023_10_02.models.SourceVault - :keyword key_url: Fully versioned Key Url pointing to a key in KeyVault. Version segment of the - Url is required regardless of rotationToLatestKeyVersionEnabled value. Required. - :paramtype key_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.key_url = key_url - - -class KeyVaultAndKeyReference(_serialization.Model): - """Key Vault Key Url and vault id of KeK, KeK is optional and when provided is used to unwrap the - encryptionKey. - - All required parameters must be populated in order to send to server. - - :ivar source_vault: Resource id of the KeyVault containing the key or secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2023_10_02.models.SourceVault - :ivar key_url: Url pointing to a key or secret in KeyVault. Required. - :vartype key_url: str - """ - - _validation = { - "source_vault": {"required": True}, - "key_url": {"required": True}, - } - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SourceVault"}, - "key_url": {"key": "keyUrl", "type": "str"}, - } - - def __init__(self, *, source_vault: "_models.SourceVault", key_url: str, **kwargs: Any) -> None: - """ - :keyword source_vault: Resource id of the KeyVault containing the key or secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2023_10_02.models.SourceVault - :keyword key_url: Url pointing to a key or secret in KeyVault. Required. - :paramtype key_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.key_url = key_url - - -class KeyVaultAndSecretReference(_serialization.Model): - """Key Vault Secret Url and vault id of the encryption key. - - All required parameters must be populated in order to send to server. - - :ivar source_vault: Resource id of the KeyVault containing the key or secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2023_10_02.models.SourceVault - :ivar secret_url: Url pointing to a key or secret in KeyVault. Required. - :vartype secret_url: str - """ - - _validation = { - "source_vault": {"required": True}, - "secret_url": {"required": True}, - } - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SourceVault"}, - "secret_url": {"key": "secretUrl", "type": "str"}, - } - - def __init__(self, *, source_vault: "_models.SourceVault", secret_url: str, **kwargs: Any) -> None: - """ - :keyword source_vault: Resource id of the KeyVault containing the key or secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2023_10_02.models.SourceVault - :keyword secret_url: Url pointing to a key or secret in KeyVault. Required. - :paramtype secret_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.secret_url = secret_url - - -class PrivateEndpoint(_serialization.Model): - """The Private Endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ARM identifier for Private Endpoint. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class PrivateEndpointConnection(_serialization.Model): - """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. - :vartype id: str - :ivar name: private endpoint connection name. - :vartype name: str - :ivar type: private endpoint connection type. - :vartype type: str - :ivar private_endpoint: The resource of private end point. - :vartype private_endpoint: ~azure.mgmt.compute.v2023_10_02.models.PrivateEndpoint - :ivar private_link_service_connection_state: A collection of information about the state of the - connection between DiskAccess and Virtual Network. - :vartype private_link_service_connection_state: - ~azure.mgmt.compute.v2023_10_02.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2023_10_02.models.PrivateEndpointConnectionProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "private_endpoint": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionState", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_link_service_connection_state: A collection of information about the state of - the connection between DiskAccess and Virtual Network. - :paramtype private_link_service_connection_state: - ~azure.mgmt.compute.v2023_10_02.models.PrivateLinkServiceConnectionState - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.private_endpoint: Optional["_models.PrivateEndpoint"] = None - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = None - - -class PrivateEndpointConnectionListResult(_serialization.Model): - """A list of private link resources. - - :ivar value: Array of private endpoint connections. - :vartype value: list[~azure.mgmt.compute.v2023_10_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. - :vartype next_link: str - """ - - _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 - ) -> None: - """ - :keyword value: Array of private endpoint connections. - :paramtype value: list[~azure.mgmt.compute.v2023_10_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class PrivateLinkResource(_serialization.Model): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: private link resource Id. - :vartype id: str - :ivar name: private link resource name. - :vartype name: str - :ivar type: private link resource type. - :vartype type: str - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - :ivar required_zone_names: The private link resource DNS zone name. - :vartype required_zone_names: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "group_id": {"readonly": True}, - "required_members": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "group_id": {"key": "properties.groupId", "type": "str"}, - "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, - } - - def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword required_zone_names: The private link resource DNS zone name. - :paramtype required_zone_names: list[str] - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.group_id: Optional[str] = None - self.required_members: Optional[List[str]] = None - self.required_zone_names = required_zone_names - - -class PrivateLinkResourceListResult(_serialization.Model): - """A list of private link resources. - - :ivar value: Array of private link resources. - :vartype value: list[~azure.mgmt.compute.v2023_10_02.models.PrivateLinkResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateLinkResource]"}, - } - - def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Array of private link resources. - :paramtype value: list[~azure.mgmt.compute.v2023_10_02.models.PrivateLinkResource] - """ - super().__init__(**kwargs) - self.value = value - - -class PrivateLinkServiceConnectionState(_serialization.Model): - """A collection of information about the state of the connection between service consumer and - provider. - - :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", and "Rejected". - :vartype status: str or - ~azure.mgmt.compute.v2023_10_02.models.PrivateEndpointServiceConnectionStatus - :ivar description: The reason for approval/rejection of the connection. - :vartype description: str - :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :vartype actions_required: str - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", and "Rejected". - :paramtype status: str or - ~azure.mgmt.compute.v2023_10_02.models.PrivateEndpointServiceConnectionStatus - :keyword description: The reason for approval/rejection of the connection. - :paramtype description: str - :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :paramtype actions_required: str - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required = actions_required - - -class PropertyUpdatesInProgress(_serialization.Model): - """Properties of the disk for which update is pending. - - :ivar target_tier: The target performance tier of the disk if a tier change operation is in - progress. - :vartype target_tier: str - """ - - _attribute_map = { - "target_tier": {"key": "targetTier", "type": "str"}, - } - - def __init__(self, *, target_tier: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword target_tier: The target performance tier of the disk if a tier change operation is in - progress. - :paramtype target_tier: str - """ - super().__init__(**kwargs) - self.target_tier = target_tier - - -class PurchasePlan(_serialization.Model): - """Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. - - All required parameters must be populated in order to send to server. - - :ivar name: The plan ID. Required. - :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 - """ - - _validation = { - "name": {"required": True}, - "publisher": {"required": True}, - "product": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - "promotion_code": {"key": "promotionCode", "type": "str"}, - } - - 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.name = name - self.publisher = publisher - self.product = product - self.promotion_code = promotion_code - - -class ResourceUriList(_serialization.Model): - """The List resources which are encrypted with the disk encryption set. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of IDs or Owner IDs of resources which are encrypted with the disk - encryption set. Required. - :vartype value: list[str] - :ivar next_link: The uri to fetch the next page of encrypted resources. Call ListNext() with - this to fetch the next page of encrypted resources. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[str]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List[str], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of IDs or Owner IDs of resources which are encrypted with the disk - encryption set. Required. - :paramtype value: list[str] - :keyword next_link: The uri to fetch the next page of encrypted resources. Call ListNext() with - this to fetch the next page of encrypted resources. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ResourceWithOptionalLocation(_serialization.Model): - """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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.tags = tags - - -class ShareInfoElement(_serialization.Model): - """ShareInfoElement. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar vm_uri: A relative URI containing the ID of the VM that has the disk attached. - :vartype vm_uri: str - """ - - _validation = { - "vm_uri": {"readonly": True}, - } - - _attribute_map = { - "vm_uri": {"key": "vmUri", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.vm_uri: Optional[str] = None - - -class Snapshot(Resource): - """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. - :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] - :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 - an optional parameter for incremental snapshot and the default behavior is the SKU will be set - to the same sku as the previous snapshot. - :vartype sku: ~azure.mgmt.compute.v2023_10_02.models.SnapshotSku - :ivar extended_location: The extended location where the snapshot will be created. Extended - location cannot be changed. - :vartype extended_location: ~azure.mgmt.compute.v2023_10_02.models.ExtendedLocation - :ivar time_created: The time when the snapshot was created. - :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2023_10_02.models.OperatingSystemTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2023_10_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.v2023_10_02.models.PurchasePlan - :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.v2023_10_02.models.SupportedCapabilities - :ivar creation_data: Disk source information. CreationData information cannot be changed after - the disk has been created. - :vartype creation_data: ~azure.mgmt.compute.v2023_10_02.models.CreationData - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. - :vartype disk_size_bytes: int - :ivar disk_state: The state of the snapshot. Known values are: "Unattached", "Attached", - "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", and "ActiveUpload". - :vartype disk_state: str or ~azure.mgmt.compute.v2023_10_02.models.DiskState - :ivar unique_id: Unique Guid identifying the resource. - :vartype unique_id: str - :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2023_10_02.models.EncryptionSettingsCollection - :ivar provisioning_state: The disk provisioning state. - :vartype provisioning_state: str - :ivar incremental: Whether a snapshot is incremental. Incremental snapshots on the same disk - occupy less space than full snapshots and can be diffed. - :vartype incremental: bool - :ivar incremental_snapshot_family_id: Incremental snapshots for a disk share an incremental - snapshot family id. The Get Page Range Diff API can only be called on incremental snapshots - with the same family id. - :vartype incremental_snapshot_family_id: str - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2023_10_02.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2023_10_02.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar security_profile: Contains the security related information for the resource. - :vartype security_profile: ~azure.mgmt.compute.v2023_10_02.models.DiskSecurityProfile - :ivar supports_hibernation: Indicates the OS on a snapshot supports hibernation. - :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2023_10_02.models.PublicNetworkAccess - :ivar completion_percent: Percentage complete for the background copy when a resource is - created via the CopyStart operation. - :vartype completion_percent: float - :ivar copy_completion_error: Indicates the error details if the background copy of a resource - created via the CopyStart operation fails. - :vartype copy_completion_error: ~azure.mgmt.compute.v2023_10_02.models.CopyCompletionError - :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :vartype data_access_auth_mode: str or - ~azure.mgmt.compute.v2023_10_02.models.DataAccessAuthMode - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "managed_by": {"readonly": True}, - "time_created": {"readonly": True}, - "disk_size_bytes": {"readonly": True}, - "disk_state": {"readonly": True}, - "unique_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "incremental_snapshot_family_id": {"readonly": 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}"}, - "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"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - "creation_data": {"key": "properties.creationData", "type": "CreationData"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "disk_size_bytes": {"key": "properties.diskSizeBytes", "type": "int"}, - "disk_state": {"key": "properties.diskState", "type": "str"}, - "unique_id": {"key": "properties.uniqueId", "type": "str"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "incremental": {"key": "properties.incremental", "type": "bool"}, - "incremental_snapshot_family_id": {"key": "properties.incrementalSnapshotFamilyId", "type": "str"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - "security_profile": {"key": "properties.securityProfile", "type": "DiskSecurityProfile"}, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "completion_percent": {"key": "properties.completionPercent", "type": "float"}, - "copy_completion_error": {"key": "properties.copyCompletionError", "type": "CopyCompletionError"}, - "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.SnapshotSku"] = None, - 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, - supported_capabilities: Optional["_models.SupportedCapabilities"] = None, - creation_data: Optional["_models.CreationData"] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - incremental: Optional[bool] = None, - encryption: Optional["_models.Encryption"] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - security_profile: Optional["_models.DiskSecurityProfile"] = None, - supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - completion_percent: Optional[float] = None, - copy_completion_error: Optional["_models.CopyCompletionError"] = None, - data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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. - :paramtype sku: ~azure.mgmt.compute.v2023_10_02.models.SnapshotSku - :keyword extended_location: The extended location where the snapshot will be created. Extended - location cannot be changed. - :paramtype extended_location: ~azure.mgmt.compute.v2023_10_02.models.ExtendedLocation - :keyword os_type: The Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2023_10_02.models.OperatingSystemTypes - :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_10_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.v2023_10_02.models.PurchasePlan - :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.v2023_10_02.models.SupportedCapabilities - :keyword creation_data: Disk source information. CreationData information cannot be changed - after the disk has been created. - :paramtype creation_data: ~azure.mgmt.compute.v2023_10_02.models.CreationData - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2023_10_02.models.EncryptionSettingsCollection - :keyword incremental: Whether a snapshot is incremental. Incremental snapshots on the same disk - occupy less space than full snapshots and can be diffed. - :paramtype incremental: bool - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2023_10_02.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2023_10_02.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword security_profile: Contains the security related information for the resource. - :paramtype security_profile: ~azure.mgmt.compute.v2023_10_02.models.DiskSecurityProfile - :keyword supports_hibernation: Indicates the OS on a snapshot supports hibernation. - :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2023_10_02.models.PublicNetworkAccess - :keyword completion_percent: Percentage complete for the background copy when a resource is - created via the CopyStart operation. - :paramtype completion_percent: float - :keyword copy_completion_error: Indicates the error details if the background copy of a - resource created via the CopyStart operation fails. - :paramtype copy_completion_error: ~azure.mgmt.compute.v2023_10_02.models.CopyCompletionError - :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :paramtype data_access_auth_mode: str or - ~azure.mgmt.compute.v2023_10_02.models.DataAccessAuthMode - """ - super().__init__(location=location, tags=tags, **kwargs) - self.managed_by: Optional[str] = None - self.sku = sku - self.extended_location = extended_location - self.time_created: Optional[datetime.datetime] = None - self.os_type = os_type - self.hyper_v_generation = hyper_v_generation - self.purchase_plan = purchase_plan - self.supported_capabilities = supported_capabilities - self.creation_data = creation_data - self.disk_size_gb = disk_size_gb - self.disk_size_bytes: Optional[int] = None - self.disk_state: Optional[Union[str, "_models.DiskState"]] = None - self.unique_id: Optional[str] = None - self.encryption_settings_collection = encryption_settings_collection - self.provisioning_state: Optional[str] = None - self.incremental = incremental - self.incremental_snapshot_family_id: Optional[str] = None - self.encryption = encryption - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - self.security_profile = security_profile - self.supports_hibernation = supports_hibernation - self.public_network_access = public_network_access - self.completion_percent = completion_percent - self.copy_completion_error = copy_completion_error - self.data_access_auth_mode = data_access_auth_mode - - -class SnapshotList(_serialization.Model): - """The List Snapshots operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of snapshots. Required. - :vartype value: list[~azure.mgmt.compute.v2023_10_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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Snapshot]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of snapshots. Required. - :paramtype value: list[~azure.mgmt.compute.v2023_10_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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class SnapshotSku(_serialization.Model): - """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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", and "Standard_ZRS". - :vartype name: str or ~azure.mgmt.compute.v2023_10_02.models.SnapshotStorageAccountTypes - :ivar tier: The sku tier. - :vartype tier: str - """ - - _validation = { - "tier": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__( - self, *, name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs: Any - ) -> None: - """ - :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", and - "Standard_ZRS". - :paramtype name: str or ~azure.mgmt.compute.v2023_10_02.models.SnapshotStorageAccountTypes - """ - super().__init__(**kwargs) - self.name = name - self.tier: Optional[str] = None - - -class SnapshotUpdate(_serialization.Model): - """Snapshot update resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar 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. - :vartype sku: ~azure.mgmt.compute.v2023_10_02.models.SnapshotSku - :ivar os_type: the Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2023_10_02.models.OperatingSystemTypes - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2023_10_02.models.EncryptionSettingsCollection - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2023_10_02.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2023_10_02.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar supports_hibernation: Indicates the OS on a snapshot supports hibernation. - :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2023_10_02.models.PublicNetworkAccess - :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :vartype data_access_auth_mode: str or - ~azure.mgmt.compute.v2023_10_02.models.DataAccessAuthMode - :ivar supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :vartype supported_capabilities: ~azure.mgmt.compute.v2023_10_02.models.SupportedCapabilities - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "SnapshotSku"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.SnapshotSku"] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - encryption: Optional["_models.Encryption"] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, - supported_capabilities: Optional["_models.SupportedCapabilities"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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. - :paramtype sku: ~azure.mgmt.compute.v2023_10_02.models.SnapshotSku - :keyword os_type: the Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2023_10_02.models.OperatingSystemTypes - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2023_10_02.models.EncryptionSettingsCollection - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2023_10_02.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2023_10_02.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword supports_hibernation: Indicates the OS on a snapshot supports hibernation. - :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2023_10_02.models.PublicNetworkAccess - :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :paramtype data_access_auth_mode: str or - ~azure.mgmt.compute.v2023_10_02.models.DataAccessAuthMode - :keyword supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :paramtype supported_capabilities: ~azure.mgmt.compute.v2023_10_02.models.SupportedCapabilities - """ - super().__init__(**kwargs) - self.tags = tags - self.sku = sku - self.os_type = os_type - self.disk_size_gb = disk_size_gb - self.encryption_settings_collection = encryption_settings_collection - self.encryption = encryption - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - self.supports_hibernation = supports_hibernation - self.public_network_access = public_network_access - self.data_access_auth_mode = data_access_auth_mode - self.supported_capabilities = supported_capabilities - - -class SourceVault(_serialization.Model): - """The vault id is an Azure Resource Manager Resource id in the form - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class SubResource(_serialization.Model): - """SubResource. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class SubResourceReadOnly(_serialization.Model): - """SubResourceReadOnly. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class SupportedCapabilities(_serialization.Model): - """List of supported capabilities persisted on the disk resource for VM use. - - :ivar disk_controller_types: The disk controllers that an OS disk supports. If set it can be - SCSI or SCSI, NVME or NVME, SCSI. - :vartype disk_controller_types: str - :ivar accelerated_network: True if the image from which the OS disk is created supports - accelerated networking. - :vartype accelerated_network: bool - :ivar architecture: CPU architecture supported by an OS disk. Known values are: "x64" and - "Arm64". - :vartype architecture: str or ~azure.mgmt.compute.v2023_10_02.models.Architecture - """ - - _attribute_map = { - "disk_controller_types": {"key": "diskControllerTypes", "type": "str"}, - "accelerated_network": {"key": "acceleratedNetwork", "type": "bool"}, - "architecture": {"key": "architecture", "type": "str"}, - } - - def __init__( - self, - *, - disk_controller_types: Optional[str] = None, - accelerated_network: Optional[bool] = None, - architecture: Optional[Union[str, "_models.Architecture"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_controller_types: The disk controllers that an OS disk supports. If set it can be - SCSI or SCSI, NVME or NVME, SCSI. - :paramtype disk_controller_types: str - :keyword accelerated_network: True if the image from which the OS disk is created supports - accelerated networking. - :paramtype accelerated_network: bool - :keyword architecture: CPU architecture supported by an OS disk. Known values are: "x64" and - "Arm64". - :paramtype architecture: str or ~azure.mgmt.compute.v2023_10_02.models.Architecture - """ - super().__init__(**kwargs) - self.disk_controller_types = disk_controller_types - self.accelerated_network = accelerated_network - self.architecture = architecture - - -class SystemData(_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. - - :ivar created_at: Specifies the time in UTC at which the Cloud Service (extended support) - resource was created. :code:`
    `Minimum api-version: 2022-04-04. - :vartype created_at: ~datetime.datetime - :ivar last_modified_at: Specifies the time in UTC at which the Cloud Service (extended support) - resource was last modified. :code:`
    `Minimum api-version: 2022-04-04. - :vartype last_modified_at: ~datetime.datetime - """ - - _validation = { - "created_at": {"readonly": True}, - "last_modified_at": {"readonly": True}, - } - - _attribute_map = { - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.created_at: Optional[datetime.datetime] = None - self.last_modified_at: Optional[datetime.datetime] = None - - -class UserAssignedIdentitiesValue(_serialization.Model): - """UserAssignedIdentitiesValue. - - 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: Optional[str] = None - self.client_id: Optional[str] = None diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/operations/__init__.py deleted file mode 100644 index 0e0c2d8aaf8d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/operations/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -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 SnapshotsOperations # 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", - "SnapshotsOperations", -] -__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_10_02/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/operations/_operations.py deleted file mode 100644 index d17f8b95ec0d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/operations/_operations.py +++ /dev/null @@ -1,5848 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import ComputeManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_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: - _headers = case_insensitive_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-10-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}", - ) - 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"), - } - - _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_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", "2023-10-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}", - ) - 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"), - } - - _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_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", "2023-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", - ) - 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"), - } - - _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_disks_delete_request( - resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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", "2023-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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-10-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", - ) - 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"), - } - - _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_disks_revoke_access_request( - resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **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 -) -> 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-10-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}", - ) - 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"), - } - - _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_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", "2023-10-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", - ) - 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"), - } - - _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) - - -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", "2023-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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", "2023-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateLinkResources", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-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}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - 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" - ), - } - - _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_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", "2023-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - 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" - ), - } - - _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_disk_accesses_delete_a_private_endpoint_connection_request( # pylint: disable=name-too-long - resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - 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" - ), - } - - _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) - - -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", "2023-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections", - ) - 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"), - } - - _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_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", "2023-10-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", - ) - 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"), - } - - _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) - - -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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}/associatedResources", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) - 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}", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) - 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", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-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", - ) - 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"), - } - - _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_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", "2023-10-02")) - 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", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2023-10-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}", - ) - 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"), - } - - _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_snapshots_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", "2023-10-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}", - ) - 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"), - } - - _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_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", "2023-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", - ) - 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"), - } - - _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_snapshots_delete_request( - resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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-10-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}/beginGetAccess", - ) - 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"), - } - - _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_snapshots_revoke_access_request( - resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-02")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -class DisksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_10_02.ComputeManagementClient`'s - :attr:`disks` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_name: str, disk: Union[_models.Disk, 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-10-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, (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_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) - - _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_create_or_update( - self, - resource_group_name: str, - disk_name: str, - disk: _models.Disk, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Creates or updates 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 - :param disk: Disk object supplied in the body of the Put disk operation. Required. - :type disk: ~azure.mgmt.compute.v2023_10_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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_10_02.models.Disk] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_name: str, - disk: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Creates or updates 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 - :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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_10_02.models.Disk] - :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. - - :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 - :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.v2023_10_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.v2023_10_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 "2023-10-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._create_or_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, **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 _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, - 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-10-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, (IOBase, bytes)): - _content = disk - else: - _json = self._serialize.body(disk, "DiskUpdate") - - _request = build_disks_update_request( - resource_group_name=resource_group_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) - - _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, - disk_name: str, - disk: _models.DiskUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Updates (patches) a disk. - - :param resource_group_name: The name of the resource group. Required. - :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.v2023_10_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.v2023_10_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. 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.v2023_10_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. 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.v2023_10_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.v2023_10_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 "2023-10-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, **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 - ) - - @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.v2023_10_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 "2023-10-02")) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) - - _request = build_disks_get_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) - - _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("Disk", 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_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-10-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. - :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 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-10-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_name=disk_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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Disk"]: - """Lists all the disks 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 Disk or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_10_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 "2023-10-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 list(self, **kwargs: Any) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2023_10_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 "2023-10-02")) - cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disks_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) - - 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, - 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-10-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disks_grant_access_request( - resource_group_name=resource_group_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) - - _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_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_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.v2023_10_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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_10_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_10_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_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.v2023_10_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.v2023_10_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 "2023-10-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, - disk_name=disk_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, 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-10-02")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disks_revoke_access_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]: - 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_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. - :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 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-10-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._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 - ) - 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 DiskAccessesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_10_02.ComputeManagementClient`'s - :attr:`disk_accesses` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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]: - 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-10-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access - else: - _json = self._serialize.body(disk_access, "DiskAccess") - - _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) - - _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_create_or_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccess, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Put disk access operation. - Required. - :type disk_access: ~azure.mgmt.compute.v2023_10_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.v2023_10_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2023_10_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Put disk access operation. - Is either a DiskAccess type or a IO[bytes] type. Required. - :type disk_access: ~azure.mgmt.compute.v2023_10_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.v2023_10_02.models.DiskAccess] - :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-10-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) - - 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 - - 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 - ) - - def _update_initial( - 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, - 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-10-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access - else: - _json = self._serialize.body(disk_access, "DiskAccessUpdate") - - _request = build_disk_accesses_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) - - _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, - disk_access_name: str, - disk_access: _models.DiskAccessUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Patch disk access operation. - Required. - :type disk_access: ~azure.mgmt.compute.v2023_10_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 DiskAccess or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_10_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the 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 DiskAccess or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_10_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - 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. - :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.v2023_10_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.v2023_10_02.models.DiskAccess] - :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-10-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._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) - - 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 - - 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 - ) - - @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.v2023_10_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 "2023-10-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]: - 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-10-02")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disk_accesses_delete_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) - - _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_access_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes 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 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-10-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 - - 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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.DiskAccess"]: - """Lists all the disk access resources 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 DiskAccess or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_10_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 "2023-10-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 list(self, **kwargs: Any) -> ItemPaged["_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.v2023_10_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 "2023-10-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 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. - :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.v2023_10_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 "2023-10-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 = 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 - - 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 - ) -> 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-10-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(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 = 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_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 - ) -> 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. - :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.v2023_10_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 PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_10_02.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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 - ) -> 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. - :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 LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_10_02.models.PrivateEndpointConnection] - :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. - - :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.v2023_10_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.v2023_10_02.models.PrivateEndpointConnection] - :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-10-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, 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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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 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.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - 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.v2023_10_02.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-10-02")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_disk_accesses_get_a_private_endpoint_connection_request( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _delete_a_private_endpoint_connection_initial( # pylint: disable=name-too-long - self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> 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-10-02")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disk_accesses_delete_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) - - _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_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. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) 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-10-02")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_a_private_endpoint_connection_initial( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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_private_endpoint_connections( - self, resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> ItemPaged["_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.v2023_10_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 "2023-10-02")) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_accesses_list_private_endpoint_connections_request( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class DiskEncryptionSetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_10_02.ComputeManagementClient`'s - :attr:`disk_encryption_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 "2023-10-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set - else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") - - _request = build_disk_encryption_sets_create_or_update_request( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2023_10_02.models.DiskEncryptionSet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_10_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_10_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Is either a DiskEncryptionSet type or a IO[bytes] type. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2023_10_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.v2023_10_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 "2023-10-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._create_or_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 - ) - - 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, - 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-10-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( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, - 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. - :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.v2023_10_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.v2023_10_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.v2023_10_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.v2023_10_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.v2023_10_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 "2023-10-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.v2023_10_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 "2023-10-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 "2023-10-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 - :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-10-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, **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) -> ItemPaged["_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.v2023_10_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 "2023-10-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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_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.v2023_10_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 "2023-10-02")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 list_associated_resources( - self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> ItemPaged[str]: - """Lists all resources that are encrypted with this 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: 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 "2023-10-02")) - cls: ClsType[_models.ResourceUriList] = 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_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, - 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("ResourceUriList", 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 DiskRestorePointOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_10_02.ComputeManagementClient`'s - :attr:`disk_restore_point` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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. - - :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 - :return: DiskRestorePoint or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_10_02.models.DiskRestorePoint - :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-10-02")) - cls: ClsType[_models.DiskRestorePoint] = kwargs.pop("cls", None) - - _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) - - _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 - ) -> ItemPaged["_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.v2023_10_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 "2023-10-02")) - cls: ClsType[_models.DiskRestorePointList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_restore_point_list_by_restore_point_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DiskRestorePointList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _grant_access_initial( - self, - resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> 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-10-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disk_restore_point_grant_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, - 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_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: _models.GrantAccessData, - *, - 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: ~azure.mgmt.compute.v2023_10_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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_10_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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: 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.v2023_10_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.v2023_10_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.v2023_10_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 "2023-10-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 "2023-10-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 - - return deserialized # type: ignore - - @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. - - :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 - :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-10-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._revoke_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, - 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 SnapshotsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_10_02.ComputeManagementClient`'s - :attr:`snapshots` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, snapshot_name: str, snapshot: Union[_models.Snapshot, 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-10-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "Snapshot") - - _request = build_snapshots_create_or_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.Snapshot, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: ~azure.mgmt.compute.v2023_10_02.models.Snapshot - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_10_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_10_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :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.v2023_10_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.v2023_10_02.models.Snapshot] - :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-10-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._create_or_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, **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 _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, - 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-10-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "SnapshotUpdate") - - _request = build_snapshots_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, - snapshot_name: str, - snapshot: _models.SnapshotUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. 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.v2023_10_02.models.SnapshotUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_10_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. - Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_10_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. Is - either a SnapshotUpdate type or a IO[bytes] type. Required. - :type snapshot: ~azure.mgmt.compute.v2023_10_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.v2023_10_02.models.Snapshot] - :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-10-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, **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 - ) - - @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.v2023_10_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 "2023-10-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]: - 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-10-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) - - 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, snapshot_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes 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: 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-10-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, - snapshot_name=snapshot_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_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Snapshot"]: - """Lists snapshots 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 Snapshot or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_10_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 "2023-10-02")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.Snapshot"]: - """Lists snapshots under a subscription. - - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_10_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 "2023-10-02")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _grant_access_initial( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, 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-10-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_snapshots_grant_access_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param grant_access_data: Access data object supplied in the body of the get snapshot access - operation. Required. - :type grant_access_data: ~azure.mgmt.compute.v2023_10_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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_10_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param 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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_10_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param 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.v2023_10_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.v2023_10_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 "2023-10-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, - snapshot_name=snapshot_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, 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 "2023-10-02")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_snapshots_revoke_access_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]: - 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_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. - :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 "2023-10-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._revoke_access_initial( - resource_group_name=resource_group_name, - snapshot_name=snapshot_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore - -_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_compute_management_client.py deleted file mode 100644 index 45d0825143c3..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_compute_management_client.py +++ /dev/null @@ -1,285 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ( - AvailabilitySetsOperations, - CapacityReservationGroupsOperations, - CapacityReservationsOperations, - DedicatedHostGroupsOperations, - DedicatedHostsOperations, - ImagesOperations, - LogAnalyticsOperations, - Operations, - ProximityPlacementGroupsOperations, - RestorePointCollectionsOperations, - RestorePointsOperations, - SshPublicKeysOperations, - UsageOperations, - VirtualMachineExtensionImagesOperations, - VirtualMachineExtensionsOperations, - VirtualMachineImagesEdgeZoneOperations, - VirtualMachineImagesOperations, - VirtualMachineRunCommandsOperations, - VirtualMachineScaleSetExtensionsOperations, - VirtualMachineScaleSetRollingUpgradesOperations, - VirtualMachineScaleSetVMExtensionsOperations, - VirtualMachineScaleSetVMRunCommandsOperations, - VirtualMachineScaleSetVMsOperations, - VirtualMachineScaleSetsOperations, - VirtualMachineSizesOperations, - VirtualMachinesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.compute.v2024_11_01.operations.Operations - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2024_11_01.operations.AvailabilitySetsOperations - :ivar capacity_reservation_groups: CapacityReservationGroupsOperations operations - :vartype capacity_reservation_groups: - azure.mgmt.compute.v2024_11_01.operations.CapacityReservationGroupsOperations - :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations - :vartype dedicated_host_groups: - azure.mgmt.compute.v2024_11_01.operations.DedicatedHostGroupsOperations - :ivar images: ImagesOperations operations - :vartype images: azure.mgmt.compute.v2024_11_01.operations.ImagesOperations - :ivar virtual_machine_images_edge_zone: VirtualMachineImagesEdgeZoneOperations operations - :vartype virtual_machine_images_edge_zone: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineImagesEdgeZoneOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineImagesOperations - :ivar log_analytics: LogAnalyticsOperations operations - :vartype log_analytics: azure.mgmt.compute.v2024_11_01.operations.LogAnalyticsOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineExtensionImagesOperations - :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations - :vartype virtual_machine_run_commands: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineRunCommandsOperations - :ivar usage: UsageOperations operations - :vartype usage: azure.mgmt.compute.v2024_11_01.operations.UsageOperations - :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations - :vartype virtual_machine_scale_sets: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machines: VirtualMachinesOperations operations - :vartype virtual_machines: azure.mgmt.compute.v2024_11_01.operations.VirtualMachinesOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineSizesOperations - :ivar proximity_placement_groups: ProximityPlacementGroupsOperations operations - :vartype proximity_placement_groups: - azure.mgmt.compute.v2024_11_01.operations.ProximityPlacementGroupsOperations - :ivar restore_point_collections: RestorePointCollectionsOperations operations - :vartype restore_point_collections: - azure.mgmt.compute.v2024_11_01.operations.RestorePointCollectionsOperations - :ivar ssh_public_keys: SshPublicKeysOperations operations - :vartype ssh_public_keys: azure.mgmt.compute.v2024_11_01.operations.SshPublicKeysOperations - :ivar capacity_reservations: CapacityReservationsOperations operations - :vartype capacity_reservations: - azure.mgmt.compute.v2024_11_01.operations.CapacityReservationsOperations - :ivar dedicated_hosts: DedicatedHostsOperations operations - :vartype dedicated_hosts: azure.mgmt.compute.v2024_11_01.operations.DedicatedHostsOperations - :ivar restore_points: RestorePointsOperations operations - :vartype restore_points: azure.mgmt.compute.v2024_11_01.operations.RestorePointsOperations - :ivar virtual_machine_scale_set_rolling_upgrades: - VirtualMachineScaleSetRollingUpgradesOperations operations - :vartype virtual_machine_scale_set_rolling_upgrades: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineScaleSetRollingUpgradesOperations - :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations - operations - :vartype virtual_machine_scale_set_extensions: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineScaleSetExtensionsOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineScaleSetVMsOperations - :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations - operations - :vartype virtual_machine_scale_set_vm_extensions: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineScaleSetVMExtensionsOperations - :ivar virtual_machine_scale_set_vm_run_commands: VirtualMachineScaleSetVMRunCommandsOperations - operations - :vartype virtual_machine_scale_set_vm_run_commands: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineScaleSetVMRunCommandsOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineExtensionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2024-11-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2024-11-01") - self.availability_sets = AvailabilitySetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.capacity_reservation_groups = CapacityReservationGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.dedicated_host_groups = DedicatedHostGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2024-11-01") - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_images = VirtualMachineImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.log_analytics = LogAnalyticsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2024-11-01") - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.proximity_placement_groups = ProximityPlacementGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.restore_point_collections = RestorePointCollectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.ssh_public_keys = SshPublicKeysOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.capacity_reservations = CapacityReservationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.dedicated_hosts = DedicatedHostsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.restore_points = RestorePointsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_configuration.py deleted file mode 100644 index 79bccfe20953..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-11-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2024-11-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_metadata.json deleted file mode 100644 index 917cc2eca3f7..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_metadata.json +++ /dev/null @@ -1,135 +0,0 @@ -{ - "chosen_version": "2024-11-01", - "total_api_version_list": ["2024-11-01"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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": { - "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_scale_sets": "VirtualMachineScaleSetsOperations", - "virtual_machines": "VirtualMachinesOperations", - "virtual_machine_sizes": "VirtualMachineSizesOperations", - "proximity_placement_groups": "ProximityPlacementGroupsOperations", - "restore_point_collections": "RestorePointCollectionsOperations", - "ssh_public_keys": "SshPublicKeysOperations", - "capacity_reservations": "CapacityReservationsOperations", - "dedicated_hosts": "DedicatedHostsOperations", - "restore_points": "RestorePointsOperations", - "virtual_machine_scale_set_rolling_upgrades": "VirtualMachineScaleSetRollingUpgradesOperations", - "virtual_machine_scale_set_extensions": "VirtualMachineScaleSetExtensionsOperations", - "virtual_machine_scale_set_vms": "VirtualMachineScaleSetVMsOperations", - "virtual_machine_scale_set_vm_extensions": "VirtualMachineScaleSetVMExtensionsOperations", - "virtual_machine_scale_set_vm_run_commands": "VirtualMachineScaleSetVMRunCommandsOperations", - "virtual_machine_extensions": "VirtualMachineExtensionsOperations" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node
    is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_version.py deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore - -_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/_compute_management_client.py deleted file mode 100644 index 918048b2e29f..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/_compute_management_client.py +++ /dev/null @@ -1,291 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ( - AvailabilitySetsOperations, - CapacityReservationGroupsOperations, - CapacityReservationsOperations, - DedicatedHostGroupsOperations, - DedicatedHostsOperations, - ImagesOperations, - LogAnalyticsOperations, - Operations, - ProximityPlacementGroupsOperations, - RestorePointCollectionsOperations, - RestorePointsOperations, - SshPublicKeysOperations, - UsageOperations, - VirtualMachineExtensionImagesOperations, - VirtualMachineExtensionsOperations, - VirtualMachineImagesEdgeZoneOperations, - VirtualMachineImagesOperations, - VirtualMachineRunCommandsOperations, - VirtualMachineScaleSetExtensionsOperations, - VirtualMachineScaleSetRollingUpgradesOperations, - VirtualMachineScaleSetVMExtensionsOperations, - VirtualMachineScaleSetVMRunCommandsOperations, - VirtualMachineScaleSetVMsOperations, - VirtualMachineScaleSetsOperations, - VirtualMachineSizesOperations, - VirtualMachinesOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: # pylint: disable=too-many-instance-attributes - """Compute Client. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.compute.v2024_11_01.aio.operations.Operations - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2024_11_01.aio.operations.AvailabilitySetsOperations - :ivar capacity_reservation_groups: CapacityReservationGroupsOperations operations - :vartype capacity_reservation_groups: - azure.mgmt.compute.v2024_11_01.aio.operations.CapacityReservationGroupsOperations - :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations - :vartype dedicated_host_groups: - azure.mgmt.compute.v2024_11_01.aio.operations.DedicatedHostGroupsOperations - :ivar images: ImagesOperations operations - :vartype images: azure.mgmt.compute.v2024_11_01.aio.operations.ImagesOperations - :ivar virtual_machine_images_edge_zone: VirtualMachineImagesEdgeZoneOperations operations - :vartype virtual_machine_images_edge_zone: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineImagesEdgeZoneOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineImagesOperations - :ivar log_analytics: LogAnalyticsOperations operations - :vartype log_analytics: azure.mgmt.compute.v2024_11_01.aio.operations.LogAnalyticsOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineExtensionImagesOperations - :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations - :vartype virtual_machine_run_commands: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineRunCommandsOperations - :ivar usage: UsageOperations operations - :vartype usage: azure.mgmt.compute.v2024_11_01.aio.operations.UsageOperations - :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations - :vartype virtual_machine_scale_sets: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machines: VirtualMachinesOperations operations - :vartype virtual_machines: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachinesOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineSizesOperations - :ivar proximity_placement_groups: ProximityPlacementGroupsOperations operations - :vartype proximity_placement_groups: - azure.mgmt.compute.v2024_11_01.aio.operations.ProximityPlacementGroupsOperations - :ivar restore_point_collections: RestorePointCollectionsOperations operations - :vartype restore_point_collections: - azure.mgmt.compute.v2024_11_01.aio.operations.RestorePointCollectionsOperations - :ivar ssh_public_keys: SshPublicKeysOperations operations - :vartype ssh_public_keys: azure.mgmt.compute.v2024_11_01.aio.operations.SshPublicKeysOperations - :ivar capacity_reservations: CapacityReservationsOperations operations - :vartype capacity_reservations: - azure.mgmt.compute.v2024_11_01.aio.operations.CapacityReservationsOperations - :ivar dedicated_hosts: DedicatedHostsOperations operations - :vartype dedicated_hosts: - azure.mgmt.compute.v2024_11_01.aio.operations.DedicatedHostsOperations - :ivar restore_points: RestorePointsOperations operations - :vartype restore_points: azure.mgmt.compute.v2024_11_01.aio.operations.RestorePointsOperations - :ivar virtual_machine_scale_set_rolling_upgrades: - VirtualMachineScaleSetRollingUpgradesOperations operations - :vartype virtual_machine_scale_set_rolling_upgrades: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineScaleSetRollingUpgradesOperations - :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations - operations - :vartype virtual_machine_scale_set_extensions: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineScaleSetExtensionsOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineScaleSetVMsOperations - :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations - operations - :vartype virtual_machine_scale_set_vm_extensions: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineScaleSetVMExtensionsOperations - :ivar virtual_machine_scale_set_vm_run_commands: VirtualMachineScaleSetVMRunCommandsOperations - operations - :vartype virtual_machine_scale_set_vm_run_commands: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineScaleSetVMRunCommandsOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineExtensionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2024-11-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2024-11-01") - self.availability_sets = AvailabilitySetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.capacity_reservation_groups = CapacityReservationGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.dedicated_host_groups = DedicatedHostGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2024-11-01") - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_images = VirtualMachineImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.log_analytics = LogAnalyticsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2024-11-01") - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.proximity_placement_groups = ProximityPlacementGroupsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.restore_point_collections = RestorePointCollectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.ssh_public_keys = SshPublicKeysOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.capacity_reservations = CapacityReservationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.dedicated_hosts = DedicatedHostsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.restore_points = RestorePointsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/_configuration.py deleted file mode 100644 index 65be166ddc7b..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-11-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2024-11-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/operations/__init__.py deleted file mode 100644 index 6718c8ecb4f9..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/operations/__init__.py +++ /dev/null @@ -1,75 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - 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 VirtualMachineScaleSetsOperations # type: ignore -from ._operations import VirtualMachinesOperations # type: ignore -from ._operations import VirtualMachineSizesOperations # type: ignore -from ._operations import ProximityPlacementGroupsOperations # type: ignore -from ._operations import RestorePointCollectionsOperations # type: ignore -from ._operations import SshPublicKeysOperations # type: ignore -from ._operations import CapacityReservationsOperations # 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 * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AvailabilitySetsOperations", - "CapacityReservationGroupsOperations", - "DedicatedHostGroupsOperations", - "ImagesOperations", - "VirtualMachineImagesEdgeZoneOperations", - "VirtualMachineImagesOperations", - "LogAnalyticsOperations", - "VirtualMachineExtensionImagesOperations", - "VirtualMachineRunCommandsOperations", - "UsageOperations", - "VirtualMachineScaleSetsOperations", - "VirtualMachinesOperations", - "VirtualMachineSizesOperations", - "ProximityPlacementGroupsOperations", - "RestorePointCollectionsOperations", - "SshPublicKeysOperations", - "CapacityReservationsOperations", - "DedicatedHostsOperations", - "RestorePointsOperations", - "VirtualMachineScaleSetRollingUpgradesOperations", - "VirtualMachineScaleSetExtensionsOperations", - "VirtualMachineScaleSetVMsOperations", - "VirtualMachineScaleSetVMExtensionsOperations", - "VirtualMachineScaleSetVMRunCommandsOperations", - "VirtualMachineExtensionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/operations/_operations.py deleted file mode 100644 index 3f153c6b9a84..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/operations/_operations.py +++ /dev/null @@ -1,23169 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import ( - build_availability_sets_cancel_migration_to_virtual_machine_scale_set_request, - build_availability_sets_convert_to_virtual_machine_scale_set_request, - build_availability_sets_create_or_update_request, - build_availability_sets_delete_request, - build_availability_sets_get_request, - build_availability_sets_list_available_sizes_request, - build_availability_sets_list_by_subscription_request, - build_availability_sets_list_request, - build_availability_sets_start_migration_to_virtual_machine_scale_set_request, - build_availability_sets_update_request, - build_availability_sets_validate_migration_to_virtual_machine_scale_set_request, - build_capacity_reservation_groups_create_or_update_request, - build_capacity_reservation_groups_delete_request, - build_capacity_reservation_groups_get_request, - build_capacity_reservation_groups_list_by_resource_group_request, - build_capacity_reservation_groups_list_by_subscription_request, - build_capacity_reservation_groups_update_request, - build_capacity_reservations_create_or_update_request, - build_capacity_reservations_delete_request, - build_capacity_reservations_get_request, - build_capacity_reservations_list_by_capacity_reservation_group_request, - build_capacity_reservations_update_request, - build_dedicated_host_groups_create_or_update_request, - build_dedicated_host_groups_delete_request, - build_dedicated_host_groups_get_request, - build_dedicated_host_groups_list_by_resource_group_request, - build_dedicated_host_groups_list_by_subscription_request, - build_dedicated_host_groups_update_request, - build_dedicated_hosts_create_or_update_request, - build_dedicated_hosts_delete_request, - build_dedicated_hosts_get_request, - build_dedicated_hosts_list_available_sizes_request, - build_dedicated_hosts_list_by_host_group_request, - build_dedicated_hosts_redeploy_request, - build_dedicated_hosts_restart_request, - build_dedicated_hosts_update_request, - build_images_create_or_update_request, - build_images_delete_request, - build_images_get_request, - build_images_list_by_resource_group_request, - build_images_list_request, - build_images_update_request, - build_log_analytics_export_request_rate_by_interval_request, - build_log_analytics_export_throttled_requests_request, - build_operations_list_request, - build_proximity_placement_groups_create_or_update_request, - build_proximity_placement_groups_delete_request, - build_proximity_placement_groups_get_request, - build_proximity_placement_groups_list_by_resource_group_request, - build_proximity_placement_groups_list_by_subscription_request, - build_proximity_placement_groups_update_request, - build_restore_point_collections_create_or_update_request, - build_restore_point_collections_delete_request, - build_restore_point_collections_get_request, - build_restore_point_collections_list_all_request, - build_restore_point_collections_list_request, - build_restore_point_collections_update_request, - build_restore_points_create_request, - build_restore_points_delete_request, - build_restore_points_get_request, - build_ssh_public_keys_create_request, - build_ssh_public_keys_delete_request, - build_ssh_public_keys_generate_key_pair_request, - build_ssh_public_keys_get_request, - build_ssh_public_keys_list_by_resource_group_request, - build_ssh_public_keys_list_by_subscription_request, - build_ssh_public_keys_update_request, - build_usage_list_request, - build_virtual_machine_extension_images_get_request, - build_virtual_machine_extension_images_list_types_request, - build_virtual_machine_extension_images_list_versions_request, - build_virtual_machine_extensions_create_or_update_request, - build_virtual_machine_extensions_delete_request, - build_virtual_machine_extensions_get_request, - build_virtual_machine_extensions_list_request, - build_virtual_machine_extensions_update_request, - build_virtual_machine_images_edge_zone_get_request, - build_virtual_machine_images_edge_zone_list_offers_request, - build_virtual_machine_images_edge_zone_list_publishers_request, - build_virtual_machine_images_edge_zone_list_request, - build_virtual_machine_images_edge_zone_list_skus_request, - build_virtual_machine_images_get_request, - build_virtual_machine_images_list_by_edge_zone_request, - build_virtual_machine_images_list_offers_request, - build_virtual_machine_images_list_publishers_request, - build_virtual_machine_images_list_request, - build_virtual_machine_images_list_skus_request, - build_virtual_machine_images_list_with_properties_request, - build_virtual_machine_run_commands_create_or_update_request, - build_virtual_machine_run_commands_delete_request, - build_virtual_machine_run_commands_get_by_virtual_machine_request, - build_virtual_machine_run_commands_get_request, - build_virtual_machine_run_commands_list_by_virtual_machine_request, - build_virtual_machine_run_commands_list_request, - build_virtual_machine_run_commands_update_request, - build_virtual_machine_scale_set_extensions_create_or_update_request, - build_virtual_machine_scale_set_extensions_delete_request, - build_virtual_machine_scale_set_extensions_get_request, - build_virtual_machine_scale_set_extensions_list_request, - build_virtual_machine_scale_set_extensions_update_request, - build_virtual_machine_scale_set_rolling_upgrades_cancel_request, - build_virtual_machine_scale_set_rolling_upgrades_get_latest_request, - build_virtual_machine_scale_set_rolling_upgrades_start_extension_upgrade_request, - build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request, - build_virtual_machine_scale_set_vm_extensions_create_or_update_request, - build_virtual_machine_scale_set_vm_extensions_delete_request, - build_virtual_machine_scale_set_vm_extensions_get_request, - build_virtual_machine_scale_set_vm_extensions_list_request, - build_virtual_machine_scale_set_vm_extensions_update_request, - build_virtual_machine_scale_set_vm_run_commands_create_or_update_request, - build_virtual_machine_scale_set_vm_run_commands_delete_request, - build_virtual_machine_scale_set_vm_run_commands_get_request, - build_virtual_machine_scale_set_vm_run_commands_list_request, - build_virtual_machine_scale_set_vm_run_commands_update_request, - build_virtual_machine_scale_set_vms_approve_rolling_upgrade_request, - build_virtual_machine_scale_set_vms_attach_detach_data_disks_request, - build_virtual_machine_scale_set_vms_deallocate_request, - build_virtual_machine_scale_set_vms_delete_request, - build_virtual_machine_scale_set_vms_get_instance_view_request, - build_virtual_machine_scale_set_vms_get_request, - build_virtual_machine_scale_set_vms_list_request, - build_virtual_machine_scale_set_vms_perform_maintenance_request, - build_virtual_machine_scale_set_vms_power_off_request, - build_virtual_machine_scale_set_vms_redeploy_request, - build_virtual_machine_scale_set_vms_reimage_all_request, - build_virtual_machine_scale_set_vms_reimage_request, - build_virtual_machine_scale_set_vms_restart_request, - build_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data_request, - build_virtual_machine_scale_set_vms_run_command_request, - build_virtual_machine_scale_set_vms_simulate_eviction_request, - build_virtual_machine_scale_set_vms_start_request, - build_virtual_machine_scale_set_vms_update_request, - build_virtual_machine_scale_sets_approve_rolling_upgrade_request, - build_virtual_machine_scale_sets_convert_to_single_placement_group_request, - build_virtual_machine_scale_sets_create_or_update_request, - build_virtual_machine_scale_sets_deallocate_request, - build_virtual_machine_scale_sets_delete_instances_request, - build_virtual_machine_scale_sets_delete_request, - build_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk_request, - build_virtual_machine_scale_sets_get_instance_view_request, - build_virtual_machine_scale_sets_get_os_upgrade_history_request, - build_virtual_machine_scale_sets_get_request, - build_virtual_machine_scale_sets_list_all_request, - build_virtual_machine_scale_sets_list_by_location_request, - build_virtual_machine_scale_sets_list_request, - build_virtual_machine_scale_sets_list_skus_request, - build_virtual_machine_scale_sets_perform_maintenance_request, - build_virtual_machine_scale_sets_power_off_request, - build_virtual_machine_scale_sets_reapply_request, - build_virtual_machine_scale_sets_redeploy_request, - build_virtual_machine_scale_sets_reimage_all_request, - build_virtual_machine_scale_sets_reimage_request, - build_virtual_machine_scale_sets_restart_request, - build_virtual_machine_scale_sets_set_orchestration_service_state_request, - build_virtual_machine_scale_sets_start_request, - build_virtual_machine_scale_sets_update_instances_request, - build_virtual_machine_scale_sets_update_request, - build_virtual_machine_sizes_list_request, - build_virtual_machines_assess_patches_request, - build_virtual_machines_attach_detach_data_disks_request, - build_virtual_machines_capture_request, - build_virtual_machines_convert_to_managed_disks_request, - build_virtual_machines_create_or_update_request, - build_virtual_machines_deallocate_request, - build_virtual_machines_delete_request, - build_virtual_machines_generalize_request, - build_virtual_machines_get_request, - build_virtual_machines_install_patches_request, - build_virtual_machines_instance_view_request, - build_virtual_machines_list_all_request, - build_virtual_machines_list_available_sizes_request, - build_virtual_machines_list_by_location_request, - build_virtual_machines_list_request, - build_virtual_machines_migrate_to_vm_scale_set_request, - build_virtual_machines_perform_maintenance_request, - build_virtual_machines_power_off_request, - build_virtual_machines_reapply_request, - build_virtual_machines_redeploy_request, - build_virtual_machines_reimage_request, - build_virtual_machines_restart_request, - build_virtual_machines_retrieve_boot_diagnostics_data_request, - build_virtual_machines_run_command_request, - build_virtual_machines_simulate_eviction_request, - build_virtual_machines_start_request, - build_virtual_machines_update_request, -) -from .._configuration import ComputeManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.Operation"]: - """List the operations for the provider. - - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.OperationListResult] = 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_operations_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(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 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 AvailabilitySetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`availability_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. - - :keyword expand: The expand expression to apply to the operation. Allowed values are - 'instanceView'. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either AvailabilitySet or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, 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(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets 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 AvailabilitySet or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, 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, availability_set_name: str, **kwargs: Any) -> _models.AvailabilitySet: - """Retrieves information about an availability set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - _request = build_availability_sets_get_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: _models.AvailabilitySet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :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: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySet, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Is either a - AvailabilitySet type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySet") - - _request = build_availability_sets_create_or_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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, - availability_set_name: str, - parameters: _models.AvailabilitySetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update 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 - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySetUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :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: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update 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 - :param parameters: Parameters supplied to the Update Availability Set operation. Is either a - AvailabilitySetUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySetUpdate or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySetUpdate") - - _request = build_availability_sets_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_availability_sets_delete_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def cancel_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> None: - """Cancel the migration operation on an Availability Set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_availability_sets_cancel_migration_to_virtual_machine_scale_set_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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 _convert_to_virtual_machine_scale_set_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Optional[Union[_models.ConvertToVirtualMachineScaleSetInput, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "ConvertToVirtualMachineScaleSetInput") - else: - _json = None - - _request = build_availability_sets_convert_to_virtual_machine_scale_set_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Optional[_models.ConvertToVirtualMachineScaleSetInput] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the - Availability Set. This does not trigger a downtime on the Virtual Machines. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. - Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ConvertToVirtualMachineScaleSetInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the - Availability Set. This does not trigger a downtime on the Virtual Machines. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. - Default value is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Optional[Union[_models.ConvertToVirtualMachineScaleSetInput, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the - Availability Set. This does not trigger a downtime on the Virtual Machines. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. Is - either a ConvertToVirtualMachineScaleSetInput type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ConvertToVirtualMachineScaleSetInput - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._convert_to_virtual_machine_scale_set_initial( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, 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 - - @overload - async def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: _models.MigrateToVirtualMachineScaleSetInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual - Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that - triggers a downtime on the Virtual Machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. - Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual - Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that - triggers a downtime on the Virtual Machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.MigrateToVirtualMachineScaleSetInput, IO[bytes]], - **kwargs: Any - ) -> None: - """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual - Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that - triggers a downtime on the Virtual Machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. Is - either a MigrateToVirtualMachineScaleSetInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput - or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "MigrateToVirtualMachineScaleSetInput") - - _request = build_availability_sets_start_migration_to_virtual_machine_scale_set_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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 - - @overload - async def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: _models.MigrateToVirtualMachineScaleSetInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Validates that the Virtual Machines in the Availability Set can be migrated to the provided - Virtual Machine Scale Set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. - Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Validates that the Virtual Machines in the Availability Set can be migrated to the provided - Virtual Machine Scale Set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.MigrateToVirtualMachineScaleSetInput, IO[bytes]], - **kwargs: Any - ) -> None: - """Validates that the Virtual Machines in the Availability Set can be migrated to the provided - Virtual Machine Scale Set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. Is - either a MigrateToVirtualMachineScaleSetInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput - or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "MigrateToVirtualMachineScaleSetInput") - - _request = build_availability_sets_validate_migration_to_virtual_machine_scale_set_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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 - - @distributed_trace - def list_available_sizes( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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_11_01.models.VirtualMachineSize] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_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 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 CapacityReservationGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`capacity_reservation_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, - resource_ids_only: Optional[Union[str, _models.ResourceIdOptionsForGetCapacityReservationGroups]] = None, - **kwargs: Any - ) -> AsyncItemPaged["_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_11_01.models.ExpandTypesForGetCapacityReservationGroups - :keyword resource_ids_only: The query option to fetch Capacity Reservation Group Resource Ids. - :code:`
    ` 'CreatedInSubscription' enables fetching Resource Ids for all capacity reservation - group resources created in the subscription. :code:`
    ` 'SharedWithSubscription' enables - fetching Resource Ids for all capacity reservation group resources shared with the - subscription. :code:`
    ` 'All' enables fetching Resource Ids for all capacity reservation - group resources shared with the subscription and created in the subscription. Known values are: - "CreatedInSubscription", "SharedWithSubscription", and "All". Default value is None. - :paramtype resource_ids_only: str or - ~azure.mgmt.compute.v2024_11_01.models.ResourceIdOptionsForGetCapacityReservationGroups - :return: An iterator like instance of either CapacityReservationGroup or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_capacity_reservation_groups_list_by_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 - - 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_resource_group( - self, - resource_group_name: str, - *, - expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, - **kwargs: Any - ) -> AsyncItemPaged["_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_11_01.models.ExpandTypesForGetCapacityReservationGroups - :return: An iterator like instance of either CapacityReservationGroup or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_capacity_reservation_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CapacityReservationGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - *, - expand: Optional[Union[str, _models.CapacityReservationGroupInstanceViewTypes]] = None, - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation that retrieves information about a capacity reservation group. - - :param resource_group_name: The name of the resource group. 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_11_01.models.CapacityReservationGroupInstanceViewTypes - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) - - _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) - - _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 - - @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. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Create capacity reservation Group. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to create or update a capacity reservation group. When updating a capacity - reservation group, only tags and sharing profile may be modified. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Create capacity reservation Group. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: Union[_models.CapacityReservationGroup, IO[bytes]], - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to create or update a capacity reservation group. When updating a capacity - reservation group, only tags and sharing profile may be modified. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Create capacity reservation Group. Is either a - CapacityReservationGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup or IO[bytes] - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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") - - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CapacityReservationGroup", 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, - 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. 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: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroupUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :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_11_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_11_01.models.CapacityReservationGroupUpdate or - IO[bytes] - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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-11-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_11_01.aio.ComputeManagementClient`'s - :attr:`dedicated_host_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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_11_01.models.DedicatedHostGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_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 - - if response.status_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 - ) -> AsyncItemPaged["_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_11_01.models.DedicatedHostGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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", "userData", and - "resiliencyView". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) - - _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) - - _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("DedicatedHostGroup", 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, - host_group_name: str, - parameters: _models.DedicatedHostGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :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: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroup, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. 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_11_01.models.DedicatedHostGroup or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DedicatedHostGroup") - - _request = build_dedicated_host_groups_create_or_update_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DedicatedHostGroup", 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, - host_group_name: str, - parameters: _models.DedicatedHostGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. 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: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroupUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Is either - a DedicatedHostGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupUpdate or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DedicatedHostGroupUpdate") - - _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) - - _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("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. The name is case insensitive. - Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_dedicated_host_groups_delete_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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 ImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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_11_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_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) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) - - @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_11_01.models.Image - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.Image] = kwargs.pop("cls", None) - - _request = build_images_get_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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("Image", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Image") - - _request = build_images_create_or_update_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 201: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: _models.Image, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Create or 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 image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Create Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.Image - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Create or 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 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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Create Image operation. Is either a Image type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.Image or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Image] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Image]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ImageUpdate") - - _request = build_images_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_update( - self, - resource_group_name: str, - image_name: str, - parameters: _models.ImageUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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 image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Update Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ImageUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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 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 Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, IO[bytes]], - **kwargs: Any - ) -> 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 image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Update Image operation. Is either a ImageUpdate - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ImageUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Image].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Image]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial(self, resource_group_name: str, image_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_images_delete_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete(self, resource_group_name: str, image_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes an Image. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - image_name=image_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, 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 VirtualMachineImagesEdgeZoneOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_images_edge_zone` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_edge_zone_list_publishers_request( - location=location, - edge_zone=edge_zone, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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, edge_zone: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of virtual machine image offers for the specified location, edge zone and - publisher. - - :param location: The name of Azure region. Required. - :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_edge_zone_list_offers_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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_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_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_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) - - _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( - 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. - - :param location: The name of Azure region. Required. - :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :keyword top: An integer value specifying the number of images to return that matches supplied - values. Default value is None. - :paramtype top: int - :keyword orderby: Specifies the order of the results returned. Formatted as an OData query. - Default value is None. - :paramtype orderby: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_edge_zone_list_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - offer=offer, - skus=skus, - subscription_id=self._config.subscription_id, - expand=expand, - top=top, - orderby=orderby, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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 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 location: The name of Azure region. Required. - :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :param version: A valid image SKU version. Required. - :type version: str - :return: VirtualMachineImage or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_edge_zone_get_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - offer=offer, - skus=skus, - version=version, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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 - - -class VirtualMachineImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_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_11_01.models.VmImagesInEdgeZoneListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VmImagesInEdgeZoneListResult] = 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) - - _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("VmImagesInEdgeZoneListResult", 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. - - :param location: The name of Azure region. Required. - :type location: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_list_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) - 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 Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_list_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_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_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_list_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) - - _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( - self, - location: str, - publisher_name: str, - offer: str, - skus: str, - *, - expand: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of all virtual machine image versions for the specified location, publisher, offer, - and SKU. - - :param location: The name of Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :keyword top: Default value is None. - :paramtype top: int - :keyword orderby: Default value is None. - :paramtype orderby: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_list_request( - location=location, - publisher_name=publisher_name, - offer=offer, - skus=skus, - subscription_id=self._config.subscription_id, - expand=expand, - top=top, - orderby=orderby, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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 get( - self, location: str, publisher_name: str, offer: str, skus: str, version: str, **kwargs: Any - ) -> _models.VirtualMachineImage: - """Gets a virtual machine image. - - :param location: The name of Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :param version: A valid image SKU version. Required. - :type version: str - :return: VirtualMachineImage or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_get_request( - location=location, - publisher_name=publisher_name, - offer=offer, - skus=skus, - version=version, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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_with_properties( - self, - location: str, - publisher_name: str, - offer: str, - skus: str, - *, - expand: str, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> List[_models.VirtualMachineImage]: - """list_with_properties. - - :param location: The name of Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :keyword expand: The expand expression to apply on the operation. Required. - :paramtype expand: str - :keyword top: Default value is None. - :paramtype top: int - :keyword orderby: Default value is None. - :paramtype orderby: str - :return: list of VirtualMachineImage or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImage]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_list_with_properties_request( - location=location, - publisher_name=publisher_name, - offer=offer, - skus=skus, - subscription_id=self._config.subscription_id, - expand=expand, - top=top, - orderby=orderby, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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 - - -class LogAnalyticsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`log_analytics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _export_request_rate_by_interval_initial( - self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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, - ) - _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["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, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 location: The name of Azure region. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. - Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RequestRateByIntervalInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either LogAnalyticsOperationResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_export_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_11_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_11_01.models.RequestRateByIntervalInput or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either LogAnalyticsOperationResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - 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._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, - **kwargs - ) - 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) - 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LogAnalyticsOperationResult]( - 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 - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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, - ) - _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["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, 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 name of Azure region. Required. - :type location: str - :param parameters: The request body. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ThrottledRequestsInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either LogAnalyticsOperationResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_export_throttled_requests( - self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show total throttled Api requests for this subscription in the given time - window. - - :param location: The name of Azure region. Required. - :type location: str - :param parameters: The request body. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either LogAnalyticsOperationResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_export_throttled_requests( - self, location: str, parameters: Union[_models.ThrottledRequestsInput, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show total throttled Api requests for this subscription in the given time - window. - - :param location: The name of Azure region. Required. - :type location: str - :param parameters: The request body. Is either a ThrottledRequestsInput type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ThrottledRequestsInput or IO[bytes] - :return: An instance of AsyncLROPoller that returns either LogAnalyticsOperationResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - 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._export_throttled_requests_initial( - location=location, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - 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) - 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": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.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_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_extension_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list_types( - self, location: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineExtensionImage]: - """Gets a list of virtual machine extension image types. - - :param location: The name of Azure region. Required. - :type location: str - :param publisher_name: Required. - :type publisher_name: str - :return: list of VirtualMachineExtensionImage or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - - _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) - - _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 list_versions( - self, - location: str, - publisher_name: str, - type: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> List[_models.VirtualMachineExtensionImage]: - """Gets a list of virtual machine extension image versions. - - :param location: The name of Azure region. Required. - :type location: str - :param publisher_name: Required. - :type publisher_name: str - :param type: Required. - :type type: str - :keyword filter: The filter to apply on the operation. Default value is None. - :paramtype filter: str - :keyword top: Default value is None. - :paramtype top: int - :keyword orderby: Default value is None. - :paramtype orderby: str - :return: list of VirtualMachineExtensionImage or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[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 = 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( - 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_11_01.models.VirtualMachineExtensionImage - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_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 = 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 - - -class VirtualMachineRunCommandsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.RunCommandDocumentBase"]: - """Lists all available run commands for a subscription in a location. - - :param location: The name of Azure region. Required. - :type location: str - :return: An iterator like instance of either RunCommandDocumentBase or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.RunCommandDocumentBase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_run_commands_list_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RunCommandListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, location: str, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: - """Gets specific run command for a subscription in a location. - - :param location: The name of Azure region. Required. - :type location: str - :param command_id: The command id. Required. - :type command_id: str - :return: RunCommandDocument or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RunCommandDocument - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) - - _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, - 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("RunCommandDocument", 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 - ) -> AsyncItemPaged["_models.VirtualMachineRunCommand"]: - """The operation to get all run commands 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 VirtualMachine. Required. - :type vm_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_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 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_11_01.models.VirtualMachineRunCommand - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - - _request = build_virtual_machine_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) - - _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 - - 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, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(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_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, - ) - _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, - 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. 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: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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_11_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_11_01.models.VirtualMachineRunCommand or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - polling: Union[bool, 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, - 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) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommand", 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.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 _update_initial( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(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_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, - ) - _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, - 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. - - :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: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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_11_01.models.VirtualMachineRunCommandUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - polling: Union[bool, 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) - - 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, 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.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 _delete_initial( - self, resource_group_name: str, vm_name: str, run_command_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_run_commands_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - run_command_name=run_command_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, vm_name: str, run_command_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to delete 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 - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - run_command_name=run_command_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 UsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.Usage"]: - """Gets, for the specified location, the current compute resource usage information as well as the - limits for compute resources under the subscription. - - :param location: The name of Azure region. Required. - :type location: str - :return: An iterator like instance of either Usage or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.Usage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ListUsagesResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ListUsagesResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.VirtualMachineScaleSet"]: - """Gets all the VM scale sets under the specified subscription for the specified location. - - :param location: The name of Azure region. Required. - :type location: str - :return: An iterator like instance of either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.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) - - @distributed_trace - def list_all(self, **kwargs: Any) -> AsyncItemPaged["_models.VirtualMachineScaleSet"]: - """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource - group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this - till nextLink is null to fetch all the VM Scale Sets. - - :return: An iterator like instance of either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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_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("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) - - 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(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.VirtualMachineScaleSet"]: - """Gets a list of all VM scale sets under a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.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_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("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_11_01.models.ExpandTypesForGetVMScaleSets - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_sets_get_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualMachineScaleSet") - - _request = build_virtual_machine_scale_sets_create_or_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - if_match=if_match, - if_none_match=if_none_match, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _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_scale_set_name: str, - parameters: _models.VirtualMachineScaleSet, - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. - :type parameters: IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_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 - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Is either a VirtualMachineScaleSet type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet or IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - parameters=parameters, - if_match=if_match, - if_none_match=if_none_match, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, 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.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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualMachineScaleSetUpdate") - - _request = build_virtual_machine_scale_sets_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - if_match=if_match, - if_none_match=if_none_match, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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_scale_set_name: str, - parameters: _models.VirtualMachineScaleSetUpdate, - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdate - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. - :type parameters: IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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_11_01.models.VirtualMachineScaleSetUpdate or - IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - parameters=parameters, - if_match=if_match, - if_none_match=if_none_match, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - 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: 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.VirtualMachineScaleSet].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualMachineScaleSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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 = 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_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. The name is case insensitive. - Required. - :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-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - force_deletion=force_deletion, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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 _approve_rolling_upgrade_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_approve_rolling_upgrade_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_approve_rolling_upgrade( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Approve upgrade on deferred rolling upgrades for OS disks in the virtual machines in a VM scale - set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_approve_rolling_upgrade( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Approve upgrade on deferred rolling upgrades for OS disks in the virtual machines in a VM scale - set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_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_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._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, 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 - - @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_11_01.models.VMScaleSetConvertToSinglePlacementGroupInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def convert_to_single_placement_group( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param parameters: The input object for ConvertToSinglePlacementGroup API. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def convert_to_single_placement_group( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VMScaleSetConvertToSinglePlacementGroupInput, IO[bytes]], - **kwargs: Any - ) -> None: - """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param parameters: The input object for ConvertToSinglePlacementGroup API. Is either a - VMScaleSetConvertToSinglePlacementGroupInput type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.compute.v2024_11_01.models.VMScaleSetConvertToSinglePlacementGroupInput or - IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VMScaleSetConvertToSinglePlacementGroupInput") - - _request = build_virtual_machine_scale_sets_convert_to_single_placement_group_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_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) - - _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_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 vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword hibernate: Optional parameter to hibernate a virtual machine from the VM scale set. - (This feature is available for VMSS with Flexible OrchestrationMode only). Default value is - None. - :paramtype hibernate: bool - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :keyword hibernate: Optional parameter to hibernate a virtual machine from the VM scale set. - (This feature is available for VMSS with Flexible OrchestrationMode only). Default value is - None. - :paramtype hibernate: bool - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._deallocate_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - hibernate=hibernate, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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 _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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - _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, - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_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_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs - :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale - set. (Feature in Preview). Default value is None. - :paramtype force_deletion: bool - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either 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_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale - set. (Feature in Preview). Default value is None. - :paramtype force_deletion: bool - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - force_deletion=force_deletion, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def force_recovery_service_fabric_platform_update_domain_walk( # pylint: disable=name-too-long - self, - resource_group_name: str, - vm_scale_set_name: str, - *, - platform_update_domain: int, - zone: Optional[str] = None, - placement_group_id: Optional[str] = None, - **kwargs: Any - ) -> _models.RecoveryWalkResponse: - """Manual platform update domain walk to update virtual machines in a service fabric virtual - machine scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :keyword platform_update_domain: The platform update domain for which a manual recovery walk is - requested. Required. - :paramtype platform_update_domain: int - :keyword zone: The zone in which the manual recovery walk is requested for cross zone virtual - machine scale set. Default value is None. - :paramtype zone: str - :keyword placement_group_id: The placement group id for which the manual recovery walk is - requested. Default value is None. - :paramtype placement_group_id: str - :return: RecoveryWalkResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RecoveryWalkResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RecoveryWalkResponse] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - platform_update_domain=platform_update_domain, - zone=zone, - placement_group_id=placement_group_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RecoveryWalkResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_instance_view( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> _models.VirtualMachineScaleSetInstanceView: - """Gets the status of a VM scale set instance. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: VirtualMachineScaleSetInstanceView or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetInstanceView - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.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 - - async def _update_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - _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, - 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_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs - :keyword content_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_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get_os_upgrade_history( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.UpgradeOperationHistoricalStatusInfo"]: - """Gets list of OS upgrades on a VM scale set instance. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An iterator like instance of either UpgradeOperationHistoricalStatusInfo or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.UpgradeOperationHistoricalStatusInfo] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_sets_get_os_upgrade_history_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_perform_maintenance( - 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]: - """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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_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 - ) -> 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. The name is case insensitive. - Required. - :type 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_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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, 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, - 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 = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_power_off_request( - resource_group_name=resource_group_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, - 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_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 - ) -> 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is None. - :paramtype skip_shutdown: bool - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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 - ) -> 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is None. - :paramtype skip_shutdown: bool - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async 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 - ) -> 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is None. - :paramtype skip_shutdown: bool - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._power_off_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - skip_shutdown=skip_shutdown, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, 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 _reapply_initial( - self, resource_group_name: str, vm_scale_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-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_sets_reapply_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._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 - - 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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_redeploy_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_redeploy( - self, - resource_group_name: str, - vm_scale_set_name: str, - 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 resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._redeploy_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reimage_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_scale_set_reimage_input, (IOBase, bytes)): - _content = vm_scale_set_reimage_input - else: - if vm_scale_set_reimage_input is not None: - _json = self._serialize.body(vm_scale_set_reimage_input, "VirtualMachineScaleSetReimageParameters") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_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_11_01.models.VirtualMachineScaleSetReimageParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which - don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual - machine is reset to initial state. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. - :type vm_scale_set_reimage_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which - don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual - machine is reset to initial state. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Is either a - VirtualMachineScaleSetReimageParameters type or a IO[bytes] type. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetReimageParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_scale_set_reimage_input=vm_scale_set_reimage_input, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, 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, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_all_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, 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, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_restart_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._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, 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 _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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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, - 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_set_orchestration_service_state( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: _models.OrchestrationServiceStateInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Changes ServiceState property for a given service. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param parameters: The input object for SetOrchestrationServiceState API. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceStateInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_set_orchestration_service_state( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Changes ServiceState property for a given service. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param parameters: The input object for SetOrchestrationServiceState API. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_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. The name is case insensitive. - Required. - :type 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_11_01.models.OrchestrationServiceStateInput or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._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, 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_skus( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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_11_01.models.VirtualMachineScaleSetSku] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetListSkusResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_sets_list_skus_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_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 - 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_start( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Starts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_start( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Starts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._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, 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 VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_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("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) - - 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, - *, - status_only: Optional[str] = None, - filter: Optional[str] = None, - expand: Optional[Union[str, _models.ExpandTypesForListVMs]] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachine"]: - """Lists all of the virtual machines in the specified subscription. Use the nextLink property in - the response to get the next page of virtual machines. - - :keyword status_only: statusOnly=true enables fetching run time status of all Virtual Machines - in the subscription. Default value is None. - :paramtype status_only: str - :keyword filter: The system query option to filter VMs returned in the response. Allowed value - is 'virtualMachineScaleSet/id' eq - /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}'. - Default value is None. - :paramtype filter: str - :keyword expand: The expand expression to apply on operation. 'instanceView' enables fetching - run time status of all Virtual Machines, this can only be specified if a valid $filter option - is specified. "instanceView" Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.ExpandTypesForListVMs - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.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 - - 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) - - 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( - self, - resource_group_name: str, - *, - filter: Optional[str] = None, - expand: Optional[Union[str, _models.ExpandTypeForListVMs]] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachine"]: - """Lists all of the virtual machines in the specified resource group. Use the nextLink property in - the response to get the next page of virtual machines. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword filter: The system query option to filter VMs returned in the response. Allowed value - is 'virtualMachineScaleSet/id' eq - /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}'. - Default value is None. - :paramtype filter: str - :keyword expand: The expand expression to apply on operation. 'instanceView' enables fetching - run time status of all Virtual Machines, this can only be specified if a valid $filter option - is specified. "instanceView" Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.ExpandTypeForListVMs - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.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 - - 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) - - 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_name: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any - ) -> _models.VirtualMachine: - """Retrieves information about the model view or the instance view of a virtual machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' retrieves a - snapshot of the runtime properties of the virtual machine that is managed by the platform and - can change outside of control plane operations. 'UserData' retrieves the UserData property as - part of the VM model view that was provided by the user during the VM Create/Update operation. - Known values are: "instanceView", "userData", and "resiliencyView". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachine - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) - - _request = build_virtual_machines_get_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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_11_01.models.VirtualMachine - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Create Virtual Machine operation. Required. - :type parameters: IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_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_11_01.models.VirtualMachine or IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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_11_01.models.VirtualMachineUpdate - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Update Virtual Machine operation. Required. - :type parameters: IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_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_11_01.models.VirtualMachineUpdate or IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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-11-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-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_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 - - 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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_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) - - _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_11_01.models.VirtualMachineAssessPatchesResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_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 - ) - 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) - 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.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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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_11_01.models.AttachDetachDataDisksRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_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. 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_11_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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the attach and detach data disks operation on the - virtual machine. Is either a AttachDetachDataDisksRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.StorageProfile] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._attach_detach_data_disks_initial( - resource_group_name=resource_group_name, - vm_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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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 = 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_11_01.models.VirtualMachineCaptureParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineCaptureResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_capture( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Capture Virtual Machine operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineCaptureResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_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_11_01.models.VirtualMachineCaptureParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineCaptureResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineCaptureResult] = kwargs.pop("cls", None) - polling: Union[bool, 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 - ) - 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) - 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.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 _convert_to_managed_disks_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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_convert_to_managed_disks_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._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, 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 _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-11-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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_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. 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._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, 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 generalize(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> None: - """Sets the OS state of the virtual machine to generalized. It is recommended to sysprep the - virtual machine before performing this operation. For Windows, please refer to `Create a - managed image of a generalized VM in Azure - `_. For - Linux, please refer to `How to create an image of a virtual machine or VHD - `_. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_virtual_machines_generalize_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(install_patches_input, (IOBase, bytes)): - _content = install_patches_input - else: - _json = self._serialize.body(install_patches_input, "VirtualMachineInstallPatchesParameters") - - _request = build_virtual_machines_install_patches_request( - 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_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_11_01.models.VirtualMachineInstallPatchesParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineInstallPatchesResult - or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_install_patches( - self, - resource_group_name: str, - vm_name: str, - install_patches_input: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. - - :param resource_group_name: The name of the resource group. 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_11_01.models.VirtualMachineInstallPatchesResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_install_patches( - self, - resource_group_name: str, - vm_name: str, - install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param install_patches_input: Input for InstallPatches as directly received by the API. Is - either a VirtualMachineInstallPatchesParameters type or a IO[bytes] type. Required. - :type install_patches_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineInstallPatchesResult - or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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._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, - **kwargs - ) - 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) - 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.VirtualMachineInstallPatchesResult].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 - ) - - @distributed_trace_async - async def instance_view( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> _models.VirtualMachineInstanceView: - """Retrieves information about the run-time state of a virtual machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: VirtualMachineInstanceView or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstanceView - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) - - _request = build_virtual_machines_instance_view_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineInstanceView", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _migrate_to_vm_scale_set_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[Union[_models.MigrateVMToVirtualMachineScaleSetInput, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "MigrateVMToVirtualMachineScaleSetInput") - else: - _json = None - - _request = build_virtual_machines_migrate_to_vm_scale_set_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_migrate_to_vm_scale_set( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[_models.MigrateVMToVirtualMachineScaleSetInput] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Migrate Virtual Machine operation. Default value - is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateVMToVirtualMachineScaleSetInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of 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_migrate_to_vm_scale_set( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Migrate Virtual Machine operation. Default value - is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of 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_migrate_to_vm_scale_set( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[Union[_models.MigrateVMToVirtualMachineScaleSetInput, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Migrate Virtual Machine operation. Is either a - MigrateVMToVirtualMachineScaleSetInput type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateVMToVirtualMachineScaleSetInput - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._migrate_to_vm_scale_set_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **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 _perform_maintenance_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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _power_off_initial( - self, resource_group_name: str, vm_name: str, *, skip_shutdown: Optional[bool] = None, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_power_off_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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_power_off( - self, resource_group_name: str, vm_name: str, *, skip_shutdown: Optional[bool] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with - the same provisioned resources. You are still charged for this virtual machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is None. - :paramtype skip_shutdown: bool - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._power_off_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - skip_shutdown=skip_shutdown, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, 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 _reapply_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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_reapply_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reapply_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_redeploy_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._redeploy_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reimage_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "VirtualMachineReimageParameters") - else: - _json = None - - _request = build_virtual_machines_reimage_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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_reimage( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[_models.VirtualMachineReimageParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, - for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial - state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If - deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is - delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should - be updated accordingly before performing the reimage. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineReimageParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_reimage( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, - for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial - state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If - deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is - delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should - be updated accordingly before performing the reimage. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, - for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial - state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If - deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is - delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should - be updated accordingly before performing the reimage. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Is either a - VirtualMachineReimageParameters type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineReimageParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _restart_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 {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_restart_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._restart_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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 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_11_01.models.RetrieveBootDiagnosticsDataResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) - - _request = build_virtual_machines_retrieve_boot_diagnostics_data_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RetrieveBootDiagnosticsDataResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _run_command_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RunCommandInput") - - _request = build_virtual_machines_run_command_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_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput or IO[bytes] - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._run_command_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def simulate_eviction(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> None: - """The operation to simulate the eviction of spot virtual machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_virtual_machines_simulate_eviction_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - 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_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_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, - 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 - - @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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._start_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_available_sizes( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes to which the specified virtual machine can be - resized. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_available_sizes_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class VirtualMachineSizesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.VirtualMachineSize"]: - """This API is deprecated. Use `Resources Skus - `_. - - :param location: The name of Azure region. Required. - :type location: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_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 - - 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 ProximityPlacementGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`proximity_placement_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a subscription. - - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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 - ) -> AsyncItemPaged["_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_11_01.models.ProximityPlacementGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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_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_11_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - _request = build_proximity_placement_groups_get_request( - resource_group_name=resource_group_name, - proximity_placement_group_name=proximity_placement_group_name, - subscription_id=self._config.subscription_id, - include_colocation_status=include_colocation_status, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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_11_01.models.ProximityPlacementGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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_11_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - 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 resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Create Proximity Placement Group operation. Is - either a ProximityPlacementGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup or IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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_11_01.models.ProximityPlacementGroupUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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_11_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - 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 resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Update Proximity Placement Group operation. Is - either a ProximityPlacementGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroupUpdate or - IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ProximityPlacementGroupUpdate") - - _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, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete(self, resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any) -> None: - """Delete a proximity placement group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_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, - 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 - - -class RestorePointCollectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`restore_point_collections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_all(self, **kwargs: Any) -> AsyncItemPaged["_models.RestorePointCollection"]: - """Gets the list of restore point collections in the subscription. Use nextLink property in the - response to get the next page of restore point collections. Do this till nextLink is not null - to fetch all the restore point collections. - - :return: An iterator like instance of either RestorePointCollection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_restore_point_collections_list_all_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RestorePointCollectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _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(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.RestorePointCollection"]: - """Gets the list of restore point collections 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 RestorePointCollection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_restore_point_collections_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RestorePointCollectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_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. 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_11_01.models.RestorePointCollectionExpandOptions - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) - - _request = build_restore_point_collections_get_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: _models.RestorePointCollection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to create or update the restore point collection. Please refer to - https://aka.ms/RestorePoints for more details. When updating a restore point collection, only - tags may be modified. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Create or Update restore point collection - operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to create or update the restore point collection. Please refer to - https://aka.ms/RestorePoints for more details. When updating a restore point collection, only - tags may be modified. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Create or Update restore point collection - operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: Union[_models.RestorePointCollection, IO[bytes]], - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to create or update the restore point collection. Please refer to - https://aka.ms/RestorePoints for more details. When updating a restore point collection, only - tags may be modified. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Create or Update restore point collection - operation. Is either a RestorePointCollection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection or IO[bytes] - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RestorePointCollection") - - _request = build_restore_point_collections_create_or_update_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RestorePointCollection", 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, - restore_point_collection_name: str, - parameters: _models.RestorePointCollectionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to update the restore point collection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Update restore point collection operation. - Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to update the restore point collection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Update restore point collection operation. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: Union[_models.RestorePointCollectionUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to update the restore point collection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Update restore point collection operation. Is - either a RestorePointCollectionUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionUpdate or - IO[bytes] - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RestorePointCollectionUpdate") - - _request = build_restore_point_collections_update_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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 - - async def _delete_initial( - self, resource_group_name: str, restore_point_collection_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_restore_point_collections_delete_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, restore_point_collection_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to delete the restore point collection. This operation will also delete all the - contained restore points. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - -class SshPublicKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`ssh_public_keys` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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_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("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) - - 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 - ) -> AsyncItemPaged["_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. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either SshPublicKeyResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_ssh_public_keys_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) - - 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, 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - - _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) - - _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("SshPublicKeyResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to create the SSH public key. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to create the SSH public key. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_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. - - :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_11_01.models.SshPublicKeyResource or IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SshPublicKeyResource") - - _request = build_ssh_public_keys_create_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, - 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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # 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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to update the SSH public key. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyUpdateResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def 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. - - :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. Is either a - SshPublicKeyUpdateResource type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyUpdateResource or - IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SshPublicKeyUpdateResource") - - _request = build_ssh_public_keys_update_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, - 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("SshPublicKeyResource", 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, ssh_public_key_name: str, **kwargs: Any) -> None: - """Delete an SSH public key. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_ssh_public_keys_delete_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) - - _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 - - @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. - - :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_11_01.models.SshGenerateKeyPairInputParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyGenerateKeyPairResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def generate_key_pair( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyGenerateKeyPairResult: - """Generates and returns a public/private key pair and populates the SSH public key resource with - the public key. The length of the key will be 3072 bits. This operation can only be performed - once per SSH public key resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to generate the SSH public key. Default value is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyGenerateKeyPairResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def generate_key_pair( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: Optional[Union[_models.SshGenerateKeyPairInputParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> _models.SshPublicKeyGenerateKeyPairResult: - """Generates and returns a public/private key pair and populates the SSH public key resource with - the public key. The length of the key will be 3072 bits. This operation can only be performed - once per SSH public key resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to generate the SSH public key. Is either a - SshGenerateKeyPairInputParameters type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshGenerateKeyPairInputParameters or - IO[bytes] - :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyGenerateKeyPairResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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_ssh_public_keys_generate_key_pair_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, - 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("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_11_01.aio.ComputeManagementClient`'s - :attr:`capacity_reservations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_by_capacity_reservation_group( - self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.CapacityReservation"]: - """Lists all of the capacity reservations in the specified capacity reservation group. Use the - nextLink property in the response to get the next page of capacity reservations. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :return: An iterator like instance of either CapacityReservation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.CapacityReservationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_capacity_reservations_list_by_capacity_reservation_group_request( - resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) - - 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, - 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' retrieves a - snapshot of the runtime properties of the capacity reservation that is managed by the platform - and can change outside of control plane operations. "instanceView" Default value is None. - :paramtype expand: str or - ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationInstanceViewTypes - :return: CapacityReservation or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CapacityReservation") - - _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) - - _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, - 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Create capacity reservation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Create capacity reservation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def 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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Create capacity reservation. Is either a - CapacityReservation type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservation or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - capacity_reservation_name=capacity_reservation_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.CapacityReservation].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CapacityReservation]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CapacityReservationUpdate") - - _request = build_capacity_reservations_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) - - _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_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: _models.CapacityReservationUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CapacityReservation]: - """The operation to update a capacity reservation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Update capacity reservation operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CapacityReservation]: - """The operation to update a capacity reservation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Update capacity reservation operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.CapacityReservation]: - """The operation to update a capacity reservation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Update capacity reservation operation. Is either - a CapacityReservationUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._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 _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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_capacity_reservations_delete_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, - 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, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to delete a capacity reservation. This operation is allowed only when all the - associated resources are disassociated from the capacity reservation. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. 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 - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - 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) - - 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 DedicatedHostsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`dedicated_hosts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_host_group( - self, resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :return: An iterator like instance of either DedicatedHost or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostListResult] = kwargs.pop("cls", None) - - 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_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, - 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("DedicatedHostListResult", 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, - 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param host_name: The name of the dedicated host. Required. - :type host_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve - the list of instance views of the dedicated host. 'UserData' is not supported for dedicated - host. Known values are: "instanceView", "userData", and "resiliencyView". Default value is - None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes - :return: DedicatedHost or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHost - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHost] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_get_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DedicatedHost", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DedicatedHost") - - _request = build_dedicated_hosts_create_or_update_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, - 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, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHost, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Create or update a dedicated host . - - :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 - :param parameters: Parameters supplied to the Create Dedicated Host. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHost - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Create or update a dedicated host . - - :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 - :param parameters: Parameters supplied to the Create Dedicated Host. 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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Create or update a dedicated host . - - :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 - :param parameters: Parameters supplied to the Create Dedicated Host. Is either a DedicatedHost - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHost or IO[bytes] - :return: An instance of AsyncLROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DedicatedHostUpdate") - - _request = build_dedicated_hosts_update_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, - 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, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHostUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Update a dedicated host . - - :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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostUpdate - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Update a dedicated host . - - :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 - :param parameters: Parameters supplied to the Update Dedicated Host 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 DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DedicatedHost]: - """Update a dedicated host . - - :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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Is either a - DedicatedHostUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_delete_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 [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, host_group_name: str, host_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete a dedicated host. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param host_name: The name of the dedicated host. Required. - :type host_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_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 - - @distributed_trace - def list_available_sizes( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> AsyncItemPaged[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. 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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_hosts_list_available_sizes_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DedicatedHostSizeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return 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 _redeploy_initial( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_redeploy_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_redeploy( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Redeploy the dedicated host. The operation will complete successfully once the dedicated host - has migrated to a new node and is running. To determine the health of VMs deployed on the - dedicated host after the redeploy check the Resource Health Center in the Azure Portal. Please - refer to https://docs.microsoft.com/azure/service-health/resource-health-overview for more - details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param host_name: The name of the dedicated host. Required. - :type host_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._redeploy_initial( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _restart_initial( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_restart_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 [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 - - @distributed_trace_async - async def begin_restart( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> AsyncLROPoller[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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param host_name: The name of the dedicated host. Required. - :type host_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._restart_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 - - -class RestorePointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`restore_points` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - *, - expand: Optional[Union[str, _models.RestorePointExpandOptions]] = None, - **kwargs: Any - ) -> _models.RestorePoint: - """The operation to get the restore point. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param restore_point_name: The name of the restore point. Required. - :type restore_point_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' retrieves - information about the run-time state of a restore point. "instanceView" Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.RestorePointExpandOptions - :return: RestorePoint or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePoint - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) - - _request = build_restore_points_get_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - restore_point_name=restore_point_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RestorePoint", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - parameters: Union[_models.RestorePoint, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RestorePoint") - - _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) - - _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 [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 = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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( - 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param restore_point_name: The name of the restore point. Required. - :type restore_point_name: str - :param parameters: Parameters supplied to the Create restore point operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePoint - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RestorePoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. 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: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RestorePoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param restore_point_name: The name of the restore point. Required. - :type restore_point_name: str - :param parameters: Parameters supplied to the Create restore point operation. Is either a - RestorePoint type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePoint or IO[bytes] - :return: An instance of AsyncLROPoller that returns either RestorePoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_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-11-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, 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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_restore_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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, restore_point_collection_name: str, 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. 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 - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - 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) - - 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 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_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_rolling_upgrades_start_extension_upgrade_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) - - _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_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._start_extension_upgrade_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, 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 _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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_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) - - _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_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._start_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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_rolling_upgrades_cancel_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) - - _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_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._cancel_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get_latest( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> _models.RollingUpgradeStatusInfo: - """Gets the status of the latest virtual machine scale set rolling upgrade. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: RollingUpgradeStatusInfo or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RollingUpgradeStatusInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.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 = 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("RollingUpgradeStatusInfo", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class VirtualMachineScaleSetExtensionsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.VirtualMachineScaleSetExtension"]: - """Gets a list of all extensions in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An iterator like instance of either VirtualMachineScaleSetExtension or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetExtensionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_set_extensions_list_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) - - @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. The name is case insensitive. - Required. - :type 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_11_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-11-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 - - 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]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtension") - - _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, - 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, - 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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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 - :param extension_parameters: Parameters supplied to the Create VM scale set Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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 - :param extension_parameters: Parameters supplied to the Create VM scale set Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtension, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to create or update an extension. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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 - :param extension_parameters: Parameters supplied to the Create VM scale set Extension - operation. Is either a VirtualMachineScaleSetExtension type or a IO[bytes] type. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, 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.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _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]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtensionUpdate") - - _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, - 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_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. The name is case insensitive. - Required. - :type 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 - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtensionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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 - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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 - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Is either a VirtualMachineScaleSetExtensionUpdate type or a IO[bytes] type. - Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtensionUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, 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.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_extensions_delete_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, - 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_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. The name is case insensitive. - Required. - :type 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 - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - 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, 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 VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - virtual_machine_scale_set_name: str, - *, - filter: Optional[str] = None, - select: Optional[str] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualMachineScaleSetVM"]: - """Gets a list of all virtual machines in a VM scale sets. - - :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 VirtualMachineScaleSet. Required. - :type virtual_machine_scale_set_name: str - :keyword filter: The filter to apply to the operation. Allowed values are - 'startswith(instanceView/statuses/code, 'PowerState') eq true', 'properties/latestModelApplied - eq true', 'properties/latestModelApplied eq false'. Default value is None. - :paramtype filter: str - :keyword select: The list parameters. Allowed values are 'instanceView', - 'instanceView/statuses'. Default value is None. - :paramtype select: str - :keyword expand: The expand expression to apply to the operation. Allowed values are - 'instanceView'. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.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) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSetVM: - """Gets a virtual machine from a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve - the instance view of the virtual machine. 'UserData' will retrieve the UserData of the virtual - machine. Known values are: "instanceView", "userData", and "resiliencyView". Default value is - None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.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 = 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("VirtualMachineScaleSetVM", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualMachineScaleSetVM") - - _request = build_virtual_machine_scale_set_vms_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - if_match=if_match, - if_none_match=if_none_match, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_update( - self, - resource_group_name: str, - 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 - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 Update Virtual Machine Scale Sets VM operation. - Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :keyword content_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) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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 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: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVM or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 Update Virtual Machine Scale Sets VM operation. - Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM or IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVM or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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) - - 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 - - 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 - ) - - async def _delete_initial( - 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, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - force_deletion=force_deletion, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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_scale_set_name: str, - instance_id: str, - *, - force_deletion: Optional[bool] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes 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 - :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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - 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 - - 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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._approve_rolling_upgrade_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _attach_detach_data_disks_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: 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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AttachDetachDataDisksRequest") - - _request = build_virtual_machine_scale_set_vms_attach_detach_data_disks_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 - 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_scale_set_name: str, - instance_id: str, - parameters: _models.AttachDetachDataDisksRequest, - *, - 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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the attach and detach data disks operation on a - Virtual Machine Scale Sets VM. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_attach_detach_data_disks( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: 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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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 AsyncLROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_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 - ) -> 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the attach and detach data disks operation on a - Virtual Machine Scale Sets VM. Is either a AttachDetachDataDisksRequest type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.StorageProfile] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._attach_detach_data_disks_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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 _deallocate_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._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, 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_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_11_01.models.VirtualMachineScaleSetVMInstanceView - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMInstanceView] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_get_instance_view_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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 - - 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-11-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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_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 vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._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, - vm_scale_set_name: str, - instance_id: str, - *, - skip_shutdown: Optional[bool] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - skip_shutdown: Optional[bool] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached - and you are getting charged for the resources. Instead, use deallocate to release resources and - avoid charges. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._power_off_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _redeploy_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_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, - 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 - - @distributed_trace_async - async def begin_redeploy( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Shuts down the virtual machine in the virtual machine scale set, moves it to a new node, and - powers it back on. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._redeploy_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reimage_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[ - Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] - ] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_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, - 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 - 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_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Default value is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMReimageParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :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. The name is case insensitive. - Required. - :type 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_11_01.models.VirtualMachineScaleSetVMReimageParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_scale_set_vm_reimage_input=vm_scale_set_vm_reimage_input, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_reimage_all( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. - This operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_all_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, 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, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_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 = 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_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._restart_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def retrieve_boot_diagnostics_data( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - sas_uri_expiration_time_in_minutes: Optional[int] = None, - **kwargs: Any - ) -> _models.RetrieveBootDiagnosticsDataResult: - """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale - set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword sas_uri_expiration_time_in_minutes: Expiration duration in minutes for the SAS URIs - with a value between 1 to 1440 minutes. **Note:** If not specified, SAS URIs will be generated - with a default expiration duration of 120 minutes. Default value is None. - :paramtype sas_uri_expiration_time_in_minutes: int - :return: RetrieveBootDiagnosticsDataResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RetrieveBootDiagnosticsDataResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RunCommandInput") - - _request = build_virtual_machine_scale_set_vms_run_command_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 - 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_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput or IO[bytes] - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._run_command_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def simulate_eviction( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> None: - """The operation to simulate the eviction of spot virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_simulate_eviction_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - async def _start_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_start_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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._start_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 - - -class VirtualMachineScaleSetVMExtensionsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vm_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: - """The operation to get all extensions of an instance in Virtual Machine Scaleset. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineScaleSetVMExtensionsListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionsListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_extensions_list_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_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, - 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineScaleSetVMExtension or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.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 = 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("VirtualMachineScaleSetVMExtension", 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, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetVMExtension") - - _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) - - _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_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetVMExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVMExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVMExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Is either a VirtualMachineScaleSetVMExtension type or a IO[bytes] type. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVMExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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, 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 _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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(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( - 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) - - _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_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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVMExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_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 resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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_11_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to update the VMSS VM extension. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Is either a VirtualMachineScaleSetVMExtensionUpdate type or a IO[bytes] type. - Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVMExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) - polling: Union[bool, 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) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, 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.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 _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, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_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) - - _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_scale_set_name: str, instance_id: str, vm_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to delete the VMSS VM extension. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, 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 VirtualMachineScaleSetVMRunCommandsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vm_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. - :type vm_scale_set_name: str - :param instance_id: The name of the VirtualMachineScaleSetVM. Required. - :type instance_id: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_set_vm_run_commands_list_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommandsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. - :type vm_scale_set_name: str - :param instance_id: The name of the VirtualMachineScaleSetVM. Required. - :type instance_id: str - :param run_command_name: The name of the VirtualMachineRunCommand. Required. - :type run_command_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineRunCommand or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_run_commands_get_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - run_command_name=run_command_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(run_command, (IOBase, bytes)): - _content = run_command - else: - _json = self._serialize.body(run_command, "VirtualMachineRunCommand") - - _request = build_virtual_machine_scale_set_vm_run_commands_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, - 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, - 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 VMSS VM 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_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: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update the VMSS VM 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_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. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update the VMSS VM 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_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. - :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - polling: Union[bool, 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, - 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("VirtualMachineRunCommand", 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.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 _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]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(run_command, (IOBase, bytes)): - _content = run_command - else: - _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") - - _request = build_virtual_machine_scale_set_vm_run_commands_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, - 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) - - 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_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 VMSS VM 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_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: Resource create parameters. Required. - :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the VMSS VM 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_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: Resource create parameters. Required. - :type run_command: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_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]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the VMSS VM 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_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: Resource create parameters. Is either a VirtualMachineRunCommandUpdate type - or a IO[bytes] type. Required. - :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - polling: Union[bool, 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, - 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("VirtualMachineRunCommand", 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.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 _delete_initial( - 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, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_run_commands_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, - 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, vm_scale_set_name: str, instance_id: str, run_command_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to delete the VMSS VM 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_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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - run_command_name=run_command_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 VirtualMachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_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. 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. Default value is None. - :paramtype expand: str - :return: VirtualMachineExtensionsListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionsListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_list_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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 - - @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. 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 vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineExtension or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_get_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineExtension") - - _request = build_virtual_machine_extensions_create_or_update_request( - resource_group_name=resource_group_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, - 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, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """The operation to create or update 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_name: The name of the virtual machine. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_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 create or update 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_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. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """The operation to create or update 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_name: The name of the virtual machine. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Is either a VirtualMachineExtension type or a IO[bytes] type. Required. - :type extension_parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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_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, - 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("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, 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( - 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 - ) - - 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 - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineExtensionUpdate") - - _request = build_virtual_machine_extensions_update_request( - resource_group_name=resource_group_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, - 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, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtensionUpdate, - *, - 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. 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 vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_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. 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 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_11_01.models.VirtualMachineExtension] - :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. 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 vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Is either a VirtualMachineExtensionUpdate type or a IO[bytes] type. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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_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, - 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("VirtualMachineExtension", 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.VirtualMachineExtension].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 - ) - - async def _delete_initial( - self, resource_group_name: str, vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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) - - _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, vm_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to delete 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_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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/operations/__init__.py deleted file mode 100644 index 6718c8ecb4f9..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/operations/__init__.py +++ /dev/null @@ -1,75 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - 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 VirtualMachineScaleSetsOperations # type: ignore -from ._operations import VirtualMachinesOperations # type: ignore -from ._operations import VirtualMachineSizesOperations # type: ignore -from ._operations import ProximityPlacementGroupsOperations # type: ignore -from ._operations import RestorePointCollectionsOperations # type: ignore -from ._operations import SshPublicKeysOperations # type: ignore -from ._operations import CapacityReservationsOperations # 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 * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AvailabilitySetsOperations", - "CapacityReservationGroupsOperations", - "DedicatedHostGroupsOperations", - "ImagesOperations", - "VirtualMachineImagesEdgeZoneOperations", - "VirtualMachineImagesOperations", - "LogAnalyticsOperations", - "VirtualMachineExtensionImagesOperations", - "VirtualMachineRunCommandsOperations", - "UsageOperations", - "VirtualMachineScaleSetsOperations", - "VirtualMachinesOperations", - "VirtualMachineSizesOperations", - "ProximityPlacementGroupsOperations", - "RestorePointCollectionsOperations", - "SshPublicKeysOperations", - "CapacityReservationsOperations", - "DedicatedHostsOperations", - "RestorePointsOperations", - "VirtualMachineScaleSetRollingUpgradesOperations", - "VirtualMachineScaleSetExtensionsOperations", - "VirtualMachineScaleSetVMsOperations", - "VirtualMachineScaleSetVMExtensionsOperations", - "VirtualMachineScaleSetVMRunCommandsOperations", - "VirtualMachineExtensionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/operations/_operations.py deleted file mode 100644 index 05915f7171f3..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/operations/_operations.py +++ /dev/null @@ -1,29653 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterator, List, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import ComputeManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_operations_list_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/operations") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", 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") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_availability_sets_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets", - ) - 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 - ), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_availability_sets_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) - 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 - ), - "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") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) - 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 - ), - "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") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_availability_sets_cancel_migration_to_virtual_machine_scale_set_request( # pylint: disable=name-too-long - resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/cancelMigrationToVirtualMachineScaleSet", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_availability_sets_convert_to_virtual_machine_scale_set_request( # pylint: disable=name-too-long - resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/convertToVirtualMachineScaleSet", - ) - 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 - ), - "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") - - # 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_availability_sets_start_migration_to_virtual_machine_scale_set_request( # pylint: disable=name-too-long - resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/startMigrationToVirtualMachineScaleSet", - ) - 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 - ), - "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") - - # 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_availability_sets_validate_migration_to_virtual_machine_scale_set_request( # pylint: disable=name-too-long - resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/validateMigrationToVirtualMachineScaleSet", - ) - 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 - ), - "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") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/capacityReservationGroups" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - if resource_ids_only is not None: - _params["resourceIdsOnly"] = _SERIALIZER.query("resource_ids_only", resource_ids_only, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups", - ) - 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 - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", - ) - 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 - ), - "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") - - 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", - ) - 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 - ), - "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") - - # 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_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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", - ) - 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 - ), - "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") - - # 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_capacity_reservation_groups_delete_request( # pylint: disable=name-too-long - resource_group_name: str, capacity_reservation_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups") - path_format_arguments = { - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups", - ) - 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 - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dedicated_host_groups_get_request( - resource_group_name: str, - host_group_name: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - 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_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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - 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_dedicated_host_groups_delete_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_images_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") - path_format_arguments = { - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images", - ) - 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 - ), - } - - _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_images_get_request( - resource_group_name: str, image_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", - ) - 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 - ), - "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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", - ) - 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 - ), - "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") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", - ) - 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 - ), - "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") - - # 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_images_delete_request( - resource_group_name: str, image_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers", - ) - path_format_arguments = { - "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 - _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_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-11-01")) - 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", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "location": _SERIALIZER.url("location", location, "str", min_length=1), - "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"), - "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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_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-11-01")) - 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", - ) - path_format_arguments = { - "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 - - # 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_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-11-01")) - 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", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "location": _SERIALIZER.url("location", location, "str", min_length=1), - "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"), - "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), - "offer": _SERIALIZER.url("offer", offer, "str"), - "skus": _SERIALIZER.url("skus", skus, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - if orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}", - ) - path_format_arguments = { - "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 - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/vmimages", - ) - path_format_arguments = { - "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 - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers" - ) - path_format_arguments = { - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers", - ) - path_format_arguments = { - "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 - - # 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_images_list_skus_request( # pylint: disable=name-too-long - location: str, publisher_name: str, offer: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus", - ) - path_format_arguments = { - "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 - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", - ) - path_format_arguments = { - "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="GET", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}", - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str", min_length=1), - "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), - "offer": _SERIALIZER.url("offer", offer, "str"), - "skus": _SERIALIZER.url("skus", skus, "str"), - "version": _SERIALIZER.url("version", version, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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_images_list_with_properties_request( # pylint: disable=name-too-long - location: str, - publisher_name: str, - offer: str, - skus: str, - subscription_id: str, - *, - expand: str, - 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-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", - ) - path_format_arguments = { - "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") - _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="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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval", - ) - path_format_arguments = { - "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") - - # 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests", - ) - path_format_arguments = { - "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") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types", - ) - path_format_arguments = { - "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 - - # 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_extension_images_list_versions_request( # pylint: disable=name-too-long - location: str, - publisher_name: str, - type: str, - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "location": _SERIALIZER.url("location", location, "str", min_length=1), - "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), - "type": _SERIALIZER.url("type", type, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - if orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}", - ) - path_format_arguments = { - "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 - _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_list_request( # pylint: disable=name-too-long - location: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands" - ) - path_format_arguments = { - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_run_commands_get_request( # pylint: disable=name-too-long - location: str, command_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}", - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str", min_length=1), - "commandId": _SERIALIZER.url("command_id", command_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", - ) - 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"), - "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="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_run_commands_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, run_command_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", - ) - 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"), - "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") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_run_commands_update_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, run_command_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", - ) - 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"), - "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") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", - ) - 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"), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages" - ) - path_format_arguments = { - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachineScaleSets", - ) - path_format_arguments = { - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_list_all_request( # pylint: disable=name-too-long - subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets" - ) - path_format_arguments = { - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets", - ) - 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 - ), - } - - _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_scale_sets_get_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.ExpandTypesForGetVMScaleSets]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", - ) - 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 - ), - "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 expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - subscription_id: str, - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", - ) - 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 - ), - "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") - - # 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) - - -def build_virtual_machine_scale_sets_update_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - subscription_id: str, - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", - ) - 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 - ), - "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") - - # 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) - - -def build_virtual_machine_scale_sets_delete_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - subscription_id: str, - *, - force_deletion: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", - ) - 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 - ), - "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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_approve_rolling_upgrade_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/approveRollingUpgrade", - ) - 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 - ), - "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") - - # 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_sets_convert_to_single_placement_group_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup", - ) - 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 - ), - "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") - - # 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_sets_deallocate_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - subscription_id: str, - *, - hibernate: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate", - ) - 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 - ), - "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 hibernate is not None: - _params["hibernate"] = _SERIALIZER.query("hibernate", hibernate, "bool") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_delete_instances_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - subscription_id: str, - *, - force_deletion: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete", - ) - 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 - ), - "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="POST", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk", - ) - 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 - ), - "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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_get_instance_view_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade", - ) - 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 - ), - "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") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_sets_perform_maintenance_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance", - ) - 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 - ), - "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") - - # 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_sets_power_off_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - subscription_id: str, - *, - skip_shutdown: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff", - ) - 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 - ), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if skip_shutdown is not None: - _params["skipShutdown"] = _SERIALIZER.query("skip_shutdown", skip_shutdown, "bool") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reapply", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy", - ) - 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 - ), - "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") - - # 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_sets_reimage_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage", - ) - 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 - ), - "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") - - # 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_sets_reimage_all_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall", - ) - 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 - ), - "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") - - # 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_sets_restart_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart", - ) - 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 - ), - "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") - - # 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_sets_set_orchestration_service_state_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/setOrchestrationServiceState", - ) - 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 - ), - "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") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start", - ) - 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 - ), - "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") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines", - ) - path_format_arguments = { - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_list_all_request( - subscription_id: str, - *, - status_only: Optional[str] = None, - filter: Optional[str] = None, - expand: Optional[Union[str, _models.ExpandTypesForListVMs]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if status_only is not None: - _params["statusOnly"] = _SERIALIZER.query("status_only", status_only, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines", - ) - 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 - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_get_request( - resource_group_name: str, - vm_name: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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) - - -def build_virtual_machines_update_request( - resource_group_name: str, - vm_name: str, - subscription_id: str, - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", - ) - 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"), - } - - _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/assessPatches", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/attachDetachDataDisks", - ) - 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"), - } - - _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_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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture", - ) - 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"), - } - - _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_machines_convert_to_managed_disks_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks", - ) - 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"), - } - - _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="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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate", - ) - 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"), - } - - _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") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_generalize_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_install_patches_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/installPatches", - ) - 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"), - } - - _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_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-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView", - ) - 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"), - } - - _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_machines_migrate_to_vm_scale_set_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/migrateToVirtualMachineScaleSet", - ) - 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"), - } - - _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_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-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_power_off_request( - resource_group_name: str, vm_name: str, subscription_id: str, *, skip_shutdown: Optional[bool] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff", - ) - 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"), - } - - _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="POST", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reapply", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_redeploy_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_reimage_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart", - ) - 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"), - } - - _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="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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/retrieveBootDiagnosticsData", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_run_command_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand", - ) - 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"), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/simulateEviction", - ) - 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"), - } - - _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="POST", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start", - ) - 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"), - } - - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machines_list_available_sizes_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes", - ) - 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"), - } - - _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_sizes_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes" - ) - path_format_arguments = { - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups" - ) - path_format_arguments = { - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups", - ) - 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 - ), - } - - _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_proximity_placement_groups_get_request( # pylint: disable=name-too-long - resource_group_name: str, - proximity_placement_group_name: str, - subscription_id: str, - *, - include_colocation_status: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", - ) - 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 - ), - "proximityPlacementGroupName": _SERIALIZER.url( - "proximity_placement_group_name", proximity_placement_group_name, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if include_colocation_status is not None: - _params["includeColocationStatus"] = _SERIALIZER.query( - "include_colocation_status", include_colocation_status, "str" - ) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_proximity_placement_groups_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", - ) - 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 - ), - "proximityPlacementGroupName": _SERIALIZER.url( - "proximity_placement_group_name", proximity_placement_group_name, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # 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_proximity_placement_groups_update_request( # pylint: disable=name-too-long - resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", - ) - 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 - ), - "proximityPlacementGroupName": _SERIALIZER.url( - "proximity_placement_group_name", proximity_placement_group_name, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # 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_proximity_placement_groups_delete_request( # pylint: disable=name-too-long - resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", - ) - 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 - ), - "proximityPlacementGroupName": _SERIALIZER.url( - "proximity_placement_group_name", proximity_placement_group_name, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/restorePointCollections" - ) - path_format_arguments = { - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections", - ) - 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 - ), - } - - _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_restore_point_collections_get_request( # pylint: disable=name-too-long - resource_group_name: str, - restore_point_collection_name: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.RestorePointCollectionExpandOptions]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}", - ) - 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 - ), - "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") - - return HttpRequest(method="GET", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}", - ) - 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 - ), - "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") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}", - ) - 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 - ), - "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") - - # 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_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-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/sshPublicKeys") - path_format_arguments = { - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys", - ) - 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 - ), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", - ) - 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 - ), - "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_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_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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", - ) - 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 - ), - "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_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_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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", - ) - 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 - ), - "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_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_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-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", - ) - 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 - ), - "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_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) - - -def build_ssh_public_keys_generate_key_pair_request( # pylint: disable=name-too-long - resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}/generateKeyPair", - ) - 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 - ), - "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_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="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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}", - ) - 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 - ), - "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") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}", - ) - 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 - ), - "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") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}", - ) - 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 - ), - "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") - - # 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_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-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dedicated_hosts_list_by_host_group_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dedicated_hosts_get_request( - resource_group_name: str, - host_group_name: str, - host_name: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - "hostName": _SERIALIZER.url("host_name", host_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dedicated_hosts_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - "hostName": _SERIALIZER.url("host_name", host_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_dedicated_hosts_update_request( - resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - "hostName": _SERIALIZER.url("host_name", host_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_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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - "hostName": _SERIALIZER.url("host_name", host_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) - - -def build_dedicated_hosts_list_available_sizes_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}/hostSizes", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - "hostName": _SERIALIZER.url("host_name", host_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dedicated_hosts_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}/redeploy", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - "hostName": _SERIALIZER.url("host_name", host_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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}/restart", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - "hostName": _SERIALIZER.url("host_name", host_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="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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}", - ) - 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 - ), - "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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}", - ) - 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 - ), - "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") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", - ) - 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 - ), - "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") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_set_extensions_update_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", - ) - 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 - ), - "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") - - # 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_virtual_machine_scale_set_extensions_delete_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines", - ) - 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 - ), - "virtualMachineScaleSetName": _SERIALIZER.url( - "virtual_machine_scale_set_name", virtual_machine_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 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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_set_vms_get_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}", - ) - 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 - ), - "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) - - -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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}", - ) - 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 - ), - "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") - - # 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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}", - ) - 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 - ), - "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="DELETE", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/approveRollingUpgrade", - ) - 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 - ), - "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") - - # Construct headers - _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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/attachDetachDataDisks", - ) - 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 - ), - "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") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/deallocate", - ) - 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 - ), - "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") - - # Construct headers - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/instanceView", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_set_vms_perform_maintenance_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/performMaintenance", - ) - 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 - ), - "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") - - # Construct headers - _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_power_off_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - subscription_id: str, - *, - skip_shutdown: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/powerOff", - ) - 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 - ), - "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 - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/redeploy", - ) - 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 - ), - "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") - - # Construct headers - _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_reimage_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/reimage", - ) - 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 - ), - "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") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/reimageall", - ) - 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 - ), - "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") - - # Construct headers - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/restart", - ) - 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 - ), - "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") - - # Construct headers - _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_retrieve_boot_diagnostics_data_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - subscription_id: str, - *, - sas_uri_expiration_time_in_minutes: Optional[int] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/retrieveBootDiagnosticsData", - ) - 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 - ), - "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 - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommand", - ) - 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 - ), - "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") - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/simulateEviction", - ) - 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 - ), - "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") - - # Construct headers - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/start", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions", - ) - 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 - ), - "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) - - -def build_virtual_machine_scale_set_vm_extensions_get_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", - ) - 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 - ), - "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") - - 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", - ) - 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 - ), - "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") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_set_vm_extensions_update_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", - ) - 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 - ), - "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") - - # 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_virtual_machine_scale_set_vm_extensions_delete_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_set_vm_run_commands_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands", - ) - 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 - ), - "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) - - -def build_virtual_machine_scale_set_vm_run_commands_get_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_set_vm_run_commands_create_or_update_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, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", - ) - 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 - ), - "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") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_scale_set_vm_run_commands_update_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, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", - ) - 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 - ), - "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") - - # 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_virtual_machine_scale_set_vm_run_commands_delete_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, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", - ) - 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 - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions", - ) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", - ) - 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") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", - ) - 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 - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", - ) - 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 - 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_virtual_machine_extensions_delete_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, vm_extension_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.Operation"]: - """List the operations for the provider. - - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.OperationListResult] = 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_operations_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(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 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 AvailabilitySetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`availability_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. - - :keyword expand: The expand expression to apply to the operation. Allowed values are - 'instanceView'. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either AvailabilitySet or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.AvailabilitySet"]: - """Lists all availability sets 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 AvailabilitySet or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_availability_sets_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - 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("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - 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, availability_set_name: str, **kwargs: Any) -> _models.AvailabilitySet: - """Retrieves information about an availability set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - _request = build_availability_sets_get_request( - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: _models.AvailabilitySet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :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: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySet, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Is either a - AvailabilitySet type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySet") - - _request = build_availability_sets_create_or_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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, - availability_set_name: str, - parameters: _models.AvailabilitySetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update 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 - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySetUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. - - :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: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update 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 - :param parameters: Parameters supplied to the Update Availability Set operation. Is either a - AvailabilitySetUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySetUpdate or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySetUpdate") - - _request = build_availability_sets_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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("AvailabilitySet", 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_availability_sets_delete_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def cancel_migration_to_virtual_machine_scale_set( # pylint: disable=inconsistent-return-statements,name-too-long - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> None: - """Cancel the migration operation on an Availability Set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_availability_sets_cancel_migration_to_virtual_machine_scale_set_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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 _convert_to_virtual_machine_scale_set_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Optional[Union[_models.ConvertToVirtualMachineScaleSetInput, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "ConvertToVirtualMachineScaleSetInput") - else: - _json = None - - _request = build_availability_sets_convert_to_virtual_machine_scale_set_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Optional[_models.ConvertToVirtualMachineScaleSetInput] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the - Availability Set. This does not trigger a downtime on the Virtual Machines. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. - Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ConvertToVirtualMachineScaleSetInput - :keyword content_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_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the - Availability Set. This does not trigger a downtime on the Virtual Machines. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. - Default value is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Optional[Union[_models.ConvertToVirtualMachineScaleSetInput, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the - Availability Set. This does not trigger a downtime on the Virtual Machines. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. Is - either a ConvertToVirtualMachineScaleSetInput type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ConvertToVirtualMachineScaleSetInput - or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._convert_to_virtual_machine_scale_set_initial( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, 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 - - @overload - def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: _models.MigrateToVirtualMachineScaleSetInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual - Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that - triggers a downtime on the Virtual Machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. - Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual - Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that - triggers a downtime on the Virtual Machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def start_migration_to_virtual_machine_scale_set( # pylint: disable=inconsistent-return-statements,name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.MigrateToVirtualMachineScaleSetInput, IO[bytes]], - **kwargs: Any - ) -> None: - """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual - Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that - triggers a downtime on the Virtual Machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. Is - either a MigrateToVirtualMachineScaleSetInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput - or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "MigrateToVirtualMachineScaleSetInput") - - _request = build_availability_sets_start_migration_to_virtual_machine_scale_set_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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 - - @overload - def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: _models.MigrateToVirtualMachineScaleSetInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Validates that the Virtual Machines in the Availability Set can be migrated to the provided - Virtual Machine Scale Set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. - Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Validates that the Virtual Machines in the Availability Set can be migrated to the provided - Virtual Machine Scale Set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def validate_migration_to_virtual_machine_scale_set( # pylint: disable=inconsistent-return-statements,name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.MigrateToVirtualMachineScaleSetInput, IO[bytes]], - **kwargs: Any - ) -> None: - """Validates that the Virtual Machines in the Availability Set can be migrated to the provided - Virtual Machine Scale Set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. Is - either a MigrateToVirtualMachineScaleSetInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput - or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "MigrateToVirtualMachineScaleSetInput") - - _request = build_availability_sets_validate_migration_to_virtual_machine_scale_set_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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 - - @distributed_trace - def list_available_sizes( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> ItemPaged["_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_11_01.models.VirtualMachineSize] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_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 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 CapacityReservationGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`capacity_reservation_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, - resource_ids_only: Optional[Union[str, _models.ResourceIdOptionsForGetCapacityReservationGroups]] = None, - **kwargs: Any - ) -> ItemPaged["_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_11_01.models.ExpandTypesForGetCapacityReservationGroups - :keyword resource_ids_only: The query option to fetch Capacity Reservation Group Resource Ids. - :code:`
    ` 'CreatedInSubscription' enables fetching Resource Ids for all capacity reservation - group resources created in the subscription. :code:`
    ` 'SharedWithSubscription' enables - fetching Resource Ids for all capacity reservation group resources shared with the - subscription. :code:`
    ` 'All' enables fetching Resource Ids for all capacity reservation - group resources shared with the subscription and created in the subscription. Known values are: - "CreatedInSubscription", "SharedWithSubscription", and "All". Default value is None. - :paramtype resource_ids_only: str or - ~azure.mgmt.compute.v2024_11_01.models.ResourceIdOptionsForGetCapacityReservationGroups - :return: An iterator like instance of either CapacityReservationGroup or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_capacity_reservation_groups_list_by_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 - ) - response = pipeline_response.http_response - - if response.status_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 - ) -> ItemPaged["_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_11_01.models.ExpandTypesForGetCapacityReservationGroups - :return: An iterator like instance of either CapacityReservationGroup or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_capacity_reservation_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CapacityReservationGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - *, - expand: Optional[Union[str, _models.CapacityReservationGroupInstanceViewTypes]] = None, - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation that retrieves information about a capacity reservation group. - - :param resource_group_name: The name of the resource group. 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_11_01.models.CapacityReservationGroupInstanceViewTypes - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) - - _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) - - _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("CapacityReservationGroup", 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, - 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Create capacity reservation Group. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to create or update a capacity reservation group. When updating a capacity - reservation group, only tags and sharing profile may be modified. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Create capacity reservation Group. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: Union[_models.CapacityReservationGroup, IO[bytes]], - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to create or update a capacity reservation group. When updating a capacity - reservation group, only tags and sharing profile may be modified. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Create capacity reservation Group. Is either a - CapacityReservationGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup or IO[bytes] - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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") - - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CapacityReservationGroup", 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, - 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. 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: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroupUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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_11_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_11_01.models.CapacityReservationGroupUpdate or - IO[bytes] - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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 = 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 - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any - ) -> None: - """The operation to delete a capacity reservation group. This operation is allowed only if all the - associated resources are disassociated from the reservation group and all capacity reservations - under the reservation group have also been deleted. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. 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-11-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) - - 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_11_01.ComputeManagementClient`'s - :attr:`dedicated_host_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_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 - - if response.status_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 - ) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 - - if response.status_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, - 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", "userData", and - "resiliencyView". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) - - _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) - - _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("DedicatedHostGroup", 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, - host_group_name: str, - parameters: _models.DedicatedHostGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. 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: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroup, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. 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_11_01.models.DedicatedHostGroup or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DedicatedHostGroup") - - _request = build_dedicated_host_groups_create_or_update_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: _models.DedicatedHostGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. 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: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroupUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an 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 - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Is either - a DedicatedHostGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupUpdate or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DedicatedHostGroupUpdate") - - _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) - - _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("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. The name is case insensitive. - Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_dedicated_host_groups_delete_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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 - - -class ImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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_11_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Image"]: - """Gets the list of images under a resource group. Use nextLink property in the response to get - the next page of Images. Do this till nextLink is null to fetch all the Images. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either Image or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, image_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.Image: - """Gets an image. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: Image or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.Image - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.Image] = kwargs.pop("cls", None) - - _request = build_images_get_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Image", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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, - image_name: str, - parameters: _models.Image, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Create or 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 image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Create Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.Image - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Image]: - """Create or 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 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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Create Image operation. Is either a Image type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.Image or IO[bytes] - :return: An instance of LROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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._create_or_update_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: 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( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Image]( - 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]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ImageUpdate") - - _request = build_images_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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_update( - self, - resource_group_name: str, - image_name: str, - parameters: _models.ImageUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_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 image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Update Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ImageUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_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 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 Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_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 image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Update Image operation. Is either a ImageUpdate - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ImageUpdate or IO[bytes] - :return: An instance of LROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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_initial( - resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: 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( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Image]( - 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]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_images_delete_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, image_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes an Image. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - image_name=image_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - -class VirtualMachineImagesEdgeZoneOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_images_edge_zone` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_edge_zone_list_publishers_request( - location=location, - edge_zone=edge_zone, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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, edge_zone: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of virtual machine image offers for the specified location, edge zone and - publisher. - - :param location: The name of Azure region. Required. - :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_edge_zone_list_offers_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_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_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_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) - - _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( - 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. - - :param location: The name of Azure region. Required. - :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :keyword top: An integer value specifying the number of images to return that matches supplied - values. Default value is None. - :paramtype top: int - :keyword orderby: Specifies the order of the results returned. Formatted as an OData query. - Default value is None. - :paramtype orderby: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_edge_zone_list_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - offer=offer, - skus=skus, - subscription_id=self._config.subscription_id, - expand=expand, - top=top, - orderby=orderby, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get( - self, location: str, 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 location: The name of Azure region. Required. - :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :param version: A valid image SKU version. Required. - :type version: str - :return: VirtualMachineImage or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_edge_zone_get_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - offer=offer, - skus=skus, - version=version, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineImage", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class VirtualMachineImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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. - - :param location: The name of Azure region. Required. - :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :return: VmImagesInEdgeZoneListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VmImagesInEdgeZoneListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VmImagesInEdgeZoneListResult] = 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) - - _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("VmImagesInEdgeZoneListResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_publishers(self, location: str, **kwargs: Any) -> List[_models.VirtualMachineImageResource]: - """Gets a list of virtual machine image publishers for the specified Azure location. - - :param location: The name of Azure region. Required. - :type location: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_list_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 = 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. - - :param location: The name of Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_list_offers_request( - location=location, - publisher_name=publisher_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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. - - :param location: The name of Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_list_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) - - _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( - self, - location: str, - publisher_name: str, - offer: str, - skus: str, - *, - expand: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of all virtual machine image versions for the specified location, publisher, offer, - and SKU. - - :param location: The name of Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :keyword top: Default value is None. - :paramtype top: int - :keyword orderby: Default value is None. - :paramtype orderby: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_list_request( - location=location, - publisher_name=publisher_name, - offer=offer, - skus=skus, - subscription_id=self._config.subscription_id, - expand=expand, - top=top, - orderby=orderby, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get( - self, location: str, publisher_name: str, offer: str, skus: str, version: str, **kwargs: Any - ) -> _models.VirtualMachineImage: - """Gets a virtual machine image. - - :param location: The name of Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :param version: A valid image SKU version. Required. - :type version: str - :return: VirtualMachineImage or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_get_request( - location=location, - publisher_name=publisher_name, - offer=offer, - skus=skus, - version=version, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineImage", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_with_properties( - self, - location: str, - publisher_name: str, - offer: str, - skus: str, - *, - expand: str, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> List[_models.VirtualMachineImage]: - """list_with_properties. - - :param location: The name of Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :keyword expand: The expand expression to apply on the operation. Required. - :paramtype expand: str - :keyword top: Default value is None. - :paramtype top: int - :keyword orderby: Default value is None. - :paramtype orderby: str - :return: list of VirtualMachineImage or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImage]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_list_with_properties_request( - location=location, - publisher_name=publisher_name, - offer=offer, - skus=skus, - subscription_id=self._config.subscription_id, - expand=expand, - top=top, - orderby=orderby, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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 LogAnalyticsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`log_analytics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["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, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_export_request_rate_by_interval( - self, - location: str, - parameters: _models.RequestRateByIntervalInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. - - :param location: The name of Azure region. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. - Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RequestRateByIntervalInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_export_request_rate_by_interval( - self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. - - :param location: The name of Azure region. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_export_request_rate_by_interval( - self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. - - :param location: The name of Azure region. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. Is - either a RequestRateByIntervalInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RequestRateByIntervalInput or - IO[bytes] - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - 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._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, - **kwargs - ) - 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) - 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": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_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.LogAnalyticsOperationResult]( - 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 - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["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, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_export_throttled_requests( - self, - location: str, - parameters: _models.ThrottledRequestsInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show total throttled Api requests for this subscription in the given time - window. - - :param location: The name of Azure region. Required. - :type location: str - :param parameters: The request body. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ThrottledRequestsInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_export_throttled_requests( - self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show total throttled Api requests for this subscription in the given time - window. - - :param location: The name of Azure region. Required. - :type location: str - :param parameters: The request body. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_export_throttled_requests( - self, location: str, parameters: Union[_models.ThrottledRequestsInput, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show total throttled Api requests for this subscription in the given time - window. - - :param location: The name of Azure region. Required. - :type location: str - :param parameters: The request body. Is either a ThrottledRequestsInput type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ThrottledRequestsInput or IO[bytes] - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LogAnalyticsOperationResult] = kwargs.pop("cls", None) - 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, - 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("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, 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.LogAnalyticsOperationResult].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 - ) - - -class VirtualMachineExtensionImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_extension_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_types( - self, location: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineExtensionImage]: - """Gets a list of virtual machine extension image types. - - :param location: The name of Azure region. Required. - :type location: str - :param publisher_name: Required. - :type publisher_name: str - :return: list of VirtualMachineExtensionImage or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - - _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) - - _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 list_versions( - self, - location: str, - publisher_name: str, - type: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> List[_models.VirtualMachineExtensionImage]: - """Gets a list of virtual machine extension image versions. - - :param location: The name of Azure region. Required. - :type location: str - :param publisher_name: Required. - :type publisher_name: str - :param type: Required. - :type type: str - :keyword filter: The filter to apply on the operation. Default value is None. - :paramtype filter: str - :keyword top: Default value is None. - :paramtype top: int - :keyword orderby: Default value is None. - :paramtype orderby: str - :return: list of VirtualMachineExtensionImage or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[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_11_01.models.VirtualMachineExtensionImage - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_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_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.RunCommandDocumentBase"]: - """Lists all available run commands for a subscription in a location. - - :param location: The name of Azure region. Required. - :type location: str - :return: An iterator like instance of either RunCommandDocumentBase or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.RunCommandDocumentBase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_run_commands_list_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RunCommandListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - 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, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: - """Gets specific run command for a subscription in a location. - - :param location: The name of Azure region. Required. - :type location: str - :param command_id: The command id. Required. - :type command_id: str - :return: RunCommandDocument or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RunCommandDocument - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) - - _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, - 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("RunCommandDocument", 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 - ) -> ItemPaged["_models.VirtualMachineRunCommand"]: - """The operation to get all run commands 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 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_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_run_commands_list_by_virtual_machine_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommandsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def 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_11_01.models.VirtualMachineRunCommand - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - - _request = build_virtual_machine_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) - - _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 - - 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, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(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_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, - ) - _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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 201: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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. 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: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - run_command: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update the run command. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the VirtualMachine. Required. - :type vm_name: str - :param run_command_name: The name of the VirtualMachineRunCommand. Required. - :type run_command_name: str - :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. - Required. - :type run_command: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update the run command. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the VirtualMachine. Required. - :type vm_name: str - :param run_command_name: The name of the VirtualMachineRunCommand. Required. - :type run_command_name: str - :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. Is - either a VirtualMachineRunCommand type or a IO[bytes] type. Required. - :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._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): - deserialized = self._deserialize("VirtualMachineRunCommand", 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.VirtualMachineRunCommand].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineRunCommand]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommandUpdate, 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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(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_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, - ) - _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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - vm_name: 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. - - :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: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - run_command: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the run command. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the VirtualMachine. Required. - :type vm_name: str - :param run_command_name: The name of the VirtualMachineRunCommand. Required. - :type run_command_name: str - :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. - Required. - :type run_command: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the run command. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the VirtualMachine. Required. - :type vm_name: str - :param run_command_name: The name of the VirtualMachineRunCommand. Required. - :type run_command_name: str - :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. Is - either a VirtualMachineRunCommandUpdate type or a IO[bytes] type. Required. - :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate or - IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - run_command_name=run_command_name, - run_command=run_command, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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, 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.VirtualMachineRunCommand].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineRunCommand]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, vm_name: str, run_command_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_run_commands_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - run_command_name=run_command_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, 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. 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 - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - vm_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) - - 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_11_01.ComputeManagementClient`'s - :attr:`usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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_11_01.models.Usage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ListUsagesResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 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) - raise HttpResponseError(response=response, 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_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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_11_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_all(self, **kwargs: Any) -> ItemPaged["_models.VirtualMachineScaleSet"]: - """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource - group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this - till nextLink is null to fetch all the VM Scale Sets. - - :return: An iterator like instance of either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = kwargs.pop("cls", None) - - 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_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("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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.VirtualMachineScaleSet"]: - """Gets a list of all VM scale sets under a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.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_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: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - vm_scale_set_name: str, - *, - expand: Optional[Union[str, _models.ExpandTypesForGetVMScaleSets]] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSet: - """Display information about a virtual machine scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :keyword expand: The expand expression to apply on the operation. 'UserData' retrieves the - UserData property of the VM scale set that was provided by the user during the VM scale set - Create/Update operation. "userData" Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.ExpandTypesForGetVMScaleSets - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_sets_get_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualMachineScaleSet") - - _request = build_virtual_machine_scale_sets_create_or_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - if_match=if_match, - if_none_match=if_none_match, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 201: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, 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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. - :type parameters: IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_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_11_01.models.VirtualMachineScaleSet or IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - parameters=parameters, - if_match=if_match, - if_none_match=if_none_match, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, 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 _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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualMachineScaleSetUpdate") - - _request = build_virtual_machine_scale_sets_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - if_match=if_match, - if_none_match=if_none_match, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSetUpdate, - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdate - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. - :type parameters: IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_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_11_01.models.VirtualMachineScaleSetUpdate or - IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - parameters=parameters, - if_match=if_match, - if_none_match=if_none_match, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - 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-11-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_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. The name is case insensitive. - Required. - :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-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - force_deletion=force_deletion, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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 _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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_approve_rolling_upgrade_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_approve_rolling_upgrade( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Approve upgrade on deferred rolling upgrades for OS disks in the virtual machines in a VM scale - set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_approve_rolling_upgrade( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Approve upgrade on deferred rolling upgrades for OS disks in the virtual machines in a VM scale - set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._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) - - 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 - - @overload - def convert_to_single_placement_group( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param parameters: The input object for ConvertToSinglePlacementGroup API. Required. - :type parameters: - ~azure.mgmt.compute.v2024_11_01.models.VMScaleSetConvertToSinglePlacementGroupInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def convert_to_single_placement_group( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param parameters: The input object for ConvertToSinglePlacementGroup API. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def convert_to_single_placement_group( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VMScaleSetConvertToSinglePlacementGroupInput, IO[bytes]], - **kwargs: Any - ) -> None: - """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param parameters: The input object for ConvertToSinglePlacementGroup API. Is either a - VMScaleSetConvertToSinglePlacementGroupInput type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.compute.v2024_11_01.models.VMScaleSetConvertToSinglePlacementGroupInput or - IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VMScaleSetConvertToSinglePlacementGroupInput") - - _request = build_virtual_machine_scale_sets_convert_to_single_placement_group_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - def _deallocate_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - *, - hibernate: Optional[bool] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_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_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword hibernate: Optional parameter to hibernate a virtual machine from the VM scale set. - (This feature is available for VMSS with Flexible OrchestrationMode only). Default value is - None. - :paramtype hibernate: bool - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_deallocate( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - hibernate: Optional[bool] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and - releases the compute resources. You are not billed for the compute resources that this virtual - machine scale set deallocates. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword hibernate: Optional parameter to hibernate a virtual machine from the VM scale set. - (This feature is available for VMSS with Flexible OrchestrationMode only). Default value is - None. - :paramtype hibernate: bool - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_deallocate( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - *, - hibernate: Optional[bool] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and - releases the compute resources. You are not billed for the compute resources that this virtual - machine scale set deallocates. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :keyword hibernate: Optional parameter to hibernate a virtual machine from the VM scale set. - (This feature is available for VMSS with Flexible OrchestrationMode only). Default value is - None. - :paramtype hibernate: bool - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._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 - ) - 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 _delete_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - *, - force_deletion: Optional[bool] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - _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, - 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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - force_deletion: Optional[bool] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Deletes virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs - :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale - set. (Feature in Preview). Default value is None. - :paramtype force_deletion: bool - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - force_deletion: Optional[bool] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Deletes virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale - set. (Feature in Preview). Default value is None. - :paramtype force_deletion: bool - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_delete_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - *, - force_deletion: Optional[bool] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale - set. (Feature in Preview). Default value is None. - :paramtype force_deletion: bool - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - force_deletion=force_deletion, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, 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 force_recovery_service_fabric_platform_update_domain_walk( # pylint: disable=name-too-long - self, - resource_group_name: str, - vm_scale_set_name: str, - *, - platform_update_domain: int, - zone: Optional[str] = None, - placement_group_id: Optional[str] = None, - **kwargs: Any - ) -> _models.RecoveryWalkResponse: - """Manual platform update domain walk to update virtual machines in a service fabric virtual - machine scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :keyword platform_update_domain: The platform update domain for which a manual recovery walk is - requested. Required. - :paramtype platform_update_domain: int - :keyword zone: The zone in which the manual recovery walk is requested for cross zone virtual - machine scale set. Default value is None. - :paramtype zone: str - :keyword placement_group_id: The placement group id for which the manual recovery walk is - requested. Default value is None. - :paramtype placement_group_id: str - :return: RecoveryWalkResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RecoveryWalkResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RecoveryWalkResponse] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - platform_update_domain=platform_update_domain, - zone=zone, - placement_group_id=placement_group_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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_11_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-11-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, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, 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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - _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, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs - :keyword content_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_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_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get_os_upgrade_history( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.UpgradeOperationHistoricalStatusInfo"]: - """Gets list of OS upgrades on a VM scale set instance. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An iterator like instance of either UpgradeOperationHistoricalStatusInfo or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.UpgradeOperationHistoricalStatusInfo] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_sets_get_os_upgrade_history_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListOSUpgradeHistory", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _perform_maintenance_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_perform_maintenance( - 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]: - """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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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, - 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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _power_off_initial( - self, - resource_group_name: str, - 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, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_power_off_request( - resource_group_name=resource_group_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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_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_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is None. - :paramtype skip_shutdown: bool - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either 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_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]: - """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. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is None. - :paramtype skip_shutdown: bool - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._power_off_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - skip_shutdown=skip_shutdown, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, 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_scale_set_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_sets_reapply_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. The name is case insensitive. - Required. - :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-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reapply_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _redeploy_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_redeploy_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_redeploy( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[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_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_redeploy( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, - and powers them back on. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._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, 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_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_scale_set_reimage_input, (IOBase, bytes)): - _content = vm_scale_set_reimage_input - else: - if vm_scale_set_reimage_input is not None: - _json = self._serialize.body(vm_scale_set_reimage_input, "VirtualMachineScaleSetReimageParameters") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetReimageParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which - don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual - machine is reset to initial state. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. - :type vm_scale_set_reimage_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which - don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual - machine is reset to initial state. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Is either a - VirtualMachineScaleSetReimageParameters type or a IO[bytes] type. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetReimageParameters or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reimage_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_scale_set_reimage_input=vm_scale_set_reimage_input, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_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. The name is case insensitive. - Required. - :type 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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._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, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _restart_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_restart_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._restart_initial( - 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, 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 _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]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param parameters: The input object for SetOrchestrationServiceState API. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceStateInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of 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_set_orchestration_service_state( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Changes ServiceState property for a given service. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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 None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_set_orchestration_service_state( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Changes ServiceState property for a given service. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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_11_01.models.OrchestrationServiceStateInput or - IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._set_orchestration_service_state_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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_skus( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineScaleSetSku"]: - """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM - instances allowed for each SKU. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An iterator like instance of either VirtualMachineScaleSetSku or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetSku] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetListSkusResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_sets_list_skus_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListSkusResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _start_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_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 - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_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 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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._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, 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 VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_by_location_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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 - ) -> ItemPaged["_models.VirtualMachine"]: - """Lists all of the virtual machines in the specified subscription. Use the nextLink property in - the response to get the next page of virtual machines. - - :keyword status_only: statusOnly=true enables fetching run time status of all Virtual Machines - in the subscription. Default value is None. - :paramtype status_only: str - :keyword filter: The system query option to filter VMs returned in the response. Allowed value - is 'virtualMachineScaleSet/id' eq - /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}'. - Default value is None. - :paramtype filter: str - :keyword expand: The expand expression to apply on operation. 'instanceView' enables fetching - run time status of all Virtual Machines, this can only be specified if a valid $filter option - is specified. "instanceView" Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.ExpandTypesForListVMs - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_all_request( - subscription_id=self._config.subscription_id, - status_only=status_only, - filter=filter, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list( - self, - resource_group_name: str, - *, - filter: Optional[str] = None, - expand: Optional[Union[str, _models.ExpandTypeForListVMs]] = None, - **kwargs: Any - ) -> ItemPaged["_models.VirtualMachine"]: - """Lists all of the virtual machines in the specified resource group. Use the nextLink property in - the response to get the next page of virtual machines. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword filter: The system query option to filter VMs returned in the response. Allowed value - is 'virtualMachineScaleSet/id' eq - /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}'. - Default value is None. - :paramtype filter: str - :keyword expand: The expand expression to apply on operation. 'instanceView' enables fetching - run time status of all Virtual Machines, this can only be specified if a valid $filter option - is specified. "instanceView" Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.ExpandTypeForListVMs - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - vm_name: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any - ) -> _models.VirtualMachine: - """Retrieves information about the model view or the instance view of a virtual machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' retrieves a - snapshot of the runtime properties of the virtual machine that is managed by the platform and - can change outside of control plane operations. 'UserData' retrieves the UserData property as - part of the VM model view that was provided by the user during the VM Create/Update operation. - Known values are: "instanceView", "userData", and "resiliencyView". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachine - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) - - _request = build_virtual_machines_get_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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, - vm_name: str, - parameters: Union[_models.VirtualMachine, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - 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_name: str, - parameters: _models.VirtualMachine, - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Create Virtual Machine operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachine - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Create Virtual Machine operation. Required. - :type parameters: IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Create Virtual Machine operation. Is either a - VirtualMachine type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachine or IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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._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 - ) - 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, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachine].from_continuation_token( - 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 _update_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineUpdate, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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 = 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: - 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 - def begin_update( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachineUpdate, - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Update Virtual Machine operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineUpdate - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Update Virtual Machine operation. Required. - :type parameters: IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Update Virtual Machine operation. Is either a - VirtualMachineUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineUpdate or IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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): - 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: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachine].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachine]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, vm_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - force_deletion=force_deletion, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - 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, 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. 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - force_deletion=force_deletion, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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 _assess_patches_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_assess_patches( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.VirtualMachineAssessPatchesResult]: - """Assess patches on the VM. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An instance of LROPoller that returns either VirtualMachineAssessPatchesResult or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineAssessPatchesResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_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._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 - ) - 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) - 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.VirtualMachineAssessPatchesResult].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 - ) - - 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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_attach_detach_data_disks( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.AttachDetachDataDisksRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from the virtual machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the attach and detach data disks operation on the - virtual machine. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_attach_detach_data_disks( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from the virtual machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the attach and detach data disks operation on the - virtual machine. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_attach_detach_data_disks( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from the virtual machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the attach and detach data disks operation on the - virtual machine. Is either a AttachDetachDataDisksRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest or - IO[bytes] - :return: An instance of LROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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 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 _capture_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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 - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_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_11_01.models.VirtualMachineCaptureParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineCaptureResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Capture Virtual Machine operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineCaptureResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_capture( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Capture Virtual Machine operation. Is either a - VirtualMachineCaptureParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureParameters or - IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineCaptureResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineCaptureResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._capture_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineCaptureResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, 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.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 - ) - - 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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_convert_to_managed_disks_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._convert_to_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 - ) - 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 _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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._deallocate_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - hibernate=hibernate, - 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 generalize( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> None: - """Sets the OS state of the virtual machine to generalized. It is recommended to sysprep the - virtual machine before performing this operation. For Windows, please refer to `Create a - managed image of a generalized VM in Azure - `_. For - Linux, please refer to `How to create an image of a virtual machine or VHD - `_. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_virtual_machines_generalize_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - def _install_patches_initial( - self, - resource_group_name: str, - vm_name: str, - 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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(install_patches_input, (IOBase, bytes)): - _content = install_patches_input - else: - _json = self._serialize.body(install_patches_input, "VirtualMachineInstallPatchesParameters") - - _request = build_virtual_machines_install_patches_request( - 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 - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_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_11_01.models.VirtualMachineInstallPatchesParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineInstallPatchesResult or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_install_patches( - self, - resource_group_name: str, - vm_name: str, - install_patches_input: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. - - :param resource_group_name: The name of the resource group. 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_11_01.models.VirtualMachineInstallPatchesResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_install_patches( - self, - resource_group_name: str, - vm_name: str, - install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param install_patches_input: Input for InstallPatches as directly received by the API. Is - either a VirtualMachineInstallPatchesParameters type or a IO[bytes] type. Required. - :type install_patches_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesParameters or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineInstallPatchesResult or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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._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, - **kwargs - ) - 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) - 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.VirtualMachineInstallPatchesResult].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 - ) - - @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_11_01.models.VirtualMachineInstanceView - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) - - _request = build_virtual_machines_instance_view_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineInstanceView", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _migrate_to_vm_scale_set_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[Union[_models.MigrateVMToVirtualMachineScaleSetInput, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "MigrateVMToVirtualMachineScaleSetInput") - else: - _json = None - - _request = build_virtual_machines_migrate_to_vm_scale_set_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_migrate_to_vm_scale_set( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[_models.MigrateVMToVirtualMachineScaleSetInput] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Migrate Virtual Machine operation. Default value - is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateVMToVirtualMachineScaleSetInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_migrate_to_vm_scale_set( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Migrate Virtual Machine operation. Default value - is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_migrate_to_vm_scale_set( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[Union[_models.MigrateVMToVirtualMachineScaleSetInput, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Migrate Virtual Machine operation. Is either a - MigrateVMToVirtualMachineScaleSetInput type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateVMToVirtualMachineScaleSetInput - or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._migrate_to_vm_scale_set_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **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 _perform_maintenance_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_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 - - 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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_power_off_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._power_off_initial( - resource_group_name=resource_group_name, - vm_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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_reapply_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reapply_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_redeploy_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[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, 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_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "VirtualMachineReimageParameters") - else: - _json = None - - _request = build_virtual_machines_reimage_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineReimageParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of 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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Is either a - VirtualMachineReimageParameters type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineReimageParameters or - IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reimage_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _restart_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_restart_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._restart_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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 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_11_01.models.RetrieveBootDiagnosticsDataResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) - - _request = build_virtual_machines_retrieve_boot_diagnostics_data_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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, - vm_name: str, - parameters: Union[_models.RunCommandInput, 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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RunCommandInput") - - _request = build_virtual_machines_run_command_request( - 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 - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput or IO[bytes] - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._run_command_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_virtual_machines_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 _start_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_start_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_start(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: - """The operation to start 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: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._start_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 - ) -> ItemPaged["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes to which the specified virtual machine can be - resized. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_available_sizes_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return 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 VirtualMachineSizesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_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 - - 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) - - 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 ProximityPlacementGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`proximity_placement_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a subscription. - - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_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 - ) -> ItemPaged["_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_11_01.models.ProximityPlacementGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProximityPlacementGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - 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_11_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - _request = build_proximity_placement_groups_get_request( - resource_group_name=resource_group_name, - proximity_placement_group_name=proximity_placement_group_name, - subscription_id=self._config.subscription_id, - include_colocation_status=include_colocation_status, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("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_11_01.models.ProximityPlacementGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - proximity_placement_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Create or update a proximity placement group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Create Proximity Placement Group operation. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def 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 resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Create Proximity Placement Group operation. Is - either a ProximityPlacementGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup or IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "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, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - proximity_placement_group_name: str, - parameters: _models.ProximityPlacementGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Update a proximity placement group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Update Proximity Placement Group operation. - Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroupUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - proximity_placement_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Update a proximity placement group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Update Proximity Placement Group operation. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def 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 resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Update Proximity Placement Group operation. Is - either a ProximityPlacementGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroupUpdate or - IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ProximityPlacementGroupUpdate") - - _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, - ) - _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("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any - ) -> None: - """Delete a proximity placement group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_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, - 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 - - -class RestorePointCollectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`restore_point_collections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_all(self, **kwargs: Any) -> ItemPaged["_models.RestorePointCollection"]: - """Gets the list of restore point collections in the subscription. Use nextLink property in the - response to get the next page of restore point collections. Do this till nextLink is not null - to fetch all the restore point collections. - - :return: An iterator like instance of either RestorePointCollection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_restore_point_collections_list_all_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RestorePointCollectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.RestorePointCollection"]: - """Gets the list of restore point collections 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 RestorePointCollection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_restore_point_collections_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RestorePointCollectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def 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. 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_11_01.models.RestorePointCollectionExpandOptions - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) - - _request = build_restore_point_collections_get_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: _models.RestorePointCollection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to create or update the restore point collection. Please refer to - https://aka.ms/RestorePoints for more details. When updating a restore point collection, only - tags may be modified. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Create or Update restore point collection - operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to create or update the restore point collection. Please refer to - https://aka.ms/RestorePoints for more details. When updating a restore point collection, only - tags may be modified. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Create or Update restore point collection - operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: Union[_models.RestorePointCollection, IO[bytes]], - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to create or update the restore point collection. Please refer to - https://aka.ms/RestorePoints for more details. When updating a restore point collection, only - tags may be modified. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Create or Update restore point collection - operation. Is either a RestorePointCollection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection or IO[bytes] - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RestorePointCollection") - - _request = build_restore_point_collections_create_or_update_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RestorePointCollection", 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, - restore_point_collection_name: str, - parameters: _models.RestorePointCollectionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to update the restore point collection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Update restore point collection operation. - Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to update the restore point collection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Update restore point collection operation. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: Union[_models.RestorePointCollectionUpdate, IO[bytes]], - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to update the restore point collection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Update restore point collection operation. Is - either a RestorePointCollectionUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionUpdate or - IO[bytes] - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RestorePointCollectionUpdate") - - _request = build_restore_point_collections_update_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) - - 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 - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_restore_point_collections_delete_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, restore_point_collection_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The operation to delete the restore point collection. This operation will also delete all the - contained restore points. - - :param resource_group_name: The name of the resource group. 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-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - -class SshPublicKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`ssh_public_keys` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.SshPublicKeyResource"]: - """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response - to get the next page of SSH public keys. - - :return: An iterator like instance of either SshPublicKeyResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 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_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) - - 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 - ) -> ItemPaged["_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. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either SshPublicKeyResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_ssh_public_keys_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - - _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) - - _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("SshPublicKeyResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: _models.SshPublicKeyResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to create the SSH public key. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to create the SSH public key. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: Union[_models.SshPublicKeyResource, IO[bytes]], - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. - - :param resource_group_name: The name of the resource group. 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_11_01.models.SshPublicKeyResource or IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SshPublicKeyResource") - - _request = build_ssh_public_keys_create_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SshPublicKeyResource", 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, - ssh_public_key_name: str, - parameters: _models.SshPublicKeyUpdateResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Updates a new SSH public key resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to update the SSH public key. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyUpdateResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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. Is either a - SshPublicKeyUpdateResource type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyUpdateResource or - IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SshPublicKeyUpdateResource") - - _request = build_ssh_public_keys_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SshPublicKeyResource", 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, ssh_public_key_name: str, **kwargs: Any - ) -> None: - """Delete an SSH public key. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_ssh_public_keys_delete_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) - - _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 - - @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. - - :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_11_01.models.SshGenerateKeyPairInputParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyGenerateKeyPairResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def generate_key_pair( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyGenerateKeyPairResult: - """Generates and returns a public/private key pair and populates the SSH public key resource with - the public key. The length of the key will be 3072 bits. This operation can only be performed - once per SSH public key resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to generate the SSH public key. Default value is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyGenerateKeyPairResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def generate_key_pair( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: Optional[Union[_models.SshGenerateKeyPairInputParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> _models.SshPublicKeyGenerateKeyPairResult: - """Generates and returns a public/private key pair and populates the SSH public key resource with - the public key. The length of the key will be 3072 bits. This operation can only be performed - once per SSH public key resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to generate the SSH public key. Is either a - SshGenerateKeyPairInputParameters type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshGenerateKeyPairInputParameters or - IO[bytes] - :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyGenerateKeyPairResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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_ssh_public_keys_generate_key_pair_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("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_11_01.ComputeManagementClient`'s - :attr:`capacity_reservations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_by_capacity_reservation_group( - self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any - ) -> ItemPaged["_models.CapacityReservation"]: - """Lists all of the capacity reservations in the specified capacity reservation group. Use the - nextLink property in the response to get the next page of capacity reservations. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :return: An iterator like instance of either CapacityReservation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.CapacityReservationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_capacity_reservations_list_by_capacity_reservation_group_request( - resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CapacityReservationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' retrieves a - snapshot of the runtime properties of the capacity reservation that is managed by the platform - and can change outside of control plane operations. "instanceView" Default value is None. - :paramtype expand: str or - ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationInstanceViewTypes - :return: CapacityReservation or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CapacityReservation") - - _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) - - _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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 201: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Create capacity reservation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CapacityReservation]: - """The operation to create or update a capacity reservation. Please note some properties can be - set only during capacity reservation creation. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Create capacity reservation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: Union[_models.CapacityReservation, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.CapacityReservation]: - """The operation to create or update a capacity reservation. Please note some properties can be - set only during capacity reservation creation. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Create capacity reservation. Is either a - CapacityReservation type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservation or IO[bytes] - :return: An instance of LROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - capacity_reservation_name=capacity_reservation_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.CapacityReservation].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CapacityReservation]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CapacityReservationUpdate") - - _request = build_capacity_reservations_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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: _models.CapacityReservationUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CapacityReservation]: - """The operation to update a capacity reservation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Update capacity reservation operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CapacityReservation]: - """The operation to update a capacity reservation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Update capacity reservation operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.CapacityReservation]: - """The operation to update a capacity reservation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Update capacity reservation operation. Is either - a CapacityReservationUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationUpdate or IO[bytes] - :return: An instance of LROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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) - - 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 _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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_capacity_reservations_delete_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, - 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, - capacity_reservation_group_name: str, - capacity_reservation_name: 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. - - :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 - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - 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) - - 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 DedicatedHostsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`dedicated_hosts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_host_group( - self, resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> ItemPaged["_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :return: An iterator like instance of either DedicatedHost or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostListResult] = kwargs.pop("cls", None) - - 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_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, - 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("DedicatedHostListResult", 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, - 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param host_name: The name of the dedicated host. Required. - :type host_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve - the list of instance views of the dedicated host. 'UserData' is not supported for dedicated - host. Known values are: "instanceView", "userData", and "resiliencyView". Default value is - None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes - :return: DedicatedHost or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHost - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHost] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_get_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DedicatedHost", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, 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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DedicatedHost") - - _request = build_dedicated_hosts_create_or_update_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 201: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHost, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Create or update a dedicated host . - - :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 - :param parameters: Parameters supplied to the Create Dedicated Host. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHost - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Create or update a dedicated host . - - :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 - :param parameters: Parameters supplied to the Create Dedicated Host. 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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHost, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Create or update a dedicated host . - - :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 - :param parameters: Parameters supplied to the Create Dedicated Host. Is either a DedicatedHost - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHost or IO[bytes] - :return: An instance of LROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, 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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DedicatedHostUpdate") - - _request = build_dedicated_hosts_update_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: _models.DedicatedHostUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Update a dedicated host . - - :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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostUpdate - :keyword content_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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Update a dedicated host . - - :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 - :param parameters: Parameters supplied to the Update Dedicated Host 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 DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - parameters: Union[_models.DedicatedHostUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DedicatedHost]: - """Update a dedicated host . - - :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 - :param parameters: Parameters supplied to the Update Dedicated Host operation. Is either a - DedicatedHostUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostUpdate or IO[bytes] - :return: An instance of LROPoller that returns either DedicatedHost or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHost] = 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, - host_group_name=host_group_name, - host_name=host_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("DedicatedHost", 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.DedicatedHost].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DedicatedHost]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_delete_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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, host_group_name: str, host_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete a dedicated host. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param host_name: The name of the dedicated host. Required. - :type host_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_available_sizes( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> ItemPaged[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. The name is case insensitive. - Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param host_name: The name of the dedicated host. Required. - :type host_name: str - :return: An iterator like instance of either str or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[str] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_hosts_list_available_sizes_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DedicatedHostSizeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return 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 _redeploy_initial( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_redeploy_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_redeploy( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Redeploy the dedicated host. The operation will complete successfully once the dedicated host - has migrated to a new node and is running. To determine the health of VMs deployed on the - dedicated host after the redeploy check the Resource Health Center in the Azure Portal. Please - refer to https://docs.microsoft.com/azure/service-health/resource-health-overview for more - details. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param host_name: The name of the dedicated host. Required. - :type host_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._redeploy_initial( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _restart_initial( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_restart_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_restart( - 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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param host_name: The name of the dedicated host. Required. - :type host_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._restart_initial( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - -class RestorePointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`restore_points` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get( - self, - resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - *, - expand: Optional[Union[str, _models.RestorePointExpandOptions]] = None, - **kwargs: Any - ) -> _models.RestorePoint: - """The operation to get the restore point. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param restore_point_name: The name of the restore point. Required. - :type restore_point_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' retrieves - information about the run-time state of a restore point. "instanceView" Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.RestorePointExpandOptions - :return: RestorePoint or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePoint - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) - - _request = build_restore_points_get_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - restore_point_name=restore_point_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RestorePoint", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - parameters: Union[_models.RestorePoint, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RestorePoint") - - _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) - - _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 [201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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( - self, - resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - parameters: _models.RestorePoint, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RestorePoint]: - """The operation to create the restore point. Updating properties of an existing restore point is - not allowed. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param restore_point_name: The name of the restore point. Required. - :type restore_point_name: str - :param parameters: Parameters supplied to the Create restore point operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePoint - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RestorePoint or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RestorePoint]: - """The operation to create the restore point. Updating properties of an existing restore point is - not allowed. - - :param resource_group_name: The name of the resource group. 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: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RestorePoint or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param restore_point_name: The name of the restore point. Required. - :type restore_point_name: str - :param parameters: Parameters supplied to the Create restore point operation. Is either a - RestorePoint type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePoint or IO[bytes] - :return: An instance of LROPoller that returns either RestorePoint or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_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-11-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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_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) - - _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, 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. 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 - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - restore_point_name=restore_point_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def 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 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_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_rolling_upgrades_start_extension_upgrade_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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._start_extension_upgrade_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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 _start_os_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request( - resource_group_name=resource_group_name, - 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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. The name is case insensitive. - Required. - :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-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._start_os_upgrade_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _cancel_initial(self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_rolling_upgrades_cancel_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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. The name is case insensitive. - Required. - :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-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._cancel_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get_latest( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> _models.RollingUpgradeStatusInfo: - """Gets the status of the latest virtual machine scale set rolling upgrade. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: RollingUpgradeStatusInfo or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RollingUpgradeStatusInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.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 - ) - - response = pipeline_response.http_response - - if response.status_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 VirtualMachineScaleSetExtensionsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.VirtualMachineScaleSetExtension"]: - """Gets a list of all extensions in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An iterator like instance of either VirtualMachineScaleSetExtension or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetExtensionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_set_extensions_list_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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_11_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-11-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, - 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, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtension") - - _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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 201: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, 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, - 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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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 - :param extension_parameters: Parameters supplied to the Create VM scale set Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :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. The name is case insensitive. - Required. - :type 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 - :param extension_parameters: Parameters supplied to the Create VM scale set Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. The name is case insensitive. - Required. - :type 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 - :param extension_parameters: Parameters supplied to the Create VM scale set Extension - operation. Is either a VirtualMachineScaleSetExtension type or a IO[bytes] type. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, 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.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtensionUpdate") - - _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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 201: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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 - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtensionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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 - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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 - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Is either a VirtualMachineScaleSetExtensionUpdate type or a IO[bytes] type. - Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtensionUpdate or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, 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.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_extensions_delete_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, - 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, 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. The name is case insensitive. - Required. - :type 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 - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, 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 VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - virtual_machine_scale_set_name: str, - *, - filter: Optional[str] = None, - select: Optional[str] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.VirtualMachineScaleSetVM"]: - """Gets a list of all virtual machines in a VM scale sets. - - :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 VirtualMachineScaleSet. Required. - :type virtual_machine_scale_set_name: str - :keyword filter: The filter to apply to the operation. Allowed values are - 'startswith(instanceView/statuses/code, 'PowerState') eq true', 'properties/latestModelApplied - eq true', 'properties/latestModelApplied eq false'. Default value is None. - :paramtype filter: str - :keyword select: The list parameters. Allowed values are 'instanceView', - 'instanceView/statuses'. Default value is None. - :paramtype select: str - :keyword expand: The expand expression to apply to the operation. Allowed values are - 'instanceView'. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_set_vms_list_request( - resource_group_name=resource_group_name, - virtual_machine_scale_set_name=virtual_machine_scale_set_name, - subscription_id=self._config.subscription_id, - filter=filter, - select=select, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVMListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve - the instance view of the virtual machine. 'UserData' will retrieve the UserData of the virtual - machine. Known values are: "instanceView", "userData", and "resiliencyView". Default value is - None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.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 - - def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualMachineScaleSetVM") - - _request = build_virtual_machine_scale_set_vms_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - if_match=if_match, - if_none_match=if_none_match, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - 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 - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 Update Virtual Machine Scale Sets VM operation. - Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :keyword content_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_11_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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 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: An instance of LROPoller that returns either VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of 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 Update Virtual Machine Scale Sets VM operation. - Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM or IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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) - - 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 - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSetVM].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetVM]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - force_deletion: Optional[bool] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - force_deletion=force_deletion, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, - vm_scale_set_name: str, - instance_id: str, - *, - force_deletion: Optional[bool] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes 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 - :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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - 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, 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 _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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._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, 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 _attach_detach_data_disks_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.AttachDetachDataDisksRequest, 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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AttachDetachDataDisksRequest") - - _request = build_virtual_machine_scale_set_vms_attach_detach_data_disks_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 - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_attach_detach_data_disks( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.AttachDetachDataDisksRequest, - *, - 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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the attach and detach data disks operation on a - Virtual Machine Scale Sets VM. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_attach_detach_data_disks( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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_11_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_11_01.models.AttachDetachDataDisksRequest or - IO[bytes] - :return: An instance of LROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.StorageProfile] = kwargs.pop("cls", None) - polling: Union[bool, 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-11-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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._deallocate_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get_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_11_01.models.VirtualMachineScaleSetVMInstanceView - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMInstanceView] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_get_instance_view_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineScaleSetVMInstanceView", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _perform_maintenance_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_perform_maintenance( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Performs maintenance on a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _power_off_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - skip_shutdown: Optional[bool] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_power_off_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - skip_shutdown: Optional[bool] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached - and you are getting charged for the resources. Instead, use deallocate to release resources and - avoid charges. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type 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 LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._power_off_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _redeploy_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_redeploy( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Shuts down the virtual machine in the virtual machine scale set, moves it to a new node, and - powers it back on. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._redeploy_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - 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 - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_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, - 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 - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Default value is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMReimageParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Default value is None. - :type vm_scale_set_vm_reimage_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[ - Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] - ] = None, - **kwargs: Any - ) -> 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Is either a VirtualMachineScaleSetVMReimageParameters type or a IO[bytes] type. Default value - is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMReimageParameters or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reimage_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - 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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reimage_all_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _restart_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._restart_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def retrieve_boot_diagnostics_data( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - sas_uri_expiration_time_in_minutes: Optional[int] = None, - **kwargs: Any - ) -> _models.RetrieveBootDiagnosticsDataResult: - """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale - set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword sas_uri_expiration_time_in_minutes: Expiration duration in minutes for the SAS URIs - with a value between 1 to 1440 minutes. **Note:** If not specified, SAS URIs will be generated - with a default expiration duration of 120 minutes. Default value is None. - :paramtype sas_uri_expiration_time_in_minutes: int - :return: RetrieveBootDiagnosticsDataResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RetrieveBootDiagnosticsDataResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _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, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, 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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RunCommandInput") - - _request = build_virtual_machine_scale_set_vms_run_command_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 - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_run_command( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput or IO[bytes] - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._run_command_initial( - resource_group_name=resource_group_name, - vm_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("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, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def simulate_eviction( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> None: - """The operation to simulate the eviction of spot virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_simulate_eviction_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - def _start_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_start_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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_start( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Starts a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._start_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - -class VirtualMachineScaleSetVMExtensionsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vm_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: - """The operation to get all extensions of an instance in Virtual Machine Scaleset. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineScaleSetVMExtensionsListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionsListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_extensions_list_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize( - "VirtualMachineScaleSetVMExtensionsListResult", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get( - self, - resource_group_name: str, - 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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineScaleSetVMExtension or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetVMExtension") - - _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) - - _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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 201: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetVMExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Is either a VirtualMachineScaleSetVMExtension type or a IO[bytes] type. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, 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 _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(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( - 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) - - _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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Is either a VirtualMachineScaleSetVMExtensionUpdate type or a IO[bytes] type. - Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionUpdate or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._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): - 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, 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.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 _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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_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) - - _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, 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 resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - 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) - - 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 VirtualMachineScaleSetVMRunCommandsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vm_run_commands` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. - :type vm_scale_set_name: str - :param instance_id: The name of the VirtualMachineScaleSetVM. Required. - :type instance_id: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_set_vm_run_commands_list_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommandsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @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. The name is case insensitive. - Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. - :type vm_scale_set_name: str - :param instance_id: The name of the VirtualMachineScaleSetVM. Required. - :type instance_id: str - :param run_command_name: The name of the VirtualMachineRunCommand. Required. - :type run_command_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineRunCommand or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_run_commands_get_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - run_command_name=run_command_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(run_command, (IOBase, bytes)): - _content = run_command - else: - _json = self._serialize.body(run_command, "VirtualMachineRunCommand") - - _request = build_virtual_machine_scale_set_vm_run_commands_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 201: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, 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, - 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 VMSS VM 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_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: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_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 VMSS VM 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_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. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_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 VMSS VM 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_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. - :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._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, - 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("VirtualMachineRunCommand", 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.VirtualMachineRunCommand].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineRunCommand]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _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]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(run_command, (IOBase, bytes)): - _content = run_command - else: - _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") - - _request = build_virtual_machine_scale_set_vm_run_commands_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_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 VMSS VM 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_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: Resource create parameters. Required. - :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_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 VMSS VM 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_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: Resource create parameters. Required. - :type run_command: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_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]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the VMSS VM 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_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: Resource create parameters. Is either a VirtualMachineRunCommandUpdate type - or a IO[bytes] type. Required. - :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate or - IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._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, - 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("VirtualMachineRunCommand", 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.VirtualMachineRunCommand].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineRunCommand]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - 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, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_run_commands_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, - 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, vm_scale_set_name: str, instance_id: str, run_command_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The operation to delete the VMSS VM 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_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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - 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) - - 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 VirtualMachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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. - - :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. Default value is None. - :paramtype expand: str - :return: VirtualMachineExtensionsListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionsListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_list_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineExtensionsListResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # 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. 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 vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineExtension or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_get_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, 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-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineExtension") - - _request = build_virtual_machine_extensions_create_or_update_request( - resource_group_name=resource_group_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 201: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to create or update 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_name: The name of the virtual machine. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to create or update 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_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. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to create or update 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_name: The name of the virtual machine. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Is either a VirtualMachineExtension type or a IO[bytes] type. Required. - :type extension_parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension or - IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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_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, - 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("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, 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( - 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 - ) - - def _update_initial( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineExtensionUpdate") - - _request = build_virtual_machine_extensions_update_request( - resource_group_name=resource_group_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, - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to update the extension. - - :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 vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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 - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to update 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_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. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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.VirtualMachineExtension]: - """The operation to update 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_name: The name of the virtual machine. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Is either a VirtualMachineExtensionUpdate type or a IO[bytes] type. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionUpdate or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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_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, - 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("VirtualMachineExtension", 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.VirtualMachineExtension].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 - ) - - def _delete_initial( - self, resource_group_name: str, vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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) - - _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, vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The operation to delete 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_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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - 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) - - 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore - -_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_compute_management_client.py deleted file mode 100644 index e6f93a0b62a2..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_compute_management_client.py +++ /dev/null @@ -1,148 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ( - CloudServiceOperatingSystemsOperations, - CloudServiceRoleInstancesOperations, - CloudServiceRolesOperations, - CloudServicesOperations, - CloudServicesUpdateDomainOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar cloud_service_role_instances: CloudServiceRoleInstancesOperations operations - :vartype cloud_service_role_instances: - azure.mgmt.compute.v2024_11_04.operations.CloudServiceRoleInstancesOperations - :ivar cloud_service_roles: CloudServiceRolesOperations operations - :vartype cloud_service_roles: - azure.mgmt.compute.v2024_11_04.operations.CloudServiceRolesOperations - :ivar cloud_services: CloudServicesOperations operations - :vartype cloud_services: azure.mgmt.compute.v2024_11_04.operations.CloudServicesOperations - :ivar cloud_services_update_domain: CloudServicesUpdateDomainOperations operations - :vartype cloud_services_update_domain: - azure.mgmt.compute.v2024_11_04.operations.CloudServicesUpdateDomainOperations - :ivar cloud_service_operating_systems: CloudServiceOperatingSystemsOperations operations - :vartype cloud_service_operating_systems: - azure.mgmt.compute.v2024_11_04.operations.CloudServiceOperatingSystemsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2024-11-04". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.cloud_service_role_instances = CloudServiceRoleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-04" - ) - self.cloud_service_roles = CloudServiceRolesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-04" - ) - self.cloud_services = CloudServicesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-04" - ) - self.cloud_services_update_domain = CloudServicesUpdateDomainOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-04" - ) - self.cloud_service_operating_systems = CloudServiceOperatingSystemsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-04" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_configuration.py deleted file mode 100644 index 9af0bcfe4c13..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-11-04". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2024-11-04") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_metadata.json deleted file mode 100644 index 4a299afec6e7..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_metadata.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "chosen_version": "2024-11-04", - "total_api_version_list": ["2024-11-04"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "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.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "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.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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": { - "cloud_service_role_instances": "CloudServiceRoleInstancesOperations", - "cloud_service_roles": "CloudServiceRolesOperations", - "cloud_services": "CloudServicesOperations", - "cloud_services_update_domain": "CloudServicesUpdateDomainOperations", - "cloud_service_operating_systems": "CloudServiceOperatingSystemsOperations" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node
    is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj 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 deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore - -_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/_compute_management_client.py deleted file mode 100644 index c478a49f5005..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/_compute_management_client.py +++ /dev/null @@ -1,152 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ( - CloudServiceOperatingSystemsOperations, - CloudServiceRoleInstancesOperations, - CloudServiceRolesOperations, - CloudServicesOperations, - CloudServicesUpdateDomainOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar cloud_service_role_instances: CloudServiceRoleInstancesOperations operations - :vartype cloud_service_role_instances: - azure.mgmt.compute.v2024_11_04.aio.operations.CloudServiceRoleInstancesOperations - :ivar cloud_service_roles: CloudServiceRolesOperations operations - :vartype cloud_service_roles: - azure.mgmt.compute.v2024_11_04.aio.operations.CloudServiceRolesOperations - :ivar cloud_services: CloudServicesOperations operations - :vartype cloud_services: azure.mgmt.compute.v2024_11_04.aio.operations.CloudServicesOperations - :ivar cloud_services_update_domain: CloudServicesUpdateDomainOperations operations - :vartype cloud_services_update_domain: - azure.mgmt.compute.v2024_11_04.aio.operations.CloudServicesUpdateDomainOperations - :ivar cloud_service_operating_systems: CloudServiceOperatingSystemsOperations operations - :vartype cloud_service_operating_systems: - azure.mgmt.compute.v2024_11_04.aio.operations.CloudServiceOperatingSystemsOperations - :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. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2024-11-04". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.cloud_service_role_instances = CloudServiceRoleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-04" - ) - self.cloud_service_roles = CloudServiceRolesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-04" - ) - self.cloud_services = CloudServicesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-04" - ) - self.cloud_services_update_domain = CloudServicesUpdateDomainOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-04" - ) - self.cloud_service_operating_systems = CloudServiceOperatingSystemsOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-04" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/_configuration.py deleted file mode 100644 index b3b6ccf587d8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :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. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-11-04". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2024-11-04") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/operations/__init__.py deleted file mode 100644 index 6422d5c48bb1..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/operations/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import CloudServiceRoleInstancesOperations # type: ignore -from ._operations import CloudServiceRolesOperations # type: ignore -from ._operations import CloudServicesOperations # type: ignore -from ._operations import CloudServicesUpdateDomainOperations # type: ignore -from ._operations import CloudServiceOperatingSystemsOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CloudServiceRoleInstancesOperations", - "CloudServiceRolesOperations", - "CloudServicesOperations", - "CloudServicesUpdateDomainOperations", - "CloudServiceOperatingSystemsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/operations/_operations.py deleted file mode 100644 index a0e7a7da9ca1..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/operations/_operations.py +++ /dev/null @@ -1,3377 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import ( - build_cloud_service_operating_systems_get_os_family_request, - build_cloud_service_operating_systems_get_os_version_request, - build_cloud_service_operating_systems_list_os_families_request, - build_cloud_service_operating_systems_list_os_versions_request, - build_cloud_service_role_instances_delete_request, - build_cloud_service_role_instances_get_instance_view_request, - build_cloud_service_role_instances_get_remote_desktop_file_request, - build_cloud_service_role_instances_get_request, - build_cloud_service_role_instances_list_request, - build_cloud_service_role_instances_rebuild_request, - build_cloud_service_role_instances_reimage_request, - build_cloud_service_role_instances_restart_request, - build_cloud_service_roles_get_request, - build_cloud_service_roles_list_request, - build_cloud_services_create_or_update_request, - build_cloud_services_delete_instances_request, - build_cloud_services_delete_request, - build_cloud_services_get_instance_view_request, - build_cloud_services_get_request, - build_cloud_services_list_all_request, - build_cloud_services_list_request, - build_cloud_services_power_off_request, - build_cloud_services_rebuild_request, - build_cloud_services_reimage_request, - build_cloud_services_restart_request, - build_cloud_services_start_request, - build_cloud_services_update_domain_get_update_domain_request, - build_cloud_services_update_domain_list_update_domains_request, - build_cloud_services_update_domain_walk_update_domain_request, - build_cloud_services_update_request, -) -from .._configuration import ComputeManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class CloudServiceRoleInstancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_04.aio.ComputeManagementClient`'s - :attr:`cloud_service_role_instances` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _delete_initial( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cloud_service_role_instances_delete_request( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a role instance from a cloud service. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, - role_instance_name: str, - resource_group_name: str, - cloud_service_name: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any - ) -> _models.RoleInstance: - """Gets a role instance from a cloud service. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :keyword expand: The expand expression to apply to the operation. 'UserData' is not supported - for cloud services. Known values are: "instanceView" and "userData". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_04.models.InstanceViewTypes - :return: RoleInstance or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_04.models.RoleInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.RoleInstance] = kwargs.pop("cls", None) - - _request = build_cloud_service_role_instances_get_request( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("RoleInstance", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_instance_view( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> _models.RoleInstanceView: - """Retrieves information about the run-time state of a role instance in a cloud service. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: RoleInstanceView or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_04.models.RoleInstanceView - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.RoleInstanceView] = kwargs.pop("cls", None) - - _request = build_cloud_service_role_instances_get_instance_view_request( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("RoleInstanceView", 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, - cloud_service_name: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.RoleInstance"]: - """Gets the list of all role instances in a cloud service. Use nextLink property in the response - to get the next page of role instances. Do this till nextLink is null to fetch all the role - instances. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :keyword expand: The expand expression to apply to the operation. 'UserData' is not supported - for cloud services. Known values are: "instanceView" and "userData". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_04.models.InstanceViewTypes - :return: An iterator like instance of either RoleInstance or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_04.models.RoleInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.RoleInstanceListResult] = 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_cloud_service_role_instances_list_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("RoleInstanceListResult", 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 _restart_initial( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cloud_service_role_instances_restart_request( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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 - - @distributed_trace_async - async def begin_restart( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The Reboot Role Instance asynchronous operation requests a reboot of a role instance in the - cloud service. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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 _reimage_initial( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cloud_service_role_instances_reimage_request( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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 - - @distributed_trace_async - async def begin_reimage( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The Reimage Role Instance asynchronous operation reinstalls the operating system on instances - of web roles or worker roles. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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 _rebuild_initial( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cloud_service_role_instances_rebuild_request( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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 - - @distributed_trace_async - async def begin_rebuild( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The Rebuild Role Instance asynchronous operation reinstalls the operating system on instances - of web roles or worker roles and initializes the storage resources that are used by them. If - you do not want to initialize storage resources, you can use Reimage Role Instance. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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._rebuild_initial( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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_remote_desktop_file( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - """Gets a remote desktop file for a role instance in a cloud service. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: AsyncIterator[bytes] or the result of cls(response) - :rtype: AsyncIterator[bytes] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cloud_service_role_instances_get_remote_desktop_file_request( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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]: - 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 - - -class CloudServiceRolesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_04.aio.ComputeManagementClient`'s - :attr:`cloud_service_roles` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, role_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> _models.CloudServiceRole: - """Gets a role from a cloud service. - - :param role_name: Name of the role. Required. - :type role_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: CloudServiceRole or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceRole - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.CloudServiceRole] = kwargs.pop("cls", None) - - _request = build_cloud_service_roles_get_request( - role_name=role_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("CloudServiceRole", 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, cloud_service_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.CloudServiceRole"]: - """Gets a list of all roles in a cloud service. Use nextLink property in the response to get the - next page of roles. Do this till nextLink is null to fetch all the roles. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An iterator like instance of either CloudServiceRole or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_04.models.CloudServiceRole] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.CloudServiceRoleListResult] = 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_cloud_service_roles_list_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("CloudServiceRoleListResult", 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 CloudServicesOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_04.aio.ComputeManagementClient`'s - :attr:`cloud_services` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - cloud_service_name: str, - parameters: Optional[Union[_models.CloudService, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, "CloudService") - else: - _json = None - - _request = build_cloud_services_create_or_update_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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) - - 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, - cloud_service_name: str, - parameters: Optional[_models.CloudService] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CloudService]: - """Create or update a cloud service. Please note some properties can be set only during cloud - service creation. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.CloudService - :keyword content_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 CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CloudService]: - """Create or update a cloud service. Please note some properties can be set only during cloud - service creation. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. 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 CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.CloudService, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.CloudService]: - """Create or update a cloud service. Please note some properties can be set only during cloud - service creation. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. Is either a CloudService type or a IO[bytes] type. - Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.CloudService or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CloudService] = 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, - cloud_service_name=cloud_service_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("CloudService", 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.CloudService].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CloudService]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.CloudServiceUpdate, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, "CloudServiceUpdate") - else: - _json = None - - _request = build_cloud_services_update_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, - cloud_service_name: str, - parameters: Optional[_models.CloudServiceUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CloudService]: - """Update a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceUpdate - :keyword content_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 CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CloudService]: - """Update a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. 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 CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.CloudServiceUpdate, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.CloudService]: - """Update a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. Is either a CloudServiceUpdate type or a IO[bytes] - type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CloudService] = 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, - cloud_service_name=cloud_service_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("CloudService", 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.CloudService].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CloudService]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cloud_services_delete_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, cloud_service_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, - cloud_service_name=cloud_service_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, cloud_service_name: str, **kwargs: Any) -> _models.CloudService: - """Display information about a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: CloudService or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_04.models.CloudService - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.CloudService] = kwargs.pop("cls", None) - - _request = build_cloud_services_get_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("CloudService", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_instance_view( - self, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> _models.CloudServiceInstanceView: - """Gets the status of a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: CloudServiceInstanceView or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceInstanceView - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.CloudServiceInstanceView] = kwargs.pop("cls", None) - - _request = build_cloud_services_get_instance_view_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("CloudServiceInstanceView", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_all(self, **kwargs: Any) -> AsyncItemPaged["_models.CloudService"]: - """Gets a list of all cloud services in the subscription, regardless of the associated resource - group. Use nextLink property in the response to get the next page of Cloud Services. Do this - till nextLink is null to fetch all the Cloud Services. - - :return: An iterator like instance of either CloudService or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.CloudServiceListResult] = 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_cloud_services_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("CloudServiceListResult", 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(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.CloudService"]: - """Gets a list of all cloud services under a resource group. Use nextLink property in the response - to get the next page of Cloud Services. Do this till nextLink is null to fetch all the Cloud - Services. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either CloudService or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.CloudServiceListResult] = 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_cloud_services_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("CloudServiceListResult", 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, cloud_service_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cloud_services_start_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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 - - @distributed_trace_async - async def begin_start( - self, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Starts the cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, - cloud_service_name=cloud_service_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 _power_off_initial( - self, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cloud_services_power_off_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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 - - @distributed_trace_async - async def begin_power_off( - self, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Power off the cloud service. Note that resources are still attached and you are getting charged - for the resources. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, - cloud_service_name=cloud_service_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 _restart_initial( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, "RoleInstances") - else: - _json = None - - _request = build_cloud_services_restart_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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_restart( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[_models.RoleInstances] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more role instances in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.RoleInstances - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_restart( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more role instances in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_restart( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more role instances in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Is either a RoleInstances type or - a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.RoleInstances or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, - cloud_service_name=cloud_service_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 - - async def _reimage_initial( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, "RoleInstances") - else: - _json = None - - _request = build_cloud_services_reimage_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[_models.RoleInstances] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimage asynchronous operation reinstalls the operating system on instances of web roles or - worker roles. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.RoleInstances - :keyword content_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, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimage asynchronous operation reinstalls the operating system on instances of web roles or - worker roles. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimage asynchronous operation reinstalls the operating system on instances of web roles or - worker roles. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Is either a RoleInstances type or - a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.RoleInstances or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, - cloud_service_name=cloud_service_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 - - async def _rebuild_initial( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, "RoleInstances") - else: - _json = None - - _request = build_cloud_services_rebuild_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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_rebuild( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[_models.RoleInstances] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker - roles and initializes the storage resources that are used by them. If you do not want to - initialize storage resources, you can use Reimage Role Instances. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.RoleInstances - :keyword content_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_rebuild( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker - roles and initializes the storage resources that are used by them. If you do not want to - initialize storage resources, you can use Reimage Role Instances. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_rebuild( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker - roles and initializes the storage resources that are used by them. If you do not want to - initialize storage resources, you can use Reimage Role Instances. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Is either a RoleInstances type or - a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.RoleInstances or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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._rebuild_initial( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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 - - async def _delete_instances_initial( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, "RoleInstances") - else: - _json = None - - _request = build_cloud_services_delete_instances_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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_delete_instances( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[_models.RoleInstances] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes role instances in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.RoleInstances - :keyword content_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, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes role instances in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_delete_instances( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes role instances in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Is either a RoleInstances type or - a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.RoleInstances or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, - cloud_service_name=cloud_service_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 CloudServicesUpdateDomainOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_04.aio.ComputeManagementClient`'s - :attr:`cloud_services_update_domain` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _walk_update_domain_initial( - self, - resource_group_name: str, - cloud_service_name: str, - update_domain: int, - parameters: Optional[Union[_models.UpdateDomain, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, "UpdateDomain") - else: - _json = None - - _request = build_cloud_services_update_domain_walk_update_domain_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - update_domain=update_domain, - 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_walk_update_domain( - self, - resource_group_name: str, - cloud_service_name: str, - update_domain: int, - parameters: Optional[_models.UpdateDomain] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Updates the role instances in the specified update domain. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param update_domain: Specifies an integer value that identifies the update domain. Update - domains are identified with a zero-based index: the first update domain has an ID of 0, the - second has an ID of 1, and so on. Required. - :type update_domain: int - :param parameters: The update domain object. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.UpdateDomain - :keyword content_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_walk_update_domain( - self, - resource_group_name: str, - cloud_service_name: str, - update_domain: int, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Updates the role instances in the specified update domain. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param update_domain: Specifies an integer value that identifies the update domain. Update - domains are identified with a zero-based index: the first update domain has an ID of 0, the - second has an ID of 1, and so on. Required. - :type update_domain: int - :param parameters: The update domain object. Default value is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_walk_update_domain( - self, - resource_group_name: str, - cloud_service_name: str, - update_domain: int, - parameters: Optional[Union[_models.UpdateDomain, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Updates the role instances in the specified update domain. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param update_domain: Specifies an integer value that identifies the update domain. Update - domains are identified with a zero-based index: the first update domain has an ID of 0, the - second has an ID of 1, and so on. Required. - :type update_domain: int - :param parameters: The update domain object. Is either a UpdateDomain type or a IO[bytes] type. - Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.UpdateDomain or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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._walk_update_domain_initial( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - update_domain=update_domain, - 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 - - @distributed_trace_async - async def get_update_domain( - self, resource_group_name: str, cloud_service_name: str, update_domain: int, **kwargs: Any - ) -> _models.UpdateDomain: - """Gets the specified update domain of a cloud service. Use nextLink property in the response to - get the next page of update domains. Do this till nextLink is null to fetch all the update - domains. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param update_domain: Specifies an integer value that identifies the update domain. Update - domains are identified with a zero-based index: the first update domain has an ID of 0, the - second has an ID of 1, and so on. Required. - :type update_domain: int - :return: UpdateDomain or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_04.models.UpdateDomain - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.UpdateDomain] = kwargs.pop("cls", None) - - _request = build_cloud_services_update_domain_get_update_domain_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - update_domain=update_domain, - 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("UpdateDomain", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_update_domains( - self, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.UpdateDomain"]: - """Gets a list of all update domains in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An iterator like instance of either UpdateDomain or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_04.models.UpdateDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.UpdateDomainListResult] = 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_cloud_services_update_domain_list_update_domains_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("UpdateDomainListResult", 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 CloudServiceOperatingSystemsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_04.aio.ComputeManagementClient`'s - :attr:`cloud_service_operating_systems` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_os_version(self, location: str, os_version_name: str, **kwargs: Any) -> _models.OSVersion: - """Gets properties of a guest operating system version that can be specified in the XML service - configuration (.cscfg) for a cloud service. - - :param location: Name of the location that the OS version pertains to. Required. - :type location: str - :param os_version_name: Name of the OS version. Required. - :type os_version_name: str - :return: OSVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_04.models.OSVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.OSVersion] = kwargs.pop("cls", None) - - _request = build_cloud_service_operating_systems_get_os_version_request( - location=location, - os_version_name=os_version_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("OSVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_os_versions(self, location: str, **kwargs: Any) -> AsyncItemPaged["_models.OSVersion"]: - """Gets a list of all guest operating system versions available to be specified in the XML service - configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the - next page of OS versions. Do this till nextLink is null to fetch all the OS versions. - - :param location: Name of the location that the OS versions pertain to. Required. - :type location: str - :return: An iterator like instance of either OSVersion or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_04.models.OSVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.OSVersionListResult] = 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_cloud_service_operating_systems_list_os_versions_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("OSVersionListResult", 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_os_family(self, location: str, os_family_name: str, **kwargs: Any) -> _models.OSFamily: - """Gets properties of a guest operating system family that can be specified in the XML service - configuration (.cscfg) for a cloud service. - - :param location: Name of the location that the OS family pertains to. Required. - :type location: str - :param os_family_name: Name of the OS family. Required. - :type os_family_name: str - :return: OSFamily or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_04.models.OSFamily - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.OSFamily] = kwargs.pop("cls", None) - - _request = build_cloud_service_operating_systems_get_os_family_request( - location=location, - os_family_name=os_family_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("OSFamily", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_os_families(self, location: str, **kwargs: Any) -> AsyncItemPaged["_models.OSFamily"]: - """Gets a list of all guest operating system families available to be specified in the XML service - configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the - next page of OS Families. Do this till nextLink is null to fetch all the OS Families. - - :param location: Name of the location that the OS families pertain to. Required. - :type location: str - :return: An iterator like instance of either OSFamily or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_04.models.OSFamily] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.OSFamilyListResult] = 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_cloud_service_operating_systems_list_os_families_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("OSFamilyListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ 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 deleted file mode 100644 index 41713729b15f..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/models/__init__.py +++ /dev/null @@ -1,146 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - ApiError, - ApiErrorBase, - CloudService, - CloudServiceExtensionProfile, - CloudServiceExtensionProperties, - CloudServiceInstanceView, - CloudServiceListResult, - CloudServiceNetworkProfile, - CloudServiceOsProfile, - CloudServiceProperties, - CloudServiceRole, - CloudServiceRoleListResult, - CloudServiceRoleProfile, - CloudServiceRoleProfileProperties, - CloudServiceRoleProperties, - CloudServiceRoleSku, - CloudServiceUpdate, - CloudServiceVaultAndSecretReference, - CloudServiceVaultCertificate, - CloudServiceVaultSecretGroup, - ExtendedLocation, - Extension, - InnerError, - InstanceSku, - InstanceViewStatusesSummary, - LoadBalancerConfiguration, - LoadBalancerConfigurationProperties, - LoadBalancerFrontendIpConfiguration, - LoadBalancerFrontendIpConfigurationProperties, - OSFamily, - OSFamilyListResult, - OSFamilyProperties, - OSVersion, - OSVersionListResult, - OSVersionProperties, - OSVersionPropertiesBase, - Resource, - ResourceInstanceViewStatus, - ResourceWithOptionalLocation, - RoleInstance, - RoleInstanceListResult, - RoleInstanceNetworkProfile, - RoleInstanceProperties, - RoleInstanceView, - RoleInstances, - StatusCodeCount, - SubResource, - SubResourceReadOnly, - SystemData, - SystemDataAutoGenerated, - UpdateDomain, - UpdateDomainListResult, - UserAssignedIdentitiesValue, -) - -from ._compute_management_client_enums import ( # type: ignore - CloudServiceSlotType, - CloudServiceUpgradeMode, - CreatedByType, - ExtendedLocationTypes, - InstanceViewTypes, - StatusLevelTypes, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ApiError", - "ApiErrorBase", - "CloudService", - "CloudServiceExtensionProfile", - "CloudServiceExtensionProperties", - "CloudServiceInstanceView", - "CloudServiceListResult", - "CloudServiceNetworkProfile", - "CloudServiceOsProfile", - "CloudServiceProperties", - "CloudServiceRole", - "CloudServiceRoleListResult", - "CloudServiceRoleProfile", - "CloudServiceRoleProfileProperties", - "CloudServiceRoleProperties", - "CloudServiceRoleSku", - "CloudServiceUpdate", - "CloudServiceVaultAndSecretReference", - "CloudServiceVaultCertificate", - "CloudServiceVaultSecretGroup", - "ExtendedLocation", - "Extension", - "InnerError", - "InstanceSku", - "InstanceViewStatusesSummary", - "LoadBalancerConfiguration", - "LoadBalancerConfigurationProperties", - "LoadBalancerFrontendIpConfiguration", - "LoadBalancerFrontendIpConfigurationProperties", - "OSFamily", - "OSFamilyListResult", - "OSFamilyProperties", - "OSVersion", - "OSVersionListResult", - "OSVersionProperties", - "OSVersionPropertiesBase", - "Resource", - "ResourceInstanceViewStatus", - "ResourceWithOptionalLocation", - "RoleInstance", - "RoleInstanceListResult", - "RoleInstanceNetworkProfile", - "RoleInstanceProperties", - "RoleInstanceView", - "RoleInstances", - "StatusCodeCount", - "SubResource", - "SubResourceReadOnly", - "SystemData", - "SystemDataAutoGenerated", - "UpdateDomain", - "UpdateDomainListResult", - "UserAssignedIdentitiesValue", - "CloudServiceSlotType", - "CloudServiceUpgradeMode", - "CreatedByType", - "ExtendedLocationTypes", - "InstanceViewTypes", - "StatusLevelTypes", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_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 deleted file mode 100644 index b046d41ecd72..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/models/_compute_management_client_enums.py +++ /dev/null @@ -1,68 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class CloudServiceSlotType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Slot type for the cloud service. - Possible values are :code:`
    `\\ :code:`
    `\\ **Production**\\ :code:`
    `\\ - :code:`
    `\\ **Staging**\\ :code:`
    `\\ :code:`
    ` - If not specified, the default value is Production. - """ - - PRODUCTION = "Production" - STAGING = "Staging" - - -class CloudServiceUpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Update mode for the cloud service. Role instances are allocated to update domains when the - service is deployed. Updates can be initiated manually in each update domain or initiated - automatically in all update domains. - Possible Values are :code:`
    `\\ :code:`
    `\\ **Auto**\\ :code:`
    `\\ :code:`
    `\\ **Manual** :code:`
    `\\ :code:`
    `\\ **Simultaneous**\\ :code:`
    `\\ - :code:`
    ` - If not specified, the default value is Auto. If set to Manual, PUT UpdateDomain must be called - to apply the update. If set to Auto, the update is automatically applied to each update domain - in sequence. - """ - - AUTO = "Auto" - MANUAL = "Manual" - 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.""" - - EDGE_ZONE = "EdgeZone" - - -class InstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """InstanceViewTypes.""" - - INSTANCE_VIEW = "instanceView" - USER_DATA = "userData" - - -class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The level code.""" - - INFO = "Info" - WARNING = "Warning" - ERROR = "Error" 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 deleted file mode 100644 index 4e42dec24772..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/models/_models_py3.py +++ /dev/null @@ -1,2167 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from collections.abc import MutableMapping -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models -JSON = MutableMapping[str, Any] - - -class ApiError(_serialization.Model): - """Api error. - - :ivar details: The Api error details. - :vartype details: list[~azure.mgmt.compute.v2024_11_04.models.ApiErrorBase] - :ivar innererror: The Api inner error. - :vartype innererror: ~azure.mgmt.compute.v2024_11_04.models.InnerError - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "details": {"key": "details", "type": "[ApiErrorBase]"}, - "innererror": {"key": "innererror", "type": "InnerError"}, - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - details: Optional[List["_models.ApiErrorBase"]] = None, - innererror: Optional["_models.InnerError"] = None, - code: Optional[str] = None, - target: Optional[str] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword details: The Api error details. - :paramtype details: list[~azure.mgmt.compute.v2024_11_04.models.ApiErrorBase] - :keyword innererror: The Api inner error. - :paramtype innererror: ~azure.mgmt.compute.v2024_11_04.models.InnerError - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.details = details - self.innererror = innererror - self.code = code - self.target = target - self.message = message - - -class ApiErrorBase(_serialization.Model): - """Api error base. - - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.target = target - self.message = message - - -class CloudService(_serialization.Model): - """Describes the cloud service. - - 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] - :ivar properties: Cloud service properties. - :vartype properties: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceProperties - :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. - :vartype zones: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "system_data": {"readonly": 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}"}, - "properties": {"key": "properties", "type": "CloudServiceProperties"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "zones": {"key": "zones", "type": "[str]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - properties: Optional["_models.CloudServiceProperties"] = None, - zones: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword properties: Cloud service properties. - :paramtype properties: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceProperties - :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] - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - self.properties = properties - self.system_data: Optional["_models.SystemData"] = None - self.zones = zones - - -class CloudServiceExtensionProfile(_serialization.Model): - """Describes a cloud service extension profile. - - :ivar extensions: List of extensions for the cloud service. - :vartype extensions: list[~azure.mgmt.compute.v2024_11_04.models.Extension] - """ - - _attribute_map = { - "extensions": {"key": "extensions", "type": "[Extension]"}, - } - - def __init__(self, *, extensions: Optional[List["_models.Extension"]] = None, **kwargs: Any) -> None: - """ - :keyword extensions: List of extensions for the cloud service. - :paramtype extensions: list[~azure.mgmt.compute.v2024_11_04.models.Extension] - """ - super().__init__(**kwargs) - self.extensions = extensions - - -class CloudServiceExtensionProperties(_serialization.Model): - """Extension Properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar publisher: The name of the extension handler publisher. - :vartype publisher: str - :ivar type: Specifies the type of the extension. - :vartype type: str - :ivar type_handler_version: Specifies the version of the extension. Specifies the version of - the extension. If this element is not specified or an asterisk (*) is used as the value, the - latest version of the extension is used. If the value is specified with a major version number - and an asterisk as the minor version number (X.), the latest minor version of the specified - major version is selected. If a major version number and a minor version number are specified - (X.Y), the specific extension version is selected. If a version is specified, an auto-upgrade - is performed on the role instance. - :vartype type_handler_version: str - :ivar auto_upgrade_minor_version: Explicitly specify whether platform can automatically upgrade - typeHandlerVersion to higher minor versions when they become available. - :vartype auto_upgrade_minor_version: bool - :ivar settings: Public settings for the extension. For JSON extensions, this is the JSON - settings for the extension. For XML Extension (like RDP), this is the XML setting for the - extension. - :vartype settings: JSON - :ivar protected_settings: Protected settings for the extension which are encrypted before sent - to the role instance. - :vartype protected_settings: JSON - :ivar protected_settings_from_key_vault: Protected settings for the extension, referenced using - KeyVault which are encrypted before sent to the role instance. - :vartype protected_settings_from_key_vault: - ~azure.mgmt.compute.v2024_11_04.models.CloudServiceVaultAndSecretReference - :ivar force_update_tag: Tag to force apply the provided public and protected settings. - Changing the tag value allows for re-running the extension without changing any of the public - or protected settings. - If forceUpdateTag is not changed, updates to public or protected settings would still be - applied by the handler. - If neither forceUpdateTag nor any of public or protected settings change, extension would flow - to the role instance with the same sequence-number, and - it is up to handler implementation whether to re-run it or not. - :vartype force_update_tag: str - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar roles_applied_to: Optional list of roles to apply this extension. If property is not - specified or '*' is specified, extension is applied to all roles in the cloud service. - :vartype roles_applied_to: list[str] - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, - "auto_upgrade_minor_version": {"key": "autoUpgradeMinorVersion", "type": "bool"}, - "settings": {"key": "settings", "type": "object"}, - "protected_settings": {"key": "protectedSettings", "type": "object"}, - "protected_settings_from_key_vault": { - "key": "protectedSettingsFromKeyVault", - "type": "CloudServiceVaultAndSecretReference", - }, - "force_update_tag": {"key": "forceUpdateTag", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "roles_applied_to": {"key": "rolesAppliedTo", "type": "[str]"}, - } - - def __init__( - self, - *, - publisher: Optional[str] = None, - type: Optional[str] = None, - type_handler_version: Optional[str] = None, - auto_upgrade_minor_version: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, - protected_settings_from_key_vault: Optional["_models.CloudServiceVaultAndSecretReference"] = None, - force_update_tag: Optional[str] = None, - roles_applied_to: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword publisher: The name of the extension handler publisher. - :paramtype publisher: str - :keyword type: Specifies the type of the extension. - :paramtype type: str - :keyword type_handler_version: Specifies the version of the extension. Specifies the version of - the extension. If this element is not specified or an asterisk (*) is used as the value, the - latest version of the extension is used. If the value is specified with a major version number - and an asterisk as the minor version number (X.), the latest minor version of the specified - major version is selected. If a major version number and a minor version number are specified - (X.Y), the specific extension version is selected. If a version is specified, an auto-upgrade - is performed on the role instance. - :paramtype type_handler_version: str - :keyword auto_upgrade_minor_version: Explicitly specify whether platform can automatically - upgrade typeHandlerVersion to higher minor versions when they become available. - :paramtype auto_upgrade_minor_version: bool - :keyword settings: Public settings for the extension. For JSON extensions, this is the JSON - settings for the extension. For XML Extension (like RDP), this is the XML setting for the - extension. - :paramtype settings: JSON - :keyword protected_settings: Protected settings for the extension which are encrypted before - sent to the role instance. - :paramtype protected_settings: JSON - :keyword protected_settings_from_key_vault: Protected settings for the extension, referenced - using KeyVault which are encrypted before sent to the role instance. - :paramtype protected_settings_from_key_vault: - ~azure.mgmt.compute.v2024_11_04.models.CloudServiceVaultAndSecretReference - :keyword force_update_tag: Tag to force apply the provided public and protected settings. - Changing the tag value allows for re-running the extension without changing any of the public - or protected settings. - If forceUpdateTag is not changed, updates to public or protected settings would still be - applied by the handler. - If neither forceUpdateTag nor any of public or protected settings change, extension would flow - to the role instance with the same sequence-number, and - it is up to handler implementation whether to re-run it or not. - :paramtype force_update_tag: str - :keyword roles_applied_to: Optional list of roles to apply this extension. If property is not - specified or '*' is specified, extension is applied to all roles in the cloud service. - :paramtype roles_applied_to: list[str] - """ - super().__init__(**kwargs) - self.publisher = publisher - self.type = type - self.type_handler_version = type_handler_version - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.settings = settings - self.protected_settings = protected_settings - self.protected_settings_from_key_vault = protected_settings_from_key_vault - self.force_update_tag = force_update_tag - self.provisioning_state: Optional[str] = None - self.roles_applied_to = roles_applied_to - - -class CloudServiceInstanceView(_serialization.Model): - """InstanceView of CloudService as a whole. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar role_instance: Instance view statuses. - :vartype role_instance: ~azure.mgmt.compute.v2024_11_04.models.InstanceViewStatusesSummary - :ivar sdk_version: The version of the SDK that was used to generate the package for the cloud - service. - :vartype sdk_version: str - :ivar private_ids: Specifies a list of unique identifiers generated internally for the cloud - service. :code:`
    `\\ :code:`
    ` NOTE: If you are using Azure Diagnostics extension, - this property can be used as 'DeploymentId' for querying details. - :vartype private_ids: list[str] - :ivar statuses: - :vartype statuses: list[~azure.mgmt.compute.v2024_11_04.models.ResourceInstanceViewStatus] - """ - - _validation = { - "sdk_version": {"readonly": True}, - "private_ids": {"readonly": True}, - "statuses": {"readonly": True}, - } - - _attribute_map = { - "role_instance": {"key": "roleInstance", "type": "InstanceViewStatusesSummary"}, - "sdk_version": {"key": "sdkVersion", "type": "str"}, - "private_ids": {"key": "privateIds", "type": "[str]"}, - "statuses": {"key": "statuses", "type": "[ResourceInstanceViewStatus]"}, - } - - def __init__(self, *, role_instance: Optional["_models.InstanceViewStatusesSummary"] = None, **kwargs: Any) -> None: - """ - :keyword role_instance: Instance view statuses. - :paramtype role_instance: ~azure.mgmt.compute.v2024_11_04.models.InstanceViewStatusesSummary - """ - super().__init__(**kwargs) - self.role_instance = role_instance - self.sdk_version: Optional[str] = None - self.private_ids: Optional[List[str]] = None - self.statuses: Optional[List["_models.ResourceInstanceViewStatus"]] = None - - -class CloudServiceListResult(_serialization.Model): - """The list operation result. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of resources. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_04.models.CloudService] - :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of - resources. Do this till nextLink is null to fetch all the resources. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[CloudService]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.CloudService"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of resources. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_04.models.CloudService] - :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page - of resources. Do this till nextLink is null to fetch all the resources. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class CloudServiceNetworkProfile(_serialization.Model): - """Network Profile for the cloud service. - - :ivar load_balancer_configurations: List of Load balancer configurations. Cloud service can - have up to two load balancer configurations, corresponding to a Public Load Balancer and an - Internal Load Balancer. - :vartype load_balancer_configurations: - list[~azure.mgmt.compute.v2024_11_04.models.LoadBalancerConfiguration] - :ivar slot_type: Slot type for the cloud service. - Possible values are :code:`
    `\\ :code:`
    `\\ **Production**\\ :code:`
    `\\ - :code:`
    `\\ **Staging**\\ :code:`
    `\\ :code:`
    ` - If not specified, the default value is Production. Known values are: "Production" and - "Staging". - :vartype slot_type: str or ~azure.mgmt.compute.v2024_11_04.models.CloudServiceSlotType - :ivar swappable_cloud_service: The id reference of the cloud service containing the target IP - with which the subject cloud service can perform a swap. This property cannot be updated once - it is set. The swappable cloud service referred by this id must be present otherwise an error - will be thrown. - :vartype swappable_cloud_service: ~azure.mgmt.compute.v2024_11_04.models.SubResource - """ - - _attribute_map = { - "load_balancer_configurations": {"key": "loadBalancerConfigurations", "type": "[LoadBalancerConfiguration]"}, - "slot_type": {"key": "slotType", "type": "str"}, - "swappable_cloud_service": {"key": "swappableCloudService", "type": "SubResource"}, - } - - def __init__( - self, - *, - load_balancer_configurations: Optional[List["_models.LoadBalancerConfiguration"]] = None, - slot_type: Optional[Union[str, "_models.CloudServiceSlotType"]] = None, - swappable_cloud_service: Optional["_models.SubResource"] = None, - **kwargs: Any - ) -> None: - """ - :keyword load_balancer_configurations: List of Load balancer configurations. Cloud service can - have up to two load balancer configurations, corresponding to a Public Load Balancer and an - Internal Load Balancer. - :paramtype load_balancer_configurations: - list[~azure.mgmt.compute.v2024_11_04.models.LoadBalancerConfiguration] - :keyword slot_type: Slot type for the cloud service. - Possible values are :code:`
    `\\ :code:`
    `\\ **Production**\\ :code:`
    `\\ - :code:`
    `\\ **Staging**\\ :code:`
    `\\ :code:`
    ` - If not specified, the default value is Production. Known values are: "Production" and - "Staging". - :paramtype slot_type: str or ~azure.mgmt.compute.v2024_11_04.models.CloudServiceSlotType - :keyword swappable_cloud_service: The id reference of the cloud service containing the target - IP with which the subject cloud service can perform a swap. This property cannot be updated - once it is set. The swappable cloud service referred by this id must be present otherwise an - error will be thrown. - :paramtype swappable_cloud_service: ~azure.mgmt.compute.v2024_11_04.models.SubResource - """ - super().__init__(**kwargs) - self.load_balancer_configurations = load_balancer_configurations - self.slot_type = slot_type - self.swappable_cloud_service = swappable_cloud_service - - -class CloudServiceOsProfile(_serialization.Model): - """Describes the OS profile for the cloud service. - - :ivar secrets: Specifies set of certificates that should be installed onto the role instances. - :vartype secrets: list[~azure.mgmt.compute.v2024_11_04.models.CloudServiceVaultSecretGroup] - """ - - _attribute_map = { - "secrets": {"key": "secrets", "type": "[CloudServiceVaultSecretGroup]"}, - } - - def __init__( - self, *, secrets: Optional[List["_models.CloudServiceVaultSecretGroup"]] = None, **kwargs: Any - ) -> None: - """ - :keyword secrets: Specifies set of certificates that should be installed onto the role - instances. - :paramtype secrets: list[~azure.mgmt.compute.v2024_11_04.models.CloudServiceVaultSecretGroup] - """ - super().__init__(**kwargs) - self.secrets = secrets - - -class CloudServiceProperties(_serialization.Model): - """Cloud service properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar package_url: Specifies a URL that refers to the location of the service package in the - Blob service. The service package URL can be Shared Access Signature (SAS) URI from any storage - account. - This is a write-only property and is not returned in GET calls. - :vartype package_url: str - :ivar configuration: Specifies the XML service configuration (.cscfg) for the cloud service. - :vartype configuration: str - :ivar configuration_url: Specifies a URL that refers to the location of the service - configuration in the Blob service. The service package URL can be Shared Access Signature - (SAS) URI from any storage account. - This is a write-only property and is not returned in GET calls. - :vartype configuration_url: str - :ivar start_cloud_service: (Optional) Indicates whether to start the cloud service immediately - after it is created. The default value is ``true``. - If false, the service model is still deployed, but the code is not run immediately. Instead, - the service is PoweredOff until you call Start, at which time the service will be started. A - deployed service still incurs charges, even if it is poweredoff. - :vartype start_cloud_service: bool - :ivar allow_model_override: (Optional) Indicates whether the role sku properties - (roleProfile.roles.sku) specified in the model/template should override the role instance count - and vm size specified in the .cscfg and .csdef respectively. - The default value is ``false``. - :vartype allow_model_override: bool - :ivar upgrade_mode: Update mode for the cloud service. Role instances are allocated to update - domains when the service is deployed. Updates can be initiated manually in each update domain - or initiated automatically in all update domains. - Possible Values are :code:`
    `\\ :code:`
    `\\ **Auto**\\ :code:`
    `\\ :code:`
    `\\ **Manual** :code:`
    `\\ :code:`
    `\\ **Simultaneous**\\ :code:`
    `\\ - :code:`
    ` - If not specified, the default value is Auto. If set to Manual, PUT UpdateDomain must be called - to apply the update. If set to Auto, the update is automatically applied to each update domain - in sequence. Known values are: "Auto", "Manual", and "Simultaneous". - :vartype upgrade_mode: str or ~azure.mgmt.compute.v2024_11_04.models.CloudServiceUpgradeMode - :ivar role_profile: Describes the role profile for the cloud service. - :vartype role_profile: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceRoleProfile - :ivar os_profile: Describes the OS profile for the cloud service. - :vartype os_profile: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceOsProfile - :ivar network_profile: Network Profile for the cloud service. - :vartype network_profile: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceNetworkProfile - :ivar extension_profile: Describes a cloud service extension profile. - :vartype extension_profile: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceExtensionProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :ivar unique_id: The unique identifier for the cloud service. - :vartype unique_id: str - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "unique_id": {"readonly": True}, - } - - _attribute_map = { - "package_url": {"key": "packageUrl", "type": "str"}, - "configuration": {"key": "configuration", "type": "str"}, - "configuration_url": {"key": "configurationUrl", "type": "str"}, - "start_cloud_service": {"key": "startCloudService", "type": "bool"}, - "allow_model_override": {"key": "allowModelOverride", "type": "bool"}, - "upgrade_mode": {"key": "upgradeMode", "type": "str"}, - "role_profile": {"key": "roleProfile", "type": "CloudServiceRoleProfile"}, - "os_profile": {"key": "osProfile", "type": "CloudServiceOsProfile"}, - "network_profile": {"key": "networkProfile", "type": "CloudServiceNetworkProfile"}, - "extension_profile": {"key": "extensionProfile", "type": "CloudServiceExtensionProfile"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "unique_id": {"key": "uniqueId", "type": "str"}, - } - - def __init__( - self, - *, - package_url: Optional[str] = None, - configuration: Optional[str] = None, - configuration_url: Optional[str] = None, - start_cloud_service: Optional[bool] = None, - allow_model_override: Optional[bool] = None, - upgrade_mode: Optional[Union[str, "_models.CloudServiceUpgradeMode"]] = None, - role_profile: Optional["_models.CloudServiceRoleProfile"] = None, - os_profile: Optional["_models.CloudServiceOsProfile"] = None, - network_profile: Optional["_models.CloudServiceNetworkProfile"] = None, - extension_profile: Optional["_models.CloudServiceExtensionProfile"] = None, - **kwargs: Any - ) -> None: - """ - :keyword package_url: Specifies a URL that refers to the location of the service package in the - Blob service. The service package URL can be Shared Access Signature (SAS) URI from any storage - account. - This is a write-only property and is not returned in GET calls. - :paramtype package_url: str - :keyword configuration: Specifies the XML service configuration (.cscfg) for the cloud service. - :paramtype configuration: str - :keyword configuration_url: Specifies a URL that refers to the location of the service - configuration in the Blob service. The service package URL can be Shared Access Signature - (SAS) URI from any storage account. - This is a write-only property and is not returned in GET calls. - :paramtype configuration_url: str - :keyword start_cloud_service: (Optional) Indicates whether to start the cloud service - immediately after it is created. The default value is ``true``. - If false, the service model is still deployed, but the code is not run immediately. Instead, - the service is PoweredOff until you call Start, at which time the service will be started. A - deployed service still incurs charges, even if it is poweredoff. - :paramtype start_cloud_service: bool - :keyword allow_model_override: (Optional) Indicates whether the role sku properties - (roleProfile.roles.sku) specified in the model/template should override the role instance count - and vm size specified in the .cscfg and .csdef respectively. - The default value is ``false``. - :paramtype allow_model_override: bool - :keyword upgrade_mode: Update mode for the cloud service. Role instances are allocated to - update domains when the service is deployed. Updates can be initiated manually in each update - domain or initiated automatically in all update domains. - Possible Values are :code:`
    `\\ :code:`
    `\\ **Auto**\\ :code:`
    `\\ :code:`
    `\\ **Manual** :code:`
    `\\ :code:`
    `\\ **Simultaneous**\\ :code:`
    `\\ - :code:`
    ` - If not specified, the default value is Auto. If set to Manual, PUT UpdateDomain must be called - to apply the update. If set to Auto, the update is automatically applied to each update domain - in sequence. Known values are: "Auto", "Manual", and "Simultaneous". - :paramtype upgrade_mode: str or ~azure.mgmt.compute.v2024_11_04.models.CloudServiceUpgradeMode - :keyword role_profile: Describes the role profile for the cloud service. - :paramtype role_profile: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceRoleProfile - :keyword os_profile: Describes the OS profile for the cloud service. - :paramtype os_profile: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceOsProfile - :keyword network_profile: Network Profile for the cloud service. - :paramtype network_profile: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceNetworkProfile - :keyword extension_profile: Describes a cloud service extension profile. - :paramtype extension_profile: - ~azure.mgmt.compute.v2024_11_04.models.CloudServiceExtensionProfile - """ - super().__init__(**kwargs) - self.package_url = package_url - self.configuration = configuration - self.configuration_url = configuration_url - self.start_cloud_service = start_cloud_service - self.allow_model_override = allow_model_override - self.upgrade_mode = upgrade_mode - self.role_profile = role_profile - self.os_profile = os_profile - self.network_profile = network_profile - self.extension_profile = extension_profile - self.provisioning_state: Optional[str] = None - self.unique_id: Optional[str] = None - - -class CloudServiceRole(_serialization.Model): - """Describes a role of the cloud service. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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. - :vartype location: str - :ivar sku: Describes the cloud service role sku. - :vartype sku: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceRoleSku - :ivar properties: The cloud service role properties. - :vartype properties: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceRoleProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "sku": {"key": "sku", "type": "CloudServiceRoleSku"}, - "properties": {"key": "properties", "type": "CloudServiceRoleProperties"}, - } - - def __init__( - self, - *, - sku: Optional["_models.CloudServiceRoleSku"] = None, - properties: Optional["_models.CloudServiceRoleProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword sku: Describes the cloud service role sku. - :paramtype sku: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceRoleSku - :keyword properties: The cloud service role properties. - :paramtype properties: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceRoleProperties - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location: Optional[str] = None - self.sku = sku - self.properties = properties - - -class CloudServiceRoleListResult(_serialization.Model): - """The list operation result. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of resources. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_04.models.CloudServiceRole] - :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of - resources. Do this till nextLink is null to fetch all the resources. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[CloudServiceRole]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.CloudServiceRole"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of resources. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_04.models.CloudServiceRole] - :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page - of resources. Do this till nextLink is null to fetch all the resources. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class CloudServiceRoleProfile(_serialization.Model): - """Describes the role profile for the cloud service. - - :ivar roles: List of roles for the cloud service. - :vartype roles: list[~azure.mgmt.compute.v2024_11_04.models.CloudServiceRoleProfileProperties] - """ - - _attribute_map = { - "roles": {"key": "roles", "type": "[CloudServiceRoleProfileProperties]"}, - } - - def __init__( - self, *, roles: Optional[List["_models.CloudServiceRoleProfileProperties"]] = None, **kwargs: Any - ) -> None: - """ - :keyword roles: List of roles for the cloud service. - :paramtype roles: - list[~azure.mgmt.compute.v2024_11_04.models.CloudServiceRoleProfileProperties] - """ - super().__init__(**kwargs) - self.roles = roles - - -class CloudServiceRoleProfileProperties(_serialization.Model): - """Describes the role properties. - - :ivar name: Resource name. - :vartype name: str - :ivar sku: Describes the cloud service role sku. - :vartype sku: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceRoleSku - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "sku": {"key": "sku", "type": "CloudServiceRoleSku"}, - } - - def __init__( - self, *, name: Optional[str] = None, sku: Optional["_models.CloudServiceRoleSku"] = None, **kwargs: Any - ) -> None: - """ - :keyword name: Resource name. - :paramtype name: str - :keyword sku: Describes the cloud service role sku. - :paramtype sku: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceRoleSku - """ - super().__init__(**kwargs) - self.name = name - self.sku = sku - - -class CloudServiceRoleProperties(_serialization.Model): - """The cloud service role properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar unique_id: Specifies the ID which uniquely identifies a cloud service role. - :vartype unique_id: str - """ - - _validation = { - "unique_id": {"readonly": True}, - } - - _attribute_map = { - "unique_id": {"key": "uniqueId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.unique_id: Optional[str] = None - - -class CloudServiceRoleSku(_serialization.Model): - """Describes the cloud service role sku. - - :ivar name: The sku name. NOTE: If the new SKU is not supported on the hardware the cloud - service is currently on, you need to delete and recreate the cloud service or move back to the - old sku. - :vartype name: str - :ivar tier: Specifies the tier of the cloud service. Possible Values are :code:`
    `\\ - :code:`
    ` **Standard** :code:`
    `\\ :code:`
    ` **Basic**. - :vartype tier: str - :ivar capacity: Specifies the number of role instances in the cloud service. - :vartype capacity: int - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "capacity": {"key": "capacity", "type": "int"}, - } - - def __init__( - self, *, name: Optional[str] = None, tier: Optional[str] = None, capacity: Optional[int] = None, **kwargs: Any - ) -> None: - """ - :keyword name: The sku name. NOTE: If the new SKU is not supported on the hardware the cloud - service is currently on, you need to delete and recreate the cloud service or move back to the - old sku. - :paramtype name: str - :keyword tier: Specifies the tier of the cloud service. Possible Values are :code:`
    `\\ - :code:`
    ` **Standard** :code:`
    `\\ :code:`
    ` **Basic**. - :paramtype tier: str - :keyword capacity: Specifies the number of role instances in the cloud service. - :paramtype capacity: int - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - self.capacity = capacity - - -class CloudServiceUpdate(_serialization.Model): - """CloudServiceUpdate. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class CloudServiceVaultAndSecretReference(_serialization.Model): - """Protected settings for the extension, referenced using KeyVault which are encrypted before sent - to the role instance. - - :ivar source_vault: The ARM Resource ID of the Key Vault. - :vartype source_vault: ~azure.mgmt.compute.v2024_11_04.models.SubResource - :ivar secret_url: Secret URL which contains the protected settings of the extension. - :vartype secret_url: str - """ - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - "secret_url": {"key": "secretUrl", "type": "str"}, - } - - def __init__( - self, *, source_vault: Optional["_models.SubResource"] = None, secret_url: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword source_vault: The ARM Resource ID of the Key Vault. - :paramtype source_vault: ~azure.mgmt.compute.v2024_11_04.models.SubResource - :keyword secret_url: Secret URL which contains the protected settings of the extension. - :paramtype secret_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.secret_url = secret_url - - -class CloudServiceVaultCertificate(_serialization.Model): - """Describes a single certificate reference in a Key Vault, and where the certificate should - reside on the role instance. - - :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as - a secret. - :vartype certificate_url: str - :ivar is_bootstrap_certificate: Flag indicating if the certificate provided is a bootstrap - certificate to be used by the Key Vault Extension to fetch the remaining certificates. - :vartype is_bootstrap_certificate: bool - """ - - _attribute_map = { - "certificate_url": {"key": "certificateUrl", "type": "str"}, - "is_bootstrap_certificate": {"key": "isBootstrapCertificate", "type": "bool"}, - } - - def __init__( - self, *, certificate_url: Optional[str] = None, is_bootstrap_certificate: Optional[bool] = None, **kwargs: Any - ) -> None: - """ - :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault - as a secret. - :paramtype certificate_url: str - :keyword is_bootstrap_certificate: Flag indicating if the certificate provided is a bootstrap - certificate to be used by the Key Vault Extension to fetch the remaining certificates. - :paramtype is_bootstrap_certificate: bool - """ - super().__init__(**kwargs) - self.certificate_url = certificate_url - self.is_bootstrap_certificate = is_bootstrap_certificate - - -class CloudServiceVaultSecretGroup(_serialization.Model): - """Describes a set of certificates which are all in the same Key Vault. - - :ivar source_vault: The relative URL of the Key Vault containing all of the certificates in - VaultCertificates. - :vartype source_vault: ~azure.mgmt.compute.v2024_11_04.models.SubResource - :ivar vault_certificates: The list of key vault references in SourceVault which contain - certificates. - :vartype vault_certificates: - list[~azure.mgmt.compute.v2024_11_04.models.CloudServiceVaultCertificate] - """ - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SubResource"}, - "vault_certificates": {"key": "vaultCertificates", "type": "[CloudServiceVaultCertificate]"}, - } - - def __init__( - self, - *, - source_vault: Optional["_models.SubResource"] = None, - vault_certificates: Optional[List["_models.CloudServiceVaultCertificate"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source_vault: The relative URL of the Key Vault containing all of the certificates in - VaultCertificates. - :paramtype source_vault: ~azure.mgmt.compute.v2024_11_04.models.SubResource - :keyword vault_certificates: The list of key vault references in SourceVault which contain - certificates. - :paramtype vault_certificates: - list[~azure.mgmt.compute.v2024_11_04.models.CloudServiceVaultCertificate] - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.vault_certificates = vault_certificates - - -class ExtendedLocation(_serialization.Model): - """The complex type of the extended location. - - :ivar name: The name of the extended location. - :vartype name: str - :ivar type: The type of the extended location. "EdgeZone" - :vartype type: str or ~azure.mgmt.compute.v2024_11_04.models.ExtendedLocationTypes - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the extended location. - :paramtype name: str - :keyword type: The type of the extended location. "EdgeZone" - :paramtype type: str or ~azure.mgmt.compute.v2024_11_04.models.ExtendedLocationTypes - """ - super().__init__(**kwargs) - self.name = name - self.type = type - - -class Extension(_serialization.Model): - """Describes a cloud service Extension. - - :ivar name: The name of the extension. - :vartype name: str - :ivar properties: Extension Properties. - :vartype properties: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceExtensionProperties - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "properties": {"key": "properties", "type": "CloudServiceExtensionProperties"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - properties: Optional["_models.CloudServiceExtensionProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the extension. - :paramtype name: str - :keyword properties: Extension Properties. - :paramtype properties: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceExtensionProperties - """ - super().__init__(**kwargs) - self.name = name - self.properties = properties - - -class InnerError(_serialization.Model): - """Inner error details. - - :ivar exceptiontype: The exception type. - :vartype exceptiontype: str - :ivar errordetail: The internal error message or exception dump. - :vartype errordetail: str - """ - - _attribute_map = { - "exceptiontype": {"key": "exceptiontype", "type": "str"}, - "errordetail": {"key": "errordetail", "type": "str"}, - } - - def __init__( - self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword exceptiontype: The exception type. - :paramtype exceptiontype: str - :keyword errordetail: The internal error message or exception dump. - :paramtype errordetail: str - """ - super().__init__(**kwargs) - self.exceptiontype = exceptiontype - self.errordetail = errordetail - - -class InstanceSku(_serialization.Model): - """The role instance SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. - :vartype name: str - :ivar tier: The tier of the cloud service role instance. - :vartype tier: str - """ - - _validation = { - "name": {"readonly": True}, - "tier": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.tier: Optional[str] = None - - -class InstanceViewStatusesSummary(_serialization.Model): - """Instance view statuses. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar statuses_summary: The summary. - :vartype statuses_summary: list[~azure.mgmt.compute.v2024_11_04.models.StatusCodeCount] - """ - - _validation = { - "statuses_summary": {"readonly": True}, - } - - _attribute_map = { - "statuses_summary": {"key": "statusesSummary", "type": "[StatusCodeCount]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.statuses_summary: Optional[List["_models.StatusCodeCount"]] = None - - -class LoadBalancerConfiguration(_serialization.Model): - """Describes the load balancer configuration. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: The name of the Load balancer. Required. - :vartype name: str - :ivar properties: Properties of the load balancer configuration. Required. - :vartype properties: ~azure.mgmt.compute.v2024_11_04.models.LoadBalancerConfigurationProperties - """ - - _validation = { - "name": {"required": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "properties": {"key": "properties", "type": "LoadBalancerConfigurationProperties"}, - } - - def __init__( - self, - *, - name: str, - properties: "_models.LoadBalancerConfigurationProperties", - id: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id. - :paramtype id: str - :keyword name: The name of the Load balancer. Required. - :paramtype name: str - :keyword properties: Properties of the load balancer configuration. Required. - :paramtype properties: - ~azure.mgmt.compute.v2024_11_04.models.LoadBalancerConfigurationProperties - """ - super().__init__(**kwargs) - self.id = id - self.name = name - self.properties = properties - - -class LoadBalancerConfigurationProperties(_serialization.Model): - """Describes the properties of the load balancer configuration. - - All required parameters must be populated in order to send to server. - - :ivar frontend_ip_configurations: Specifies the frontend IP to be used for the load balancer. - Only IPv4 frontend IP address is supported. Each load balancer configuration must have exactly - one frontend IP configuration. Required. - :vartype frontend_ip_configurations: - list[~azure.mgmt.compute.v2024_11_04.models.LoadBalancerFrontendIpConfiguration] - """ - - _validation = { - "frontend_ip_configurations": {"required": True}, - } - - _attribute_map = { - "frontend_ip_configurations": { - "key": "frontendIpConfigurations", - "type": "[LoadBalancerFrontendIpConfiguration]", - }, - } - - def __init__( - self, *, frontend_ip_configurations: List["_models.LoadBalancerFrontendIpConfiguration"], **kwargs: Any - ) -> None: - """ - :keyword frontend_ip_configurations: Specifies the frontend IP to be used for the load - balancer. Only IPv4 frontend IP address is supported. Each load balancer configuration must - have exactly one frontend IP configuration. Required. - :paramtype frontend_ip_configurations: - list[~azure.mgmt.compute.v2024_11_04.models.LoadBalancerFrontendIpConfiguration] - """ - super().__init__(**kwargs) - self.frontend_ip_configurations = frontend_ip_configurations - - -class LoadBalancerFrontendIpConfiguration(_serialization.Model): - """Specifies the frontend IP to be used for the load balancer. Only IPv4 frontend IP address is - supported. Each load balancer configuration must have exactly one frontend IP configuration. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the resource that is unique within the set of frontend IP - configurations used by the load balancer. This name can be used to access the resource. - Required. - :vartype name: str - :ivar properties: Properties of load balancer frontend ip configuration. Required. - :vartype properties: - ~azure.mgmt.compute.v2024_11_04.models.LoadBalancerFrontendIpConfigurationProperties - """ - - _validation = { - "name": {"required": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "properties": {"key": "properties", "type": "LoadBalancerFrontendIpConfigurationProperties"}, - } - - def __init__( - self, *, name: str, properties: "_models.LoadBalancerFrontendIpConfigurationProperties", **kwargs: Any - ) -> None: - """ - :keyword name: The name of the resource that is unique within the set of frontend IP - configurations used by the load balancer. This name can be used to access the resource. - Required. - :paramtype name: str - :keyword properties: Properties of load balancer frontend ip configuration. Required. - :paramtype properties: - ~azure.mgmt.compute.v2024_11_04.models.LoadBalancerFrontendIpConfigurationProperties - """ - super().__init__(**kwargs) - self.name = name - self.properties = properties - - -class LoadBalancerFrontendIpConfigurationProperties(_serialization.Model): # pylint: disable=name-too-long - """Describes a cloud service IP Configuration. - - :ivar public_ip_address: The reference to the public ip address resource. - :vartype public_ip_address: ~azure.mgmt.compute.v2024_11_04.models.SubResource - :ivar subnet: The reference to the virtual network subnet resource. - :vartype subnet: ~azure.mgmt.compute.v2024_11_04.models.SubResource - :ivar private_ip_address: The virtual network private IP address of the IP configuration. - :vartype private_ip_address: str - """ - - _attribute_map = { - "public_ip_address": {"key": "publicIPAddress", "type": "SubResource"}, - "subnet": {"key": "subnet", "type": "SubResource"}, - "private_ip_address": {"key": "privateIPAddress", "type": "str"}, - } - - def __init__( - self, - *, - public_ip_address: Optional["_models.SubResource"] = None, - subnet: Optional["_models.SubResource"] = None, - private_ip_address: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword public_ip_address: The reference to the public ip address resource. - :paramtype public_ip_address: ~azure.mgmt.compute.v2024_11_04.models.SubResource - :keyword subnet: The reference to the virtual network subnet resource. - :paramtype subnet: ~azure.mgmt.compute.v2024_11_04.models.SubResource - :keyword private_ip_address: The virtual network private IP address of the IP configuration. - :paramtype private_ip_address: str - """ - super().__init__(**kwargs) - self.public_ip_address = public_ip_address - self.subnet = subnet - self.private_ip_address = private_ip_address - - -class OSFamily(_serialization.Model): - """Describes a cloud service OS family. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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. - :vartype location: str - :ivar properties: OS family properties. - :vartype properties: ~azure.mgmt.compute.v2024_11_04.models.OSFamilyProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "properties": {"key": "properties", "type": "OSFamilyProperties"}, - } - - def __init__(self, *, properties: Optional["_models.OSFamilyProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: OS family properties. - :paramtype properties: ~azure.mgmt.compute.v2024_11_04.models.OSFamilyProperties - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location: Optional[str] = None - self.properties = properties - - -class OSFamilyListResult(_serialization.Model): - """The list operation result. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of resources. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_04.models.OSFamily] - :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of - resources. Do this till nextLink is null to fetch all the resources. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[OSFamily]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.OSFamily"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of resources. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_04.models.OSFamily] - :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page - of resources. Do this till nextLink is null to fetch all the resources. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class OSFamilyProperties(_serialization.Model): - """OS family properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The OS family name. - :vartype name: str - :ivar label: The OS family label. - :vartype label: str - :ivar versions: List of OS versions belonging to this family. - :vartype versions: list[~azure.mgmt.compute.v2024_11_04.models.OSVersionPropertiesBase] - """ - - _validation = { - "name": {"readonly": True}, - "label": {"readonly": True}, - "versions": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "versions": {"key": "versions", "type": "[OSVersionPropertiesBase]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.label: Optional[str] = None - self.versions: Optional[List["_models.OSVersionPropertiesBase"]] = None - - -class OSVersion(_serialization.Model): - """Describes a cloud service OS version. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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. - :vartype location: str - :ivar properties: OS version properties. - :vartype properties: ~azure.mgmt.compute.v2024_11_04.models.OSVersionProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "properties": {"key": "properties", "type": "OSVersionProperties"}, - } - - def __init__(self, *, properties: Optional["_models.OSVersionProperties"] = None, **kwargs: Any) -> None: - """ - :keyword properties: OS version properties. - :paramtype properties: ~azure.mgmt.compute.v2024_11_04.models.OSVersionProperties - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location: Optional[str] = None - self.properties = properties - - -class OSVersionListResult(_serialization.Model): - """The list operation result. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of resources. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_04.models.OSVersion] - :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of - resources. Do this till nextLink is null to fetch all the resources. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[OSVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.OSVersion"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of resources. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_04.models.OSVersion] - :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page - of resources. Do this till nextLink is null to fetch all the resources. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class OSVersionProperties(_serialization.Model): - """OS version properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar family: The family of this OS version. - :vartype family: str - :ivar family_label: The family label of this OS version. - :vartype family_label: str - :ivar version: The OS version. - :vartype version: str - :ivar label: The OS version label. - :vartype label: str - :ivar is_default: Specifies whether this is the default OS version for its family. - :vartype is_default: bool - :ivar is_active: Specifies whether this OS version is active. - :vartype is_active: bool - """ - - _validation = { - "family": {"readonly": True}, - "family_label": {"readonly": True}, - "version": {"readonly": True}, - "label": {"readonly": True}, - "is_default": {"readonly": True}, - "is_active": {"readonly": True}, - } - - _attribute_map = { - "family": {"key": "family", "type": "str"}, - "family_label": {"key": "familyLabel", "type": "str"}, - "version": {"key": "version", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "is_default": {"key": "isDefault", "type": "bool"}, - "is_active": {"key": "isActive", "type": "bool"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.family: Optional[str] = None - self.family_label: Optional[str] = None - self.version: Optional[str] = None - self.label: Optional[str] = None - self.is_default: Optional[bool] = None - self.is_active: Optional[bool] = None - - -class OSVersionPropertiesBase(_serialization.Model): - """Configuration view of an OS version. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar version: The OS version. - :vartype version: str - :ivar label: The OS version label. - :vartype label: str - :ivar is_default: Specifies whether this is the default OS version for its family. - :vartype is_default: bool - :ivar is_active: Specifies whether this OS version is active. - :vartype is_active: bool - """ - - _validation = { - "version": {"readonly": True}, - "label": {"readonly": True}, - "is_default": {"readonly": True}, - "is_active": {"readonly": True}, - } - - _attribute_map = { - "version": {"key": "version", "type": "str"}, - "label": {"key": "label", "type": "str"}, - "is_default": {"key": "isDefault", "type": "bool"}, - "is_active": {"key": "isActive", "type": "bool"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.version: Optional[str] = None - self.label: Optional[str] = None - self.is_default: Optional[bool] = None - self.is_active: Optional[bool] = None - - -class Resource(_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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - - -class ResourceInstanceViewStatus(_serialization.Model): - """Instance view status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The status code. - :vartype code: str - :ivar display_status: The short localizable label for the status. - :vartype display_status: str - :ivar message: The detailed status message, including for alerts and error messages. - :vartype message: str - :ivar time: The time of the status. - :vartype time: ~datetime.datetime - :ivar level: The level code. Known values are: "Info", "Warning", and "Error". - :vartype level: str or ~azure.mgmt.compute.v2024_11_04.models.StatusLevelTypes - """ - - _validation = { - "code": {"readonly": True}, - "display_status": {"readonly": True}, - "message": {"readonly": True}, - "time": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "display_status": {"key": "displayStatus", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "time": {"key": "time", "type": "iso-8601"}, - "level": {"key": "level", "type": "str"}, - } - - def __init__(self, *, level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, **kwargs: Any) -> None: - """ - :keyword level: The level code. Known values are: "Info", "Warning", and "Error". - :paramtype level: str or ~azure.mgmt.compute.v2024_11_04.models.StatusLevelTypes - """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.display_status: Optional[str] = None - self.message: Optional[str] = None - self.time: Optional[datetime.datetime] = None - self.level = level - - -class ResourceWithOptionalLocation(_serialization.Model): - """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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.tags = tags - - -class RoleInstance(_serialization.Model): - """Describes the cloud service role instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The role instance SKU. - :vartype sku: ~azure.mgmt.compute.v2024_11_04.models.InstanceSku - :ivar properties: Role instance properties. - :vartype properties: ~azure.mgmt.compute.v2024_11_04.models.RoleInstanceProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - "tags": {"readonly": 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}"}, - "sku": {"key": "sku", "type": "InstanceSku"}, - "properties": {"key": "properties", "type": "RoleInstanceProperties"}, - } - - def __init__( - self, - *, - sku: Optional["_models.InstanceSku"] = None, - properties: Optional["_models.RoleInstanceProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword sku: The role instance SKU. - :paramtype sku: ~azure.mgmt.compute.v2024_11_04.models.InstanceSku - :keyword properties: Role instance properties. - :paramtype properties: ~azure.mgmt.compute.v2024_11_04.models.RoleInstanceProperties - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location: Optional[str] = None - self.tags: Optional[Dict[str, str]] = None - self.sku = sku - self.properties = properties - - -class RoleInstanceListResult(_serialization.Model): - """The list operation result. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of resources. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_04.models.RoleInstance] - :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of - resources. Do this till nextLink is null to fetch all the resources. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RoleInstance]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.RoleInstance"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of resources. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_04.models.RoleInstance] - :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page - of resources. Do this till nextLink is null to fetch all the resources. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleInstanceNetworkProfile(_serialization.Model): - """Describes the network profile for the role instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the role instance. - :vartype network_interfaces: list[~azure.mgmt.compute.v2024_11_04.models.SubResource] - """ - - _validation = { - "network_interfaces": {"readonly": True}, - } - - _attribute_map = { - "network_interfaces": {"key": "networkInterfaces", "type": "[SubResource]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.network_interfaces: Optional[List["_models.SubResource"]] = None - - -class RoleInstanceProperties(_serialization.Model): - """Role instance properties. - - :ivar network_profile: Describes the network profile for the role instance. - :vartype network_profile: ~azure.mgmt.compute.v2024_11_04.models.RoleInstanceNetworkProfile - :ivar instance_view: The instance view of the role instance. - :vartype instance_view: ~azure.mgmt.compute.v2024_11_04.models.RoleInstanceView - """ - - _attribute_map = { - "network_profile": {"key": "networkProfile", "type": "RoleInstanceNetworkProfile"}, - "instance_view": {"key": "instanceView", "type": "RoleInstanceView"}, - } - - def __init__( - self, - *, - network_profile: Optional["_models.RoleInstanceNetworkProfile"] = None, - instance_view: Optional["_models.RoleInstanceView"] = None, - **kwargs: Any - ) -> None: - """ - :keyword network_profile: Describes the network profile for the role instance. - :paramtype network_profile: ~azure.mgmt.compute.v2024_11_04.models.RoleInstanceNetworkProfile - :keyword instance_view: The instance view of the role instance. - :paramtype instance_view: ~azure.mgmt.compute.v2024_11_04.models.RoleInstanceView - """ - super().__init__(**kwargs) - self.network_profile = network_profile - self.instance_view = instance_view - - -class RoleInstances(_serialization.Model): - """Specifies a list of role instances from the cloud service. - - All required parameters must be populated in order to send to server. - - :ivar role_instances: List of cloud service role instance names. Value of '*' will signify all - role instances of the cloud service. Required. - :vartype role_instances: list[str] - """ - - _validation = { - "role_instances": {"required": True}, - } - - _attribute_map = { - "role_instances": {"key": "roleInstances", "type": "[str]"}, - } - - def __init__(self, *, role_instances: List[str], **kwargs: Any) -> None: - """ - :keyword role_instances: List of cloud service role instance names. Value of '*' will signify - all role instances of the cloud service. Required. - :paramtype role_instances: list[str] - """ - super().__init__(**kwargs) - self.role_instances = role_instances - - -class RoleInstanceView(_serialization.Model): - """The instance view of the role instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar platform_update_domain: The Update Domain. - :vartype platform_update_domain: int - :ivar platform_fault_domain: The Fault Domain. - :vartype platform_fault_domain: int - :ivar private_id: Specifies a unique identifier generated internally for the cloud service - associated with this role instance. :code:`
    `\\ :code:`
    ` NOTE: If you are using - Azure Diagnostics extension, this property can be used as 'DeploymentId' for querying details. - :vartype private_id: str - :ivar statuses: - :vartype statuses: list[~azure.mgmt.compute.v2024_11_04.models.ResourceInstanceViewStatus] - """ - - _validation = { - "platform_update_domain": {"readonly": True}, - "platform_fault_domain": {"readonly": True}, - "private_id": {"readonly": True}, - "statuses": {"readonly": True}, - } - - _attribute_map = { - "platform_update_domain": {"key": "platformUpdateDomain", "type": "int"}, - "platform_fault_domain": {"key": "platformFaultDomain", "type": "int"}, - "private_id": {"key": "privateId", "type": "str"}, - "statuses": {"key": "statuses", "type": "[ResourceInstanceViewStatus]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.platform_update_domain: Optional[int] = None - self.platform_fault_domain: Optional[int] = None - self.private_id: Optional[str] = None - self.statuses: Optional[List["_models.ResourceInstanceViewStatus"]] = None - - -class StatusCodeCount(_serialization.Model): - """The status code and count of the cloud service instance view statuses. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The instance view status code. - :vartype code: str - :ivar count: Number of instances having this status code. - :vartype count: int - """ - - _validation = { - "code": {"readonly": True}, - "count": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "count": {"key": "count", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.count: Optional[int] = None - - -class SubResource(_serialization.Model): - """SubResource. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class SubResourceReadOnly(_serialization.Model): - """SubResourceReadOnly. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = 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. - - :ivar created_at: Specifies the time in UTC at which the Cloud Service (extended support) - resource was created. :code:`
    `Minimum api-version: 2022-04-04. - :vartype created_at: ~datetime.datetime - :ivar last_modified_at: Specifies the time in UTC at which the Cloud Service (extended support) - resource was last modified. :code:`
    `Minimum api-version: 2022-04-04. - :vartype last_modified_at: ~datetime.datetime - """ - - _validation = { - "created_at": {"readonly": True}, - "last_modified_at": {"readonly": True}, - } - - _attribute_map = { - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.created_at: Optional[datetime.datetime] = None - self.last_modified_at: Optional[datetime.datetime] = None - - -class UpdateDomain(_serialization.Model): - """Defines an update domain for the cloud service. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource Name. - :vartype name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - - -class UpdateDomainListResult(_serialization.Model): - """The list operation result. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of resources. Required. - :vartype value: list[~azure.mgmt.compute.v2024_11_04.models.UpdateDomain] - :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of - resources. Do this till nextLink is null to fetch all the resources. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[UpdateDomain]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.UpdateDomain"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of resources. Required. - :paramtype value: list[~azure.mgmt.compute.v2024_11_04.models.UpdateDomain] - :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page - of resources. Do this till nextLink is null to fetch all the resources. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class UserAssignedIdentitiesValue(_serialization.Model): - """UserAssignedIdentitiesValue. - - 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: Optional[str] = None - self.client_id: Optional[str] = None diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/operations/__init__.py deleted file mode 100644 index 6422d5c48bb1..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/operations/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import CloudServiceRoleInstancesOperations # type: ignore -from ._operations import CloudServiceRolesOperations # type: ignore -from ._operations import CloudServicesOperations # type: ignore -from ._operations import CloudServicesUpdateDomainOperations # type: ignore -from ._operations import CloudServiceOperatingSystemsOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CloudServiceRoleInstancesOperations", - "CloudServiceRolesOperations", - "CloudServicesOperations", - "CloudServicesUpdateDomainOperations", - "CloudServiceOperatingSystemsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/operations/_operations.py deleted file mode 100644 index 38609786ba1f..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/operations/_operations.py +++ /dev/null @@ -1,4292 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import ComputeManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_cloud_service_role_instances_delete_request( # pylint: disable=name-too-long - role_instance_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}", - ) - path_format_arguments = { - "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_service_role_instances_get_request( # pylint: disable=name-too-long - role_instance_name: str, - resource_group_name: str, - cloud_service_name: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}", - ) - path_format_arguments = { - "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_service_role_instances_get_instance_view_request( # pylint: disable=name-too-long - role_instance_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/instanceView", - ) - path_format_arguments = { - "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_service_role_instances_list_request( # pylint: disable=name-too-long - resource_group_name: str, - cloud_service_name: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_service_role_instances_restart_request( # pylint: disable=name-too-long - role_instance_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/restart", - ) - path_format_arguments = { - "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_service_role_instances_reimage_request( # pylint: disable=name-too-long - role_instance_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/reimage", - ) - path_format_arguments = { - "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_service_role_instances_rebuild_request( # pylint: disable=name-too-long - role_instance_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/rebuild", - ) - path_format_arguments = { - "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_service_role_instances_get_remote_desktop_file_request( # pylint: disable=name-too-long - role_instance_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/x-rdp") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/remoteDesktopFile", - ) - path_format_arguments = { - "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_service_roles_get_request( - role_name: str, resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roles/{roleName}", - ) - path_format_arguments = { - "roleName": _SERIALIZER.url("role_name", role_name, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_service_roles_list_request( - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roles", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_services_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - 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/cloudServices/{cloudServiceName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_services_update_request( - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - 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/cloudServices/{cloudServiceName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_services_delete_request( - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_services_get_request( - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_services_get_instance_view_request( # pylint: disable=name-too-long - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/instanceView", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_services_list_all_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/cloudServices") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_services_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_services_start_request( - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/start", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_services_power_off_request( - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/poweroff", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_services_restart_request( - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - 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/cloudServices/{cloudServiceName}/restart", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_services_reimage_request( - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - 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/cloudServices/{cloudServiceName}/reimage", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_services_rebuild_request( - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - 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/cloudServices/{cloudServiceName}/rebuild", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_services_delete_instances_request( # pylint: disable=name-too-long - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - 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/cloudServices/{cloudServiceName}/delete", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_services_update_domain_walk_update_domain_request( # pylint: disable=name-too-long - resource_group_name: str, cloud_service_name: str, update_domain: int, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - 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/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "updateDomain": _SERIALIZER.url("update_domain", update_domain, "int"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_services_update_domain_get_update_domain_request( # pylint: disable=name-too-long - resource_group_name: str, cloud_service_name: str, update_domain: int, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "updateDomain": _SERIALIZER.url("update_domain", update_domain, "int"), - "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_cloud_services_update_domain_list_update_domains_request( # pylint: disable=name-too-long - resource_group_name: str, cloud_service_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_service_operating_systems_get_os_version_request( # pylint: disable=name-too-long - location: str, os_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", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsVersions/{osVersionName}", - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "osVersionName": _SERIALIZER.url("os_version_name", os_version_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_service_operating_systems_list_os_versions_request( # pylint: disable=name-too-long - location: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsVersions", - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_service_operating_systems_get_os_family_request( # pylint: disable=name-too-long - location: str, os_family_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsFamilies/{osFamilyName}", - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "osFamilyName": _SERIALIZER.url("os_family_name", os_family_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cloud_service_operating_systems_list_os_families_request( # pylint: disable=name-too-long - location: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-04")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsFamilies", - ) - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class CloudServiceRoleInstancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_04.ComputeManagementClient`'s - :attr:`cloud_service_role_instances` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _delete_initial( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cloud_service_role_instances_delete_request( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a role instance from a cloud service. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, - role_instance_name: str, - resource_group_name: str, - cloud_service_name: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any - ) -> _models.RoleInstance: - """Gets a role instance from a cloud service. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :keyword expand: The expand expression to apply to the operation. 'UserData' is not supported - for cloud services. Known values are: "instanceView" and "userData". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_04.models.InstanceViewTypes - :return: RoleInstance or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_04.models.RoleInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.RoleInstance] = kwargs.pop("cls", None) - - _request = build_cloud_service_role_instances_get_request( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("RoleInstance", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_instance_view( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> _models.RoleInstanceView: - """Retrieves information about the run-time state of a role instance in a cloud service. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: RoleInstanceView or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_04.models.RoleInstanceView - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.RoleInstanceView] = kwargs.pop("cls", None) - - _request = build_cloud_service_role_instances_get_instance_view_request( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("RoleInstanceView", 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, - cloud_service_name: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any - ) -> ItemPaged["_models.RoleInstance"]: - """Gets the list of all role instances in a cloud service. Use nextLink property in the response - to get the next page of role instances. Do this till nextLink is null to fetch all the role - instances. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :keyword expand: The expand expression to apply to the operation. 'UserData' is not supported - for cloud services. Known values are: "instanceView" and "userData". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_04.models.InstanceViewTypes - :return: An iterator like instance of either RoleInstance or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_04.models.RoleInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.RoleInstanceListResult] = 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_cloud_service_role_instances_list_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("RoleInstanceListResult", 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 _restart_initial( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cloud_service_role_instances_restart_request( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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 - - return deserialized # type: ignore - - @distributed_trace - def begin_restart( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The Reboot Role Instance asynchronous operation requests a reboot of a role instance in the - cloud service. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cloud_service_role_instances_reimage_request( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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 - - return deserialized # type: ignore - - @distributed_trace - def begin_reimage( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The Reimage Role Instance asynchronous operation reinstalls the operating system on instances - of web roles or worker roles. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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 _rebuild_initial( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cloud_service_role_instances_rebuild_request( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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 - - return deserialized # type: ignore - - @distributed_trace - def begin_rebuild( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The Rebuild Role Instance asynchronous operation reinstalls the operating system on instances - of web roles or worker roles and initializes the storage resources that are used by them. If - you do not want to initialize storage resources, you can use Reimage Role Instance. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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._rebuild_initial( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get_remote_desktop_file( - self, role_instance_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> Iterator[bytes]: - """Gets a remote desktop file for a role instance in a cloud service. - - :param role_instance_name: Name of the role instance. Required. - :type role_instance_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: Iterator[bytes] or the result of cls(response) - :rtype: Iterator[bytes] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cloud_service_role_instances_get_remote_desktop_file_request( - role_instance_name=role_instance_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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]: - 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 - - -class CloudServiceRolesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_04.ComputeManagementClient`'s - :attr:`cloud_service_roles` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, role_name: str, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> _models.CloudServiceRole: - """Gets a role from a cloud service. - - :param role_name: Name of the role. Required. - :type role_name: str - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: CloudServiceRole or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceRole - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.CloudServiceRole] = kwargs.pop("cls", None) - - _request = build_cloud_service_roles_get_request( - role_name=role_name, - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("CloudServiceRole", 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, cloud_service_name: str, **kwargs: Any - ) -> ItemPaged["_models.CloudServiceRole"]: - """Gets a list of all roles in a cloud service. Use nextLink property in the response to get the - next page of roles. Do this till nextLink is null to fetch all the roles. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An iterator like instance of either CloudServiceRole or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_04.models.CloudServiceRole] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.CloudServiceRoleListResult] = 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_cloud_service_roles_list_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("CloudServiceRoleListResult", 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 CloudServicesOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_04.ComputeManagementClient`'s - :attr:`cloud_services` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - cloud_service_name: str, - parameters: Optional[Union[_models.CloudService, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, "CloudService") - else: - _json = None - - _request = build_cloud_services_create_or_update_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[_models.CloudService] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CloudService]: - """Create or update a cloud service. Please note some properties can be set only during cloud - service creation. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.CloudService - :keyword content_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 CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CloudService]: - """Create or update a cloud service. Please note some properties can be set only during cloud - service creation. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. 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 CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.CloudService, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.CloudService]: - """Create or update a cloud service. Please note some properties can be set only during cloud - service creation. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. Is either a CloudService type or a IO[bytes] type. - Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.CloudService or IO[bytes] - :return: An instance of LROPoller that returns either CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CloudService] = 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, - cloud_service_name=cloud_service_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("CloudService", 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.CloudService].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CloudService]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.CloudServiceUpdate, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, "CloudServiceUpdate") - else: - _json = None - - _request = build_cloud_services_update_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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]: - 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, - cloud_service_name: str, - parameters: Optional[_models.CloudServiceUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CloudService]: - """Update a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceUpdate - :keyword content_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 CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CloudService]: - """Update a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. 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 CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.CloudServiceUpdate, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.CloudService]: - """Update a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: The cloud service object. Is either a CloudServiceUpdate type or a IO[bytes] - type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceUpdate or IO[bytes] - :return: An instance of LROPoller that returns either CloudService or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CloudService] = 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, - cloud_service_name=cloud_service_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("CloudService", 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.CloudService].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CloudService]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, cloud_service_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cloud_services_delete_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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, cloud_service_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, - cloud_service_name=cloud_service_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get(self, resource_group_name: str, cloud_service_name: str, **kwargs: Any) -> _models.CloudService: - """Display information about a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: CloudService or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_04.models.CloudService - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.CloudService] = kwargs.pop("cls", None) - - _request = build_cloud_services_get_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("CloudService", 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, cloud_service_name: str, **kwargs: Any - ) -> _models.CloudServiceInstanceView: - """Gets the status of a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: CloudServiceInstanceView or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceInstanceView - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.CloudServiceInstanceView] = kwargs.pop("cls", None) - - _request = build_cloud_services_get_instance_view_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("CloudServiceInstanceView", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_all(self, **kwargs: Any) -> ItemPaged["_models.CloudService"]: - """Gets a list of all cloud services in the subscription, regardless of the associated resource - group. Use nextLink property in the response to get the next page of Cloud Services. Do this - till nextLink is null to fetch all the Cloud Services. - - :return: An iterator like instance of either CloudService or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.CloudServiceListResult] = 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_cloud_services_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("CloudServiceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.CloudService"]: - """Gets a list of all cloud services under a resource group. Use nextLink property in the response - to get the next page of Cloud Services. Do this till nextLink is null to fetch all the Cloud - Services. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either CloudService or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_04.models.CloudService] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.CloudServiceListResult] = 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_cloud_services_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("CloudServiceListResult", 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, cloud_service_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cloud_services_start_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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 - - return deserialized # type: ignore - - @distributed_trace - def begin_start(self, resource_group_name: str, cloud_service_name: str, **kwargs: Any) -> LROPoller[None]: - """Starts the cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, - cloud_service_name=cloud_service_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 _power_off_initial(self, resource_group_name: str, cloud_service_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_cloud_services_power_off_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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 - - return deserialized # type: ignore - - @distributed_trace - def begin_power_off(self, resource_group_name: str, cloud_service_name: str, **kwargs: Any) -> LROPoller[None]: - """Power off the cloud service. Note that resources are still attached and you are getting charged - for the resources. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, - cloud_service_name=cloud_service_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 _restart_initial( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, "RoleInstances") - else: - _json = None - - _request = build_cloud_services_restart_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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_restart( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[_models.RoleInstances] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more role instances in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.RoleInstances - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_restart( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more role instances in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. 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_restart( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more role instances in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Is either a RoleInstances type or - a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.RoleInstances or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, - cloud_service_name=cloud_service_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _reimage_initial( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, "RoleInstances") - else: - _json = None - - _request = build_cloud_services_reimage_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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_reimage( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[_models.RoleInstances] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimage asynchronous operation reinstalls the operating system on instances of web roles or - worker roles. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.RoleInstances - :keyword content_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, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimage asynchronous operation reinstalls the operating system on instances of web roles or - worker roles. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. 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, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Reimage asynchronous operation reinstalls the operating system on instances of web roles or - worker roles. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Is either a RoleInstances type or - a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.RoleInstances or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, - cloud_service_name=cloud_service_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _rebuild_initial( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, "RoleInstances") - else: - _json = None - - _request = build_cloud_services_rebuild_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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_rebuild( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[_models.RoleInstances] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker - roles and initializes the storage resources that are used by them. If you do not want to - initialize storage resources, you can use Reimage Role Instances. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.RoleInstances - :keyword content_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_rebuild( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker - roles and initializes the storage resources that are used by them. If you do not want to - initialize storage resources, you can use Reimage Role Instances. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. 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_rebuild( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker - roles and initializes the storage resources that are used by them. If you do not want to - initialize storage resources, you can use Reimage Role Instances. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Is either a RoleInstances type or - a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.RoleInstances or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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._rebuild_initial( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _delete_instances_initial( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, "RoleInstances") - else: - _json = None - - _request = build_cloud_services_delete_instances_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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_delete_instances( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[_models.RoleInstances] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Deletes role instances in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.RoleInstances - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_delete_instances( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Deletes role instances in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. 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_delete_instances( - self, - resource_group_name: str, - cloud_service_name: str, - parameters: Optional[Union[_models.RoleInstances, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes role instances in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param parameters: List of cloud service role instance names. Is either a RoleInstances type or - a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.RoleInstances or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, - cloud_service_name=cloud_service_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - -class CloudServicesUpdateDomainOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_04.ComputeManagementClient`'s - :attr:`cloud_services_update_domain` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 _walk_update_domain_initial( - self, - resource_group_name: str, - cloud_service_name: str, - update_domain: int, - parameters: Optional[Union[_models.UpdateDomain, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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, "UpdateDomain") - else: - _json = None - - _request = build_cloud_services_update_domain_walk_update_domain_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - update_domain=update_domain, - 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_walk_update_domain( - self, - resource_group_name: str, - cloud_service_name: str, - update_domain: int, - parameters: Optional[_models.UpdateDomain] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Updates the role instances in the specified update domain. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param update_domain: Specifies an integer value that identifies the update domain. Update - domains are identified with a zero-based index: the first update domain has an ID of 0, the - second has an ID of 1, and so on. Required. - :type update_domain: int - :param parameters: The update domain object. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.UpdateDomain - :keyword content_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_walk_update_domain( - self, - resource_group_name: str, - cloud_service_name: str, - update_domain: int, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Updates the role instances in the specified update domain. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param update_domain: Specifies an integer value that identifies the update domain. Update - domains are identified with a zero-based index: the first update domain has an ID of 0, the - second has an ID of 1, and so on. Required. - :type update_domain: int - :param parameters: The update domain object. 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_walk_update_domain( - self, - resource_group_name: str, - cloud_service_name: str, - update_domain: int, - parameters: Optional[Union[_models.UpdateDomain, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Updates the role instances in the specified update domain. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param update_domain: Specifies an integer value that identifies the update domain. Update - domains are identified with a zero-based index: the first update domain has an ID of 0, the - second has an ID of 1, and so on. Required. - :type update_domain: int - :param parameters: The update domain object. Is either a UpdateDomain type or a IO[bytes] type. - Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_04.models.UpdateDomain or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - 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._walk_update_domain_initial( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - update_domain=update_domain, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get_update_domain( - self, resource_group_name: str, cloud_service_name: str, update_domain: int, **kwargs: Any - ) -> _models.UpdateDomain: - """Gets the specified update domain of a cloud service. Use nextLink property in the response to - get the next page of update domains. Do this till nextLink is null to fetch all the update - domains. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :param update_domain: Specifies an integer value that identifies the update domain. Update - domains are identified with a zero-based index: the first update domain has an ID of 0, the - second has an ID of 1, and so on. Required. - :type update_domain: int - :return: UpdateDomain or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_04.models.UpdateDomain - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.UpdateDomain] = kwargs.pop("cls", None) - - _request = build_cloud_services_update_domain_get_update_domain_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_name, - update_domain=update_domain, - 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("UpdateDomain", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_update_domains( - self, resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> ItemPaged["_models.UpdateDomain"]: - """Gets a list of all update domains in a cloud service. - - :param resource_group_name: Name of the resource group. Required. - :type resource_group_name: str - :param cloud_service_name: Name of the cloud service. Required. - :type cloud_service_name: str - :return: An iterator like instance of either UpdateDomain or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_04.models.UpdateDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.UpdateDomainListResult] = 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_cloud_services_update_domain_list_update_domains_request( - resource_group_name=resource_group_name, - cloud_service_name=cloud_service_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("UpdateDomainListResult", 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 CloudServiceOperatingSystemsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_04.ComputeManagementClient`'s - :attr:`cloud_service_operating_systems` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_os_version(self, location: str, os_version_name: str, **kwargs: Any) -> _models.OSVersion: - """Gets properties of a guest operating system version that can be specified in the XML service - configuration (.cscfg) for a cloud service. - - :param location: Name of the location that the OS version pertains to. Required. - :type location: str - :param os_version_name: Name of the OS version. Required. - :type os_version_name: str - :return: OSVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_04.models.OSVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.OSVersion] = kwargs.pop("cls", None) - - _request = build_cloud_service_operating_systems_get_os_version_request( - location=location, - os_version_name=os_version_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("OSVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_os_versions(self, location: str, **kwargs: Any) -> ItemPaged["_models.OSVersion"]: - """Gets a list of all guest operating system versions available to be specified in the XML service - configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the - next page of OS versions. Do this till nextLink is null to fetch all the OS versions. - - :param location: Name of the location that the OS versions pertain to. Required. - :type location: str - :return: An iterator like instance of either OSVersion or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_04.models.OSVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.OSVersionListResult] = 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_cloud_service_operating_systems_list_os_versions_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("OSVersionListResult", 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_os_family(self, location: str, os_family_name: str, **kwargs: Any) -> _models.OSFamily: - """Gets properties of a guest operating system family that can be specified in the XML service - configuration (.cscfg) for a cloud service. - - :param location: Name of the location that the OS family pertains to. Required. - :type location: str - :param os_family_name: Name of the OS family. Required. - :type os_family_name: str - :return: OSFamily or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_04.models.OSFamily - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.OSFamily] = kwargs.pop("cls", None) - - _request = build_cloud_service_operating_systems_get_os_family_request( - location=location, - os_family_name=os_family_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("OSFamily", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_os_families(self, location: str, **kwargs: Any) -> ItemPaged["_models.OSFamily"]: - """Gets a list of all guest operating system families available to be specified in the XML service - configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the - next page of OS Families. Do this till nextLink is null to fetch all the OS Families. - - :param location: Name of the location that the OS families pertain to. Required. - :type location: str - :return: An iterator like instance of either OSFamily or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_04.models.OSFamily] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-04")) - cls: ClsType[_models.OSFamilyListResult] = 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_cloud_service_operating_systems_list_os_families_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("OSFamilyListResult", 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/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/__init__.py deleted file mode 100644 index ab7c46e8991d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2025_01_02/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_compute_management_client.py deleted file mode 100644 index d719d9d4472c..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_compute_management_client.py +++ /dev/null @@ -1,143 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.settings import settings -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from . import models as _models -from ._configuration import ComputeManagementClientConfiguration -from ._utils.serialization import Deserializer, Serializer -from .operations import ( - DiskAccessesOperations, - DiskEncryptionSetsOperations, - DiskRestorePointOperations, - DisksOperations, - SnapshotsOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar disk_accesses: DiskAccessesOperations operations - :vartype disk_accesses: azure.mgmt.compute.v2025_01_02.operations.DiskAccessesOperations - :ivar disk_encryption_sets: DiskEncryptionSetsOperations operations - :vartype disk_encryption_sets: - azure.mgmt.compute.v2025_01_02.operations.DiskEncryptionSetsOperations - :ivar disks: DisksOperations operations - :vartype disks: azure.mgmt.compute.v2025_01_02.operations.DisksOperations - :ivar snapshots: SnapshotsOperations operations - :vartype snapshots: azure.mgmt.compute.v2025_01_02.operations.SnapshotsOperations - :ivar disk_restore_point: DiskRestorePointOperations operations - :vartype disk_restore_point: - azure.mgmt.compute.v2025_01_02.operations.DiskRestorePointOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2025-01-02". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.disk_accesses = DiskAccessesOperations( - self._client, self._config, self._serialize, self._deserialize, "2025-01-02" - ) - self.disk_encryption_sets = DiskEncryptionSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2025-01-02" - ) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize, "2025-01-02") - self.snapshots = SnapshotsOperations( - self._client, self._config, self._serialize, self._deserialize, "2025-01-02" - ) - self.disk_restore_point = DiskRestorePointOperations( - self._client, self._config, self._serialize, self._deserialize, "2025-01-02" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_configuration.py deleted file mode 100644 index 00a1cafe1c2f..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2025-01-02". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2025-01-02") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_metadata.json deleted file mode 100644 index c71355a2047d..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_metadata.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "chosen_version": "2025-01-02", - "total_api_version_list": ["2025-01-02"], - "client": { - "name": "ComputeManagementClient", - "filename": "_compute_management_client", - "description": "Compute Client.", - "host_value": null, - "parameterized_host_template": null, - "azure_arm": true, - "has_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \"._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.core.settings\": [\"settings\"], \"azure.mgmt.core.tools\": [\"get_arm_endpoints\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"stdlib\": {\"typing\": [\"Optional\", \"cast\"], \"typing_extensions\": [\"Self\"]}, \"local\": {\"._configuration\": [\"ComputeManagementClientConfiguration\"], \".._utils.serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "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": { - "disk_accesses": "DiskAccessesOperations", - "disk_encryption_sets": "DiskEncryptionSetsOperations", - "disks": "DisksOperations", - "snapshots": "SnapshotsOperations", - "disk_restore_point": "DiskRestorePointOperations" - } -} diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_utils/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_utils/__init__.py deleted file mode 100644 index 0af9b28f6607..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_utils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_utils/serialization.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_utils/serialization.py deleted file mode 100644 index f5187701d7be..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_utils/serialization.py +++ /dev/null @@ -1,2032 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node
    is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_version.py deleted file mode 100644 index 6ba690f28963..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/aio/__init__.py deleted file mode 100644 index d3fd1ba93379..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._compute_management_client import ComputeManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ComputeManagementClient", -] -__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/v2025_01_02/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/aio/_compute_management_client.py deleted file mode 100644 index 5541cd43f537..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/aio/_compute_management_client.py +++ /dev/null @@ -1,147 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.settings import settings -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.mgmt.core.tools import get_arm_endpoints - -from .. import models as _models -from .._utils.serialization import Deserializer, Serializer -from ._configuration import ComputeManagementClientConfiguration -from .operations import ( - DiskAccessesOperations, - DiskEncryptionSetsOperations, - DiskRestorePointOperations, - DisksOperations, - SnapshotsOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClient: - """Compute Client. - - :ivar disk_accesses: DiskAccessesOperations operations - :vartype disk_accesses: azure.mgmt.compute.v2025_01_02.aio.operations.DiskAccessesOperations - :ivar disk_encryption_sets: DiskEncryptionSetsOperations operations - :vartype disk_encryption_sets: - azure.mgmt.compute.v2025_01_02.aio.operations.DiskEncryptionSetsOperations - :ivar disks: DisksOperations operations - :vartype disks: azure.mgmt.compute.v2025_01_02.aio.operations.DisksOperations - :ivar snapshots: SnapshotsOperations operations - :vartype snapshots: azure.mgmt.compute.v2025_01_02.aio.operations.SnapshotsOperations - :ivar disk_restore_point: DiskRestorePointOperations operations - :vartype disk_restore_point: - azure.mgmt.compute.v2025_01_02.aio.operations.DiskRestorePointOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is None. - :type base_url: str - :keyword api_version: Api Version. Default value is "2025-01-02". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any - ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore - _endpoints = get_arm_endpoints(_cloud) - if not base_url: - base_url = _endpoints["resource_manager"] - credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) - self._config = ComputeManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs - ) - - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs - ) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.disk_accesses = DiskAccessesOperations( - self._client, self._config, self._serialize, self._deserialize, "2025-01-02" - ) - self.disk_encryption_sets = DiskEncryptionSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2025-01-02" - ) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize, "2025-01-02") - self.snapshots = SnapshotsOperations( - self._client, self._config, self._serialize, self._deserialize, "2025-01-02" - ) - self.disk_restore_point = DiskRestorePointOperations( - self._client, self._config, self._serialize, self._deserialize, "2025-01-02" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/aio/_configuration.py deleted file mode 100644 index 7e939c921ea3..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/aio/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for ComputeManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2025-01-02". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2025-01-02") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-compute/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/aio/operations/__init__.py deleted file mode 100644 index e14bc6862637..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/aio/operations/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import DiskAccessesOperations # type: ignore -from ._operations import DiskEncryptionSetsOperations # 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__ = [ - "DiskAccessesOperations", - "DiskEncryptionSetsOperations", - "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/v2025_01_02/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/aio/operations/_operations.py deleted file mode 100644 index 4fc514013b73..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/aio/operations/_operations.py +++ /dev/null @@ -1,4913 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import ( - build_disk_accesses_create_or_update_request, - build_disk_accesses_delete_a_private_endpoint_connection_request, - build_disk_accesses_delete_request, - build_disk_accesses_get_a_private_endpoint_connection_request, - build_disk_accesses_get_private_link_resources_request, - build_disk_accesses_get_request, - build_disk_accesses_list_by_resource_group_request, - build_disk_accesses_list_private_endpoint_connections_request, - build_disk_accesses_list_request, - build_disk_accesses_update_a_private_endpoint_connection_request, - build_disk_accesses_update_request, - build_disk_encryption_sets_create_or_update_request, - build_disk_encryption_sets_delete_request, - build_disk_encryption_sets_get_request, - build_disk_encryption_sets_list_associated_resources_request, - build_disk_encryption_sets_list_by_resource_group_request, - build_disk_encryption_sets_list_request, - build_disk_encryption_sets_update_request, - build_disk_restore_point_get_request, - build_disk_restore_point_grant_access_request, - build_disk_restore_point_list_by_restore_point_request, - build_disk_restore_point_revoke_access_request, - build_disks_create_or_update_request, - build_disks_delete_request, - build_disks_get_request, - build_disks_grant_access_request, - build_disks_list_by_resource_group_request, - build_disks_list_request, - build_disks_revoke_access_request, - build_disks_update_request, - build_snapshots_create_or_update_request, - build_snapshots_delete_request, - build_snapshots_get_request, - build_snapshots_grant_access_request, - build_snapshots_list_by_resource_group_request, - build_snapshots_list_request, - build_snapshots_revoke_access_request, - build_snapshots_update_request, -) -from .._configuration import ComputeManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DiskAccessesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2025_01_02.aio.ComputeManagementClient`'s - :attr:`disk_accesses` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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.v2025_01_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 "2025-01-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) -> AsyncItemPaged["_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.v2025_01_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 "2025-01-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.v2025_01_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 "2025-01-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_access_name: str, - disk_access: Union[_models.DiskAccess, 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 "2025-01-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access - else: - _json = self._serialize.body(disk_access, "DiskAccess") - - _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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccess, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. - - :param resource_group_name: The name of the resource group. 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. - Required. - :type disk_access: ~azure.mgmt.compute.v2025_01_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.v2025_01_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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. - 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.v2025_01_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2025_01_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.v2025_01_02.models.DiskAccess] - :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 "2025-01-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) - - 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 - - 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.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 - ) - - async def _update_initial( - 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, - 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 "2025-01-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access - else: - _json = self._serialize.body(disk_access, "DiskAccessUpdate") - - _request = build_disk_accesses_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) - - _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_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccessUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Updates (patches) 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 - :param disk_access: disk access object supplied in the body of the Patch disk access operation. - Required. - :type disk_access: ~azure.mgmt.compute.v2025_01_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 DiskAccess or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2025_01_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Updates (patches) 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 - :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 DiskAccess or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2025_01_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - 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. 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.v2025_01_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.v2025_01_02.models.DiskAccess] - :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 "2025-01-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._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) - - 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 - - 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.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 - ) - - async def _delete_initial( - self, resource_group_name: str, disk_access_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 "2025-01-02")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disk_accesses_delete_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) - - _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_access_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes 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 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 "2025-01-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, 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_private_endpoint_connections( - self, resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2025_01_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 "2025-01-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) - - @distributed_trace_async - async def get_a_private_endpoint_connection( - self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets information about a private endpoint connection under a disk access resource. - - :param resource_group_name: The name of the resource group. 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.v2025_01_02.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2025-01-02")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_disk_accesses_get_a_private_endpoint_connection_request( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _update_a_private_endpoint_connection_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> 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 "2025-01-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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_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. 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.v2025_01_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.v2025_01_02.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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] - :keyword content_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.v2025_01_02.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long - self, - resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection under disk access resource, this can't be used - to create a new private endpoint connection. - - :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.v2025_01_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.v2025_01_02.models.PrivateEndpointConnection] - :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 "2025-01-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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 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.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 - ) - - 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, - 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 "2025-01-02")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disk_accesses_delete_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) - - _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_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. - - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2025-01-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_a_private_endpoint_connection_initial( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - 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_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.v2025_01_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 "2025-01-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 - - -class DiskEncryptionSetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2025_01_02.aio.ComputeManagementClient`'s - :attr:`disk_encryption_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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.v2025_01_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 "2025-01-02")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.DiskEncryptionSet"]: - """Lists all the disk encryption sets under a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either DiskEncryptionSet or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2025_01_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 "2025-01-02")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> _models.DiskEncryptionSet: - """Gets information about a disk encryption set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :return: DiskEncryptionSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2025_01_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 "2025-01-02")) - cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) - - _request = build_disk_encryption_sets_get_request( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiskEncryptionSet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2025-01-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set - else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") - - _request = build_disk_encryption_sets_create_or_update_request( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2025_01_02.models.DiskEncryptionSet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2025_01_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2025_01_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :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.v2025_01_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.v2025_01_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 "2025-01-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._create_or_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 _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, - 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 "2025-01-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set - else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSetUpdate") - - _request = build_disk_encryption_sets_update_request( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_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. 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.v2025_01_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.v2025_01_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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.v2025_01_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.v2025_01_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.v2025_01_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 "2025-01-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 "2025-01-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 "2025-01-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( - 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_associated_resources( - self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> AsyncItemPaged[str]: - """Lists all resources that are encrypted with this 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 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 "2025-01-02")) - cls: ClsType[_models.ResourceUriList] = 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_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, - 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("ResourceUriList", 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 DisksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2025_01_02.aio.ComputeManagementClient`'s - :attr:`disks` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_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.v2025_01_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 "2025-01-02")) - cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disks_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Disk"]: - """Lists all the disks under a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either Disk or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2025_01_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 "2025-01-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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_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. 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.v2025_01_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 "2025-01-02")) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) - - _request = build_disks_get_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) - - _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("Disk", 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 - ) -> 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 "2025-01-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk, (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_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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - disk_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.v2025_01_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.v2025_01_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.v2025_01_02.models.Disk] - :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. - - :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.v2025_01_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.v2025_01_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 "2025-01-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, 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, - 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("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, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Disk].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Disk]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _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, - 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 "2025-01-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk, (IOBase, bytes)): - _content = disk - else: - _json = self._serialize.body(disk, "DiskUpdate") - - _request = build_disks_update_request( - resource_group_name=resource_group_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) - - _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_update( - self, - resource_group_name: str, - disk_name: str, - disk: _models.DiskUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Updates (patches) a disk. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Patch disk operation. Required. - :type disk: ~azure.mgmt.compute.v2025_01_02.models.DiskUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2025_01_02.models.Disk] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - disk_name: str, - disk: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Updates (patches) a disk. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Patch disk operation. Required. - :type disk: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2025_01_02.models.Disk] - :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. - - :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.v2025_01_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.v2025_01_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 "2025-01-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, 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, - 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("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, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Disk].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Disk]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_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 "2025-01-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 "2025-01-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_name: str, - grant_access_data: Union[_models.GrantAccessData, 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 "2025-01-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disks_grant_access_request( - resource_group_name=resource_group_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) - - _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_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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.v2025_01_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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2025_01_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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: IO[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.v2025_01_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> 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. Is either a GrantAccessData type or a IO[bytes] type. Required. - :type grant_access_data: ~azure.mgmt.compute.v2025_01_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.v2025_01_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 "2025-01-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, - disk_name=disk_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, 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 "2025-01-02")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disks_revoke_access_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]: - 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_revoke_access( - self, resource_group_name: str, disk_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Revokes 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 - :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 "2025-01-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) - - 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 SnapshotsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2025_01_02.aio.ComputeManagementClient`'s - :attr:`snapshots` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> AsyncItemPaged["_models.Snapshot"]: - """Lists snapshots under a subscription. - - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2025_01_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 "2025-01-02")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - 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) -> AsyncItemPaged["_models.Snapshot"]: - """Lists snapshots 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 Snapshot or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2025_01_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 "2025-01-02")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - 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, snapshot_name: str, **kwargs: Any) -> _models.Snapshot: - """Gets information about 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: Snapshot or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2025_01_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 "2025-01-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 _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, - 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 "2025-01-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "Snapshot") - - _request = build_snapshots_create_or_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.Snapshot, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: ~azure.mgmt.compute.v2025_01_02.models.Snapshot - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2025_01_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :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 AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2025_01_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. 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.v2025_01_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.v2025_01_02.models.Snapshot] - :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 "2025-01-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, 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, - 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 _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, - 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 "2025-01-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "SnapshotUpdate") - - _request = build_snapshots_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.SnapshotUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. - Required. - :type snapshot: ~azure.mgmt.compute.v2025_01_02.models.SnapshotUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2025_01_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. - Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2025_01_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. Is - either a SnapshotUpdate type or a IO[bytes] type. Required. - :type snapshot: ~azure.mgmt.compute.v2025_01_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.v2025_01_02.models.Snapshot] - :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 "2025-01-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, 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 "2025-01-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 "2025-01-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, - snapshot_name=snapshot_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, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, 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 "2025-01-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_snapshots_grant_access_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param grant_access_data: Access data object supplied in the body of the get snapshot access - operation. Required. - :type grant_access_data: ~azure.mgmt.compute.v2025_01_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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2025_01_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param 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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2025_01_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param 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.v2025_01_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.v2025_01_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 "2025-01-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, - snapshot_name=snapshot_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, 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 "2025-01-02")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_snapshots_revoke_access_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]: - 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_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. 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 "2025-01-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, - snapshot_name=snapshot_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 DiskRestorePointOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2025_01_02.aio.ComputeManagementClient`'s - :attr:`disk_restore_point` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_restore_point( - self, resource_group_name: str, restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :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.v2025_01_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 "2025-01-02")) - cls: ClsType[_models.DiskRestorePointList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_restore_point_list_by_restore_point_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskRestorePointList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @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. - - :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.v2025_01_02.models.DiskRestorePoint - :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 "2025-01-02")) - cls: ClsType[_models.DiskRestorePoint] = kwargs.pop("cls", None) - - _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) - - _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 - - 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 - ) -> 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 "2025-01-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disk_restore_point_grant_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, - 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_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: _models.GrantAccessData, - *, - 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. 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 - :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.v2025_01_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 AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2025_01_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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: 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. 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 - :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.v2025_01_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. - - :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 - :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.v2025_01_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.v2025_01_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 "2025-01-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 "2025-01-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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_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. - - :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: 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 "2025-01-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, - 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, - 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/models/__init__.py deleted file mode 100644 index b8e649a31690..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/models/__init__.py +++ /dev/null @@ -1,192 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - AccessUri, - ApiError, - ApiErrorBase, - AvailabilityPolicy, - CopyCompletionError, - CreationData, - Disk, - DiskAccess, - DiskAccessList, - DiskAccessUpdate, - DiskEncryptionSet, - DiskEncryptionSetList, - DiskEncryptionSetUpdate, - DiskList, - DiskPurchasePlan, - DiskRestorePoint, - DiskRestorePointList, - DiskSecurityProfile, - DiskSku, - DiskUpdate, - Encryption, - EncryptionSetIdentity, - EncryptionSettingsCollection, - EncryptionSettingsElement, - ExtendedLocation, - GrantAccessData, - ImageDiskReference, - InnerError, - KeyForDiskEncryptionSet, - KeyVaultAndKeyReference, - KeyVaultAndSecretReference, - PrivateEndpoint, - PrivateEndpointConnection, - PrivateEndpointConnectionListResult, - PrivateLinkResource, - PrivateLinkResourceListResult, - PrivateLinkServiceConnectionState, - PropertyUpdatesInProgress, - ProxyResource, - Resource, - ResourceAutoGenerated, - ResourceUriList, - ResourceWithOptionalLocation, - ShareInfoElement, - Snapshot, - SnapshotList, - SnapshotSku, - SnapshotUpdate, - SourceVault, - SubResource, - SubResourceReadOnly, - SupportedCapabilities, - SystemData, - SystemDataAutoGenerated, - TrackedResource, - UserAssignedIdentitiesValue, - UserAssignedIdentitiesValueAutoGenerated, -) - -from ._compute_management_client_enums import ( # type: ignore - AccessLevel, - Architecture, - AvailabilityPolicyDiskDelay, - CopyCompletionErrorReason, - CreatedByType, - DataAccessAuthMode, - DiskCreateOption, - DiskEncryptionSetIdentityType, - DiskEncryptionSetType, - DiskSecurityTypes, - DiskState, - DiskStorageAccountTypes, - EncryptionType, - ExtendedLocationTypes, - FileFormat, - HyperVGeneration, - NetworkAccessPolicy, - OperatingSystemTypes, - PrivateEndpointConnectionProvisioningState, - PrivateEndpointServiceConnectionStatus, - ProvisionedBandwidthCopyOption, - PublicNetworkAccess, - SnapshotAccessState, - SnapshotStorageAccountTypes, - SupportedSecurityOption, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AccessUri", - "ApiError", - "ApiErrorBase", - "AvailabilityPolicy", - "CopyCompletionError", - "CreationData", - "Disk", - "DiskAccess", - "DiskAccessList", - "DiskAccessUpdate", - "DiskEncryptionSet", - "DiskEncryptionSetList", - "DiskEncryptionSetUpdate", - "DiskList", - "DiskPurchasePlan", - "DiskRestorePoint", - "DiskRestorePointList", - "DiskSecurityProfile", - "DiskSku", - "DiskUpdate", - "Encryption", - "EncryptionSetIdentity", - "EncryptionSettingsCollection", - "EncryptionSettingsElement", - "ExtendedLocation", - "GrantAccessData", - "ImageDiskReference", - "InnerError", - "KeyForDiskEncryptionSet", - "KeyVaultAndKeyReference", - "KeyVaultAndSecretReference", - "PrivateEndpoint", - "PrivateEndpointConnection", - "PrivateEndpointConnectionListResult", - "PrivateLinkResource", - "PrivateLinkResourceListResult", - "PrivateLinkServiceConnectionState", - "PropertyUpdatesInProgress", - "ProxyResource", - "Resource", - "ResourceAutoGenerated", - "ResourceUriList", - "ResourceWithOptionalLocation", - "ShareInfoElement", - "Snapshot", - "SnapshotList", - "SnapshotSku", - "SnapshotUpdate", - "SourceVault", - "SubResource", - "SubResourceReadOnly", - "SupportedCapabilities", - "SystemData", - "SystemDataAutoGenerated", - "TrackedResource", - "UserAssignedIdentitiesValue", - "UserAssignedIdentitiesValueAutoGenerated", - "AccessLevel", - "Architecture", - "AvailabilityPolicyDiskDelay", - "CopyCompletionErrorReason", - "CreatedByType", - "DataAccessAuthMode", - "DiskCreateOption", - "DiskEncryptionSetIdentityType", - "DiskEncryptionSetType", - "DiskSecurityTypes", - "DiskState", - "DiskStorageAccountTypes", - "EncryptionType", - "ExtendedLocationTypes", - "FileFormat", - "HyperVGeneration", - "NetworkAccessPolicy", - "OperatingSystemTypes", - "PrivateEndpointConnectionProvisioningState", - "PrivateEndpointServiceConnectionStatus", - "ProvisionedBandwidthCopyOption", - "PublicNetworkAccess", - "SnapshotAccessState", - "SnapshotStorageAccountTypes", - "SupportedSecurityOption", -] -__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/v2025_01_02/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/models/_compute_management_client_enums.py deleted file mode 100644 index 9dc6320a9ec3..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/models/_compute_management_client_enums.py +++ /dev/null @@ -1,329 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The Access Level, accepted values include None, Read, Write.""" - - NONE = "None" - READ = "Read" - WRITE = "Write" - - -class Architecture(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """CPU architecture supported by an OS disk.""" - - X64 = "x64" - ARM64 = "Arm64" - - -class AvailabilityPolicyDiskDelay(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Determines on how to handle disks with slow I/O.""" - - NONE = "None" - """Defaults to behavior without av policy specified, which is VM restart upon slow disk io.""" - AUTOMATIC_REATTACH = "AutomaticReattach" - """Upon a disk io failure or slow response, try detaching then reattaching the disk.""" - - -class CopyCompletionErrorReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the error code if the background copy of a resource created via the CopyStart - operation fails. - """ - - COPY_SOURCE_NOT_FOUND = "CopySourceNotFound" - """Indicates that the source snapshot was deleted while the background copy of the resource - 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.""" - - AZURE_ACTIVE_DIRECTORY = "AzureActiveDirectory" - """When export/upload URL is used, the system checks if the user has an identity in Azure Active - Directory and has necessary permissions to export/upload the data. Please refer to - aka.ms/DisksAzureADAuth.""" - NONE = "None" - """No additional authentication would be performed when accessing export/upload URL.""" - - -class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This enumerates the possible sources of a disk's creation.""" - - EMPTY = "Empty" - """Create an empty data disk of a size given by diskSizeGB.""" - ATTACH = "Attach" - """Disk will be attached to a VM.""" - FROM_IMAGE = "FromImage" - """Create a new disk from a platform image specified by the given imageReference or - galleryImageReference.""" - IMPORT = "Import" - """Create a disk by importing from a blob specified by a sourceUri in a storage account specified - by storageAccountId.""" - COPY = "Copy" - """Create a new disk or snapshot by copying from a disk or snapshot specified by the given - sourceResourceId.""" - RESTORE = "Restore" - """Create a new disk by copying from a backup recovery point.""" - UPLOAD = "Upload" - """Create a new disk by obtaining a write token and using it to directly upload the contents of - the disk.""" - COPY_START = "CopyStart" - """Create a new disk by using a deep copy process, where the resource creation is considered - complete only after all data has been copied from the source.""" - IMPORT_SECURE = "ImportSecure" - """Similar to Import create option. Create a new Trusted Launch VM or Confidential VM supported - disk by importing additional blobs for VM guest state specified by securityDataUri and VM - metadata specified by securityMetadataUri in storage account specified by storageAccountId. The - VM metadata is optional and only required for certain Confidential VM configurations and not - required for Trusted Launch VM.""" - UPLOAD_PREPARED_SECURE = "UploadPreparedSecure" - """Similar to Upload create option. Create a new Trusted Launch VM or Confidential VM supported - disk and upload using write token in disk, VM guest state and VM metadata. The VM metadata is - optional and only required for certain Confidential VM configurations and not required for - Trusted Launch VM.""" - COPY_FROM_SAN_SNAPSHOT = "CopyFromSanSnapshot" - """Create a new disk by exporting from elastic san volume snapshot""" - IMPORT_ENUM = "Import" - """Create a disk by importing from a blob specified by a sourceUri in a storage account specified - by storageAccountId.""" - - -class DiskEncryptionSetIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported - for new creations. Disk Encryption Sets can be updated with Identity type None during migration - of subscription to a new Azure Active Directory tenant; it will cause the encrypted resources - to lose access to the keys. - """ - - SYSTEM_ASSIGNED = "SystemAssigned" - USER_ASSIGNED = "UserAssigned" - SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" - NONE = "None" - - -class DiskEncryptionSetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of key used to encrypt the data of the disk.""" - - ENCRYPTION_AT_REST_WITH_CUSTOMER_KEY = "EncryptionAtRestWithCustomerKey" - """Resource using diskEncryptionSet would be encrypted at rest with Customer managed key that can - be changed and revoked by a customer.""" - ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" - """Resource using diskEncryptionSet would be encrypted at rest with two layers of encryption. One - of the keys is Customer managed and the other key is Platform managed.""" - CONFIDENTIAL_VM_ENCRYPTED_WITH_CUSTOMER_KEY = "ConfidentialVmEncryptedWithCustomerKey" - """Confidential VM supported disk and VM guest state would be encrypted with customer managed key.""" - - -class DiskSecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the SecurityType of the VM. Applicable for OS disks only.""" - - TRUSTED_LAUNCH = "TrustedLaunch" - """Trusted Launch provides security features such as secure boot and virtual Trusted Platform - Module (vTPM)""" - CONFIDENTIAL_VM_VMGUEST_STATE_ONLY_ENCRYPTED_WITH_PLATFORM_KEY = ( - "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey" - ) - """Indicates Confidential VM disk with only VM guest state encrypted""" - CONFIDENTIAL_VM_DISK_ENCRYPTED_WITH_PLATFORM_KEY = "ConfidentialVM_DiskEncryptedWithPlatformKey" - """Indicates Confidential VM disk with both OS disk and VM guest state encrypted with a platform - managed key""" - CONFIDENTIAL_VM_DISK_ENCRYPTED_WITH_CUSTOMER_KEY = "ConfidentialVM_DiskEncryptedWithCustomerKey" - """Indicates Confidential VM disk with both OS disk and VM guest state encrypted with a customer - managed key""" - CONFIDENTIAL_VM_NON_PERSISTED_TPM = "ConfidentialVM_NonPersistedTPM" - """Indicates Confidential VM disk with a ephemeral vTPM. vTPM state is not persisted across VM - reboots.""" - - -class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This enumerates the possible state of the disk.""" - - UNATTACHED = "Unattached" - """The disk is not being used and can be attached to a VM.""" - ATTACHED = "Attached" - """The disk is currently attached to a running VM.""" - RESERVED = "Reserved" - """The disk is attached to a stopped-deallocated VM.""" - FROZEN = "Frozen" - """The disk is attached to a VM which is in hibernated state.""" - ACTIVE_SAS = "ActiveSAS" - """The disk currently has an Active SAS Uri associated with it.""" - ACTIVE_SAS_FROZEN = "ActiveSASFrozen" - """The disk is attached to a VM in hibernated state and has an active SAS URI associated with it.""" - READY_TO_UPLOAD = "ReadyToUpload" - """A disk is ready to be created by upload by requesting a write token.""" - ACTIVE_UPLOAD = "ActiveUpload" - """A disk is created for upload and a write token has been issued for uploading to it.""" - - -class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The sku name.""" - - STANDARD_LRS = "Standard_LRS" - """Standard HDD locally redundant storage. Best for backup, non-critical, and infrequent access.""" - PREMIUM_LRS = "Premium_LRS" - """Premium SSD locally redundant storage. Best for production and performance sensitive workloads.""" - STANDARD_SSD_LRS = "StandardSSD_LRS" - """Standard SSD locally redundant storage. Best for web servers, lightly used enterprise - applications and dev/test.""" - ULTRA_SSD_LRS = "UltraSSD_LRS" - """Ultra SSD locally redundant storage. Best for IO-intensive workloads such as SAP HANA, top tier - databases (for example, SQL, Oracle), and other transaction-heavy workloads.""" - PREMIUM_ZRS = "Premium_ZRS" - """Premium SSD zone redundant storage. Best for the production workloads that need storage - resiliency against zone failures.""" - STANDARD_SSD_ZRS = "StandardSSD_ZRS" - """Standard SSD zone redundant storage. Best for web servers, lightly used enterprise applications - and dev/test that need storage resiliency against zone failures.""" - PREMIUM_V2_LRS = "PremiumV2_LRS" - """Premium SSD v2 locally redundant storage. Best for production and performance-sensitive - workloads that consistently require low latency and high IOPS and throughput.""" - - -class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of key used to encrypt the data of the disk.""" - - ENCRYPTION_AT_REST_WITH_PLATFORM_KEY = "EncryptionAtRestWithPlatformKey" - """Disk is encrypted at rest with Platform managed key. It is the default encryption type. This is - not a valid encryption type for disk encryption sets.""" - ENCRYPTION_AT_REST_WITH_CUSTOMER_KEY = "EncryptionAtRestWithCustomerKey" - """Disk is encrypted at rest with Customer managed key that can be changed and revoked by a - customer.""" - ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" - """Disk is encrypted at rest with 2 layers of encryption. One of the keys is Customer managed and - the other key is Platform managed.""" - - -class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of extendedLocation.""" - - EDGE_ZONE = "EdgeZone" - - -class FileFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Used to specify the file format when making request for SAS on a VHDX file format snapshot.""" - - VHD = "VHD" - """A VHD file is a disk image file in the Virtual Hard Disk file format.""" - VHDX = "VHDX" - """A VHDX file is a disk image file in the Virtual Hard Disk v2 file format.""" - - -class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The hypervisor generation of the Virtual Machine. Applicable to OS disks only.""" - - V1 = "V1" - V2 = "V2" - - -class NetworkAccessPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Policy for accessing the disk via network.""" - - ALLOW_ALL = "AllowAll" - """The disk can be exported or uploaded to from any network.""" - ALLOW_PRIVATE = "AllowPrivate" - """The disk can be exported or uploaded to using a DiskAccess resource's private endpoints.""" - DENY_ALL = "DenyAll" - """The disk cannot be exported.""" - - -class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The Operating System type.""" - - WINDOWS = "Windows" - LINUX = "Linux" - - -class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current provisioning state.""" - - SUCCEEDED = "Succeeded" - CREATING = "Creating" - DELETING = "Deleting" - FAILED = "Failed" - - -class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The private endpoint connection status.""" - - PENDING = "Pending" - APPROVED = "Approved" - REJECTED = "Rejected" - - -class ProvisionedBandwidthCopyOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """If this field is set on a snapshot and createOption is CopyStart, the snapshot will be copied - at a quicker speed. - """ - - NONE = "None" - ENHANCED = "Enhanced" - - -class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Policy for controlling export on the disk.""" - - ENABLED = "Enabled" - """You can generate a SAS URI to access the underlying data of the disk publicly on the internet - when NetworkAccessPolicy is set to AllowAll. You can access the data via the SAS URI only from - your trusted Azure VNET when NetworkAccessPolicy is set to AllowPrivate.""" - DISABLED = "Disabled" - """You cannot access the underlying data of the disk publicly on the internet even when - NetworkAccessPolicy is set to AllowAll. You can access the data via the SAS URI only from your - trusted Azure VNET when NetworkAccessPolicy is set to AllowPrivate.""" - - -class SnapshotAccessState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The state of snapshot which determines the access availability of the snapshot.""" - - UNKNOWN = "Unknown" - """Default value.""" - PENDING = "Pending" - """The snapshot cannot be used for restore, copy or download to offline.""" - AVAILABLE = "Available" - """The snapshot can be used for restore, copy to different region, and download to offline.""" - INSTANT_ACCESS = "InstantAccess" - """The snapshot can be used for restoring disks with fast performance but cannot be copied or - downloaded.""" - AVAILABLE_WITH_INSTANT_ACCESS = "AvailableWithInstantAccess" - """The snapshot can be used for restoring disks with fast performance, copied and downloaded.""" - - -class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The sku name.""" - - STANDARD_LRS = "Standard_LRS" - """Standard HDD locally redundant storage""" - PREMIUM_LRS = "Premium_LRS" - """Premium SSD locally redundant storage""" - STANDARD_ZRS = "Standard_ZRS" - """Standard zone redundant storage""" - - -class SupportedSecurityOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Refers to the security capability of the disk supported to create a Trusted launch or - Confidential VM. - """ - - TRUSTED_LAUNCH_SUPPORTED = "TrustedLaunchSupported" - """The disk supports creating Trusted Launch VMs.""" - TRUSTED_LAUNCH_AND_CONFIDENTIAL_VM_SUPPORTED = "TrustedLaunchAndConfidentialVMSupported" - """The disk supports creating both Trusted Launch and Confidential VMs.""" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/models/_models_py3.py deleted file mode 100644 index 191c4e102d31..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/models/_models_py3.py +++ /dev/null @@ -1,3517 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# 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 .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -class AccessUri(_serialization.Model): - """A disk access SAS uri. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar access_sas: A SAS uri for accessing a disk. - :vartype access_sas: str - :ivar security_data_access_sas: A SAS uri for accessing a VM guest state. - :vartype security_data_access_sas: str - :ivar security_metadata_access_sas: A SAS uri for accessing a VM metadata. - :vartype security_metadata_access_sas: str - """ - - _validation = { - "access_sas": {"readonly": True}, - "security_data_access_sas": {"readonly": True}, - "security_metadata_access_sas": {"readonly": True}, - } - - _attribute_map = { - "access_sas": {"key": "accessSAS", "type": "str"}, - "security_data_access_sas": {"key": "securityDataAccessSAS", "type": "str"}, - "security_metadata_access_sas": {"key": "securityMetadataAccessSAS", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.access_sas: Optional[str] = None - self.security_data_access_sas: Optional[str] = None - self.security_metadata_access_sas: Optional[str] = None - - -class ApiError(_serialization.Model): - """Api error. - - :ivar details: The Api error details. - :vartype details: list[~azure.mgmt.compute.v2025_01_02.models.ApiErrorBase] - :ivar innererror: The Api inner error. - :vartype innererror: ~azure.mgmt.compute.v2025_01_02.models.InnerError - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "details": {"key": "details", "type": "[ApiErrorBase]"}, - "innererror": {"key": "innererror", "type": "InnerError"}, - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, - *, - details: Optional[List["_models.ApiErrorBase"]] = None, - innererror: Optional["_models.InnerError"] = None, - code: Optional[str] = None, - target: Optional[str] = None, - message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword details: The Api error details. - :paramtype details: list[~azure.mgmt.compute.v2025_01_02.models.ApiErrorBase] - :keyword innererror: The Api inner error. - :paramtype innererror: ~azure.mgmt.compute.v2025_01_02.models.InnerError - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.details = details - self.innererror = innererror - self.code = code - self.target = target - self.message = message - - -class ApiErrorBase(_serialization.Model): - """Api error base. - - :ivar code: The error code. - :vartype code: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar message: The error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: The error code. - :paramtype code: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword message: The error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.target = target - self.message = message - - -class AvailabilityPolicy(_serialization.Model): - """In the case of an availability or connectivity issue with the data disk, specify the behavior - of your VM. - - :ivar action_on_disk_delay: Determines on how to handle disks with slow I/O. Known values are: - "None" and "AutomaticReattach". - :vartype action_on_disk_delay: str or - ~azure.mgmt.compute.v2025_01_02.models.AvailabilityPolicyDiskDelay - """ - - _attribute_map = { - "action_on_disk_delay": {"key": "actionOnDiskDelay", "type": "str"}, - } - - def __init__( - self, *, action_on_disk_delay: Optional[Union[str, "_models.AvailabilityPolicyDiskDelay"]] = None, **kwargs: Any - ) -> None: - """ - :keyword action_on_disk_delay: Determines on how to handle disks with slow I/O. Known values - are: "None" and "AutomaticReattach". - :paramtype action_on_disk_delay: str or - ~azure.mgmt.compute.v2025_01_02.models.AvailabilityPolicyDiskDelay - """ - super().__init__(**kwargs) - self.action_on_disk_delay = action_on_disk_delay - - -class CopyCompletionError(_serialization.Model): - """Indicates the error details if the background copy of a resource created via the CopyStart - operation fails. - - All required parameters must be populated in order to send to server. - - :ivar error_code: Indicates the error code if the background copy of a resource created via the - CopyStart operation fails. Required. "CopySourceNotFound" - :vartype error_code: str or ~azure.mgmt.compute.v2025_01_02.models.CopyCompletionErrorReason - :ivar error_message: Indicates the error message if the background copy of a resource created - via the CopyStart operation fails. Required. - :vartype error_message: str - """ - - _validation = { - "error_code": {"required": True}, - "error_message": {"required": True}, - } - - _attribute_map = { - "error_code": {"key": "errorCode", "type": "str"}, - "error_message": {"key": "errorMessage", "type": "str"}, - } - - def __init__( - self, *, error_code: Union[str, "_models.CopyCompletionErrorReason"], error_message: str, **kwargs: Any - ) -> None: - """ - :keyword error_code: Indicates the error code if the background copy of a resource created via - the CopyStart operation fails. Required. "CopySourceNotFound" - :paramtype error_code: str or ~azure.mgmt.compute.v2025_01_02.models.CopyCompletionErrorReason - :keyword error_message: Indicates the error message if the background copy of a resource - created via the CopyStart operation fails. Required. - :paramtype error_message: str - """ - super().__init__(**kwargs) - self.error_code = error_code - self.error_message = error_message - - -class CreationData(_serialization.Model): - """Data used when creating a disk. - - 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 create_option: This enumerates the possible sources of a disk's creation. Required. Known - values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", "CopyStart", - "ImportSecure", "UploadPreparedSecure", "CopyFromSanSnapshot", and "Import". - :vartype create_option: str or ~azure.mgmt.compute.v2025_01_02.models.DiskCreateOption - :ivar storage_account_id: Required if createOption is Import. The Azure Resource Manager - identifier of the storage account containing the blob to import as a disk. - :vartype storage_account_id: str - :ivar image_reference: Disk source information for PIR or user images. - :vartype image_reference: ~azure.mgmt.compute.v2025_01_02.models.ImageDiskReference - :ivar gallery_image_reference: Required if creating from a Gallery Image. The - id/sharedGalleryImageId/communityGalleryImageId of the ImageDiskReference will be the ARM id of - the shared galley image version from which to create a disk. - :vartype gallery_image_reference: ~azure.mgmt.compute.v2025_01_02.models.ImageDiskReference - :ivar source_uri: If createOption is Import, this is the URI of a blob to be imported into a - managed disk. - :vartype source_uri: str - :ivar source_resource_id: If createOption is Copy, this is the ARM id of the source snapshot or - disk. - :vartype source_resource_id: str - :ivar source_unique_id: If this field is set, this is the unique id identifying the source of - this resource. - :vartype source_unique_id: str - :ivar upload_size_bytes: If createOption is Upload, this is the size of the contents of the - upload including the VHD footer. This value should be between 20972032 (20 MiB + 512 bytes for - the VHD footer) and 35183298347520 bytes (32 TiB + 512 bytes for the VHD footer). - :vartype upload_size_bytes: int - :ivar logical_sector_size: Logical sector size in bytes for Ultra disks. Supported values are - 512 ad 4096. 4096 is the default. - :vartype logical_sector_size: int - :ivar security_data_uri: If createOption is ImportSecure, this is the URI of a blob to be - imported into VM guest state. - :vartype security_data_uri: str - :ivar security_metadata_uri: If createOption is ImportSecure, this is the URI of a blob to be - imported into VM metadata for Confidential VM. - :vartype security_metadata_uri: str - :ivar performance_plus: Set this flag to true to get a boost on the performance target of the - disk deployed, see here on the respective performance target. This flag can only be set on disk - creation time and cannot be disabled after enabled. - :vartype performance_plus: bool - :ivar elastic_san_resource_id: Required if createOption is CopyFromSanSnapshot. This is the ARM - id of the source elastic san volume snapshot. - :vartype elastic_san_resource_id: str - :ivar provisioned_bandwidth_copy_speed: If this field is set on a snapshot and createOption is - CopyStart, the snapshot will be copied at a quicker speed. Known values are: "None" and - "Enhanced". - :vartype provisioned_bandwidth_copy_speed: str or - ~azure.mgmt.compute.v2025_01_02.models.ProvisionedBandwidthCopyOption - :ivar instant_access_duration_minutes: For snapshots created from Premium SSD v2 or Ultra disk, - this property determines the time in minutes the snapshot is retained for instant access to - enable faster restore. - :vartype instant_access_duration_minutes: int - """ - - _validation = { - "create_option": {"required": True}, - "source_unique_id": {"readonly": True}, - "instant_access_duration_minutes": {"minimum": 1}, - } - - _attribute_map = { - "create_option": {"key": "createOption", "type": "str"}, - "storage_account_id": {"key": "storageAccountId", "type": "str"}, - "image_reference": {"key": "imageReference", "type": "ImageDiskReference"}, - "gallery_image_reference": {"key": "galleryImageReference", "type": "ImageDiskReference"}, - "source_uri": {"key": "sourceUri", "type": "str"}, - "source_resource_id": {"key": "sourceResourceId", "type": "str"}, - "source_unique_id": {"key": "sourceUniqueId", "type": "str"}, - "upload_size_bytes": {"key": "uploadSizeBytes", "type": "int"}, - "logical_sector_size": {"key": "logicalSectorSize", "type": "int"}, - "security_data_uri": {"key": "securityDataUri", "type": "str"}, - "security_metadata_uri": {"key": "securityMetadataUri", "type": "str"}, - "performance_plus": {"key": "performancePlus", "type": "bool"}, - "elastic_san_resource_id": {"key": "elasticSanResourceId", "type": "str"}, - "provisioned_bandwidth_copy_speed": {"key": "provisionedBandwidthCopySpeed", "type": "str"}, - "instant_access_duration_minutes": {"key": "instantAccessDurationMinutes", "type": "int"}, - } - - def __init__( - self, - *, - create_option: Union[str, "_models.DiskCreateOption"], - storage_account_id: Optional[str] = None, - image_reference: Optional["_models.ImageDiskReference"] = None, - gallery_image_reference: Optional["_models.ImageDiskReference"] = None, - source_uri: Optional[str] = None, - source_resource_id: Optional[str] = None, - upload_size_bytes: Optional[int] = None, - logical_sector_size: Optional[int] = None, - security_data_uri: Optional[str] = None, - security_metadata_uri: Optional[str] = None, - performance_plus: Optional[bool] = None, - elastic_san_resource_id: Optional[str] = None, - provisioned_bandwidth_copy_speed: Optional[Union[str, "_models.ProvisionedBandwidthCopyOption"]] = None, - instant_access_duration_minutes: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword create_option: This enumerates the possible sources of a disk's creation. Required. - Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", - "CopyStart", "ImportSecure", "UploadPreparedSecure", "CopyFromSanSnapshot", and "Import". - :paramtype create_option: str or ~azure.mgmt.compute.v2025_01_02.models.DiskCreateOption - :keyword storage_account_id: Required if createOption is Import. The Azure Resource Manager - identifier of the storage account containing the blob to import as a disk. - :paramtype storage_account_id: str - :keyword image_reference: Disk source information for PIR or user images. - :paramtype image_reference: ~azure.mgmt.compute.v2025_01_02.models.ImageDiskReference - :keyword gallery_image_reference: Required if creating from a Gallery Image. The - id/sharedGalleryImageId/communityGalleryImageId of the ImageDiskReference will be the ARM id of - the shared galley image version from which to create a disk. - :paramtype gallery_image_reference: ~azure.mgmt.compute.v2025_01_02.models.ImageDiskReference - :keyword source_uri: If createOption is Import, this is the URI of a blob to be imported into a - managed disk. - :paramtype source_uri: str - :keyword source_resource_id: If createOption is Copy, this is the ARM id of the source snapshot - or disk. - :paramtype source_resource_id: str - :keyword upload_size_bytes: If createOption is Upload, this is the size of the contents of the - upload including the VHD footer. This value should be between 20972032 (20 MiB + 512 bytes for - the VHD footer) and 35183298347520 bytes (32 TiB + 512 bytes for the VHD footer). - :paramtype upload_size_bytes: int - :keyword logical_sector_size: Logical sector size in bytes for Ultra disks. Supported values - are 512 ad 4096. 4096 is the default. - :paramtype logical_sector_size: int - :keyword security_data_uri: If createOption is ImportSecure, this is the URI of a blob to be - imported into VM guest state. - :paramtype security_data_uri: str - :keyword security_metadata_uri: If createOption is ImportSecure, this is the URI of a blob to - be imported into VM metadata for Confidential VM. - :paramtype security_metadata_uri: str - :keyword performance_plus: Set this flag to true to get a boost on the performance target of - the disk deployed, see here on the respective performance target. This flag can only be set on - disk creation time and cannot be disabled after enabled. - :paramtype performance_plus: bool - :keyword elastic_san_resource_id: Required if createOption is CopyFromSanSnapshot. This is the - ARM id of the source elastic san volume snapshot. - :paramtype elastic_san_resource_id: str - :keyword provisioned_bandwidth_copy_speed: If this field is set on a snapshot and createOption - is CopyStart, the snapshot will be copied at a quicker speed. Known values are: "None" and - "Enhanced". - :paramtype provisioned_bandwidth_copy_speed: str or - ~azure.mgmt.compute.v2025_01_02.models.ProvisionedBandwidthCopyOption - :keyword instant_access_duration_minutes: For snapshots created from Premium SSD v2 or Ultra - disk, this property determines the time in minutes the snapshot is retained for instant access - to enable faster restore. - :paramtype instant_access_duration_minutes: int - """ - super().__init__(**kwargs) - self.create_option = create_option - self.storage_account_id = storage_account_id - self.image_reference = image_reference - self.gallery_image_reference = gallery_image_reference - self.source_uri = source_uri - self.source_resource_id = source_resource_id - self.source_unique_id: Optional[str] = None - self.upload_size_bytes = upload_size_bytes - self.logical_sector_size = logical_sector_size - self.security_data_uri = security_data_uri - self.security_metadata_uri = security_metadata_uri - self.performance_plus = performance_plus - self.elastic_san_resource_id = elastic_san_resource_id - self.provisioned_bandwidth_copy_speed = provisioned_bandwidth_copy_speed - self.instant_access_duration_minutes = instant_access_duration_minutes - - -class Resource(_serialization.Model): - """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}. - :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.v2025_01_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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.system_data: Optional["_models.SystemData"] = 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: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :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.v2025_01_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}, - } - - _attribute_map = { - "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"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :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.tags = tags - self.location = location - - -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: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :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.v2025_01_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 - disk attached. maxShares should be set to a value greater than one for disks to allow attaching - them to multiple VMs. - :vartype managed_by_extended: list[str] - :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, - Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS. - :vartype sku: ~azure.mgmt.compute.v2025_01_02.models.DiskSku - :ivar zones: The Logical zone list for Disk. - :vartype zones: list[str] - :ivar extended_location: The extended location where the disk will be created. Extended - location cannot be changed. - :vartype extended_location: ~azure.mgmt.compute.v2025_01_02.models.ExtendedLocation - :ivar time_created: The time when the disk was created. - :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2025_01_02.models.OperatingSystemTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2025_01_02.models.HyperVGeneration - :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.v2025_01_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.v2025_01_02.models.SupportedCapabilities - :ivar creation_data: Disk source information. CreationData information cannot be changed after - the disk has been created. - :vartype creation_data: ~azure.mgmt.compute.v2025_01_02.models.CreationData - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. - :vartype disk_size_bytes: int - :ivar unique_id: Unique Guid identifying the resource. - :vartype unique_id: str - :ivar encryption_settings_collection: Encryption settings collection used for Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2025_01_02.models.EncryptionSettingsCollection - :ivar provisioning_state: The disk provisioning state. - :vartype provisioning_state: str - :ivar disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :vartype disk_m_bps_read_write: int - :ivar disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_only: int - :ivar disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :vartype disk_m_bps_read_only: int - :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", - "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", and "ActiveUpload". - :vartype disk_state: str or ~azure.mgmt.compute.v2025_01_02.models.DiskState - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2025_01_02.models.Encryption - :ivar max_shares: The maximum number of VMs that can attach to the disk at the same time. Value - greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :vartype max_shares: int - :ivar share_info: Details of the list of all VMs that have the disk attached. maxShares should - be set to a value greater than one for disks to allow attaching them to multiple VMs. - :vartype share_info: list[~azure.mgmt.compute.v2025_01_02.models.ShareInfoElement] - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2025_01_02.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar bursting_enabled_time: Latest time when bursting was last enabled on a disk. - :vartype bursting_enabled_time: ~datetime.datetime - :ivar tier: Performance tier of the disk (e.g, P4, S10) as described here: - https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra - disks. - :vartype tier: str - :ivar bursting_enabled: Set to true to enable bursting beyond the provisioned performance - target of the disk. Bursting is disabled by default. Does not apply to Ultra disks. - :vartype bursting_enabled: bool - :ivar property_updates_in_progress: Properties of the disk for which update is pending. - :vartype property_updates_in_progress: - ~azure.mgmt.compute.v2025_01_02.models.PropertyUpdatesInProgress - :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. - :vartype supports_hibernation: bool - :ivar security_profile: Contains the security related information for the resource. - :vartype security_profile: ~azure.mgmt.compute.v2025_01_02.models.DiskSecurityProfile - :ivar completion_percent: Percentage complete for the background copy when a resource is - created via the CopyStart operation. - :vartype completion_percent: float - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2025_01_02.models.PublicNetworkAccess - :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :vartype data_access_auth_mode: str or - ~azure.mgmt.compute.v2025_01_02.models.DataAccessAuthMode - :ivar optimized_for_frequent_attach: Setting this property to true improves reliability and - performance of data disks that are frequently (more than 5 times a day) by detached from one - virtual machine and attached to another. This property should not be set for disks that are not - detached and attached frequently as it causes the disks to not align with the fault domain of - the virtual machine. - :vartype optimized_for_frequent_attach: bool - :ivar last_ownership_update_time: The UTC time when the ownership state of the disk was last - changed i.e., the time the disk was last attached or detached from a VM or the time when the VM - to which the disk was attached was deallocated or started. - :vartype last_ownership_update_time: ~datetime.datetime - :ivar availability_policy: Determines how platform treats disk failures. - :vartype availability_policy: ~azure.mgmt.compute.v2025_01_02.models.AvailabilityPolicy - """ - - _validation = { - "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}, - "time_created": {"readonly": True}, - "disk_size_bytes": {"readonly": True}, - "unique_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "disk_state": {"readonly": True}, - "share_info": {"readonly": True}, - "bursting_enabled_time": {"readonly": True}, - "property_updates_in_progress": {"readonly": True}, - "last_ownership_update_time": {"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"}, - "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"}, - "zones": {"key": "zones", "type": "[str]"}, - "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": "DiskPurchasePlan"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - "creation_data": {"key": "properties.creationData", "type": "CreationData"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "disk_size_bytes": {"key": "properties.diskSizeBytes", "type": "int"}, - "unique_id": {"key": "properties.uniqueId", "type": "str"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "disk_iops_read_write": {"key": "properties.diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "properties.diskMBpsReadWrite", "type": "int"}, - "disk_iops_read_only": {"key": "properties.diskIOPSReadOnly", "type": "int"}, - "disk_m_bps_read_only": {"key": "properties.diskMBpsReadOnly", "type": "int"}, - "disk_state": {"key": "properties.diskState", "type": "str"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "max_shares": {"key": "properties.maxShares", "type": "int"}, - "share_info": {"key": "properties.shareInfo", "type": "[ShareInfoElement]"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - "bursting_enabled_time": {"key": "properties.burstingEnabledTime", "type": "iso-8601"}, - "tier": {"key": "properties.tier", "type": "str"}, - "bursting_enabled": {"key": "properties.burstingEnabled", "type": "bool"}, - "property_updates_in_progress": { - "key": "properties.propertyUpdatesInProgress", - "type": "PropertyUpdatesInProgress", - }, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "security_profile": {"key": "properties.securityProfile", "type": "DiskSecurityProfile"}, - "completion_percent": {"key": "properties.completionPercent", "type": "float"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, - "optimized_for_frequent_attach": {"key": "properties.optimizedForFrequentAttach", "type": "bool"}, - "last_ownership_update_time": {"key": "properties.LastOwnershipUpdateTime", "type": "iso-8601"}, - "availability_policy": {"key": "properties.availabilityPolicy", "type": "AvailabilityPolicy"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.DiskSku"] = None, - zones: Optional[List[str]] = None, - 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.DiskPurchasePlan"] = None, - supported_capabilities: Optional["_models.SupportedCapabilities"] = None, - creation_data: Optional["_models.CreationData"] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - disk_iops_read_write: Optional[int] = None, - disk_m_bps_read_write: Optional[int] = None, - disk_iops_read_only: Optional[int] = None, - disk_m_bps_read_only: Optional[int] = None, - encryption: Optional["_models.Encryption"] = None, - max_shares: Optional[int] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - tier: Optional[str] = None, - bursting_enabled: Optional[bool] = None, - supports_hibernation: Optional[bool] = None, - security_profile: Optional["_models.DiskSecurityProfile"] = None, - completion_percent: Optional[float] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, - optimized_for_frequent_attach: Optional[bool] = None, - availability_policy: Optional["_models.AvailabilityPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :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.v2025_01_02.models.DiskSku - :keyword zones: The Logical zone list for Disk. - :paramtype zones: list[str] - :keyword extended_location: The extended location where the disk will be created. Extended - location cannot be changed. - :paramtype extended_location: ~azure.mgmt.compute.v2025_01_02.models.ExtendedLocation - :keyword os_type: The Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2025_01_02.models.OperatingSystemTypes - :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.v2025_01_02.models.HyperVGeneration - :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.v2025_01_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.v2025_01_02.models.SupportedCapabilities - :keyword creation_data: Disk source information. CreationData information cannot be changed - after the disk has been created. - :paramtype creation_data: ~azure.mgmt.compute.v2025_01_02.models.CreationData - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used for Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2025_01_02.models.EncryptionSettingsCollection - :keyword disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_write: int - :keyword disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :paramtype disk_m_bps_read_write: int - :keyword disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_only: int - :keyword disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :paramtype disk_m_bps_read_only: int - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2025_01_02.models.Encryption - :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. - Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :paramtype max_shares: int - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2025_01_02.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword tier: Performance tier of the disk (e.g, P4, S10) as described here: - https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra - disks. - :paramtype tier: str - :keyword bursting_enabled: Set to true to enable bursting beyond the provisioned performance - target of the disk. Bursting is disabled by default. Does not apply to Ultra disks. - :paramtype bursting_enabled: bool - :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. - :paramtype supports_hibernation: bool - :keyword security_profile: Contains the security related information for the resource. - :paramtype security_profile: ~azure.mgmt.compute.v2025_01_02.models.DiskSecurityProfile - :keyword completion_percent: Percentage complete for the background copy when a resource is - created via the CopyStart operation. - :paramtype completion_percent: float - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2025_01_02.models.PublicNetworkAccess - :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :paramtype data_access_auth_mode: str or - ~azure.mgmt.compute.v2025_01_02.models.DataAccessAuthMode - :keyword optimized_for_frequent_attach: Setting this property to true improves reliability and - performance of data disks that are frequently (more than 5 times a day) by detached from one - virtual machine and attached to another. This property should not be set for disks that are not - detached and attached frequently as it causes the disks to not align with the fault domain of - the virtual machine. - :paramtype optimized_for_frequent_attach: bool - :keyword availability_policy: Determines how platform treats disk failures. - :paramtype availability_policy: ~azure.mgmt.compute.v2025_01_02.models.AvailabilityPolicy - """ - super().__init__(tags=tags, location=location, **kwargs) - self.managed_by: Optional[str] = None - self.managed_by_extended: Optional[List[str]] = None - self.sku = sku - self.zones = zones - self.extended_location = extended_location - self.time_created: Optional[datetime.datetime] = None - self.os_type = os_type - self.hyper_v_generation = hyper_v_generation - self.purchase_plan = purchase_plan - self.supported_capabilities = supported_capabilities - self.creation_data = creation_data - self.disk_size_gb = disk_size_gb - self.disk_size_bytes: Optional[int] = None - self.unique_id: Optional[str] = None - self.encryption_settings_collection = encryption_settings_collection - self.provisioning_state: Optional[str] = None - self.disk_iops_read_write = disk_iops_read_write - self.disk_m_bps_read_write = disk_m_bps_read_write - self.disk_iops_read_only = disk_iops_read_only - self.disk_m_bps_read_only = disk_m_bps_read_only - self.disk_state: Optional[Union[str, "_models.DiskState"]] = None - self.encryption = encryption - self.max_shares = max_shares - self.share_info: Optional[List["_models.ShareInfoElement"]] = None - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - self.bursting_enabled_time: Optional[datetime.datetime] = None - self.tier = tier - self.bursting_enabled = bursting_enabled - self.property_updates_in_progress: Optional["_models.PropertyUpdatesInProgress"] = None - self.supports_hibernation = supports_hibernation - self.security_profile = security_profile - self.completion_percent = completion_percent - self.public_network_access = public_network_access - self.data_access_auth_mode = data_access_auth_mode - self.optimized_for_frequent_attach = optimized_for_frequent_attach - self.last_ownership_update_time: Optional[datetime.datetime] = None - self.availability_policy = availability_policy - - -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: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :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.v2025_01_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.v2025_01_02.models.ExtendedLocation - :ivar private_endpoint_connections: A readonly collection of private endpoint connections - created on the disk. Currently only one endpoint connection is supported. - :vartype private_endpoint_connections: - list[~azure.mgmt.compute.v2025_01_02.models.PrivateEndpointConnection] - :ivar provisioning_state: The disk access resource provisioning state. - :vartype provisioning_state: str - :ivar time_created: The time when the disk access was created. - :vartype time_created: ~datetime.datetime - """ - - _validation = { - "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}, - "time_created": {"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"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - "private_endpoint_connections": { - "key": "properties.privateEndpointConnections", - "type": "[PrivateEndpointConnection]", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - extended_location: Optional["_models.ExtendedLocation"] = None, - **kwargs: Any - ) -> None: - """ - :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.v2025_01_02.models.ExtendedLocation - """ - super().__init__(tags=tags, location=location, **kwargs) - self.extended_location = extended_location - self.private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None - self.provisioning_state: Optional[str] = None - self.time_created: Optional[datetime.datetime] = None - - -class DiskAccessList(_serialization.Model): - """The List disk access operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The DiskAccess items on this page. Required. - :vartype value: list[~azure.mgmt.compute.v2025_01_02.models.DiskAccess] - :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": "[DiskAccess]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.DiskAccess"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The DiskAccess items on this page. Required. - :paramtype value: list[~azure.mgmt.compute.v2025_01_02.models.DiskAccess] - :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 DiskAccessUpdate(_serialization.Model): - """Used for updating a disk access resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -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: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :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.v2025_01_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.v2025_01_02.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and - "ConfidentialVmEncryptedWithCustomerKey". - :vartype encryption_type: str or ~azure.mgmt.compute.v2025_01_02.models.DiskEncryptionSetType - :ivar active_key: The key vault key which is currently used by this disk encryption set. - :vartype active_key: ~azure.mgmt.compute.v2025_01_02.models.KeyForDiskEncryptionSet - :ivar previous_keys: A readonly collection of key vault keys previously used by this disk - encryption set while a key rotation is in progress. It will be empty if there is no ongoing key - rotation. - :vartype previous_keys: list[~azure.mgmt.compute.v2025_01_02.models.KeyForDiskEncryptionSet] - :ivar provisioning_state: The disk encryption set provisioning state. - :vartype provisioning_state: str - :ivar rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating of - this disk encryption set to the latest key version. - :vartype rotation_to_latest_key_version_enabled: bool - :ivar last_key_rotation_timestamp: The time when the active key of this disk encryption set was - updated. - :vartype last_key_rotation_timestamp: ~datetime.datetime - :ivar auto_key_rotation_error: The error that was encountered during auto-key rotation. If an - error is present, then auto-key rotation will not be attempted until the error on this disk - encryption set is fixed. - :vartype auto_key_rotation_error: ~azure.mgmt.compute.v2025_01_02.models.ApiError - :ivar federated_client_id: Multi-tenant application client id to access key vault in a - different tenant. Setting the value to 'None' will clear the property. - :vartype federated_client_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - "previous_keys": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "last_key_rotation_timestamp": {"readonly": True}, - "auto_key_rotation_error": {"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"}, - "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"}, - "previous_keys": {"key": "properties.previousKeys", "type": "[KeyForDiskEncryptionSet]"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "rotation_to_latest_key_version_enabled": { - "key": "properties.rotationToLatestKeyVersionEnabled", - "type": "bool", - }, - "last_key_rotation_timestamp": {"key": "properties.lastKeyRotationTimestamp", "type": "iso-8601"}, - "auto_key_rotation_error": {"key": "properties.autoKeyRotationError", "type": "ApiError"}, - "federated_client_id": {"key": "properties.federatedClientId", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, - active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, - rotation_to_latest_key_version_enabled: Optional[bool] = None, - federated_client_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :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.v2025_01_02.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values - are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and - "ConfidentialVmEncryptedWithCustomerKey". - :paramtype encryption_type: str or ~azure.mgmt.compute.v2025_01_02.models.DiskEncryptionSetType - :keyword active_key: The key vault key which is currently used by this disk encryption set. - :paramtype active_key: ~azure.mgmt.compute.v2025_01_02.models.KeyForDiskEncryptionSet - :keyword rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating - of this disk encryption set to the latest key version. - :paramtype rotation_to_latest_key_version_enabled: bool - :keyword federated_client_id: Multi-tenant application client id to access key vault in a - different tenant. Setting the value to 'None' will clear the property. - :paramtype federated_client_id: str - """ - super().__init__(tags=tags, location=location, **kwargs) - self.identity = identity - self.encryption_type = encryption_type - self.active_key = active_key - self.previous_keys: Optional[List["_models.KeyForDiskEncryptionSet"]] = None - self.provisioning_state: Optional[str] = None - self.rotation_to_latest_key_version_enabled = rotation_to_latest_key_version_enabled - self.last_key_rotation_timestamp: Optional[datetime.datetime] = None - self.auto_key_rotation_error: Optional["_models.ApiError"] = None - self.federated_client_id = federated_client_id - - -class DiskEncryptionSetList(_serialization.Model): - """The List disk encryption set operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The DiskEncryptionSet items on this page. Required. - :vartype value: list[~azure.mgmt.compute.v2025_01_02.models.DiskEncryptionSet] - :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": "[DiskEncryptionSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DiskEncryptionSet"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The DiskEncryptionSet items on this page. Required. - :paramtype value: list[~azure.mgmt.compute.v2025_01_02.models.DiskEncryptionSet] - :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 DiskEncryptionSetUpdate(_serialization.Model): - """disk encryption set update resource. - - :ivar tags: Resource tags. - :vartype tags: dict[str, 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.v2025_01_02.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and - "ConfidentialVmEncryptedWithCustomerKey". - :vartype encryption_type: str or ~azure.mgmt.compute.v2025_01_02.models.DiskEncryptionSetType - :ivar active_key: Key Vault Key Url to be used for server side encryption of Managed Disks and - Snapshots. - :vartype active_key: ~azure.mgmt.compute.v2025_01_02.models.KeyForDiskEncryptionSet - :ivar rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating of - this disk encryption set to the latest key version. - :vartype rotation_to_latest_key_version_enabled: bool - :ivar federated_client_id: Multi-tenant application client id to access key vault in a - different tenant. Setting the value to 'None' will clear the property. - :vartype federated_client_id: str - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "identity": {"key": "identity", "type": "EncryptionSetIdentity"}, - "encryption_type": {"key": "properties.encryptionType", "type": "str"}, - "active_key": {"key": "properties.activeKey", "type": "KeyForDiskEncryptionSet"}, - "rotation_to_latest_key_version_enabled": { - "key": "properties.rotationToLatestKeyVersionEnabled", - "type": "bool", - }, - "federated_client_id": {"key": "properties.federatedClientId", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, - active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, - rotation_to_latest_key_version_enabled: Optional[bool] = None, - federated_client_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2025_01_02.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values - are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", and - "ConfidentialVmEncryptedWithCustomerKey". - :paramtype encryption_type: str or ~azure.mgmt.compute.v2025_01_02.models.DiskEncryptionSetType - :keyword active_key: Key Vault Key Url to be used for server side encryption of Managed Disks - and Snapshots. - :paramtype active_key: ~azure.mgmt.compute.v2025_01_02.models.KeyForDiskEncryptionSet - :keyword rotation_to_latest_key_version_enabled: Set this flag to true to enable auto-updating - of this disk encryption set to the latest key version. - :paramtype rotation_to_latest_key_version_enabled: bool - :keyword federated_client_id: Multi-tenant application client id to access key vault in a - different tenant. Setting the value to 'None' will clear the property. - :paramtype federated_client_id: str - """ - super().__init__(**kwargs) - self.tags = tags - self.identity = identity - self.encryption_type = encryption_type - self.active_key = active_key - self.rotation_to_latest_key_version_enabled = rotation_to_latest_key_version_enabled - self.federated_client_id = federated_client_id - - -class DiskList(_serialization.Model): - """The List Disks operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The Disk items on this page. Required. - :vartype value: list[~azure.mgmt.compute.v2025_01_02.models.Disk] - :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": "[Disk]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The Disk items on this page. Required. - :paramtype value: list[~azure.mgmt.compute.v2025_01_02.models.Disk] - :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 DiskPurchasePlan(_serialization.Model): - """Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. - - All required parameters must be populated in order to send to server. - - :ivar name: The plan ID. Required. - :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 - """ - - _validation = { - "name": {"required": True}, - "publisher": {"required": True}, - "product": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - "promotion_code": {"key": "promotionCode", "type": "str"}, - } - - 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.name = name - self.publisher = publisher - self.product = product - self.promotion_code = promotion_code - - -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have - tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :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.v2025_01_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: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :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.v2025_01_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. - :vartype source_resource_id: str - :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2025_01_02.models.OperatingSystemTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2025_01_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.v2025_01_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.v2025_01_02.models.SupportedCapabilities - :ivar family_id: id of the backing snapshot's MIS family. - :vartype family_id: str - :ivar source_unique_id: unique incarnation id of the source disk. - :vartype source_unique_id: str - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2025_01_02.models.Encryption - :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. - :vartype supports_hibernation: bool - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2025_01_02.models.NetworkAccessPolicy - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2025_01_02.models.PublicNetworkAccess - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar completion_percent: Percentage complete for the background copy of disk restore point - when source resource is from a different region. - :vartype completion_percent: float - :ivar replication_state: Replication state of disk restore point when source resource is from a - different region. - :vartype replication_state: str - :ivar source_resource_location: Location of source disk or source disk restore point when - source resource is from a different region. - :vartype source_resource_location: str - :ivar security_profile: Contains the security related information for the resource. - :vartype security_profile: ~azure.mgmt.compute.v2025_01_02.models.DiskSecurityProfile - :ivar logical_sector_size: Logical sector size in bytes for disk restore points of UltraSSD_LRS - and PremiumV2_LRS disks. Supported values are 512 and 4096. 4096 is the default. - :vartype logical_sector_size: int - """ - - _validation = { - "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}, - "family_id": {"readonly": True}, - "source_unique_id": {"readonly": True}, - "encryption": {"readonly": True}, - "replication_state": {"readonly": True}, - "source_resource_location": {"readonly": True}, - "logical_sector_size": {"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"}, - "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": "DiskPurchasePlan"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - "family_id": {"key": "properties.familyId", "type": "str"}, - "source_unique_id": {"key": "properties.sourceUniqueId", "type": "str"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - "completion_percent": {"key": "properties.completionPercent", "type": "float"}, - "replication_state": {"key": "properties.replicationState", "type": "str"}, - "source_resource_location": {"key": "properties.sourceResourceLocation", "type": "str"}, - "security_profile": {"key": "properties.securityProfile", "type": "DiskSecurityProfile"}, - "logical_sector_size": {"key": "properties.logicalSectorSize", "type": "int"}, - } - - def __init__( - self, - *, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = 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, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - disk_access_id: Optional[str] = None, - completion_percent: Optional[float] = None, - security_profile: Optional["_models.DiskSecurityProfile"] = None, - **kwargs: Any - ) -> None: - """ - :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.v2025_01_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.v2025_01_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.v2025_01_02.models.SupportedCapabilities - :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. - :paramtype supports_hibernation: bool - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2025_01_02.models.NetworkAccessPolicy - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2025_01_02.models.PublicNetworkAccess - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword completion_percent: Percentage complete for the background copy of disk restore point - when source resource is from a different region. - :paramtype completion_percent: float - :keyword security_profile: Contains the security related information for the resource. - :paramtype security_profile: ~azure.mgmt.compute.v2025_01_02.models.DiskSecurityProfile - """ - super().__init__(**kwargs) - self.time_created: Optional[datetime.datetime] = None - self.source_resource_id: Optional[str] = None - self.os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None - self.hyper_v_generation = hyper_v_generation - self.purchase_plan = purchase_plan - self.supported_capabilities = supported_capabilities - self.family_id: Optional[str] = None - self.source_unique_id: Optional[str] = None - self.encryption: Optional["_models.Encryption"] = None - self.supports_hibernation = supports_hibernation - self.network_access_policy = network_access_policy - self.public_network_access = public_network_access - self.disk_access_id = disk_access_id - self.completion_percent = completion_percent - self.replication_state: Optional[str] = None - self.source_resource_location: Optional[str] = None - self.security_profile = security_profile - self.logical_sector_size: Optional[int] = 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: The DiskRestorePoint items on this page. Required. - :vartype value: list[~azure.mgmt.compute.v2025_01_02.models.DiskRestorePoint] - :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": "[DiskRestorePoint]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DiskRestorePoint"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The DiskRestorePoint items on this page. Required. - :paramtype value: list[~azure.mgmt.compute.v2025_01_02.models.DiskRestorePoint] - :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 DiskSecurityProfile(_serialization.Model): - """Contains the security related information for the resource. - - :ivar security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. Known - values are: "TrustedLaunch", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", - "ConfidentialVM_DiskEncryptedWithPlatformKey", "ConfidentialVM_DiskEncryptedWithCustomerKey", - and "ConfidentialVM_NonPersistedTPM". - :vartype security_type: str or ~azure.mgmt.compute.v2025_01_02.models.DiskSecurityTypes - :ivar secure_vm_disk_encryption_set_id: ResourceId of the disk encryption set associated to - Confidential VM supported disk encrypted with customer managed key. - :vartype secure_vm_disk_encryption_set_id: str - """ - - _attribute_map = { - "security_type": {"key": "securityType", "type": "str"}, - "secure_vm_disk_encryption_set_id": {"key": "secureVMDiskEncryptionSetId", "type": "str"}, - } - - def __init__( - self, - *, - security_type: Optional[Union[str, "_models.DiskSecurityTypes"]] = None, - secure_vm_disk_encryption_set_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. - Known values are: "TrustedLaunch", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", - "ConfidentialVM_DiskEncryptedWithPlatformKey", "ConfidentialVM_DiskEncryptedWithCustomerKey", - and "ConfidentialVM_NonPersistedTPM". - :paramtype security_type: str or ~azure.mgmt.compute.v2025_01_02.models.DiskSecurityTypes - :keyword secure_vm_disk_encryption_set_id: ResourceId of the disk encryption set associated to - Confidential VM supported disk encrypted with customer managed key. - :paramtype secure_vm_disk_encryption_set_id: str - """ - super().__init__(**kwargs) - self.security_type = security_type - self.secure_vm_disk_encryption_set_id = secure_vm_disk_encryption_set_id - - -class DiskSku(_serialization.Model): - """The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, - Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", - "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", and "PremiumV2_LRS". - :vartype name: str or ~azure.mgmt.compute.v2025_01_02.models.DiskStorageAccountTypes - :ivar tier: The sku tier. - :vartype tier: str - """ - - _validation = { - "tier": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__(self, *, name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs: Any) -> None: - """ - :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", and "PremiumV2_LRS". - :paramtype name: str or ~azure.mgmt.compute.v2025_01_02.models.DiskStorageAccountTypes - """ - super().__init__(**kwargs) - self.name = name - self.tier: Optional[str] = None - - -class DiskUpdate(_serialization.Model): - """Disk update resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, - Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS. - :vartype sku: ~azure.mgmt.compute.v2025_01_02.models.DiskSku - :ivar os_type: the Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2025_01_02.models.OperatingSystemTypes - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2025_01_02.models.EncryptionSettingsCollection - :ivar disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_write: int - :ivar disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :vartype disk_m_bps_read_write: int - :ivar disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :vartype disk_iops_read_only: int - :ivar disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :vartype disk_m_bps_read_only: int - :ivar max_shares: The maximum number of VMs that can attach to the disk at the same time. Value - greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :vartype max_shares: int - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2025_01_02.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2025_01_02.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar tier: Performance tier of the disk (e.g, P4, S10) as described here: - https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra - disks. - :vartype tier: str - :ivar bursting_enabled: Set to true to enable bursting beyond the provisioned performance - 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.v2025_01_02.models.DiskPurchasePlan - :ivar supported_capabilities: List of supported capabilities to be added on the OS disk. - :vartype supported_capabilities: ~azure.mgmt.compute.v2025_01_02.models.SupportedCapabilities - :ivar property_updates_in_progress: Properties of the disk for which update is pending. - :vartype property_updates_in_progress: - ~azure.mgmt.compute.v2025_01_02.models.PropertyUpdatesInProgress - :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. - :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2025_01_02.models.PublicNetworkAccess - :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :vartype data_access_auth_mode: str or - ~azure.mgmt.compute.v2025_01_02.models.DataAccessAuthMode - :ivar optimized_for_frequent_attach: Setting this property to true improves reliability and - performance of data disks that are frequently (more than 5 times a day) by detached from one - virtual machine and attached to another. This property should not be set for disks that are not - detached and attached frequently as it causes the disks to not align with the fault domain of - the virtual machine. - :vartype optimized_for_frequent_attach: bool - :ivar availability_policy: Determines how platform treats disk failures. - :vartype availability_policy: ~azure.mgmt.compute.v2025_01_02.models.AvailabilityPolicy - """ - - _validation = { - "property_updates_in_progress": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "DiskSku"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "disk_iops_read_write": {"key": "properties.diskIOPSReadWrite", "type": "int"}, - "disk_m_bps_read_write": {"key": "properties.diskMBpsReadWrite", "type": "int"}, - "disk_iops_read_only": {"key": "properties.diskIOPSReadOnly", "type": "int"}, - "disk_m_bps_read_only": {"key": "properties.diskMBpsReadOnly", "type": "int"}, - "max_shares": {"key": "properties.maxShares", "type": "int"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "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": "DiskPurchasePlan"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - "property_updates_in_progress": { - "key": "properties.propertyUpdatesInProgress", - "type": "PropertyUpdatesInProgress", - }, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, - "optimized_for_frequent_attach": {"key": "properties.optimizedForFrequentAttach", "type": "bool"}, - "availability_policy": {"key": "properties.availabilityPolicy", "type": "AvailabilityPolicy"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.DiskSku"] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - disk_iops_read_write: Optional[int] = None, - disk_m_bps_read_write: Optional[int] = None, - disk_iops_read_only: Optional[int] = None, - disk_m_bps_read_only: Optional[int] = None, - max_shares: Optional[int] = None, - encryption: Optional["_models.Encryption"] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - tier: Optional[str] = None, - bursting_enabled: Optional[bool] = 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, - data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, - optimized_for_frequent_attach: Optional[bool] = None, - availability_policy: Optional["_models.AvailabilityPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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.v2025_01_02.models.DiskSku - :keyword os_type: the Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2025_01_02.models.OperatingSystemTypes - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2025_01_02.models.EncryptionSettingsCollection - :keyword disk_iops_read_write: The number of IOPS allowed for this disk; only settable for - UltraSSD disks. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_write: int - :keyword disk_m_bps_read_write: The bandwidth allowed for this disk; only settable for UltraSSD - disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of - 10. - :paramtype disk_m_bps_read_write: int - :keyword disk_iops_read_only: The total number of IOPS that will be allowed across all VMs - mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes. - :paramtype disk_iops_read_only: int - :keyword disk_m_bps_read_only: The total throughput (MBps) that will be allowed across all VMs - mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses - the ISO notation, of powers of 10. - :paramtype disk_m_bps_read_only: int - :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. - Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. - :paramtype max_shares: int - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2025_01_02.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2025_01_02.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword tier: Performance tier of the disk (e.g, P4, S10) as described here: - https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra - disks. - :paramtype tier: str - :keyword bursting_enabled: Set to true to enable bursting beyond the provisioned performance - 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.v2025_01_02.models.DiskPurchasePlan - :keyword supported_capabilities: List of supported capabilities to be added on the OS disk. - :paramtype supported_capabilities: ~azure.mgmt.compute.v2025_01_02.models.SupportedCapabilities - :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. - :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2025_01_02.models.PublicNetworkAccess - :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :paramtype data_access_auth_mode: str or - ~azure.mgmt.compute.v2025_01_02.models.DataAccessAuthMode - :keyword optimized_for_frequent_attach: Setting this property to true improves reliability and - performance of data disks that are frequently (more than 5 times a day) by detached from one - virtual machine and attached to another. This property should not be set for disks that are not - detached and attached frequently as it causes the disks to not align with the fault domain of - the virtual machine. - :paramtype optimized_for_frequent_attach: bool - :keyword availability_policy: Determines how platform treats disk failures. - :paramtype availability_policy: ~azure.mgmt.compute.v2025_01_02.models.AvailabilityPolicy - """ - super().__init__(**kwargs) - self.tags = tags - self.sku = sku - self.os_type = os_type - self.disk_size_gb = disk_size_gb - self.encryption_settings_collection = encryption_settings_collection - self.disk_iops_read_write = disk_iops_read_write - self.disk_m_bps_read_write = disk_m_bps_read_write - self.disk_iops_read_only = disk_iops_read_only - self.disk_m_bps_read_only = disk_m_bps_read_only - self.max_shares = max_shares - self.encryption = encryption - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - self.tier = tier - self.bursting_enabled = bursting_enabled - self.purchase_plan = purchase_plan - self.supported_capabilities = supported_capabilities - self.property_updates_in_progress: Optional["_models.PropertyUpdatesInProgress"] = None - self.supports_hibernation = supports_hibernation - self.public_network_access = public_network_access - self.data_access_auth_mode = data_access_auth_mode - self.optimized_for_frequent_attach = optimized_for_frequent_attach - self.availability_policy = availability_policy - - -class Encryption(_serialization.Model): - """Encryption at rest settings for disk or snapshot. - - :ivar disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling - encryption at rest. - :vartype disk_encryption_set_id: str - :ivar type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and - "EncryptionAtRestWithPlatformAndCustomerKeys". - :vartype type: str or ~azure.mgmt.compute.v2025_01_02.models.EncryptionType - """ - - _attribute_map = { - "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - disk_encryption_set_id: Optional[str] = None, - type: Optional[Union[str, "_models.EncryptionType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling - encryption at rest. - :paramtype disk_encryption_set_id: str - :keyword type: The type of key used to encrypt the data of the disk. Known values are: - "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", and - "EncryptionAtRestWithPlatformAndCustomerKeys". - :paramtype type: str or ~azure.mgmt.compute.v2025_01_02.models.EncryptionType - """ - super().__init__(**kwargs) - self.disk_encryption_set_id = disk_encryption_set_id - self.type = type - - -class EncryptionSetIdentity(_serialization.Model): - """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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is - supported for new creations. Disk Encryption Sets can be updated with Identity type None during - migration of subscription to a new Azure Active Directory tenant; it will cause the encrypted - resources to lose access to the keys. Known values are: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", and "None". - :vartype type: str or ~azure.mgmt.compute.v2025_01_02.models.DiskEncryptionSetIdentityType - :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id of the Managed Identity Resource. This will be sent to the RP - from ARM via the x-ms-client-tenant-id header in the PUT request if the resource has a - systemAssigned(implicit) identity. - :vartype tenant_id: str - :ivar user_assigned_identities: The list of user identities associated with the disk encryption - set. The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2025_01_02.models.UserAssignedIdentitiesValue] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentitiesValue}"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.DiskEncryptionSetIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned - is supported for new creations. Disk Encryption Sets can be updated with Identity type None - during migration of subscription to a new Azure Active Directory tenant; it will cause the - encrypted resources to lose access to the keys. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :paramtype type: str or ~azure.mgmt.compute.v2025_01_02.models.DiskEncryptionSetIdentityType - :keyword user_assigned_identities: The list of user identities associated with the disk - encryption set. The user identity dictionary key references will be ARM resource ids in the - form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.compute.v2025_01_02.models.UserAssignedIdentitiesValue] - """ - super().__init__(**kwargs) - self.type = type - self.principal_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.user_assigned_identities = user_assigned_identities - - -class EncryptionSettingsCollection(_serialization.Model): - """Encryption settings for disk or snapshot. - - All required parameters must be populated in order to send to server. - - :ivar enabled: Set this flag to true and provide DiskEncryptionKey and optional - KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and - KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, - the existing settings remain unchanged. Required. - :vartype enabled: bool - :ivar encryption_settings: A collection of encryption settings, one for each disk volume. - :vartype encryption_settings: - list[~azure.mgmt.compute.v2025_01_02.models.EncryptionSettingsElement] - :ivar encryption_settings_version: Describes what type of encryption is used for the disks. - Once this field is set, it cannot be overwritten. '1.0' corresponds to Azure Disk Encryption - with AAD app.'1.1' corresponds to Azure Disk Encryption. - :vartype encryption_settings_version: str - """ - - _validation = { - "enabled": {"required": True}, - } - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "encryption_settings": {"key": "encryptionSettings", "type": "[EncryptionSettingsElement]"}, - "encryption_settings_version": {"key": "encryptionSettingsVersion", "type": "str"}, - } - - def __init__( - self, - *, - enabled: bool, - encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, - encryption_settings_version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Set this flag to true and provide DiskEncryptionKey and optional - KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and - KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, - the existing settings remain unchanged. Required. - :paramtype enabled: bool - :keyword encryption_settings: A collection of encryption settings, one for each disk volume. - :paramtype encryption_settings: - list[~azure.mgmt.compute.v2025_01_02.models.EncryptionSettingsElement] - :keyword encryption_settings_version: Describes what type of encryption is used for the disks. - Once this field is set, it cannot be overwritten. '1.0' corresponds to Azure Disk Encryption - with AAD app.'1.1' corresponds to Azure Disk Encryption. - :paramtype encryption_settings_version: str - """ - super().__init__(**kwargs) - self.enabled = enabled - self.encryption_settings = encryption_settings - self.encryption_settings_version = encryption_settings_version - - -class EncryptionSettingsElement(_serialization.Model): - """Encryption settings for one disk volume. - - :ivar disk_encryption_key: Key Vault Secret Url and vault id of the disk encryption key. - :vartype disk_encryption_key: ~azure.mgmt.compute.v2025_01_02.models.KeyVaultAndSecretReference - :ivar key_encryption_key: Key Vault Key Url and vault id of the key encryption key. - KeyEncryptionKey is optional and when provided is used to unwrap the disk encryption key. - :vartype key_encryption_key: ~azure.mgmt.compute.v2025_01_02.models.KeyVaultAndKeyReference - """ - - _attribute_map = { - "disk_encryption_key": {"key": "diskEncryptionKey", "type": "KeyVaultAndSecretReference"}, - "key_encryption_key": {"key": "keyEncryptionKey", "type": "KeyVaultAndKeyReference"}, - } - - def __init__( - self, - *, - disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_encryption_key: Key Vault Secret Url and vault id of the disk encryption key. - :paramtype disk_encryption_key: - ~azure.mgmt.compute.v2025_01_02.models.KeyVaultAndSecretReference - :keyword key_encryption_key: Key Vault Key Url and vault id of the key encryption key. - KeyEncryptionKey is optional and when provided is used to unwrap the disk encryption key. - :paramtype key_encryption_key: ~azure.mgmt.compute.v2025_01_02.models.KeyVaultAndKeyReference - """ - super().__init__(**kwargs) - self.disk_encryption_key = disk_encryption_key - self.key_encryption_key = key_encryption_key - - -class ExtendedLocation(_serialization.Model): - """The complex type of the extended location. - - :ivar name: The name of the extended location. - :vartype name: str - :ivar type: The type of the extended location. "EdgeZone" - :vartype type: str or ~azure.mgmt.compute.v2025_01_02.models.ExtendedLocationTypes - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the extended location. - :paramtype name: str - :keyword type: The type of the extended location. "EdgeZone" - :paramtype type: str or ~azure.mgmt.compute.v2025_01_02.models.ExtendedLocationTypes - """ - super().__init__(**kwargs) - self.name = name - self.type = type - - -class GrantAccessData(_serialization.Model): - """Data used for requesting a SAS. - - All required parameters must be populated in order to send to server. - - :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.v2025_01_02.models.AccessLevel - :ivar duration_in_seconds: Time duration in seconds until the SAS access expires. Required. - :vartype duration_in_seconds: int - :ivar get_secure_vm_guest_state_sas: Set this flag to true to get additional SAS for VM guest - state. - :vartype get_secure_vm_guest_state_sas: bool - :ivar file_format: Used to specify the file format when making request for SAS on a VHDX file - format snapshot. Known values are: "VHD" and "VHDX". - :vartype file_format: str or ~azure.mgmt.compute.v2025_01_02.models.FileFormat - """ - - _validation = { - "access": {"required": True}, - "duration_in_seconds": {"required": True}, - } - - _attribute_map = { - "access": {"key": "access", "type": "str"}, - "duration_in_seconds": {"key": "durationInSeconds", "type": "int"}, - "get_secure_vm_guest_state_sas": {"key": "getSecureVMGuestStateSAS", "type": "bool"}, - "file_format": {"key": "fileFormat", "type": "str"}, - } - - def __init__( - self, - *, - access: Union[str, "_models.AccessLevel"], - duration_in_seconds: int, - get_secure_vm_guest_state_sas: Optional[bool] = None, - file_format: Optional[Union[str, "_models.FileFormat"]] = None, - **kwargs: Any - ) -> None: - """ - :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.v2025_01_02.models.AccessLevel - :keyword duration_in_seconds: Time duration in seconds until the SAS access expires. Required. - :paramtype duration_in_seconds: int - :keyword get_secure_vm_guest_state_sas: Set this flag to true to get additional SAS for VM - guest state. - :paramtype get_secure_vm_guest_state_sas: bool - :keyword file_format: Used to specify the file format when making request for SAS on a VHDX - file format snapshot. Known values are: "VHD" and "VHDX". - :paramtype file_format: str or ~azure.mgmt.compute.v2025_01_02.models.FileFormat - """ - super().__init__(**kwargs) - self.access = access - self.duration_in_seconds = duration_in_seconds - self.get_secure_vm_guest_state_sas = get_secure_vm_guest_state_sas - self.file_format = file_format - - -class ImageDiskReference(_serialization.Model): - """The source image used for creating the disk. - - :ivar id: A relative uri containing either a Platform Image Repository, user image, or Azure - Compute Gallery image reference. - :vartype id: str - :ivar shared_gallery_image_id: A relative uri containing a direct shared Azure Compute Gallery - image reference. - :vartype shared_gallery_image_id: str - :ivar community_gallery_image_id: A relative uri containing a community Azure Compute Gallery - image reference. - :vartype community_gallery_image_id: str - :ivar lun: If the disk is created from an image's data disk, this is an index that indicates - which of the data disks in the image to use. For OS disks, this field is null. - :vartype lun: int - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "shared_gallery_image_id": {"key": "sharedGalleryImageId", "type": "str"}, - "community_gallery_image_id": {"key": "communityGalleryImageId", "type": "str"}, - "lun": {"key": "lun", "type": "int"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - shared_gallery_image_id: Optional[str] = None, - community_gallery_image_id: Optional[str] = None, - lun: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: A relative uri containing either a Platform Image Repository, user image, or Azure - Compute Gallery image reference. - :paramtype id: str - :keyword shared_gallery_image_id: A relative uri containing a direct shared Azure Compute - Gallery image reference. - :paramtype shared_gallery_image_id: str - :keyword community_gallery_image_id: A relative uri containing a community Azure Compute - Gallery image reference. - :paramtype community_gallery_image_id: str - :keyword lun: If the disk is created from an image's data disk, this is an index that indicates - which of the data disks in the image to use. For OS disks, this field is null. - :paramtype lun: int - """ - super().__init__(**kwargs) - self.id = id - self.shared_gallery_image_id = shared_gallery_image_id - self.community_gallery_image_id = community_gallery_image_id - self.lun = lun - - -class InnerError(_serialization.Model): - """Inner error details. - - :ivar exceptiontype: The exception type. - :vartype exceptiontype: str - :ivar errordetail: The internal error message or exception dump. - :vartype errordetail: str - """ - - _attribute_map = { - "exceptiontype": {"key": "exceptiontype", "type": "str"}, - "errordetail": {"key": "errordetail", "type": "str"}, - } - - def __init__( - self, *, exceptiontype: Optional[str] = None, errordetail: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword exceptiontype: The exception type. - :paramtype exceptiontype: str - :keyword errordetail: The internal error message or exception dump. - :paramtype errordetail: str - """ - super().__init__(**kwargs) - self.exceptiontype = exceptiontype - self.errordetail = errordetail - - -class KeyForDiskEncryptionSet(_serialization.Model): - """Key Vault Key Url to be used for server side encryption of Managed Disks and Snapshots. - - All required parameters must be populated in order to send to server. - - :ivar source_vault: Resource id of the KeyVault containing the key or secret. This property is - optional and cannot be used if the KeyVault subscription is not the same as the Disk Encryption - Set subscription. - :vartype source_vault: ~azure.mgmt.compute.v2025_01_02.models.SourceVault - :ivar key_url: Fully versioned Key Url pointing to a key in KeyVault. Version segment of the - Url is required regardless of rotationToLatestKeyVersionEnabled value. Required. - :vartype key_url: str - """ - - _validation = { - "key_url": {"required": True}, - } - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SourceVault"}, - "key_url": {"key": "keyUrl", "type": "str"}, - } - - def __init__(self, *, key_url: str, source_vault: Optional["_models.SourceVault"] = None, **kwargs: Any) -> None: - """ - :keyword source_vault: Resource id of the KeyVault containing the key or secret. This property - is optional and cannot be used if the KeyVault subscription is not the same as the Disk - Encryption Set subscription. - :paramtype source_vault: ~azure.mgmt.compute.v2025_01_02.models.SourceVault - :keyword key_url: Fully versioned Key Url pointing to a key in KeyVault. Version segment of the - Url is required regardless of rotationToLatestKeyVersionEnabled value. Required. - :paramtype key_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.key_url = key_url - - -class KeyVaultAndKeyReference(_serialization.Model): - """Key Vault Key Url and vault id of KeK, KeK is optional and when provided is used to unwrap the - encryptionKey. - - All required parameters must be populated in order to send to server. - - :ivar source_vault: Resource id of the KeyVault containing the key or secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2025_01_02.models.SourceVault - :ivar key_url: Url pointing to a key or secret in KeyVault. Required. - :vartype key_url: str - """ - - _validation = { - "source_vault": {"required": True}, - "key_url": {"required": True}, - } - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SourceVault"}, - "key_url": {"key": "keyUrl", "type": "str"}, - } - - def __init__(self, *, source_vault: "_models.SourceVault", key_url: str, **kwargs: Any) -> None: - """ - :keyword source_vault: Resource id of the KeyVault containing the key or secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2025_01_02.models.SourceVault - :keyword key_url: Url pointing to a key or secret in KeyVault. Required. - :paramtype key_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.key_url = key_url - - -class KeyVaultAndSecretReference(_serialization.Model): - """Key Vault Secret Url and vault id of the encryption key. - - All required parameters must be populated in order to send to server. - - :ivar source_vault: Resource id of the KeyVault containing the key or secret. Required. - :vartype source_vault: ~azure.mgmt.compute.v2025_01_02.models.SourceVault - :ivar secret_url: Url pointing to a key or secret in KeyVault. Required. - :vartype secret_url: str - """ - - _validation = { - "source_vault": {"required": True}, - "secret_url": {"required": True}, - } - - _attribute_map = { - "source_vault": {"key": "sourceVault", "type": "SourceVault"}, - "secret_url": {"key": "secretUrl", "type": "str"}, - } - - def __init__(self, *, source_vault: "_models.SourceVault", secret_url: str, **kwargs: Any) -> None: - """ - :keyword source_vault: Resource id of the KeyVault containing the key or secret. Required. - :paramtype source_vault: ~azure.mgmt.compute.v2025_01_02.models.SourceVault - :keyword secret_url: Url pointing to a key or secret in KeyVault. Required. - :paramtype secret_url: str - """ - super().__init__(**kwargs) - self.source_vault = source_vault - self.secret_url = secret_url - - -class PrivateEndpoint(_serialization.Model): - """The Private Endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ARM identifier for Private Endpoint. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -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: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :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.v2025_01_02.models.SystemData - :ivar private_endpoint: The resource of private end point. - :vartype private_endpoint: ~azure.mgmt.compute.v2025_01_02.models.PrivateEndpoint - :ivar private_link_service_connection_state: A collection of information about the state of the - connection between DiskAccess and Virtual Network. - :vartype private_link_service_connection_state: - ~azure.mgmt.compute.v2025_01_02.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.compute.v2025_01_02.models.PrivateEndpointConnectionProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "private_endpoint": {"readonly": True}, - "provisioning_state": {"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"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionState", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_link_service_connection_state: A collection of information about the state of - the connection between DiskAccess and Virtual Network. - :paramtype private_link_service_connection_state: - ~azure.mgmt.compute.v2025_01_02.models.PrivateLinkServiceConnectionState - """ - super().__init__(**kwargs) - self.private_endpoint: Optional["_models.PrivateEndpoint"] = None - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = None - - -class PrivateEndpointConnectionListResult(_serialization.Model): - """A list of private link resources. - - 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.v2025_01_02.models.PrivateEndpointConnection] - :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: List["_models.PrivateEndpointConnection"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The PrivateEndpointConnection items on this page. Required. - :paramtype value: list[~azure.mgmt.compute.v2025_01_02.models.PrivateEndpointConnection] - :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 PrivateLinkResource(_serialization.Model): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: private link resource Id. - :vartype id: str - :ivar name: private link resource name. - :vartype name: str - :ivar type: private link resource type. - :vartype type: str - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - :ivar required_zone_names: The private link resource DNS zone name. - :vartype required_zone_names: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "group_id": {"readonly": True}, - "required_members": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "group_id": {"key": "properties.groupId", "type": "str"}, - "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, - } - - def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword required_zone_names: The private link resource DNS zone name. - :paramtype required_zone_names: list[str] - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.group_id: Optional[str] = None - self.required_members: Optional[List[str]] = None - self.required_zone_names = required_zone_names - - -class PrivateLinkResourceListResult(_serialization.Model): - """A list of private link resources. - - :ivar value: Array of private link resources. - :vartype value: list[~azure.mgmt.compute.v2025_01_02.models.PrivateLinkResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateLinkResource]"}, - } - - def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Array of private link resources. - :paramtype value: list[~azure.mgmt.compute.v2025_01_02.models.PrivateLinkResource] - """ - super().__init__(**kwargs) - self.value = value - - -class PrivateLinkServiceConnectionState(_serialization.Model): - """A collection of information about the state of the connection between service consumer and - provider. - - :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", and "Rejected". - :vartype status: str or - ~azure.mgmt.compute.v2025_01_02.models.PrivateEndpointServiceConnectionStatus - :ivar description: The reason for approval/rejection of the connection. - :vartype description: str - :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :vartype actions_required: str - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", and "Rejected". - :paramtype status: str or - ~azure.mgmt.compute.v2025_01_02.models.PrivateEndpointServiceConnectionStatus - :keyword description: The reason for approval/rejection of the connection. - :paramtype description: str - :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :paramtype actions_required: str - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required = actions_required - - -class PropertyUpdatesInProgress(_serialization.Model): - """Properties of the disk for which update is pending. - - :ivar target_tier: The target performance tier of the disk if a tier change operation is in - progress. - :vartype target_tier: str - """ - - _attribute_map = { - "target_tier": {"key": "targetTier", "type": "str"}, - } - - def __init__(self, *, target_tier: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword target_tier: The target performance tier of the disk if a tier change operation is in - progress. - :paramtype target_tier: str - """ - super().__init__(**kwargs) - self.target_tier = target_tier - - -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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.location = location - self.tags = tags - - -class ResourceUriList(_serialization.Model): - """The List resources which are encrypted with the disk encryption set. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of IDs or Owner IDs of resources which are encrypted with the disk - encryption set. Required. - :vartype value: list[str] - :ivar next_link: The uri to fetch the next page of encrypted resources. Call ListNext() with - this to fetch the next page of encrypted resources. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[str]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List[str], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of IDs or Owner IDs of resources which are encrypted with the disk - encryption set. Required. - :paramtype value: list[str] - :keyword next_link: The uri to fetch the next page of encrypted resources. Call ListNext() with - this to fetch the next page of encrypted resources. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ResourceWithOptionalLocation(_serialization.Model): - """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: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.tags = tags - - -class ShareInfoElement(_serialization.Model): - """ShareInfoElement. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar vm_uri: A relative URI containing the ID of the VM that has the disk attached. - :vartype vm_uri: str - """ - - _validation = { - "vm_uri": {"readonly": True}, - } - - _attribute_map = { - "vm_uri": {"key": "vmUri", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.vm_uri: Optional[str] = None - - -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: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :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.v2025_01_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 - an optional parameter for incremental snapshot and the default behavior is the SKU will be set - to the same sku as the previous snapshot. - :vartype sku: ~azure.mgmt.compute.v2025_01_02.models.SnapshotSku - :ivar extended_location: The extended location where the snapshot will be created. Extended - location cannot be changed. - :vartype extended_location: ~azure.mgmt.compute.v2025_01_02.models.ExtendedLocation - :ivar time_created: The time when the snapshot was created. - :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2025_01_02.models.OperatingSystemTypes - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2025_01_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.v2025_01_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.v2025_01_02.models.SupportedCapabilities - :ivar creation_data: Disk source information. CreationData information cannot be changed after - the disk has been created. - :vartype creation_data: ~azure.mgmt.compute.v2025_01_02.models.CreationData - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. - :vartype disk_size_bytes: int - :ivar disk_state: The state of the snapshot. Known values are: "Unattached", "Attached", - "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", and "ActiveUpload". - :vartype disk_state: str or ~azure.mgmt.compute.v2025_01_02.models.DiskState - :ivar unique_id: Unique Guid identifying the resource. - :vartype unique_id: str - :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2025_01_02.models.EncryptionSettingsCollection - :ivar provisioning_state: The disk provisioning state. - :vartype provisioning_state: str - :ivar incremental: Whether a snapshot is incremental. Incremental snapshots on the same disk - occupy less space than full snapshots and can be diffed. - :vartype incremental: bool - :ivar incremental_snapshot_family_id: Incremental snapshots for a disk share an incremental - snapshot family id. The Get Page Range Diff API can only be called on incremental snapshots - with the same family id. - :vartype incremental_snapshot_family_id: str - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2025_01_02.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2025_01_02.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar security_profile: Contains the security related information for the resource. - :vartype security_profile: ~azure.mgmt.compute.v2025_01_02.models.DiskSecurityProfile - :ivar supports_hibernation: Indicates the OS on a snapshot supports hibernation. - :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2025_01_02.models.PublicNetworkAccess - :ivar completion_percent: Percentage complete for the background copy when a resource is - created via the CopyStart operation. - :vartype completion_percent: float - :ivar copy_completion_error: Indicates the error details if the background copy of a resource - created via the CopyStart operation fails. - :vartype copy_completion_error: ~azure.mgmt.compute.v2025_01_02.models.CopyCompletionError - :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :vartype data_access_auth_mode: str or - ~azure.mgmt.compute.v2025_01_02.models.DataAccessAuthMode - :ivar snapshot_access_state: The state of snapshot which determines the access availability of - the snapshot. Known values are: "Unknown", "Pending", "Available", "InstantAccess", and - "AvailableWithInstantAccess". - :vartype snapshot_access_state: str or - ~azure.mgmt.compute.v2025_01_02.models.SnapshotAccessState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - "managed_by": {"readonly": True}, - "time_created": {"readonly": True}, - "disk_size_bytes": {"readonly": True}, - "disk_state": {"readonly": True}, - "unique_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "incremental_snapshot_family_id": {"readonly": True}, - "snapshot_access_state": {"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"}, - "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": "DiskPurchasePlan"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - "creation_data": {"key": "properties.creationData", "type": "CreationData"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "disk_size_bytes": {"key": "properties.diskSizeBytes", "type": "int"}, - "disk_state": {"key": "properties.diskState", "type": "str"}, - "unique_id": {"key": "properties.uniqueId", "type": "str"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "incremental": {"key": "properties.incremental", "type": "bool"}, - "incremental_snapshot_family_id": {"key": "properties.incrementalSnapshotFamilyId", "type": "str"}, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - "security_profile": {"key": "properties.securityProfile", "type": "DiskSecurityProfile"}, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "completion_percent": {"key": "properties.completionPercent", "type": "float"}, - "copy_completion_error": {"key": "properties.copyCompletionError", "type": "CopyCompletionError"}, - "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, - "snapshot_access_state": {"key": "properties.snapshotAccessState", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.SnapshotSku"] = None, - 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.DiskPurchasePlan"] = None, - supported_capabilities: Optional["_models.SupportedCapabilities"] = None, - creation_data: Optional["_models.CreationData"] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - incremental: Optional[bool] = None, - encryption: Optional["_models.Encryption"] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - security_profile: Optional["_models.DiskSecurityProfile"] = None, - supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - completion_percent: Optional[float] = None, - copy_completion_error: Optional["_models.CopyCompletionError"] = None, - data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, - **kwargs: Any - ) -> None: - """ - :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. - :paramtype sku: ~azure.mgmt.compute.v2025_01_02.models.SnapshotSku - :keyword extended_location: The extended location where the snapshot will be created. Extended - location cannot be changed. - :paramtype extended_location: ~azure.mgmt.compute.v2025_01_02.models.ExtendedLocation - :keyword os_type: The Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2025_01_02.models.OperatingSystemTypes - :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.v2025_01_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.v2025_01_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.v2025_01_02.models.SupportedCapabilities - :keyword creation_data: Disk source information. CreationData information cannot be changed - after the disk has been created. - :paramtype creation_data: ~azure.mgmt.compute.v2025_01_02.models.CreationData - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2025_01_02.models.EncryptionSettingsCollection - :keyword incremental: Whether a snapshot is incremental. Incremental snapshots on the same disk - occupy less space than full snapshots and can be diffed. - :paramtype incremental: bool - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2025_01_02.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2025_01_02.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword security_profile: Contains the security related information for the resource. - :paramtype security_profile: ~azure.mgmt.compute.v2025_01_02.models.DiskSecurityProfile - :keyword supports_hibernation: Indicates the OS on a snapshot supports hibernation. - :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2025_01_02.models.PublicNetworkAccess - :keyword completion_percent: Percentage complete for the background copy when a resource is - created via the CopyStart operation. - :paramtype completion_percent: float - :keyword copy_completion_error: Indicates the error details if the background copy of a - resource created via the CopyStart operation fails. - :paramtype copy_completion_error: ~azure.mgmt.compute.v2025_01_02.models.CopyCompletionError - :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :paramtype data_access_auth_mode: str or - ~azure.mgmt.compute.v2025_01_02.models.DataAccessAuthMode - """ - super().__init__(tags=tags, location=location, **kwargs) - self.managed_by: Optional[str] = None - self.sku = sku - self.extended_location = extended_location - self.time_created: Optional[datetime.datetime] = None - self.os_type = os_type - self.hyper_v_generation = hyper_v_generation - self.purchase_plan = purchase_plan - self.supported_capabilities = supported_capabilities - self.creation_data = creation_data - self.disk_size_gb = disk_size_gb - self.disk_size_bytes: Optional[int] = None - self.disk_state: Optional[Union[str, "_models.DiskState"]] = None - self.unique_id: Optional[str] = None - self.encryption_settings_collection = encryption_settings_collection - self.provisioning_state: Optional[str] = None - self.incremental = incremental - self.incremental_snapshot_family_id: Optional[str] = None - self.encryption = encryption - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - self.security_profile = security_profile - self.supports_hibernation = supports_hibernation - self.public_network_access = public_network_access - self.completion_percent = completion_percent - self.copy_completion_error = copy_completion_error - self.data_access_auth_mode = data_access_auth_mode - self.snapshot_access_state: Optional[Union[str, "_models.SnapshotAccessState"]] = None - - -class SnapshotList(_serialization.Model): - """The List Snapshots operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of snapshots. Required. - :vartype value: list[~azure.mgmt.compute.v2025_01_02.models.Snapshot] - :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": "[Snapshot]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of snapshots. Required. - :paramtype value: list[~azure.mgmt.compute.v2025_01_02.models.Snapshot] - :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 SnapshotSku(_serialization.Model): - """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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", and "Standard_ZRS". - :vartype name: str or ~azure.mgmt.compute.v2025_01_02.models.SnapshotStorageAccountTypes - :ivar tier: The sku tier. - :vartype tier: str - """ - - _validation = { - "tier": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__( - self, *, name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs: Any - ) -> None: - """ - :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", and - "Standard_ZRS". - :paramtype name: str or ~azure.mgmt.compute.v2025_01_02.models.SnapshotStorageAccountTypes - """ - super().__init__(**kwargs) - self.name = name - self.tier: Optional[str] = None - - -class SnapshotUpdate(_serialization.Model): - """Snapshot update resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar 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. - :vartype sku: ~azure.mgmt.compute.v2025_01_02.models.SnapshotSku - :ivar os_type: the Operating System type. Known values are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.compute.v2025_01_02.models.OperatingSystemTypes - :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :vartype disk_size_gb: int - :ivar encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :vartype encryption_settings_collection: - ~azure.mgmt.compute.v2025_01_02.models.EncryptionSettingsCollection - :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed - keys or platform managed keys. - :vartype encryption: ~azure.mgmt.compute.v2025_01_02.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :vartype network_access_policy: str or - ~azure.mgmt.compute.v2025_01_02.models.NetworkAccessPolicy - :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. - :vartype disk_access_id: str - :ivar supports_hibernation: Indicates the OS on a snapshot supports hibernation. - :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.compute.v2025_01_02.models.PublicNetworkAccess - :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :vartype data_access_auth_mode: str or - ~azure.mgmt.compute.v2025_01_02.models.DataAccessAuthMode - :ivar supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :vartype supported_capabilities: ~azure.mgmt.compute.v2025_01_02.models.SupportedCapabilities - :ivar snapshot_access_state: The state of snapshot which determines the access availability of - the snapshot. Known values are: "Unknown", "Pending", "Available", "InstantAccess", and - "AvailableWithInstantAccess". - :vartype snapshot_access_state: str or - ~azure.mgmt.compute.v2025_01_02.models.SnapshotAccessState - """ - - _validation = { - "snapshot_access_state": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "SnapshotSku"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, - "encryption_settings_collection": { - "key": "properties.encryptionSettingsCollection", - "type": "EncryptionSettingsCollection", - }, - "encryption": {"key": "properties.encryption", "type": "Encryption"}, - "network_access_policy": {"key": "properties.networkAccessPolicy", "type": "str"}, - "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, - "supports_hibernation": {"key": "properties.supportsHibernation", "type": "bool"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "data_access_auth_mode": {"key": "properties.dataAccessAuthMode", "type": "str"}, - "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, - "snapshot_access_state": {"key": "properties.snapshotAccessState", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.SnapshotSku"] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, - encryption: Optional["_models.Encryption"] = None, - network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, - disk_access_id: Optional[str] = None, - supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, - data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, - supported_capabilities: Optional["_models.SupportedCapabilities"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, 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. - :paramtype sku: ~azure.mgmt.compute.v2025_01_02.models.SnapshotSku - :keyword os_type: the Operating System type. Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2025_01_02.models.OperatingSystemTypes - :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it - indicates the size of the disk to create. If this field is present for updates or creation with - other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a - running VM, and can only increase the disk's size. - :paramtype disk_size_gb: int - :keyword encryption_settings_collection: Encryption settings collection used be Azure Disk - Encryption, can contain multiple encryption settings per disk or snapshot. - :paramtype encryption_settings_collection: - ~azure.mgmt.compute.v2025_01_02.models.EncryptionSettingsCollection - :keyword encryption: Encryption property can be used to encrypt data at rest with customer - managed keys or platform managed keys. - :paramtype encryption: ~azure.mgmt.compute.v2025_01_02.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Known values are: - "AllowAll", "AllowPrivate", and "DenyAll". - :paramtype network_access_policy: str or - ~azure.mgmt.compute.v2025_01_02.models.NetworkAccessPolicy - :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on - disks. - :paramtype disk_access_id: str - :keyword supports_hibernation: Indicates the OS on a snapshot supports hibernation. - :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Known values are: - "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.compute.v2025_01_02.models.PublicNetworkAccess - :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". - :paramtype data_access_auth_mode: str or - ~azure.mgmt.compute.v2025_01_02.models.DataAccessAuthMode - :keyword supported_capabilities: List of supported capabilities for the image from which the OS - disk was created. - :paramtype supported_capabilities: ~azure.mgmt.compute.v2025_01_02.models.SupportedCapabilities - """ - super().__init__(**kwargs) - self.tags = tags - self.sku = sku - self.os_type = os_type - self.disk_size_gb = disk_size_gb - self.encryption_settings_collection = encryption_settings_collection - self.encryption = encryption - self.network_access_policy = network_access_policy - self.disk_access_id = disk_access_id - self.supports_hibernation = supports_hibernation - self.public_network_access = public_network_access - self.data_access_auth_mode = data_access_auth_mode - self.supported_capabilities = supported_capabilities - self.snapshot_access_state: Optional[Union[str, "_models.SnapshotAccessState"]] = None - - -class SourceVault(_serialization.Model): - """The vault id is an Azure Resource Manager Resource id in the form - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class SubResource(_serialization.Model): - """SubResource. - - :ivar id: Resource Id. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource Id. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class SubResourceReadOnly(_serialization.Model): - """SubResourceReadOnly. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class SupportedCapabilities(_serialization.Model): - """List of supported capabilities persisted on the disk resource for VM use. - - :ivar disk_controller_types: The disk controllers that an OS disk supports. If set it can be - SCSI or SCSI, NVME or NVME, SCSI. - :vartype disk_controller_types: str - :ivar accelerated_network: True if the image from which the OS disk is created supports - accelerated networking. - :vartype accelerated_network: bool - :ivar architecture: CPU architecture supported by an OS disk. Known values are: "x64" and - "Arm64". - :vartype architecture: str or ~azure.mgmt.compute.v2025_01_02.models.Architecture - :ivar supported_security_option: Refers to the security capability of the disk supported to - create a Trusted launch or Confidential VM. Known values are: "TrustedLaunchSupported" and - "TrustedLaunchAndConfidentialVMSupported". - :vartype supported_security_option: str or - ~azure.mgmt.compute.v2025_01_02.models.SupportedSecurityOption - """ - - _attribute_map = { - "disk_controller_types": {"key": "diskControllerTypes", "type": "str"}, - "accelerated_network": {"key": "acceleratedNetwork", "type": "bool"}, - "architecture": {"key": "architecture", "type": "str"}, - "supported_security_option": {"key": "supportedSecurityOption", "type": "str"}, - } - - def __init__( - self, - *, - disk_controller_types: Optional[str] = None, - accelerated_network: Optional[bool] = None, - architecture: Optional[Union[str, "_models.Architecture"]] = None, - supported_security_option: Optional[Union[str, "_models.SupportedSecurityOption"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword disk_controller_types: The disk controllers that an OS disk supports. If set it can be - SCSI or SCSI, NVME or NVME, SCSI. - :paramtype disk_controller_types: str - :keyword accelerated_network: True if the image from which the OS disk is created supports - accelerated networking. - :paramtype accelerated_network: bool - :keyword architecture: CPU architecture supported by an OS disk. Known values are: "x64" and - "Arm64". - :paramtype architecture: str or ~azure.mgmt.compute.v2025_01_02.models.Architecture - :keyword supported_security_option: Refers to the security capability of the disk supported to - create a Trusted launch or Confidential VM. Known values are: "TrustedLaunchSupported" and - "TrustedLaunchAndConfidentialVMSupported". - :paramtype supported_security_option: str or - ~azure.mgmt.compute.v2025_01_02.models.SupportedSecurityOption - """ - super().__init__(**kwargs) - self.disk_controller_types = disk_controller_types - self.accelerated_network = accelerated_network - self.architecture = architecture - self.supported_security_option = supported_security_option - - -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.v2025_01_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.v2025_01_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.v2025_01_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.v2025_01_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. - - :ivar created_at: Specifies the time in UTC at which the Cloud Service (extended support) - resource was created. :code:`
    `Minimum api-version: 2022-04-04. - :vartype created_at: ~datetime.datetime - :ivar last_modified_at: Specifies the time in UTC at which the Cloud Service (extended support) - resource was last modified. :code:`
    `Minimum api-version: 2022-04-04. - :vartype last_modified_at: ~datetime.datetime - """ - - _validation = { - "created_at": {"readonly": True}, - "last_modified_at": {"readonly": True}, - } - - _attribute_map = { - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.created_at: Optional[datetime.datetime] = None - self.last_modified_at: Optional[datetime.datetime] = None - - -class UserAssignedIdentitiesValue(_serialization.Model): - """UserAssignedIdentitiesValue. - - 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: Optional[str] = None - self.client_id: Optional[str] = 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: Optional[str] = None - self.client_id: Optional[str] = None diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/operations/__init__.py deleted file mode 100644 index e14bc6862637..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/operations/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import DiskAccessesOperations # type: ignore -from ._operations import DiskEncryptionSetsOperations # 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__ = [ - "DiskAccessesOperations", - "DiskEncryptionSetsOperations", - "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/v2025_01_02/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/operations/_operations.py deleted file mode 100644 index 1948056444b5..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/operations/_operations.py +++ /dev/null @@ -1,6126 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import ComputeManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -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", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses") - path_format_arguments = { - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 - 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", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses", - ) - 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 - ), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", - ) - 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 - ), - "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_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_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", "2025-01-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}", - ) - 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 - ), - "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_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_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", "2025-01-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}", - ) - 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 - ), - "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", - ) - 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 - ), - "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_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) - - -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", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections", - ) - 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 - ), - "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_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_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", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - 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 - ), - "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 - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-01-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}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - 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 - ), - "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 - - # 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_disk_accesses_delete_a_private_endpoint_connection_request( # pylint: disable=name-too-long - resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - 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 - ), - "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 - - # 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) - - -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", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privatelinkresources", - ) - 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 - ), - "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") - path_format_arguments = { - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets", - ) - 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 - ), - } - - _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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", - ) - 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 - ), - "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_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_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", "2025-01-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}", - ) - 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 - ), - "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-01-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}", - ) - 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 - ), - "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", - ) - 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 - ), - "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_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) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}/associatedResources", - ) - 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 - ), - "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") - path_format_arguments = { - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks", - ) - 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 - ), - } - - _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_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", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", - ) - 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 - ), - "diskName": _SERIALIZER.url("disk_name", disk_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_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", "2025-01-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}", - ) - 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 - ), - "diskName": _SERIALIZER.url("disk_name", disk_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_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", "2025-01-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}", - ) - 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 - ), - "diskName": _SERIALIZER.url("disk_name", disk_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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", - ) - 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 - ), - "diskName": _SERIALIZER.url("disk_name", disk_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) - - -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", "2025-01-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", - ) - 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 - ), - "diskName": _SERIALIZER.url("disk_name", disk_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="POST", 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 -) -> 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", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess", - ) - 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 - ), - "diskName": _SERIALIZER.url("disk_name", disk_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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") - path_format_arguments = { - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots", - ) - 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 - ), - } - - _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_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", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", - ) - 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 - ), - "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_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_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", "2025-01-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}", - ) - 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 - ), - "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_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_snapshots_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", "2025-01-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}", - ) - 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 - ), - "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_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_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", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", - ) - 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 - ), - "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_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) - - -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", "2025-01-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}/beginGetAccess", - ) - 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 - ), - "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_snapshots_revoke_access_request( - resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-01-02")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess", - ) - 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 - ), - "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_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="POST", 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 -) -> 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", "2025-01-02")) - 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", - ) - 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 - ), - "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 - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-01-02")) - 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}", - ) - 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 - ), - "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 - - # 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-01-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", - ) - 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 - ), - "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 - - # 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_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", "2025-01-02")) - 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", - ) - 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 - ), - "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 - - # Construct parameters - _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) - - -class DiskAccessesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2025_01_02.ComputeManagementClient`'s - :attr:`disk_accesses` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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.v2025_01_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 "2025-01-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) -> ItemPaged["_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.v2025_01_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 "2025-01-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.v2025_01_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 "2025-01-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_access_name: str, - disk_access: Union[_models.DiskAccess, 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 "2025-01-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access - else: - _json = self._serialize.body(disk_access, "DiskAccess") - - _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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccess, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. - - :param resource_group_name: The name of the resource group. 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. - Required. - :type disk_access: ~azure.mgmt.compute.v2025_01_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.v2025_01_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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. - 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.v2025_01_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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.v2025_01_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.v2025_01_02.models.DiskAccess] - :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 "2025-01-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) - - 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 - - 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.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 - ) - - def _update_initial( - 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, - 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 "2025-01-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access - else: - _json = self._serialize.body(disk_access, "DiskAccessUpdate") - - _request = build_disk_accesses_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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccessUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Updates (patches) 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 - :param disk_access: disk access object supplied in the body of the Patch disk access operation. - Required. - :type disk_access: ~azure.mgmt.compute.v2025_01_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 DiskAccess or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2025_01_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Updates (patches) 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 - :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 DiskAccess or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2025_01_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - 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. 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.v2025_01_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.v2025_01_02.models.DiskAccess] - :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 "2025-01-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._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) - - 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 - - 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.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 - ) - - def _delete_initial(self, resource_group_name: str, disk_access_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 "2025-01-02")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disk_accesses_delete_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) - - _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_access_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes 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 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 "2025-01-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 - - 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_private_endpoint_connections( - self, resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> ItemPaged["_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.v2025_01_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 "2025-01-02")) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_accesses_list_private_endpoint_connections_request( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @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. 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.v2025_01_02.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2025-01-02")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_disk_accesses_get_a_private_endpoint_connection_request( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _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 - ) -> 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 "2025-01-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(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 = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_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 - ) -> 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. 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.v2025_01_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 PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2025_01_02.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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 - ) -> 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. 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] - :keyword content_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.v2025_01_02.models.PrivateEndpointConnection] - :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. - - :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.v2025_01_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.v2025_01_02.models.PrivateEndpointConnection] - :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 "2025-01-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, 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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - 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 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.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # 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]: - 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 "2025-01-02")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disk_accesses_delete_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) - - _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_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. The name is case insensitive. - Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2025-01-02")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_a_private_endpoint_connection_initial( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get_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.v2025_01_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 "2025-01-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 = 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 - - -class DiskEncryptionSetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2025_01_02.ComputeManagementClient`'s - :attr:`disk_encryption_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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.v2025_01_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 "2025-01-02")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.DiskEncryptionSet"]: - """Lists all the disk encryption sets under a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either DiskEncryptionSet or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2025_01_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 "2025-01-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 - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any) -> _models.DiskEncryptionSet: - """Gets information about a disk encryption set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :return: DiskEncryptionSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2025_01_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 "2025-01-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 _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 "2025-01-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set - else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") - - _request = build_disk_encryption_sets_create_or_update_request( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. 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.v2025_01_02.models.DiskEncryptionSet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2025_01_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2025_01_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :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.v2025_01_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.v2025_01_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 "2025-01-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._create_or_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 _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, - 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 "2025-01-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( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_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. 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.v2025_01_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.v2025_01_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. 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.v2025_01_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.v2025_01_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.v2025_01_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 "2025-01-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 "2025-01-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 "2025-01-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_associated_resources( - self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> ItemPaged[str]: - """Lists all resources that are encrypted with this 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 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 "2025-01-02")) - cls: ClsType[_models.ResourceUriList] = 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_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, - 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("ResourceUriList", 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 DisksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2025_01_02.ComputeManagementClient`'s - :attr:`disks` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_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.paging.ItemPaged[~azure.mgmt.compute.v2025_01_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 "2025-01-02")) - cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disks_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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 list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Disk"]: - """Lists all the disks under a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :return: An iterator like instance of either Disk or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2025_01_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 "2025-01-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.v2025_01_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 "2025-01-02")) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) - - _request = build_disks_get_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) - - _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("Disk", 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 - ) -> 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 "2025-01-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, (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_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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_name: str, - disk: _models.Disk, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_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.v2025_01_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 Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2025_01_02.models.Disk] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_name: str, - disk: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_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 LROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2025_01_02.models.Disk] - :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. - - :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.v2025_01_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.v2025_01_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 "2025-01-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._create_or_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 _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, - 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 "2025-01-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, (IOBase, bytes)): - _content = disk - else: - _json = self._serialize.body(disk, "DiskUpdate") - - _request = build_disks_update_request( - resource_group_name=resource_group_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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_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.v2025_01_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.v2025_01_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.v2025_01_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.v2025_01_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.v2025_01_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 "2025-01-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, - 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 "2025-01-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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_name: str, **kwargs: Any) -> LROPoller[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 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 "2025-01-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_name=disk_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 _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, - 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 "2025-01-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disks_grant_access_request( - resource_group_name=resource_group_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) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_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.v2025_01_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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2025_01_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_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: IO[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.v2025_01_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_grant_access( - self, - resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_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. Is either a GrantAccessData type or a IO[bytes] type. Required. - :type grant_access_data: ~azure.mgmt.compute.v2025_01_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.v2025_01_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 "2025-01-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, - disk_name=disk_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, 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2025-01-02")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disks_revoke_access_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]: - 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_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. 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 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 "2025-01-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._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 - ) - 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 SnapshotsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2025_01_02.ComputeManagementClient`'s - :attr:`snapshots` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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) -> ItemPaged["_models.Snapshot"]: - """Lists snapshots under a subscription. - - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2025_01_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 "2025-01-02")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - 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) -> ItemPaged["_models.Snapshot"]: - """Lists snapshots 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 Snapshot or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2025_01_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 "2025-01-02")) - cls: ClsType[_models.SnapshotList] = 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_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) - - 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("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) - - 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, snapshot_name: str, **kwargs: Any) -> _models.Snapshot: - """Gets information about 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: Snapshot or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2025_01_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 "2025-01-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 _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, - 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 "2025-01-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "Snapshot") - - _request = build_snapshots_create_or_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.Snapshot, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. 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.v2025_01_02.models.Snapshot - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2025_01_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :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.v2025_01_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. 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.v2025_01_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.v2025_01_02.models.Snapshot] - :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 "2025-01-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._create_or_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 _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, - 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 "2025-01-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "SnapshotUpdate") - - _request = build_snapshots_update_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.SnapshotUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. - Required. - :type snapshot: ~azure.mgmt.compute.v2025_01_02.models.SnapshotUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2025_01_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. - Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2025_01_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. Is - either a SnapshotUpdate type or a IO[bytes] type. Required. - :type snapshot: ~azure.mgmt.compute.v2025_01_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.v2025_01_02.models.Snapshot] - :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 "2025-01-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 "2025-01-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 "2025-01-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, - snapshot_name=snapshot_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 _grant_access_initial( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, 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 "2025-01-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_snapshots_grant_access_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: _models.GrantAccessData, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param grant_access_data: Access data object supplied in the body of the get snapshot access - operation. Required. - :type grant_access_data: ~azure.mgmt.compute.v2025_01_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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2025_01_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param 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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2025_01_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_grant_access( - self, - resource_group_name: str, - snapshot_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param 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.v2025_01_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.v2025_01_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 "2025-01-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, - snapshot_name=snapshot_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, 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 "2025-01-02")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_snapshots_revoke_access_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]: - 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_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. 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 "2025-01-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._revoke_access_initial( - resource_group_name=resource_group_name, - snapshot_name=snapshot_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 DiskRestorePointOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2025_01_02.ComputeManagementClient`'s - :attr:`disk_restore_point` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: ComputeManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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_restore_point( - self, resource_group_name: str, restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :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.v2025_01_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 "2025-01-02")) - cls: ClsType[_models.DiskRestorePointList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_restore_point_list_by_restore_point_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DiskRestorePointList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @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. - - :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.v2025_01_02.models.DiskRestorePoint - :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 "2025-01-02")) - cls: ClsType[_models.DiskRestorePoint] = kwargs.pop("cls", None) - - _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) - - _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 - - 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 - ) -> 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 "2025-01-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(grant_access_data, (IOBase, bytes)): - _content = grant_access_data - else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") - - _request = build_disk_restore_point_grant_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_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: _models.GrantAccessData, - *, - 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. 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 - :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.v2025_01_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 AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2025_01_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - 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: 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. 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 - :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.v2025_01_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. 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 - :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.v2025_01_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.v2025_01_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 "2025-01-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 "2025-01-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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = 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_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. 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: 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 "2025-01-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._revoke_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, - 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2025_01_02/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_multi_role.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_multi_role.py index bf3a8452b426..b1f6d5819e32 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_multi_role.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_multi_role.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_multi_role_with_zones.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_multi_role_with_zones.py index d57098825ef3..a33c60aacba0 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_multi_role_with_zones.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_multi_role_with_zones.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_single_role.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_single_role.py index 86e162ab72e4..7da75e34b09c 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_single_role.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_single_role.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_single_role_and_certificate.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_single_role_and_certificate.py index af69aef19276..3b89b3ccd0c9 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_single_role_and_certificate.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_single_role_and_certificate.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_single_role_and_rdp.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_single_role_and_rdp.py index 7ab165b9c9e8..4232f304eb55 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_single_role_and_rdp.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_create_with_single_role_and_rdp.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_delete.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_delete.py index 2851b5b04159..d90f4be001f6 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_delete.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_get_instance_view_with_multi_role.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_get_instance_view_with_multi_role.py index bf29b73f203c..c0807e229ca4 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_get_instance_view_with_multi_role.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_get_instance_view_with_multi_role.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_get_with_multi_role_and_rdp.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_get_with_multi_role_and_rdp.py index 9b55d77c548a..79bc4b57d8b6 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_get_with_multi_role_and_rdp.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_get_with_multi_role_and_rdp.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_list_by_resource_group.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_list_by_resource_group.py index d6dd72634a30..560e851c2663 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_list_by_resource_group.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_list_by_resource_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_list_by_subscription.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_list_by_subscription.py index b6f2275d3fcf..974f898952fd 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_list_by_subscription.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_list_by_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_os_families_list.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_os_families_list.py index 9b3e32b5a128..28355d769fd5 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_os_families_list.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_os_families_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_os_family_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_os_family_get.py index 49bad03daf85..e75f605526d9 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_os_family_get.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_os_family_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_os_version_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_os_version_get.py index 95a788765ee0..45e42980d9fb 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_os_version_get.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_os_version_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_os_version_list.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_os_version_list.py index 8cba44e533f3..ca6548120c96 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_os_version_list.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_os_version_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_power_off.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_power_off.py index 0fc51f290487..0a50f23c3ad6 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_power_off.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_power_off.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_get.py index e16ce8b338cf..b24b53535af1 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_get.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_delete.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_delete.py index 4e596e423902..c9626f7888fb 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_delete.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_delete_by_cloud_service.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_delete_by_cloud_service.py index bf45db6f130b..34ad242eb72a 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_delete_by_cloud_service.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_delete_by_cloud_service.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_get.py index 6236d2409659..4d4680a92418 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_get.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_get_instance_view.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_get_instance_view.py index c27e710d4bf5..22f3e69e7de2 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_get_instance_view.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_get_instance_view.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_get_remote_desktop_file.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_get_remote_desktop_file.py index 5f122dd40bc5..8bc5597d91b9 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_get_remote_desktop_file.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_get_remote_desktop_file.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_rebuild.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_rebuild.py index 5c7e04dcd164..49fcbed0d45f 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_rebuild.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_rebuild.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_rebuild_by_cloud_service.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_rebuild_by_cloud_service.py index ebd2113a3901..0d7bd42e4c22 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_rebuild_by_cloud_service.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_rebuild_by_cloud_service.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_reimage.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_reimage.py index a4081cb64ebd..9423eec9b8e2 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_reimage.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_reimage.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_reimage_by_cloud_service.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_reimage_by_cloud_service.py index 539fa11c3f93..f083223b9f90 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_reimage_by_cloud_service.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_reimage_by_cloud_service.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_restart.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_restart.py index 6c36d7239411..c3e43a744084 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_restart.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_restart.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_restart_by_cloud_service.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_restart_by_cloud_service.py index f0c5b3eabd81..56ce358e4f6d 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_restart_by_cloud_service.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_instance_restart_by_cloud_service.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_list.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_list.py index 0ecc989267ef..63a0cbe33bb7 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_list.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_role_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_roles_instance_list.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_roles_instance_list.py index cce48fed1e7c..485af911d58e 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_roles_instance_list.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_roles_instance_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_start.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_start.py index cdc2f6174d63..2c476b3329f5 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_start.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_start.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_update_domain_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_update_domain_get.py index dc4235f6dfd6..089858e36412 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_update_domain_get.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_update_domain_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_update_domain_list.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_update_domain_list.py index 6cf055f2fa5f..b88da5d42dd8 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_update_domain_list.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_update_domain_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_update_domain_update.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_update_domain_update.py index 814f70dd7a63..e0db89c068d9 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_update_domain_update.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_update_domain_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_update_to_include_tags.py b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_update_to_include_tags.py index 7a7a2458ef37..797401b358ac 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_update_to_include_tags.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/cloud_service_update_to_include_tags.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/community_gallery_examples/community_gallery_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/community_gallery_examples/community_gallery_get.py new file mode 100644 index 000000000000..2ced71acb040 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/community_gallery_examples/community_gallery_get.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python community_gallery_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.community_galleries.get( + location="myLocation", + public_gallery_name="publicGalleryName", + ) + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/communityGalleryExamples/CommunityGallery_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/community_gallery_examples/community_gallery_image_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/community_gallery_examples/community_gallery_image_get.py new file mode 100644 index 000000000000..4b0bf693912d --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/community_gallery_examples/community_gallery_image_get.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python community_gallery_image_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.community_gallery_images.get( + location="myLocation", + public_gallery_name="publicGalleryName", + gallery_image_name="myGalleryImageName", + ) + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/communityGalleryExamples/CommunityGalleryImage_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/community_gallery_examples/community_gallery_image_list.py b/sdk/compute/azure-mgmt-compute/generated_samples/community_gallery_examples/community_gallery_image_list.py new file mode 100644 index 000000000000..716ba32bcbbe --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/community_gallery_examples/community_gallery_image_list.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python community_gallery_image_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.community_gallery_images.list( + location="myLocation", + public_gallery_name="publicGalleryName", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/communityGalleryExamples/CommunityGalleryImage_List.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/community_gallery_examples/community_gallery_image_version_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/community_gallery_examples/community_gallery_image_version_get.py new file mode 100644 index 000000000000..3a041a31c2e0 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/community_gallery_examples/community_gallery_image_version_get.py @@ -0,0 +1,45 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python community_gallery_image_version_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.community_gallery_image_versions.get( + location="myLocation", + public_gallery_name="publicGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image_version_name="myGalleryImageVersionName", + ) + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/communityGalleryExamples/CommunityGalleryImageVersion_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/community_gallery_examples/community_gallery_image_version_list.py b/sdk/compute/azure-mgmt-compute/generated_samples/community_gallery_examples/community_gallery_image_version_list.py new file mode 100644 index 000000000000..02f0516404ed --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/community_gallery_examples/community_gallery_image_version_list.py @@ -0,0 +1,45 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python community_gallery_image_version_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.community_gallery_image_versions.list( + location="myLocation", + public_gallery_name="publicGalleryName", + gallery_image_name="myGalleryImageName", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/communityGalleryExamples/CommunityGalleryImageVersion_List.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_create.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_create.py index 97cad9764b60..b9a278509166 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_create.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_Create.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskAccessExamples/DiskAccess_Create.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_delete.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_delete.py index 17a0722cb21a..f0789f54a550 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_delete.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_Delete.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskAccessExamples/DiskAccess_Delete.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_get.py index ceca6101dfb9..4fba98615977 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_get.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_Get.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskAccessExamples/DiskAccess_Get.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_get_with_private_endpoints.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_get_with_private_endpoints.py index de358be8ce2e..8406b8f74c81 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_get_with_private_endpoints.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_get_with_private_endpoints.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_Get_WithPrivateEndpoints.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskAccessExamples/DiskAccess_Get_WithPrivateEndpoints.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_list_by_resource_group.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_list_by_resource_group.py index b8662ccfe00e..53fd494512ca 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_list_by_resource_group.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_list_by_resource_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_ListByResourceGroup.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskAccessExamples/DiskAccess_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_list_by_subscription.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_list_by_subscription.py index 142b57681e9c..7af9ce72dfd7 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_list_by_subscription.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_list_by_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_ListBySubscription.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskAccessExamples/DiskAccess_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_endpoint_connection_approve.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_endpoint_connection_approve.py index 41f560569825..96e7596b8af7 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_endpoint_connection_approve.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_endpoint_connection_approve.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -48,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_Approve.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_Approve.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_endpoint_connection_delete.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_endpoint_connection_delete.py index da8adb833755..415ff76bd57e 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_endpoint_connection_delete.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_endpoint_connection_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_Delete.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_Delete.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_endpoint_connection_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_endpoint_connection_get.py index 2bc46b14ce47..f6ac11979199 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_endpoint_connection_get.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_endpoint_connection_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_Get.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_Get.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_endpoint_connection_list_by_disk_access.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_endpoint_connection_list_by_disk_access.py index 1df6e60af4a2..fe96178f6a81 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_endpoint_connection_list_by_disk_access.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_endpoint_connection_list_by_disk_access.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_ListByDiskAccess.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_ListByDiskAccess.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_link_resources_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_link_resources_get.py index a40bf6090061..4c550fb1b59b 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_link_resources_get.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_private_link_resources_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccessPrivateLinkResources_Get.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskAccessExamples/DiskAccessPrivateLinkResources_Get.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_update.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_update.py index f414a67fe1a3..aed9b94000c3 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_update.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_access_examples/disk_access_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_Update.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskAccessExamples/DiskAccess_Update.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_create.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_create.py index 9f2d8e1654e4..1a35fe57b8f1 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_create.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -52,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Create.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Create.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_create_with_key_vault_from_adifferent_subscription.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_create_with_key_vault_from_adifferent_subscription.py index 702f2823d1d2..e7fc117ec63c 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_create_with_key_vault_from_adifferent_subscription.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_create_with_key_vault_from_adifferent_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -47,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Create_WithKeyVaultFromADifferentSubscription.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Create_WithKeyVaultFromADifferentSubscription.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_create_with_key_vault_from_adifferent_tenant.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_create_with_key_vault_from_adifferent_tenant.py index f2c3adc9657c..7622ed967857 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_create_with_key_vault_from_adifferent_tenant.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_create_with_key_vault_from_adifferent_tenant.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -53,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Create_WithKeyVaultFromADifferentTenant.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Create_WithKeyVaultFromADifferentTenant.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_delete.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_delete.py index ca69cd88f2d8..35191740e305 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_delete.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Delete.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Delete.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_get.py index dbd80a15a3d4..8e0844e5da1c 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_get.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Get.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Get.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_get_with_auto_key_rotation_error.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_get_with_auto_key_rotation_error.py index 5f824b1136b2..9f5ed294bcd7 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_get_with_auto_key_rotation_error.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_get_with_auto_key_rotation_error.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Get_WithAutoKeyRotationError.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Get_WithAutoKeyRotationError.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_list_associated_resources.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_list_associated_resources.py index b4068acad625..33062630e89b 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_list_associated_resources.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_list_associated_resources.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_ListAssociatedResources.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_ListAssociatedResources.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_list_by_resource_group.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_list_by_resource_group.py index b474c02e52c2..d7e6d017fa72 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_list_by_resource_group.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_list_by_resource_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_ListByResourceGroup.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_list_by_subscription.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_list_by_subscription.py index eab1b807db3b..9513658b8c09 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_list_by_subscription.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_list_by_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_ListBySubscription.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_update.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_update.py index 7bf84999b7c3..90b732c0aa7a 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_update.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -51,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Update.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Update.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_update_with_rotation_to_latest_key_version_enabled.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_update_with_rotation_to_latest_key_version_enabled.py index b4772c71f981..b032aeb22f60 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_update_with_rotation_to_latest_key_version_enabled.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_update_with_rotation_to_latest_key_version_enabled.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -47,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Update_WithRotationToLatestKeyVersionEnabled.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Update_WithRotationToLatestKeyVersionEnabled.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_update_with_rotation_to_latest_key_version_enabled_in_progress.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_update_with_rotation_to_latest_key_version_enabled_in_progress.py index 955f8c8406aa..bd51875cffec 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_update_with_rotation_to_latest_key_version_enabled_in_progress.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_encryption_set_examples/disk_encryption_set_update_with_rotation_to_latest_key_version_enabled_in_progress.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -47,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Update_WithRotationToLatestKeyVersionEnabledInProgress.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Update_WithRotationToLatestKeyVersionEnabledInProgress.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_begin_get_access.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_begin_get_access.py index dac1d02928f0..4d2d13e31e0f 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_begin_get_access.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_begin_get_access.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_BeginGetAccess.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_BeginGetAccess.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_begin_get_access_with_vm_guest_state.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_begin_get_access_with_vm_guest_state.py index 88b97889c689..a33ef5cd56c9 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_begin_get_access_with_vm_guest_state.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_begin_get_access_with_vm_guest_state.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_BeginGetAccess_WithVMGuestState.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_BeginGetAccess_WithVMGuestState.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_by_copying_asnapshot.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_by_copying_asnapshot.py index 20b9f82eca61..17a6d9960676 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_by_copying_asnapshot.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_by_copying_asnapshot.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -48,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_ByCopyingASnapshot.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_ByCopyingASnapshot.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_by_importing_blob_from_adifferent_subscription.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_by_importing_blob_from_adifferent_subscription.py index 7aa89b64dae3..6cfcf9ff7528 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_by_importing_blob_from_adifferent_subscription.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_by_importing_blob_from_adifferent_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -49,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_ByImportingBlobFromADifferentSubscription.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_ByImportingBlobFromADifferentSubscription.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_by_importing_blob_from_the_same_subscription.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_by_importing_blob_from_the_same_subscription.py index 934583fabf4e..08ff0cece9cb 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_by_importing_blob_from_the_same_subscription.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_by_importing_blob_from_the_same_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -48,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_ByImportingBlobFromTheSameSubscription.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_ByImportingBlobFromTheSameSubscription.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_confidential_vm_supported_disk_encrypted_with_cmk.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_confidential_vm_supported_disk_encrypted_with_cmk.py index 1ed8adbdf5b5..4f7d20f2a0d2 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_confidential_vm_supported_disk_encrypted_with_cmk.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_confidential_vm_supported_disk_encrypted_with_cmk.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -55,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_ConfidentialVMSupportedDiskEncryptedWithCMK.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_ConfidentialVMSupportedDiskEncryptedWithCMK.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_empty.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_empty.py index e2c519be5787..49d359fb7f89 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_empty.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_empty.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_Empty.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_Empty.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_azure_compute_gallery_community_image.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_azure_compute_gallery_community_image.py index 50f29f64105d..d51f03604059 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_azure_compute_gallery_community_image.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_azure_compute_gallery_community_image.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -51,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_FromAnAzureComputeGalleryCommunityImage.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_FromAnAzureComputeGalleryCommunityImage.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_azure_compute_gallery_direct_shared_image.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_azure_compute_gallery_direct_shared_image.py index 6bd4fdfb8f0d..f4f93c8a8a7b 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_azure_compute_gallery_direct_shared_image.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_azure_compute_gallery_direct_shared_image.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -51,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_FromAnAzureComputeGalleryDirectSharedImage.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_FromAnAzureComputeGalleryDirectSharedImage.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_azure_compute_gallery_image.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_azure_compute_gallery_image.py index 785c2e0f0a18..05450473ed19 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_azure_compute_gallery_image.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_azure_compute_gallery_image.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -51,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_FromAnAzureComputeGalleryImage.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_FromAnAzureComputeGalleryImage.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_elastic_san_volume_snapshot.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_elastic_san_volume_snapshot.py index 10dc348c0fdc..c5229a3fd2d8 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_elastic_san_volume_snapshot.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_elastic_san_volume_snapshot.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -48,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_FromAnElasticSanVolumeSnapshot.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_FromAnElasticSanVolumeSnapshot.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_existing_managed_disk.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_existing_managed_disk.py index ca42fd8c791c..6c7f78a6a052 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_existing_managed_disk.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_an_existing_managed_disk.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -48,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_FromAnExistingManagedDisk.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_FromAnExistingManagedDisk.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_aplatform_image.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_aplatform_image.py index 42b1496211ac..4b3dc00dab4f 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_aplatform_image.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_aplatform_image.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -51,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_FromAPlatformImage.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_FromAPlatformImage.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_import_secure.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_import_secure.py index 060f6d7b4aba..2a266828e161 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_import_secure.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_import_secure.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -52,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_FromImportSecure.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_FromImportSecure.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_upload_prepared_secure.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_upload_prepared_secure.py index 22e20aab336a..17b3026a7da0 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_upload_prepared_secure.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_from_upload_prepared_secure.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -47,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_FromUploadPreparedSecure.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_FromUploadPreparedSecure.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_in_extended_location.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_in_extended_location.py index fd4c88c0f82c..36e0e168f6a8 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_in_extended_location.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_in_extended_location.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -44,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_InExtendedLocation.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_InExtendedLocation.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_or_update_bursting_enabled.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_or_update_bursting_enabled.py index 97c6b232b6c6..530b0ea21fa4 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_or_update_bursting_enabled.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_or_update_bursting_enabled.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_CreateOrUpdate_BurstingEnabled.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_CreateOrUpdate_BurstingEnabled.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_performance_plus.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_performance_plus.py index 4cde7ebcdfa9..a64f29b4bf6d 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_performance_plus.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_performance_plus.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -43,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_PerformancePlus.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_PerformancePlus.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_upload_disk.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_upload_disk.py index bf95f0e03e5f..cb305dfb1c22 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_upload_disk.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_upload_disk.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -43,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_UploadDisk.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_UploadDisk.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_data_access_auth_mode.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_data_access_auth_mode.py index e5a8458e712a..048accdeb21b 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_data_access_auth_mode.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_data_access_auth_mode.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -47,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_WithDataAccessAuthMode.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_WithDataAccessAuthMode.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_disk_access.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_disk_access.py index 398b2da9568a..5049bebedcd5 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_disk_access.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_disk_access.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -48,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_WithDiskAccess.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_WithDiskAccess.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_disk_encryption_set.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_disk_encryption_set.py index 9b0b4b1946dd..89b4c2cf8ae7 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_disk_encryption_set.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_disk_encryption_set.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -49,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_WithDiskEncryptionSet.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_WithDiskEncryptionSet.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_logical_sector_size.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_logical_sector_size.py index bce6f56a8096..046dbf65fd10 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_logical_sector_size.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_logical_sector_size.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -44,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_WithLogicalSectorSize.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_WithLogicalSectorSize.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_optimized_for_frequent_attach.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_optimized_for_frequent_attach.py index b3ddd3ccddbe..5b72eb35d48b 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_optimized_for_frequent_attach.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_optimized_for_frequent_attach.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -47,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_WithOptimizedForFrequentAttach.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_WithOptimizedForFrequentAttach.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_premium_v2_lrsaccount_type.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_premium_v2_lrsaccount_type.py index 0e50a18adb51..f8e67db99f82 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_premium_v2_lrsaccount_type.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_premium_v2_lrsaccount_type.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -49,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_WithPremiumV2_LRSAccountType.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_WithPremiumV2_LRSAccountType.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_security_profile.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_security_profile.py index 1a9bc8924f33..b2b5f0b28bb1 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_security_profile.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_security_profile.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -52,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_WithSecurityProfile.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_WithSecurityProfile.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_ssdzrs_account_type.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_ssdzrs_account_type.py index 10da5e107d02..3f328848619d 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_ssdzrs_account_type.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_ssdzrs_account_type.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -44,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_WithSSDZRSAccountType.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_WithSSDZRSAccountType.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_ultra_ssd_read_only.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_ultra_ssd_read_only.py index 2eac09808083..f35701d536cd 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_ultra_ssd_read_only.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_create_with_ultra_ssd_read_only.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -50,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Create_WithUltraSSD_ReadOnly.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Create_WithUltraSSD_ReadOnly.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_delete.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_delete.py index 99dc221a7f52..522e4111d7eb 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_delete.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Delete.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Delete.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_end_get_access.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_end_get_access.py index eeddf7689d33..141c81879b5d 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_end_get_access.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_end_get_access.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_EndGetAccess.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_EndGetAccess.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_get.py index 90676c88bcef..7d585443575f 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_get.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Get.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Get.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_list_by_resource_group.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_list_by_resource_group.py index e6af0b1bc36f..1b672239fc8a 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_list_by_resource_group.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_list_by_resource_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_ListByResourceGroup.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_list_by_subscription.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_list_by_subscription.py index f95774e6fb19..f70d9490ecea 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_list_by_subscription.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_list_by_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_ListBySubscription.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_add_accelerated_networking.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_add_accelerated_networking.py index afed7b4e6496..8751f0a757f2 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_add_accelerated_networking.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_add_accelerated_networking.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Update_AddAcceleratedNetworking.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Update_AddAcceleratedNetworking.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_add_disk_controller_types.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_add_disk_controller_types.py index c4cfd0e0693c..97f71e35147f 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_add_disk_controller_types.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_add_disk_controller_types.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Update_AddDiskControllerTypes.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Update_AddDiskControllerTypes.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_add_purchase_plan.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_add_purchase_plan.py index d29afc50d257..3c68ba6056c2 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_add_purchase_plan.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_add_purchase_plan.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -49,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Update_AddPurchasePlan.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Update_AddPurchasePlan.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_add_supports_hibernation.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_add_supports_hibernation.py index 69736abb5463..a47bc12ddf63 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_add_supports_hibernation.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_add_supports_hibernation.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Update_AddSupportsHibernation.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Update_AddSupportsHibernation.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_change_tier.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_change_tier.py index 273e6953dcc0..74720b1e8066 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_change_tier.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_change_tier.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Update_ChangeTier.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Update_ChangeTier.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_disable_bursting.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_disable_bursting.py index 050e489221dd..f706121742a9 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_disable_bursting.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_disable_bursting.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Update_DisableBursting.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Update_DisableBursting.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_disable_optimized_for_frequent_attach.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_disable_optimized_for_frequent_attach.py index bf2650004623..1edeb09c6416 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_disable_optimized_for_frequent_attach.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_disable_optimized_for_frequent_attach.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Update_DisableOptimizedForFrequentAttach.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Update_DisableOptimizedForFrequentAttach.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_remove_disk_access.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_remove_disk_access.py index 756ca94a5754..b2ab60f878aa 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_remove_disk_access.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_remove_disk_access.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Update_RemoveDiskAccess.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Update_RemoveDiskAccess.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_to_add_architecture.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_to_add_architecture.py index b9344b5793cd..b35625630018 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_to_add_architecture.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_examples/disk_update_to_add_architecture.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Update_ToAddArchitecture.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_Update_ToAddArchitecture.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_begin_get_access.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_begin_get_access.py index e5ea91088852..1ca9ea2898ce 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_begin_get_access.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_begin_get_access.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -42,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskRestorePointExamples/DiskRestorePoint_BeginGetAccess.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskRestorePointExamples/DiskRestorePoint_BeginGetAccess.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_end_get_access.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_end_get_access.py index 595992d03b10..90a717a1218c 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_end_get_access.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_end_get_access.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskRestorePointExamples/DiskRestorePoint_EndGetAccess.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskRestorePointExamples/DiskRestorePoint_EndGetAccess.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_get.py index f7b75dcd318b..c08ea5b05c48 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_get.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskRestorePointExamples/DiskRestorePoint_Get.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskRestorePointExamples/DiskRestorePoint_Get.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_get_when_source_resource_is_from_different_region.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_get_when_source_resource_is_from_different_region.py index bbc152efc831..3bd6f803455b 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_get_when_source_resource_is_from_different_region.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_get_when_source_resource_is_from_different_region.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskRestorePointExamples/DiskRestorePoint_Get_WhenSourceResourceIsFromDifferentRegion.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskRestorePointExamples/DiskRestorePoint_Get_WhenSourceResourceIsFromDifferentRegion.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_list_by_vm_restore_point.py b/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_list_by_vm_restore_point.py index e22aa59222e1..cadb01fa494c 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_list_by_vm_restore_point.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/disk_restore_point_examples/disk_restore_point_list_by_vm_restore_point.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskRestorePointExamples/DiskRestorePoint_ListByVmRestorePoint.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskRestorePointExamples/DiskRestorePoint_ListByVmRestorePoint.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/community_gallery_create.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/community_gallery_create.py new file mode 100644 index 000000000000..78198381fd19 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/community_gallery_create.py @@ -0,0 +1,58 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python community_gallery_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.galleries.begin_create_or_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery={ + "location": "West US", + "properties": { + "description": "This is the gallery description.", + "sharingProfile": { + "communityGalleryInfo": { + "eula": "eula", + "publicNamePrefix": "PirPublic", + "publisherContact": "pir@microsoft.com", + "publisherUri": "uri", + }, + "permissions": "Community", + }, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/CommunityGallery_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/community_gallery_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/community_gallery_get.py new file mode 100644 index 000000000000..56fc4bd4066a --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/community_gallery_get.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python community_gallery_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.galleries.get( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + ) + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/CommunityGallery_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_add_to_sharing_profile.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_add_to_sharing_profile.py new file mode 100644 index 000000000000..d520a195cc5a --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_add_to_sharing_profile.py @@ -0,0 +1,53 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_add_to_sharing_profile.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_sharing_profile.begin_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + sharing_update={ + "groups": [ + { + "ids": ["34a4ab42-0d72-47d9-bd1a-aed207386dac", "380fd389-260b-41aa-bad9-0a83108c370b"], + "type": "Subscriptions", + }, + {"ids": ["c24c76aa-8897-4027-9b03-8f7928b54ff6"], "type": "AADTenants"}, + ], + "operationType": "Add", + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_AddToSharingProfile.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_create.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_create.py new file mode 100644 index 000000000000..556303256a02 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_create.py @@ -0,0 +1,70 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_application_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_applications.begin_create_or_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_application_name="myGalleryApplicationName", + gallery_application={ + "location": "West US", + "properties": { + "customActions": [ + { + "description": "This is the custom action description.", + "name": "myCustomAction", + "parameters": [ + { + "defaultValue": "default value of parameter.", + "description": "This is the description of the parameter", + "name": "myCustomActionParameter", + "required": False, + "type": "String", + } + ], + "script": "myCustomActionScript", + } + ], + "description": "This is the gallery application description.", + "eula": "This is the gallery application EULA.", + "privacyStatementUri": "myPrivacyStatementUri}", + "releaseNoteUri": "myReleaseNoteUri", + "supportedOSType": "Windows", + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplication_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_delete.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_delete.py new file mode 100644 index 000000000000..d4c46cf6460e --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_delete.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_application_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + client.gallery_applications.begin_delete( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_application_name="myGalleryApplicationName", + ).result() + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplication_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_get.py new file mode 100644 index 000000000000..0e5fed4b59b7 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_get.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_application_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_applications.get( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_application_name="myGalleryApplicationName", + ) + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplication_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_list_by_gallery.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_list_by_gallery.py new file mode 100644 index 000000000000..68def517f838 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_list_by_gallery.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_application_list_by_gallery.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_applications.list_by_gallery( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplication_ListByGallery.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_update.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_update.py new file mode 100644 index 000000000000..7a46d72e8717 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_update.py @@ -0,0 +1,69 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_application_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_applications.begin_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_application_name="myGalleryApplicationName", + gallery_application={ + "properties": { + "customActions": [ + { + "description": "This is the custom action description.", + "name": "myCustomAction", + "parameters": [ + { + "defaultValue": "default value of parameter.", + "description": "This is the description of the parameter", + "name": "myCustomActionParameter", + "required": False, + "type": "String", + } + ], + "script": "myCustomActionScript", + } + ], + "description": "This is the gallery application description.", + "eula": "This is the gallery application EULA.", + "privacyStatementUri": "myPrivacyStatementUri}", + "releaseNoteUri": "myReleaseNoteUri", + "supportedOSType": "Windows", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplication_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_version_create.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_version_create.py new file mode 100644 index 000000000000..3f7c946c9a04 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_version_create.py @@ -0,0 +1,87 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_application_version_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_application_versions.begin_create_or_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_application_name="myGalleryApplicationName", + gallery_application_version_name="1.0.0", + gallery_application_version={ + "location": "West US", + "properties": { + "publishingProfile": { + "customActions": [ + { + "description": "This is the custom action description.", + "name": "myCustomAction", + "parameters": [ + { + "defaultValue": "default value of parameter.", + "description": "This is the description of the parameter", + "name": "myCustomActionParameter", + "required": False, + "type": "String", + } + ], + "script": "myCustomActionScript", + } + ], + "endOfLifeDate": "2019-07-01T07:00:00Z", + "manageActions": { + "install": 'powershell -command "Expand-Archive -Path package.zip -DestinationPath C:\\package"', + "remove": "del C:\\package ", + }, + "replicaCount": 1, + "source": { + "mediaLink": "https://mystorageaccount.blob.core.windows.net/mycontainer/package.zip?{sasKey}" + }, + "storageAccountType": "Standard_LRS", + "targetRegions": [ + { + "excludeFromLatest": False, + "name": "West US", + "regionalReplicaCount": 1, + "storageAccountType": "Standard_LRS", + } + ], + }, + "safetyProfile": {"allowDeletionOfReplicatedLocations": False}, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_version_delete.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_version_delete.py new file mode 100644 index 000000000000..105f37a63999 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_version_delete.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_application_version_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + client.gallery_application_versions.begin_delete( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_application_name="myGalleryApplicationName", + gallery_application_version_name="1.0.0", + ).result() + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_version_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_version_get.py new file mode 100644 index 000000000000..6f1250ae7e8c --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_version_get.py @@ -0,0 +1,45 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_application_version_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_application_versions.get( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_application_name="myGalleryApplicationName", + gallery_application_version_name="1.0.0", + ) + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_version_get_with_replication_status.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_version_get_with_replication_status.py new file mode 100644 index 000000000000..05e13a88e706 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_version_get_with_replication_status.py @@ -0,0 +1,45 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_application_version_get_with_replication_status.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_application_versions.get( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_application_name="myGalleryApplicationName", + gallery_application_version_name="1.0.0", + ) + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Get_WithReplicationStatus.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_version_list_by_gallery_application.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_version_list_by_gallery_application.py new file mode 100644 index 000000000000..93ef7c16cd12 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_version_list_by_gallery_application.py @@ -0,0 +1,45 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_application_version_list_by_gallery_application.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_application_versions.list_by_gallery_application( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_application_name="myGalleryApplicationName", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_ListByGalleryApplication.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_version_update.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_version_update.py new file mode 100644 index 000000000000..533100daa774 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_application_version_update.py @@ -0,0 +1,70 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_application_version_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_application_versions.begin_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_application_name="myGalleryApplicationName", + gallery_application_version_name="1.0.0", + gallery_application_version={ + "properties": { + "publishingProfile": { + "endOfLifeDate": "2019-07-01T07:00:00Z", + "manageActions": { + "install": 'powershell -command "Expand-Archive -Path package.zip -DestinationPath C:\\package"', + "remove": "del C:\\package ", + }, + "replicaCount": 1, + "source": { + "mediaLink": "https://mystorageaccount.blob.core.windows.net/mycontainer/package.zip?{sasKey}" + }, + "storageAccountType": "Standard_LRS", + "targetRegions": [ + { + "excludeFromLatest": False, + "name": "West US", + "regionalReplicaCount": 1, + "storageAccountType": "Standard_LRS", + } + ], + }, + "safetyProfile": {"allowDeletionOfReplicatedLocations": False}, + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_create.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_create.py new file mode 100644 index 000000000000..64fb238bfedc --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_create.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.galleries.begin_create_or_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery={"location": "West US", "properties": {"description": "This is the gallery description."}}, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_create_soft_deletion_enabled.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_create_soft_deletion_enabled.py new file mode 100644 index 000000000000..7fd07e70deef --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_create_soft_deletion_enabled.py @@ -0,0 +1,50 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_create_soft_deletion_enabled.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.galleries.begin_create_or_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery={ + "location": "West US", + "properties": { + "description": "This is the gallery description.", + "softDeletePolicy": {"isSoftDeleteEnabled": True}, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Create_SoftDeletionEnabled.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_create_with_sharing_profile.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_create_with_sharing_profile.py new file mode 100644 index 000000000000..95bf661bc989 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_create_with_sharing_profile.py @@ -0,0 +1,50 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_create_with_sharing_profile.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.galleries.begin_create_or_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery={ + "location": "West US", + "properties": { + "description": "This is the gallery description.", + "sharingProfile": {"permissions": "Groups"}, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Create_WithSharingProfile.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_delete.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_delete.py new file mode 100644 index 000000000000..64ed76fb1bdb --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_delete.py @@ -0,0 +1,42 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + client.galleries.begin_delete( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + ).result() + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_enable_community_gallery.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_enable_community_gallery.py new file mode 100644 index 000000000000..144d5c65b6ba --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_enable_community_gallery.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_enable_community_gallery.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_sharing_profile.begin_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + sharing_update={"operationType": "EnableCommunity"}, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_EnableCommunityGallery.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_get.py new file mode 100644 index 000000000000..44fe5705721b --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_get.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.galleries.get( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + ) + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_get_with_expand_sharing_profile_groups.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_get_with_expand_sharing_profile_groups.py new file mode 100644 index 000000000000..1dc1390f525e --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_get_with_expand_sharing_profile_groups.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_get_with_expand_sharing_profile_groups.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.galleries.get( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + ) + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get_WithExpandSharingProfileGroups.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_get_with_select_permissions.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_get_with_select_permissions.py new file mode 100644 index 000000000000..bda17a7e9dd9 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_get_with_select_permissions.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_get_with_select_permissions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.galleries.get( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + ) + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get_WithSelectPermissions.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_create.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_create.py new file mode 100644 index 000000000000..8a8051365555 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_create.py @@ -0,0 +1,53 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_images.begin_create_or_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image={ + "location": "West US", + "properties": { + "hyperVGeneration": "V1", + "identifier": {"offer": "myOfferName", "publisher": "myPublisherName", "sku": "mySkuName"}, + "osState": "Generalized", + "osType": "Windows", + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImage_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_delete.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_delete.py new file mode 100644 index 000000000000..c4bf7f94cf03 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_delete.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + client.gallery_images.begin_delete( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + ).result() + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImage_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_get.py new file mode 100644 index 000000000000..bc4c7f429963 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_get.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_images.get( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + ) + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImage_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_list_by_gallery.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_list_by_gallery.py new file mode 100644 index 000000000000..2e375abe10f5 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_list_by_gallery.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_list_by_gallery.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_images.list_by_gallery( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImage_ListByGallery.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_update.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_update.py new file mode 100644 index 000000000000..f9a255739700 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_update.py @@ -0,0 +1,52 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_images.begin_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image={ + "properties": { + "hyperVGeneration": "V1", + "identifier": {"offer": "myOfferName", "publisher": "myPublisherName", "sku": "mySkuName"}, + "osState": "Generalized", + "osType": "Windows", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImage_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create.py new file mode 100644 index 000000000000..d96d638a971c --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create.py @@ -0,0 +1,101 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_version_create.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_image_versions.begin_create_or_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image_version_name="1.0.0", + gallery_image_version={ + "location": "West US", + "properties": { + "publishingProfile": { + "targetRegions": [ + { + "encryption": { + "dataDiskImages": [ + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet", + "lun": 0, + }, + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet", + "lun": 1, + }, + ], + "osDiskImage": { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet" + }, + }, + "excludeFromLatest": False, + "name": "West US", + "regionalReplicaCount": 1, + }, + { + "encryption": { + "dataDiskImages": [ + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet", + "lun": 0, + }, + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet", + "lun": 1, + }, + ], + "osDiskImage": { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet" + }, + }, + "excludeFromLatest": False, + "name": "East US", + "regionalReplicaCount": 2, + "storageAccountType": "Standard_ZRS", + }, + ] + }, + "safetyProfile": {"allowDeletionOfReplicatedLocations": False}, + "storageProfile": { + "source": { + "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}" + } + }, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_community_image_version_as_source.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_community_image_version_as_source.py new file mode 100644 index 000000000000..5a5d06db8440 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_community_image_version_as_source.py @@ -0,0 +1,101 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_version_create_with_community_image_version_as_source.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_image_versions.begin_create_or_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image_version_name="1.0.0", + gallery_image_version={ + "location": "West US", + "properties": { + "publishingProfile": { + "targetRegions": [ + { + "encryption": { + "dataDiskImages": [ + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet", + "lun": 0, + }, + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet", + "lun": 1, + }, + ], + "osDiskImage": { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet" + }, + }, + "excludeFromLatest": False, + "name": "West US", + "regionalReplicaCount": 1, + }, + { + "encryption": { + "dataDiskImages": [ + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet", + "lun": 0, + }, + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet", + "lun": 1, + }, + ], + "osDiskImage": { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet" + }, + }, + "excludeFromLatest": False, + "name": "East US", + "regionalReplicaCount": 2, + "storageAccountType": "Standard_ZRS", + }, + ] + }, + "safetyProfile": {"allowDeletionOfReplicatedLocations": False}, + "storageProfile": { + "source": { + "communityGalleryImageId": "/communityGalleries/{communityGalleryName}/images/{communityGalleryImageName}" + } + }, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Create_WithCommunityImageVersionAsSource.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_image_version_as_source.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_image_version_as_source.py new file mode 100644 index 000000000000..1e500cd0e37f --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_image_version_as_source.py @@ -0,0 +1,101 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_version_create_with_image_version_as_source.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_image_versions.begin_create_or_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image_version_name="1.0.0", + gallery_image_version={ + "location": "West US", + "properties": { + "publishingProfile": { + "targetRegions": [ + { + "encryption": { + "dataDiskImages": [ + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet", + "lun": 0, + }, + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet", + "lun": 1, + }, + ], + "osDiskImage": { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet" + }, + }, + "excludeFromLatest": False, + "name": "West US", + "regionalReplicaCount": 1, + }, + { + "encryption": { + "dataDiskImages": [ + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet", + "lun": 0, + }, + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet", + "lun": 1, + }, + ], + "osDiskImage": { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet" + }, + }, + "excludeFromLatest": False, + "name": "East US", + "regionalReplicaCount": 2, + "storageAccountType": "Standard_ZRS", + }, + ] + }, + "safetyProfile": {"allowDeletionOfReplicatedLocations": False}, + "storageProfile": { + "source": { + "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionName}" + } + }, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Create_WithImageVersionAsSource.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_shallow_replication_mode.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_shallow_replication_mode.py new file mode 100644 index 000000000000..ea48b3466fd1 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_shallow_replication_mode.py @@ -0,0 +1,60 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_version_create_with_shallow_replication_mode.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_image_versions.begin_create_or_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image_version_name="1.0.0", + gallery_image_version={ + "location": "West US", + "properties": { + "publishingProfile": { + "replicationMode": "Shallow", + "targetRegions": [{"excludeFromLatest": False, "name": "West US", "regionalReplicaCount": 1}], + }, + "safetyProfile": {"allowDeletionOfReplicatedLocations": False}, + "storageProfile": { + "source": { + "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}" + } + }, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Create_WithShallowReplicationMode.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_snapshots_as_source.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_snapshots_as_source.py new file mode 100644 index 000000000000..e88f5b8d72c2 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_snapshots_as_source.py @@ -0,0 +1,105 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_version_create_with_snapshots_as_source.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_image_versions.begin_create_or_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image_version_name="1.0.0", + gallery_image_version={ + "location": "West US", + "properties": { + "publishingProfile": { + "targetRegions": [ + { + "encryption": { + "dataDiskImages": [ + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet", + "lun": 1, + } + ], + "osDiskImage": { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet" + }, + }, + "excludeFromLatest": False, + "name": "West US", + "regionalReplicaCount": 1, + }, + { + "encryption": { + "dataDiskImages": [ + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet", + "lun": 1, + } + ], + "osDiskImage": { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet" + }, + }, + "excludeFromLatest": False, + "name": "East US", + "regionalReplicaCount": 2, + "storageAccountType": "Standard_ZRS", + }, + ] + }, + "safetyProfile": {"allowDeletionOfReplicatedLocations": False}, + "storageProfile": { + "dataDiskImages": [ + { + "hostCaching": "None", + "lun": 1, + "source": { + "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}" + }, + } + ], + "osDiskImage": { + "hostCaching": "ReadOnly", + "source": { + "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}" + }, + }, + }, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Create_WithSnapshotsAsSource.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_target_extended_locations.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_target_extended_locations.py new file mode 100644 index 000000000000..177aeb2d23cf --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_target_extended_locations.py @@ -0,0 +1,101 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_version_create_with_target_extended_locations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_image_versions.begin_create_or_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image_version_name="1.0.0", + gallery_image_version={ + "location": "West US", + "properties": { + "publishingProfile": { + "targetRegions": [ + { + "encryption": { + "dataDiskImages": [ + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet", + "lun": 0, + }, + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet", + "lun": 1, + }, + ], + "osDiskImage": { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet" + }, + }, + "excludeFromLatest": False, + "name": "West US", + "regionalReplicaCount": 1, + }, + { + "encryption": { + "dataDiskImages": [ + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet", + "lun": 0, + }, + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet", + "lun": 1, + }, + ], + "osDiskImage": { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet" + }, + }, + "excludeFromLatest": False, + "name": "East US", + "regionalReplicaCount": 2, + "storageAccountType": "Standard_ZRS", + }, + ] + }, + "safetyProfile": {"allowDeletionOfReplicatedLocations": False}, + "storageProfile": { + "source": { + "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}" + } + }, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Create_WithTargetExtendedLocations.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_vhd.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_vhd.py new file mode 100644 index 000000000000..ffc1dd3303fb --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_vhd.py @@ -0,0 +1,96 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_version_create_with_vhd.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_image_versions.begin_create_or_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image_version_name="1.0.0", + gallery_image_version={ + "location": "West US", + "properties": { + "publishingProfile": { + "targetRegions": [ + { + "encryption": { + "dataDiskImages": [ + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet", + "lun": 1, + } + ], + "osDiskImage": { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet" + }, + }, + "excludeFromLatest": False, + "name": "West US", + "regionalReplicaCount": 1, + }, + { + "excludeFromLatest": False, + "name": "East US", + "regionalReplicaCount": 2, + "storageAccountType": "Standard_ZRS", + }, + ] + }, + "safetyProfile": {"allowDeletionOfReplicatedLocations": False}, + "storageProfile": { + "dataDiskImages": [ + { + "hostCaching": "None", + "lun": 1, + "source": { + "storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}", + "uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd", + }, + } + ], + "osDiskImage": { + "hostCaching": "ReadOnly", + "source": { + "storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}", + "uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd", + }, + }, + }, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Create_WithVHD.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_vhd_uefi_settings.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_vhd_uefi_settings.py new file mode 100644 index 000000000000..cff5f331979e --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_vhd_uefi_settings.py @@ -0,0 +1,106 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_version_create_with_vhd_uefi_settings.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_image_versions.begin_create_or_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image_version_name="1.0.0", + gallery_image_version={ + "location": "West US", + "properties": { + "publishingProfile": { + "targetRegions": [ + { + "encryption": { + "dataDiskImages": [ + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet", + "lun": 1, + } + ], + "osDiskImage": { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet" + }, + }, + "excludeFromLatest": False, + "name": "West US", + "regionalReplicaCount": 1, + }, + { + "excludeFromLatest": False, + "name": "East US", + "regionalReplicaCount": 2, + "storageAccountType": "Standard_ZRS", + }, + ] + }, + "safetyProfile": {"allowDeletionOfReplicatedLocations": False}, + "securityProfile": { + "uefiSettings": { + "additionalSignatures": { + "db": [{"type": "x509", "value": [""]}], + "dbx": [{"type": "x509", "value": [""]}], + "kek": [{"type": "sha256", "value": [""]}], + }, + "signatureTemplateNames": ["MicrosoftUefiCertificateAuthorityTemplate"], + } + }, + "storageProfile": { + "dataDiskImages": [ + { + "hostCaching": "None", + "lun": 1, + "source": { + "storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}", + "uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd", + }, + } + ], + "osDiskImage": { + "hostCaching": "ReadOnly", + "source": { + "storageAccountId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}", + "uri": "https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd", + }, + }, + }, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Create_WithVHD_UefiSettings.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_vm_as_source.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_vm_as_source.py new file mode 100644 index 000000000000..6c947aa84fa0 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_create_with_vm_as_source.py @@ -0,0 +1,101 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_version_create_with_vm_as_source.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_image_versions.begin_create_or_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image_version_name="1.0.0", + gallery_image_version={ + "location": "West US", + "properties": { + "publishingProfile": { + "targetRegions": [ + { + "encryption": { + "dataDiskImages": [ + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet", + "lun": 0, + }, + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet", + "lun": 1, + }, + ], + "osDiskImage": { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet" + }, + }, + "excludeFromLatest": False, + "name": "West US", + "regionalReplicaCount": 2, + }, + { + "encryption": { + "dataDiskImages": [ + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet", + "lun": 0, + }, + { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet", + "lun": 1, + }, + ], + "osDiskImage": { + "diskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet" + }, + }, + "excludeFromLatest": False, + "name": "East US", + "regionalReplicaCount": 2, + "storageAccountType": "Standard_ZRS", + }, + ] + }, + "safetyProfile": {"allowDeletionOfReplicatedLocations": False}, + "storageProfile": { + "source": { + "virtualMachineId": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vmName}" + } + }, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Create_WithVmAsSource.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_delete.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_delete.py new file mode 100644 index 000000000000..3c5f627d3ae1 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_delete.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_version_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + client.gallery_image_versions.begin_delete( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image_version_name="1.0.0", + ).result() + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_get.py new file mode 100644 index 000000000000..27ddd61a7388 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_get.py @@ -0,0 +1,45 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_version_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_image_versions.get( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image_version_name="1.0.0", + ) + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_get_with_replication_status.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_get_with_replication_status.py new file mode 100644 index 000000000000..55919ee2114a --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_get_with_replication_status.py @@ -0,0 +1,45 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_version_get_with_replication_status.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_image_versions.get( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image_version_name="1.0.0", + ) + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithReplicationStatus.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_get_with_snapshots_as_source.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_get_with_snapshots_as_source.py new file mode 100644 index 000000000000..e651ae507cdd --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_get_with_snapshots_as_source.py @@ -0,0 +1,45 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_version_get_with_snapshots_as_source.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_image_versions.get( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image_version_name="1.0.0", + ) + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithSnapshotsAsSource.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_get_with_vhd_as_source.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_get_with_vhd_as_source.py new file mode 100644 index 000000000000..4b12891c9e54 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_get_with_vhd_as_source.py @@ -0,0 +1,45 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_version_get_with_vhd_as_source.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_image_versions.get( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image_version_name="1.0.0", + ) + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithVhdAsSource.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_list_by_gallery_image.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_list_by_gallery_image.py new file mode 100644 index 000000000000..108022537c4f --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_list_by_gallery_image.py @@ -0,0 +1,45 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_version_list_by_gallery_image.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_image_versions.list_by_gallery_image( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_ListByGalleryImage.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_update.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_update.py new file mode 100644 index 000000000000..83a1f05d675f --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_update.py @@ -0,0 +1,60 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_version_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_image_versions.begin_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image_version_name="1.0.0", + gallery_image_version={ + "properties": { + "publishingProfile": { + "targetRegions": [ + {"name": "West US", "regionalReplicaCount": 1}, + {"name": "East US", "regionalReplicaCount": 2, "storageAccountType": "Standard_ZRS"}, + ] + }, + "storageProfile": { + "source": { + "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}" + } + }, + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_update_without_source_id.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_update_without_source_id.py new file mode 100644 index 000000000000..11d0d189bb32 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_image_version_update_without_source_id.py @@ -0,0 +1,56 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_image_version_update_without_source_id.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_image_versions.begin_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery_image_name="myGalleryImageName", + gallery_image_version_name="1.0.0", + gallery_image_version={ + "properties": { + "publishingProfile": { + "targetRegions": [ + {"name": "West US", "regionalReplicaCount": 1}, + {"name": "East US", "regionalReplicaCount": 2, "storageAccountType": "Standard_ZRS"}, + ] + }, + "storageProfile": {}, + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Update_WithoutSourceId.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_list_by_resource_group.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_list_by_resource_group.py new file mode 100644 index 000000000000..e6aabacdd6f7 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_list_by_resource_group.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_list_by_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.galleries.list_by_resource_group( + resource_group_name="myResourceGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_ListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_list_by_subscription.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_list_by_subscription.py new file mode 100644 index 000000000000..34afc0096b5b --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_list_by_subscription.py @@ -0,0 +1,41 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_list_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.galleries.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_ListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_reset_sharing_profile.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_reset_sharing_profile.py new file mode 100644 index 000000000000..93a39812d9bc --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_reset_sharing_profile.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_reset_sharing_profile.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.gallery_sharing_profile.begin_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + sharing_update={"operationType": "Reset"}, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_ResetSharingProfile.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_update.py b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_update.py new file mode 100644 index 000000000000..182049484e13 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/gallery_examples/gallery_update.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python gallery_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.galleries.begin_update( + resource_group_name="myResourceGroup", + gallery_name="myGalleryName", + gallery={"properties": {"description": "This is the gallery description."}}, + ).result() + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/shared_gallery_examples/shared_gallery_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/shared_gallery_examples/shared_gallery_get.py new file mode 100644 index 000000000000..f92ac03939d8 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/shared_gallery_examples/shared_gallery_get.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python shared_gallery_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.shared_galleries.get( + location="myLocation", + gallery_unique_name="galleryUniqueName", + ) + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/sharedGalleryExamples/SharedGallery_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/shared_gallery_examples/shared_gallery_image_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/shared_gallery_examples/shared_gallery_image_get.py new file mode 100644 index 000000000000..b9d1fb193c3d --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/shared_gallery_examples/shared_gallery_image_get.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python shared_gallery_image_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.shared_gallery_images.get( + location="myLocation", + gallery_unique_name="galleryUniqueName", + gallery_image_name="myGalleryImageName", + ) + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/sharedGalleryExamples/SharedGalleryImage_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/shared_gallery_examples/shared_gallery_image_version_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/shared_gallery_examples/shared_gallery_image_version_get.py new file mode 100644 index 000000000000..982837520222 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/shared_gallery_examples/shared_gallery_image_version_get.py @@ -0,0 +1,45 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python shared_gallery_image_version_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.shared_gallery_image_versions.get( + location="myLocation", + gallery_unique_name="galleryUniqueName", + gallery_image_name="myGalleryImageName", + gallery_image_version_name="myGalleryImageVersionName", + ) + print(response) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/sharedGalleryExamples/SharedGalleryImageVersion_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/shared_gallery_examples/shared_gallery_image_versions_list.py b/sdk/compute/azure-mgmt-compute/generated_samples/shared_gallery_examples/shared_gallery_image_versions_list.py new file mode 100644 index 000000000000..519a20e2f3ac --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/shared_gallery_examples/shared_gallery_image_versions_list.py @@ -0,0 +1,45 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python shared_gallery_image_versions_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.shared_gallery_image_versions.list( + location="myLocation", + gallery_unique_name="galleryUniqueName", + gallery_image_name="myGalleryImageName", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/sharedGalleryExamples/SharedGalleryImageVersions_List.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/shared_gallery_examples/shared_gallery_images_list.py b/sdk/compute/azure-mgmt-compute/generated_samples/shared_gallery_examples/shared_gallery_images_list.py new file mode 100644 index 000000000000..19bda95a8a20 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/shared_gallery_examples/shared_gallery_images_list.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python shared_gallery_images_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.shared_gallery_images.list( + location="myLocation", + gallery_unique_name="galleryUniqueName", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/sharedGalleryExamples/SharedGalleryImages_List.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/shared_gallery_examples/shared_gallery_list.py b/sdk/compute/azure-mgmt-compute/generated_samples/shared_gallery_examples/shared_gallery_list.py new file mode 100644 index 000000000000..3bb357f3e8a7 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/shared_gallery_examples/shared_gallery_list.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python shared_gallery_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.shared_galleries.list( + location="myLocation", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/sharedGalleryExamples/SharedGallery_List.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/skus/list_available_resource_skus.py b/sdk/compute/azure-mgmt-compute/generated_samples/skus/list_available_resource_skus.py new file mode 100644 index 000000000000..f9b2fe7ed9da --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/skus/list_available_resource_skus.py @@ -0,0 +1,41 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python list_available_resource_skus.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.resource_skus.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/Skus/stable/2021-07-01/examples/skus/ListAvailableResourceSkus.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/skus/list_available_resource_skus_for_aregion.py b/sdk/compute/azure-mgmt-compute/generated_samples/skus/list_available_resource_skus_for_aregion.py new file mode 100644 index 000000000000..41ec903d41ac --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/skus/list_available_resource_skus_for_aregion.py @@ -0,0 +1,41 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python list_available_resource_skus_for_aregion.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.resource_skus.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/Skus/stable/2021-07-01/examples/skus/ListAvailableResourceSkusForARegion.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/skus/list_available_resource_skus_with_extended_locations.py b/sdk/compute/azure-mgmt-compute/generated_samples/skus/list_available_resource_skus_with_extended_locations.py new file mode 100644 index 000000000000..792fa90d1da4 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/generated_samples/skus/list_available_resource_skus_with_extended_locations.py @@ -0,0 +1,41 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.compute import ComputeManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-compute +# USAGE + python list_available_resource_skus_with_extended_locations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ComputeManagementClient( + credential=DefaultAzureCredential(), + subscription_id="{subscription-id}", + ) + + response = client.resource_skus.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/Skus/stable/2021-07-01/examples/skus/ListAvailableResourceSkusWithExtendedLocations.json +if __name__ == "__main__": + main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_begin_get_access.py b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_begin_get_access.py index d0d174c8e81e..8ac47991d6cf 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_begin_get_access.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_begin_get_access.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_BeginGetAccess.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/snapshotExamples/Snapshot_BeginGetAccess.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_by_importing_an_unmanaged_blob_from_adifferent_subscription.py b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_by_importing_an_unmanaged_blob_from_adifferent_subscription.py index 8922711656f7..d506b0eb0224 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_by_importing_an_unmanaged_blob_from_adifferent_subscription.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_by_importing_an_unmanaged_blob_from_adifferent_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -49,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Create_ByImportingAnUnmanagedBlobFromADifferentSubscription.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/snapshotExamples/Snapshot_Create_ByImportingAnUnmanagedBlobFromADifferentSubscription.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_by_importing_an_unmanaged_blob_from_the_same_subscription.py b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_by_importing_an_unmanaged_blob_from_the_same_subscription.py index ed3ca4a988b0..2849ec3f0c2e 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_by_importing_an_unmanaged_blob_from_the_same_subscription.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_by_importing_an_unmanaged_blob_from_the_same_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -48,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Create_ByImportingAnUnmanagedBlobFromTheSameSubscription.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/snapshotExamples/Snapshot_Create_ByImportingAnUnmanagedBlobFromTheSameSubscription.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_enhanced_provisioned_bandwidth_copy_speed.py b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_enhanced_provisioned_bandwidth_copy_speed.py index ead5d0d92f16..bcf2c5cc53ac 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_enhanced_provisioned_bandwidth_copy_speed.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_enhanced_provisioned_bandwidth_copy_speed.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -49,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Create_EnhancedProvisionedBandwidthCopySpeed.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/snapshotExamples/Snapshot_Create_EnhancedProvisionedBandwidthCopySpeed.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_from_an_elastic_san_volume_snapshot.py b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_from_an_elastic_san_volume_snapshot.py index 75b10efe4514..1ecb57495a17 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_from_an_elastic_san_volume_snapshot.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_from_an_elastic_san_volume_snapshot.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -48,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Create_FromAnElasticSanVolumeSnapshot.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/snapshotExamples/Snapshot_Create_FromAnElasticSanVolumeSnapshot.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_from_an_existing_snapshot.py b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_from_an_existing_snapshot.py index e7a406b0cb54..b605fe6476ff 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_from_an_existing_snapshot.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_from_an_existing_snapshot.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -48,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Create_FromAnExistingSnapshot.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/snapshotExamples/Snapshot_Create_FromAnExistingSnapshot.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_from_an_existing_snapshot_in_different_region.py b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_from_an_existing_snapshot_in_different_region.py index 25aa20df9bf6..9e08e695a39c 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_from_an_existing_snapshot_in_different_region.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_create_from_an_existing_snapshot_in_different_region.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -48,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Create_FromAnExistingSnapshotInDifferentRegion.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/snapshotExamples/Snapshot_Create_FromAnExistingSnapshotInDifferentRegion.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_delete.py b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_delete.py index c75e1bb8ac9e..03118449464f 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_delete.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Delete.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/snapshotExamples/Snapshot_Delete.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_end_get_access.py b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_end_get_access.py index b6ac7a330308..2a96c66f9991 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_end_get_access.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_end_get_access.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_EndGetAccess.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/snapshotExamples/Snapshot_EndGetAccess.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_get.py b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_get.py index 8dba3d86e961..2a8b2703c844 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_get.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Get.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/snapshotExamples/Snapshot_Get.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_get_incremental_snapshot.py b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_get_incremental_snapshot.py index ae35864ef5fb..fa7916c6d118 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_get_incremental_snapshot.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_get_incremental_snapshot.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_GetIncrementalSnapshot.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/snapshotExamples/Snapshot_GetIncrementalSnapshot.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_list_by_resource_group.py b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_list_by_resource_group.py index af8956775d37..ea832087929e 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_list_by_resource_group.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_list_by_resource_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_ListByResourceGroup.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/snapshotExamples/Snapshot_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_list_by_subscription.py b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_list_by_subscription.py index 1f98f2c353f2..067104f3c073 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_list_by_subscription.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_list_by_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_ListBySubscription.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/snapshotExamples/Snapshot_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_update.py b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_update.py index 6961a0400343..86a99cee3f03 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_update.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -43,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Update.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/snapshotExamples/Snapshot_Update.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_update_with_accelerated_network.py b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_update_with_accelerated_network.py index b1a2cad95e69..56a58ff1e92b 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_update_with_accelerated_network.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/snapshot_examples/snapshot_update_with_accelerated_network.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient @@ -43,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Update_WithAcceleratedNetwork.json +# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/snapshotExamples/Snapshot_Update_WithAcceleratedNetwork.json if __name__ == "__main__": main() diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_availability_sets_operations.py index 2148217256d4..c478d9bbe5d0 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_availability_sets_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_availability_sets_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_availability_sets_operations_async.py index 436a4724d3c5..18ac70c0f33a 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_availability_sets_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_availability_sets_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservation_groups_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservation_groups_operations.py index 58539fb5a5fb..1c1c98cf3c8d 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservation_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservation_groups_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservation_groups_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservation_groups_operations_async.py index 2b62f4dc2307..75ddc42a15f9 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservation_groups_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservation_groups_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservations_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservations_operations.py index 6b29bbd0fe75..38f467118ade 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservations_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservations_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservations_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservations_operations_async.py index 79c1224b3325..d35c12a92be0 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservations_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservations_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_galleries_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_galleries_operations.py index 7e3a010cce65..37f906325415 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_galleries_operations.py @@ -20,11 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_community_galleries_get(self, resource_group): response = self.client.community_galleries.get( location="str", public_gallery_name="str", - api_version="2021-07-01", + api_version="2023-07-03", ) # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_galleries_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_galleries_operations_async.py index b0e5d19ab55c..9c91c94cbb86 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_galleries_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_galleries_operations_async.py @@ -21,11 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_community_galleries_get(self, resource_group): response = await self.client.community_galleries.get( location="str", public_gallery_name="str", - api_version="2021-07-01", + api_version="2023-07-03", ) # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_gallery_image_versions_operations.py index 6d786ca4644e..5eb61782d1f3 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_gallery_image_versions_operations.py @@ -20,14 +20,27 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_community_gallery_image_versions_get(self, resource_group): response = self.client.community_gallery_image_versions.get( location="str", public_gallery_name="str", gallery_image_name="str", gallery_image_version_name="str", - api_version="2021-07-01", + api_version="2023-07-03", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_community_gallery_image_versions_list(self, resource_group): + response = self.client.community_gallery_image_versions.list( + location="str", + public_gallery_name="str", + gallery_image_name="str", + api_version="2023-07-03", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_gallery_image_versions_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_gallery_image_versions_operations_async.py index cdd7a46d0047..a218e8f4dc89 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_gallery_image_versions_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_gallery_image_versions_operations_async.py @@ -21,14 +21,27 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_community_gallery_image_versions_get(self, resource_group): response = await self.client.community_gallery_image_versions.get( location="str", public_gallery_name="str", gallery_image_name="str", gallery_image_version_name="str", - api_version="2021-07-01", + api_version="2023-07-03", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_community_gallery_image_versions_list(self, resource_group): + response = self.client.community_gallery_image_versions.list( + location="str", + public_gallery_name="str", + gallery_image_name="str", + api_version="2023-07-03", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_gallery_images_operations.py index d63ed6f037f9..5b30eb7a0ab4 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_gallery_images_operations.py @@ -20,13 +20,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_community_gallery_images_get(self, resource_group): response = self.client.community_gallery_images.get( location="str", public_gallery_name="str", gallery_image_name="str", - api_version="2021-07-01", + api_version="2023-07-03", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_community_gallery_images_list(self, resource_group): + response = self.client.community_gallery_images.list( + location="str", + public_gallery_name="str", + api_version="2023-07-03", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_gallery_images_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_gallery_images_operations_async.py index bf9c6d6c24dc..f2d41fd7b62b 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_gallery_images_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_community_gallery_images_operations_async.py @@ -21,13 +21,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_community_gallery_images_get(self, resource_group): response = await self.client.community_gallery_images.get( location="str", public_gallery_name="str", gallery_image_name="str", - api_version="2021-07-01", + api_version="2023-07-03", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_community_gallery_images_list(self, resource_group): + response = self.client.community_gallery_images.list( + location="str", + public_gallery_name="str", + api_version="2023-07-03", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_host_groups_operations.py index e51be9ce01a9..f5fecefe839d 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_host_groups_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_host_groups_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_host_groups_operations_async.py index dd0d2eddc6a7..c47664beb1b2 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_host_groups_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_host_groups_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_hosts_operations.py index 1beeab205a8a..e3a492853617 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_hosts_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_hosts_operations_async.py index 8f88bd04ae56..142b29b70e22 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_hosts_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_hosts_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_accesses_operations.py index c65bd549409f..90c590cc9d1e 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_accesses_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_accesses_operations.py @@ -20,12 +20,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_disk_accesses_begin_create_or_update(self, resource_group): response = self.client.disk_accesses.begin_create_or_update( resource_group_name=resource_group.name, disk_access_name="str", disk_access={ "location": "str", + "extendedLocation": {"name": "str", "type": "str"}, "id": "str", "name": "str", "privateEndpointConnections": [ @@ -47,7 +48,7 @@ def test_begin_create_or_update(self, resource_group): "timeCreated": "2020-02-20 00:00:00", "type": "str", }, - api_version="2020-05-01", + api_version="2023-10-02", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -55,12 +56,12 @@ def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_update(self, resource_group): + def test_disk_accesses_begin_update(self, resource_group): response = self.client.disk_accesses.begin_update( resource_group_name=resource_group.name, disk_access_name="str", disk_access={"tags": {"str": "str"}}, - api_version="2020-05-01", + api_version="2023-10-02", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -68,11 +69,11 @@ def test_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_disk_accesses_get(self, resource_group): response = self.client.disk_accesses.get( resource_group_name=resource_group.name, disk_access_name="str", - api_version="2020-05-01", + api_version="2023-10-02", ) # please add some check logic here by yourself @@ -80,11 +81,11 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_delete(self, resource_group): + def test_disk_accesses_begin_delete(self, resource_group): response = self.client.disk_accesses.begin_delete( resource_group_name=resource_group.name, disk_access_name="str", - api_version="2020-05-01", + api_version="2023-10-02", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -92,10 +93,10 @@ def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_resource_group(self, resource_group): + def test_disk_accesses_list_by_resource_group(self, resource_group): response = self.client.disk_accesses.list_by_resource_group( resource_group_name=resource_group.name, - api_version="2020-05-01", + api_version="2023-10-02", ) result = [r for r in response] # please add some check logic here by yourself @@ -103,9 +104,9 @@ def test_list_by_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_disk_accesses_list(self, resource_group): response = self.client.disk_accesses.list( - api_version="2020-05-01", + api_version="2023-10-02", ) result = [r for r in response] # please add some check logic here by yourself @@ -113,12 +114,71 @@ def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get_private_link_resources(self, resource_group): + def test_disk_accesses_get_private_link_resources(self, resource_group): response = self.client.disk_accesses.get_private_link_resources( resource_group_name=resource_group.name, disk_access_name="str", - api_version="2020-05-01", + api_version="2023-10-02", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_disk_accesses_begin_update_a_private_endpoint_connection(self, resource_group): + response = self.client.disk_accesses.begin_update_a_private_endpoint_connection( + resource_group_name=resource_group.name, + disk_access_name="str", + private_endpoint_connection_name="str", + private_endpoint_connection={ + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": {"actionsRequired": "str", "description": "str", "status": "str"}, + "provisioningState": "str", + "type": "str", + }, + api_version="2023-10-02", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_disk_accesses_get_a_private_endpoint_connection(self, resource_group): + response = self.client.disk_accesses.get_a_private_endpoint_connection( + resource_group_name=resource_group.name, + disk_access_name="str", + private_endpoint_connection_name="str", + api_version="2023-10-02", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_disk_accesses_begin_delete_a_private_endpoint_connection(self, resource_group): + response = self.client.disk_accesses.begin_delete_a_private_endpoint_connection( + resource_group_name=resource_group.name, + disk_access_name="str", + private_endpoint_connection_name="str", + api_version="2023-10-02", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_disk_accesses_list_private_endpoint_connections(self, resource_group): + response = self.client.disk_accesses.list_private_endpoint_connections( + resource_group_name=resource_group.name, + disk_access_name="str", + api_version="2023-10-02", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_accesses_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_accesses_operations_async.py index df7171a140af..189bff582750 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_accesses_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_accesses_operations_async.py @@ -21,13 +21,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_disk_accesses_begin_create_or_update(self, resource_group): response = await ( await self.client.disk_accesses.begin_create_or_update( resource_group_name=resource_group.name, disk_access_name="str", disk_access={ "location": "str", + "extendedLocation": {"name": "str", "type": "str"}, "id": "str", "name": "str", "privateEndpointConnections": [ @@ -49,7 +50,7 @@ async def test_begin_create_or_update(self, resource_group): "timeCreated": "2020-02-20 00:00:00", "type": "str", }, - api_version="2020-05-01", + api_version="2023-10-02", ) ).result() # call '.result()' to poll until service return final result @@ -58,13 +59,13 @@ async def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_update(self, resource_group): + async def test_disk_accesses_begin_update(self, resource_group): response = await ( await self.client.disk_accesses.begin_update( resource_group_name=resource_group.name, disk_access_name="str", disk_access={"tags": {"str": "str"}}, - api_version="2020-05-01", + api_version="2023-10-02", ) ).result() # call '.result()' to poll until service return final result @@ -73,11 +74,11 @@ async def test_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_disk_accesses_get(self, resource_group): response = await self.client.disk_accesses.get( resource_group_name=resource_group.name, disk_access_name="str", - api_version="2020-05-01", + api_version="2023-10-02", ) # please add some check logic here by yourself @@ -85,12 +86,12 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_delete(self, resource_group): + async def test_disk_accesses_begin_delete(self, resource_group): response = await ( await self.client.disk_accesses.begin_delete( resource_group_name=resource_group.name, disk_access_name="str", - api_version="2020-05-01", + api_version="2023-10-02", ) ).result() # call '.result()' to poll until service return final result @@ -99,10 +100,10 @@ async def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_resource_group(self, resource_group): + async def test_disk_accesses_list_by_resource_group(self, resource_group): response = self.client.disk_accesses.list_by_resource_group( resource_group_name=resource_group.name, - api_version="2020-05-01", + api_version="2023-10-02", ) result = [r async for r in response] # please add some check logic here by yourself @@ -110,9 +111,9 @@ async def test_list_by_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_disk_accesses_list(self, resource_group): response = self.client.disk_accesses.list( - api_version="2020-05-01", + api_version="2023-10-02", ) result = [r async for r in response] # please add some check logic here by yourself @@ -120,12 +121,79 @@ async def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get_private_link_resources(self, resource_group): + async def test_disk_accesses_get_private_link_resources(self, resource_group): response = await self.client.disk_accesses.get_private_link_resources( resource_group_name=resource_group.name, disk_access_name="str", - api_version="2020-05-01", + api_version="2023-10-02", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_disk_accesses_begin_update_a_private_endpoint_connection(self, resource_group): + response = await ( + await self.client.disk_accesses.begin_update_a_private_endpoint_connection( + resource_group_name=resource_group.name, + disk_access_name="str", + private_endpoint_connection_name="str", + private_endpoint_connection={ + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "type": "str", + }, + api_version="2023-10-02", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_disk_accesses_get_a_private_endpoint_connection(self, resource_group): + response = await self.client.disk_accesses.get_a_private_endpoint_connection( + resource_group_name=resource_group.name, + disk_access_name="str", + private_endpoint_connection_name="str", + api_version="2023-10-02", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_disk_accesses_begin_delete_a_private_endpoint_connection(self, resource_group): + response = await ( + await self.client.disk_accesses.begin_delete_a_private_endpoint_connection( + resource_group_name=resource_group.name, + disk_access_name="str", + private_endpoint_connection_name="str", + api_version="2023-10-02", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_disk_accesses_list_private_endpoint_connections(self, resource_group): + response = self.client.disk_accesses.list_private_endpoint_connections( + resource_group_name=resource_group.name, + disk_access_name="str", + api_version="2023-10-02", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_encryption_sets_operations.py index 5dfcf519a336..92fa6b41ccc3 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_encryption_sets_operations.py @@ -20,22 +20,38 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_disk_encryption_sets_begin_create_or_update(self, resource_group): response = self.client.disk_encryption_sets.begin_create_or_update( resource_group_name=resource_group.name, disk_encryption_set_name="str", disk_encryption_set={ "location": "str", "activeKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + "autoKeyRotationError": { + "code": "str", + "details": [{"code": "str", "message": "str", "target": "str"}], + "innererror": {"errordetail": "str", "exceptiontype": "str"}, + "message": "str", + "target": "str", + }, + "encryptionType": "str", + "federatedClientId": "str", "id": "str", - "identity": {"principalId": "str", "tenantId": "str", "type": "str"}, + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "lastKeyRotationTimestamp": "2020-02-20 00:00:00", "name": "str", "previousKeys": [{"keyUrl": "str", "sourceVault": {"id": "str"}}], "provisioningState": "str", + "rotationToLatestKeyVersionEnabled": bool, "tags": {"str": "str"}, "type": "str", }, - api_version="2019-07-01", + api_version="2023-10-02", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -43,12 +59,24 @@ def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_update(self, resource_group): + def test_disk_encryption_sets_begin_update(self, resource_group): response = self.client.disk_encryption_sets.begin_update( resource_group_name=resource_group.name, disk_encryption_set_name="str", - disk_encryption_set={"activeKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, "tags": {"str": "str"}}, - api_version="2019-07-01", + disk_encryption_set={ + "activeKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + "encryptionType": "str", + "federatedClientId": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "rotationToLatestKeyVersionEnabled": bool, + "tags": {"str": "str"}, + }, + api_version="2023-10-02", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -56,11 +84,11 @@ def test_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_disk_encryption_sets_get(self, resource_group): response = self.client.disk_encryption_sets.get( resource_group_name=resource_group.name, disk_encryption_set_name="str", - api_version="2019-07-01", + api_version="2023-10-02", ) # please add some check logic here by yourself @@ -68,11 +96,11 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_delete(self, resource_group): + def test_disk_encryption_sets_begin_delete(self, resource_group): response = self.client.disk_encryption_sets.begin_delete( resource_group_name=resource_group.name, disk_encryption_set_name="str", - api_version="2019-07-01", + api_version="2023-10-02", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -80,10 +108,10 @@ def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_resource_group(self, resource_group): + def test_disk_encryption_sets_list_by_resource_group(self, resource_group): response = self.client.disk_encryption_sets.list_by_resource_group( resource_group_name=resource_group.name, - api_version="2019-07-01", + api_version="2023-10-02", ) result = [r for r in response] # please add some check logic here by yourself @@ -91,9 +119,21 @@ def test_list_by_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_disk_encryption_sets_list(self, resource_group): response = self.client.disk_encryption_sets.list( - api_version="2019-07-01", + api_version="2023-10-02", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_disk_encryption_sets_list_associated_resources(self, resource_group): + response = self.client.disk_encryption_sets.list_associated_resources( + resource_group_name=resource_group.name, + disk_encryption_set_name="str", + api_version="2023-10-02", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_encryption_sets_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_encryption_sets_operations_async.py index a5482cbc807a..f22e43e68ce3 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_encryption_sets_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_encryption_sets_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_disk_encryption_sets_begin_create_or_update(self, resource_group): response = await ( await self.client.disk_encryption_sets.begin_create_or_update( resource_group_name=resource_group.name, @@ -29,15 +29,31 @@ async def test_begin_create_or_update(self, resource_group): disk_encryption_set={ "location": "str", "activeKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + "autoKeyRotationError": { + "code": "str", + "details": [{"code": "str", "message": "str", "target": "str"}], + "innererror": {"errordetail": "str", "exceptiontype": "str"}, + "message": "str", + "target": "str", + }, + "encryptionType": "str", + "federatedClientId": "str", "id": "str", - "identity": {"principalId": "str", "tenantId": "str", "type": "str"}, + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "lastKeyRotationTimestamp": "2020-02-20 00:00:00", "name": "str", "previousKeys": [{"keyUrl": "str", "sourceVault": {"id": "str"}}], "provisioningState": "str", + "rotationToLatestKeyVersionEnabled": bool, "tags": {"str": "str"}, "type": "str", }, - api_version="2019-07-01", + api_version="2023-10-02", ) ).result() # call '.result()' to poll until service return final result @@ -46,16 +62,25 @@ async def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_update(self, resource_group): + async def test_disk_encryption_sets_begin_update(self, resource_group): response = await ( await self.client.disk_encryption_sets.begin_update( resource_group_name=resource_group.name, disk_encryption_set_name="str", disk_encryption_set={ "activeKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + "encryptionType": "str", + "federatedClientId": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "rotationToLatestKeyVersionEnabled": bool, "tags": {"str": "str"}, }, - api_version="2019-07-01", + api_version="2023-10-02", ) ).result() # call '.result()' to poll until service return final result @@ -64,11 +89,11 @@ async def test_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_disk_encryption_sets_get(self, resource_group): response = await self.client.disk_encryption_sets.get( resource_group_name=resource_group.name, disk_encryption_set_name="str", - api_version="2019-07-01", + api_version="2023-10-02", ) # please add some check logic here by yourself @@ -76,12 +101,12 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_delete(self, resource_group): + async def test_disk_encryption_sets_begin_delete(self, resource_group): response = await ( await self.client.disk_encryption_sets.begin_delete( resource_group_name=resource_group.name, disk_encryption_set_name="str", - api_version="2019-07-01", + api_version="2023-10-02", ) ).result() # call '.result()' to poll until service return final result @@ -90,10 +115,10 @@ async def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_resource_group(self, resource_group): + async def test_disk_encryption_sets_list_by_resource_group(self, resource_group): response = self.client.disk_encryption_sets.list_by_resource_group( resource_group_name=resource_group.name, - api_version="2019-07-01", + api_version="2023-10-02", ) result = [r async for r in response] # please add some check logic here by yourself @@ -101,9 +126,21 @@ async def test_list_by_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_disk_encryption_sets_list(self, resource_group): response = self.client.disk_encryption_sets.list( - api_version="2019-07-01", + api_version="2023-10-02", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_disk_encryption_sets_list_associated_resources(self, resource_group): + response = self.client.disk_encryption_sets.list_associated_resources( + resource_group_name=resource_group.name, + disk_encryption_set_name="str", + api_version="2023-10-02", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_restore_point_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_restore_point_operations.py index b51db8e6ccd9..b23bc852d356 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_restore_point_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_restore_point_operations.py @@ -20,13 +20,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_disk_restore_point_get(self, resource_group): response = self.client.disk_restore_point.get( resource_group_name=resource_group.name, restore_point_collection_name="str", vm_restore_point_name="str", disk_restore_point_name="str", - api_version="2020-09-30", + api_version="2023-10-02", ) # please add some check logic here by yourself @@ -34,13 +34,47 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_restore_point(self, resource_group): + def test_disk_restore_point_list_by_restore_point(self, resource_group): response = self.client.disk_restore_point.list_by_restore_point( resource_group_name=resource_group.name, restore_point_collection_name="str", vm_restore_point_name="str", - api_version="2020-09-30", + api_version="2023-10-02", ) result = [r for r in response] # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_disk_restore_point_begin_grant_access(self, resource_group): + response = self.client.disk_restore_point.begin_grant_access( + resource_group_name=resource_group.name, + restore_point_collection_name="str", + vm_restore_point_name="str", + disk_restore_point_name="str", + grant_access_data={ + "access": "str", + "durationInSeconds": 0, + "fileFormat": "str", + "getSecureVMGuestStateSAS": bool, + }, + api_version="2023-10-02", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_disk_restore_point_begin_revoke_access(self, resource_group): + response = self.client.disk_restore_point.begin_revoke_access( + resource_group_name=resource_group.name, + restore_point_collection_name="str", + vm_restore_point_name="str", + disk_restore_point_name="str", + api_version="2023-10-02", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_restore_point_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_restore_point_operations_async.py index 56382cbab5ba..f1dc4912c815 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_restore_point_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disk_restore_point_operations_async.py @@ -21,13 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_disk_restore_point_get(self, resource_group): response = await self.client.disk_restore_point.get( resource_group_name=resource_group.name, restore_point_collection_name="str", vm_restore_point_name="str", disk_restore_point_name="str", - api_version="2020-09-30", + api_version="2023-10-02", ) # please add some check logic here by yourself @@ -35,13 +35,51 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_restore_point(self, resource_group): + async def test_disk_restore_point_list_by_restore_point(self, resource_group): response = self.client.disk_restore_point.list_by_restore_point( resource_group_name=resource_group.name, restore_point_collection_name="str", vm_restore_point_name="str", - api_version="2020-09-30", + api_version="2023-10-02", ) result = [r async for r in response] # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_disk_restore_point_begin_grant_access(self, resource_group): + response = await ( + await self.client.disk_restore_point.begin_grant_access( + resource_group_name=resource_group.name, + restore_point_collection_name="str", + vm_restore_point_name="str", + disk_restore_point_name="str", + grant_access_data={ + "access": "str", + "durationInSeconds": 0, + "fileFormat": "str", + "getSecureVMGuestStateSAS": bool, + }, + api_version="2023-10-02", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_disk_restore_point_begin_revoke_access(self, resource_group): + response = await ( + await self.client.disk_restore_point.begin_revoke_access( + resource_group_name=resource_group.name, + restore_point_collection_name="str", + vm_restore_point_name="str", + disk_restore_point_name="str", + api_version="2023-10-02", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disks_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disks_operations.py index 986661b9fc5d..67e98db0ba6c 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disks_operations.py @@ -20,36 +20,92 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_disks_begin_create_or_update(self, resource_group): response = self.client.disks.begin_create_or_update( resource_group_name=resource_group.name, disk_name="str", disk={ "location": "str", - "accountType": "str", + "LastOwnershipUpdateTime": "2020-02-20 00:00:00", + "burstingEnabled": bool, + "burstingEnabledTime": "2020-02-20 00:00:00", + "completionPercent": 0.0, "creationData": { "createOption": "str", - "imageReference": {"id": "str", "lun": 0}, + "elasticSanResourceId": "str", + "galleryImageReference": { + "communityGalleryImageId": "str", + "id": "str", + "lun": 0, + "sharedGalleryImageId": "str", + }, + "imageReference": { + "communityGalleryImageId": "str", + "id": "str", + "lun": 0, + "sharedGalleryImageId": "str", + }, + "logicalSectorSize": 0, + "performancePlus": bool, + "provisionedBandwidthCopySpeed": "str", + "securityDataUri": "str", "sourceResourceId": "str", + "sourceUniqueId": "str", "sourceUri": "str", "storageAccountId": "str", + "uploadSizeBytes": 0, }, + "dataAccessAuthMode": "str", + "diskAccessId": "str", + "diskIOPSReadOnly": 0, + "diskIOPSReadWrite": 0, + "diskMBpsReadOnly": 0, + "diskMBpsReadWrite": 0, + "diskSizeBytes": 0, "diskSizeGB": 0, - "encryptionSettings": { - "diskEncryptionKey": {"secretUrl": "str", "sourceVault": {"id": "str"}}, + "diskState": "str", + "encryption": {"diskEncryptionSetId": "str", "type": "str"}, + "encryptionSettingsCollection": { "enabled": bool, - "keyEncryptionKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + "encryptionSettings": [ + { + "diskEncryptionKey": {"secretUrl": "str", "sourceVault": {"id": "str"}}, + "keyEncryptionKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + } + ], + "encryptionSettingsVersion": "str", }, + "extendedLocation": {"name": "str", "type": "str"}, + "hyperVGeneration": "str", "id": "str", + "managedBy": "str", + "managedByExtended": ["str"], + "maxShares": 0, "name": "str", + "networkAccessPolicy": "str", + "optimizedForFrequentAttach": bool, "osType": "str", - "ownerId": "str", + "propertyUpdatesInProgress": {"targetTier": "str"}, "provisioningState": "str", + "publicNetworkAccess": "str", + "purchasePlan": {"name": "str", "product": "str", "publisher": "str", "promotionCode": "str"}, + "securityProfile": {"secureVMDiskEncryptionSetId": "str", "securityType": "str"}, + "shareInfo": [{"vmUri": "str"}], + "sku": {"name": "str", "tier": "str"}, + "supportedCapabilities": { + "acceleratedNetwork": bool, + "architecture": "str", + "diskControllerTypes": "str", + }, + "supportsHibernation": bool, "tags": {"str": "str"}, + "tier": "str", "timeCreated": "2020-02-20 00:00:00", "type": "str", + "uniqueId": "str", + "zones": ["str"], }, - api_version="2016-04-30-preview", + api_version="2023-10-02", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -57,29 +113,48 @@ def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_update(self, resource_group): + def test_disks_begin_update(self, resource_group): response = self.client.disks.begin_update( resource_group_name=resource_group.name, disk_name="str", disk={ - "accountType": "str", - "creationData": { - "createOption": "str", - "imageReference": {"id": "str", "lun": 0}, - "sourceResourceId": "str", - "sourceUri": "str", - "storageAccountId": "str", - }, + "burstingEnabled": bool, + "dataAccessAuthMode": "str", + "diskAccessId": "str", + "diskIOPSReadOnly": 0, + "diskIOPSReadWrite": 0, + "diskMBpsReadOnly": 0, + "diskMBpsReadWrite": 0, "diskSizeGB": 0, - "encryptionSettings": { - "diskEncryptionKey": {"secretUrl": "str", "sourceVault": {"id": "str"}}, + "encryption": {"diskEncryptionSetId": "str", "type": "str"}, + "encryptionSettingsCollection": { "enabled": bool, - "keyEncryptionKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + "encryptionSettings": [ + { + "diskEncryptionKey": {"secretUrl": "str", "sourceVault": {"id": "str"}}, + "keyEncryptionKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + } + ], + "encryptionSettingsVersion": "str", }, + "maxShares": 0, + "networkAccessPolicy": "str", + "optimizedForFrequentAttach": bool, "osType": "str", + "propertyUpdatesInProgress": {"targetTier": "str"}, + "publicNetworkAccess": "str", + "purchasePlan": {"name": "str", "product": "str", "publisher": "str", "promotionCode": "str"}, + "sku": {"name": "str", "tier": "str"}, + "supportedCapabilities": { + "acceleratedNetwork": bool, + "architecture": "str", + "diskControllerTypes": "str", + }, + "supportsHibernation": bool, "tags": {"str": "str"}, + "tier": "str", }, - api_version="2016-04-30-preview", + api_version="2023-10-02", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -87,11 +162,11 @@ def test_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_disks_get(self, resource_group): response = self.client.disks.get( resource_group_name=resource_group.name, disk_name="str", - api_version="2016-04-30-preview", + api_version="2023-10-02", ) # please add some check logic here by yourself @@ -99,11 +174,11 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_delete(self, resource_group): + def test_disks_begin_delete(self, resource_group): response = self.client.disks.begin_delete( resource_group_name=resource_group.name, disk_name="str", - api_version="2016-04-30-preview", + api_version="2023-10-02", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -111,10 +186,10 @@ def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_resource_group(self, resource_group): + def test_disks_list_by_resource_group(self, resource_group): response = self.client.disks.list_by_resource_group( resource_group_name=resource_group.name, - api_version="2016-04-30-preview", + api_version="2023-10-02", ) result = [r for r in response] # please add some check logic here by yourself @@ -122,9 +197,9 @@ def test_list_by_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_disks_list(self, resource_group): response = self.client.disks.list( - api_version="2016-04-30-preview", + api_version="2023-10-02", ) result = [r for r in response] # please add some check logic here by yourself @@ -132,12 +207,17 @@ def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_grant_access(self, resource_group): + def test_disks_begin_grant_access(self, resource_group): response = self.client.disks.begin_grant_access( resource_group_name=resource_group.name, disk_name="str", - grant_access_data={"access": "str", "durationInSeconds": 0}, - api_version="2016-04-30-preview", + grant_access_data={ + "access": "str", + "durationInSeconds": 0, + "fileFormat": "str", + "getSecureVMGuestStateSAS": bool, + }, + api_version="2023-10-02", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -145,11 +225,11 @@ def test_begin_grant_access(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_revoke_access(self, resource_group): + def test_disks_begin_revoke_access(self, resource_group): response = self.client.disks.begin_revoke_access( resource_group_name=resource_group.name, disk_name="str", - api_version="2016-04-30-preview", + api_version="2023-10-02", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disks_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disks_operations_async.py index 5fcc4b78e169..5e58e9452090 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disks_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_disks_operations_async.py @@ -21,37 +21,93 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_disks_begin_create_or_update(self, resource_group): response = await ( await self.client.disks.begin_create_or_update( resource_group_name=resource_group.name, disk_name="str", disk={ "location": "str", - "accountType": "str", + "LastOwnershipUpdateTime": "2020-02-20 00:00:00", + "burstingEnabled": bool, + "burstingEnabledTime": "2020-02-20 00:00:00", + "completionPercent": 0.0, "creationData": { "createOption": "str", - "imageReference": {"id": "str", "lun": 0}, + "elasticSanResourceId": "str", + "galleryImageReference": { + "communityGalleryImageId": "str", + "id": "str", + "lun": 0, + "sharedGalleryImageId": "str", + }, + "imageReference": { + "communityGalleryImageId": "str", + "id": "str", + "lun": 0, + "sharedGalleryImageId": "str", + }, + "logicalSectorSize": 0, + "performancePlus": bool, + "provisionedBandwidthCopySpeed": "str", + "securityDataUri": "str", "sourceResourceId": "str", + "sourceUniqueId": "str", "sourceUri": "str", "storageAccountId": "str", + "uploadSizeBytes": 0, }, + "dataAccessAuthMode": "str", + "diskAccessId": "str", + "diskIOPSReadOnly": 0, + "diskIOPSReadWrite": 0, + "diskMBpsReadOnly": 0, + "diskMBpsReadWrite": 0, + "diskSizeBytes": 0, "diskSizeGB": 0, - "encryptionSettings": { - "diskEncryptionKey": {"secretUrl": "str", "sourceVault": {"id": "str"}}, + "diskState": "str", + "encryption": {"diskEncryptionSetId": "str", "type": "str"}, + "encryptionSettingsCollection": { "enabled": bool, - "keyEncryptionKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + "encryptionSettings": [ + { + "diskEncryptionKey": {"secretUrl": "str", "sourceVault": {"id": "str"}}, + "keyEncryptionKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + } + ], + "encryptionSettingsVersion": "str", }, + "extendedLocation": {"name": "str", "type": "str"}, + "hyperVGeneration": "str", "id": "str", + "managedBy": "str", + "managedByExtended": ["str"], + "maxShares": 0, "name": "str", + "networkAccessPolicy": "str", + "optimizedForFrequentAttach": bool, "osType": "str", - "ownerId": "str", + "propertyUpdatesInProgress": {"targetTier": "str"}, "provisioningState": "str", + "publicNetworkAccess": "str", + "purchasePlan": {"name": "str", "product": "str", "publisher": "str", "promotionCode": "str"}, + "securityProfile": {"secureVMDiskEncryptionSetId": "str", "securityType": "str"}, + "shareInfo": [{"vmUri": "str"}], + "sku": {"name": "str", "tier": "str"}, + "supportedCapabilities": { + "acceleratedNetwork": bool, + "architecture": "str", + "diskControllerTypes": "str", + }, + "supportsHibernation": bool, "tags": {"str": "str"}, + "tier": "str", "timeCreated": "2020-02-20 00:00:00", "type": "str", + "uniqueId": "str", + "zones": ["str"], }, - api_version="2016-04-30-preview", + api_version="2023-10-02", ) ).result() # call '.result()' to poll until service return final result @@ -60,30 +116,49 @@ async def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_update(self, resource_group): + async def test_disks_begin_update(self, resource_group): response = await ( await self.client.disks.begin_update( resource_group_name=resource_group.name, disk_name="str", disk={ - "accountType": "str", - "creationData": { - "createOption": "str", - "imageReference": {"id": "str", "lun": 0}, - "sourceResourceId": "str", - "sourceUri": "str", - "storageAccountId": "str", - }, + "burstingEnabled": bool, + "dataAccessAuthMode": "str", + "diskAccessId": "str", + "diskIOPSReadOnly": 0, + "diskIOPSReadWrite": 0, + "diskMBpsReadOnly": 0, + "diskMBpsReadWrite": 0, "diskSizeGB": 0, - "encryptionSettings": { - "diskEncryptionKey": {"secretUrl": "str", "sourceVault": {"id": "str"}}, + "encryption": {"diskEncryptionSetId": "str", "type": "str"}, + "encryptionSettingsCollection": { "enabled": bool, - "keyEncryptionKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + "encryptionSettings": [ + { + "diskEncryptionKey": {"secretUrl": "str", "sourceVault": {"id": "str"}}, + "keyEncryptionKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + } + ], + "encryptionSettingsVersion": "str", }, + "maxShares": 0, + "networkAccessPolicy": "str", + "optimizedForFrequentAttach": bool, "osType": "str", + "propertyUpdatesInProgress": {"targetTier": "str"}, + "publicNetworkAccess": "str", + "purchasePlan": {"name": "str", "product": "str", "publisher": "str", "promotionCode": "str"}, + "sku": {"name": "str", "tier": "str"}, + "supportedCapabilities": { + "acceleratedNetwork": bool, + "architecture": "str", + "diskControllerTypes": "str", + }, + "supportsHibernation": bool, "tags": {"str": "str"}, + "tier": "str", }, - api_version="2016-04-30-preview", + api_version="2023-10-02", ) ).result() # call '.result()' to poll until service return final result @@ -92,11 +167,11 @@ async def test_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_disks_get(self, resource_group): response = await self.client.disks.get( resource_group_name=resource_group.name, disk_name="str", - api_version="2016-04-30-preview", + api_version="2023-10-02", ) # please add some check logic here by yourself @@ -104,12 +179,12 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_delete(self, resource_group): + async def test_disks_begin_delete(self, resource_group): response = await ( await self.client.disks.begin_delete( resource_group_name=resource_group.name, disk_name="str", - api_version="2016-04-30-preview", + api_version="2023-10-02", ) ).result() # call '.result()' to poll until service return final result @@ -118,10 +193,10 @@ async def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_resource_group(self, resource_group): + async def test_disks_list_by_resource_group(self, resource_group): response = self.client.disks.list_by_resource_group( resource_group_name=resource_group.name, - api_version="2016-04-30-preview", + api_version="2023-10-02", ) result = [r async for r in response] # please add some check logic here by yourself @@ -129,9 +204,9 @@ async def test_list_by_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_disks_list(self, resource_group): response = self.client.disks.list( - api_version="2016-04-30-preview", + api_version="2023-10-02", ) result = [r async for r in response] # please add some check logic here by yourself @@ -139,13 +214,18 @@ async def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_grant_access(self, resource_group): + async def test_disks_begin_grant_access(self, resource_group): response = await ( await self.client.disks.begin_grant_access( resource_group_name=resource_group.name, disk_name="str", - grant_access_data={"access": "str", "durationInSeconds": 0}, - api_version="2016-04-30-preview", + grant_access_data={ + "access": "str", + "durationInSeconds": 0, + "fileFormat": "str", + "getSecureVMGuestStateSAS": bool, + }, + api_version="2023-10-02", ) ).result() # call '.result()' to poll until service return final result @@ -154,12 +234,12 @@ async def test_begin_grant_access(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_revoke_access(self, resource_group): + async def test_disks_begin_revoke_access(self, resource_group): response = await ( await self.client.disks.begin_revoke_access( resource_group_name=resource_group.name, disk_name="str", - api_version="2016-04-30-preview", + api_version="2023-10-02", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_galleries_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_galleries_operations.py index 7e5500b4918c..99efaa88e52d 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_galleries_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_galleries_begin_create_or_update(self, resource_group): response = self.client.galleries.begin_create_or_update( resource_group_name=resource_group.name, gallery_name="str", @@ -31,10 +31,27 @@ def test_begin_create_or_update(self, resource_group): "identifier": {"uniqueName": "str"}, "name": "str", "provisioningState": "str", + "sharingProfile": { + "communityGalleryInfo": { + "communityGalleryEnabled": bool, + "eula": "str", + "publicNamePrefix": "str", + "publicNames": ["str"], + "publisherContact": "str", + "publisherUri": "str", + }, + "groups": [{"ids": ["str"], "type": "str"}], + "permissions": "str", + }, + "sharingStatus": { + "aggregatedState": "str", + "summary": [{"details": "str", "region": "str", "state": "str"}], + }, + "softDeletePolicy": {"isSoftDeleteEnabled": bool}, "tags": {"str": "str"}, "type": "str", }, - api_version="2018-06-01", + api_version="2023-07-03", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -42,11 +59,49 @@ def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_galleries_begin_update(self, resource_group): + response = self.client.galleries.begin_update( + resource_group_name=resource_group.name, + gallery_name="str", + gallery={ + "description": "str", + "id": "str", + "identifier": {"uniqueName": "str"}, + "name": "str", + "provisioningState": "str", + "sharingProfile": { + "communityGalleryInfo": { + "communityGalleryEnabled": bool, + "eula": "str", + "publicNamePrefix": "str", + "publicNames": ["str"], + "publisherContact": "str", + "publisherUri": "str", + }, + "groups": [{"ids": ["str"], "type": "str"}], + "permissions": "str", + }, + "sharingStatus": { + "aggregatedState": "str", + "summary": [{"details": "str", "region": "str", "state": "str"}], + }, + "softDeletePolicy": {"isSoftDeleteEnabled": bool}, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-03", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_galleries_get(self, resource_group): response = self.client.galleries.get( resource_group_name=resource_group.name, gallery_name="str", - api_version="2018-06-01", + api_version="2023-07-03", ) # please add some check logic here by yourself @@ -54,11 +109,11 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_delete(self, resource_group): + def test_galleries_begin_delete(self, resource_group): response = self.client.galleries.begin_delete( resource_group_name=resource_group.name, gallery_name="str", - api_version="2018-06-01", + api_version="2023-07-03", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -66,10 +121,10 @@ def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_resource_group(self, resource_group): + def test_galleries_list_by_resource_group(self, resource_group): response = self.client.galleries.list_by_resource_group( resource_group_name=resource_group.name, - api_version="2018-06-01", + api_version="2023-07-03", ) result = [r for r in response] # please add some check logic here by yourself @@ -77,9 +132,9 @@ def test_list_by_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_galleries_list(self, resource_group): response = self.client.galleries.list( - api_version="2018-06-01", + api_version="2023-07-03", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_galleries_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_galleries_operations_async.py index fa1b890f14fd..8ae9a07cfbeb 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_galleries_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_galleries_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_galleries_begin_create_or_update(self, resource_group): response = await ( await self.client.galleries.begin_create_or_update( resource_group_name=resource_group.name, @@ -33,10 +33,27 @@ async def test_begin_create_or_update(self, resource_group): "identifier": {"uniqueName": "str"}, "name": "str", "provisioningState": "str", + "sharingProfile": { + "communityGalleryInfo": { + "communityGalleryEnabled": bool, + "eula": "str", + "publicNamePrefix": "str", + "publicNames": ["str"], + "publisherContact": "str", + "publisherUri": "str", + }, + "groups": [{"ids": ["str"], "type": "str"}], + "permissions": "str", + }, + "sharingStatus": { + "aggregatedState": "str", + "summary": [{"details": "str", "region": "str", "state": "str"}], + }, + "softDeletePolicy": {"isSoftDeleteEnabled": bool}, "tags": {"str": "str"}, "type": "str", }, - api_version="2018-06-01", + api_version="2023-07-03", ) ).result() # call '.result()' to poll until service return final result @@ -45,11 +62,51 @@ async def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_galleries_begin_update(self, resource_group): + response = await ( + await self.client.galleries.begin_update( + resource_group_name=resource_group.name, + gallery_name="str", + gallery={ + "description": "str", + "id": "str", + "identifier": {"uniqueName": "str"}, + "name": "str", + "provisioningState": "str", + "sharingProfile": { + "communityGalleryInfo": { + "communityGalleryEnabled": bool, + "eula": "str", + "publicNamePrefix": "str", + "publicNames": ["str"], + "publisherContact": "str", + "publisherUri": "str", + }, + "groups": [{"ids": ["str"], "type": "str"}], + "permissions": "str", + }, + "sharingStatus": { + "aggregatedState": "str", + "summary": [{"details": "str", "region": "str", "state": "str"}], + }, + "softDeletePolicy": {"isSoftDeleteEnabled": bool}, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-03", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_galleries_get(self, resource_group): response = await self.client.galleries.get( resource_group_name=resource_group.name, gallery_name="str", - api_version="2018-06-01", + api_version="2023-07-03", ) # please add some check logic here by yourself @@ -57,12 +114,12 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_delete(self, resource_group): + async def test_galleries_begin_delete(self, resource_group): response = await ( await self.client.galleries.begin_delete( resource_group_name=resource_group.name, gallery_name="str", - api_version="2018-06-01", + api_version="2023-07-03", ) ).result() # call '.result()' to poll until service return final result @@ -71,10 +128,10 @@ async def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_resource_group(self, resource_group): + async def test_galleries_list_by_resource_group(self, resource_group): response = self.client.galleries.list_by_resource_group( resource_group_name=resource_group.name, - api_version="2018-06-01", + api_version="2023-07-03", ) result = [r async for r in response] # please add some check logic here by yourself @@ -82,9 +139,9 @@ async def test_list_by_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_galleries_list(self, resource_group): response = self.client.galleries.list( - api_version="2018-06-01", + api_version="2023-07-03", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_application_versions_operations.py index 6a991d328cac..6754d21022fa 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_application_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_application_versions_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_gallery_application_versions_begin_create_or_update(self, resource_group): response = self.client.gallery_application_versions.begin_create_or_update( resource_group_name=resource_group.name, gallery_name="str", @@ -33,23 +33,78 @@ def test_begin_create_or_update(self, resource_group): "provisioningState": "str", "publishingProfile": { "source": {"mediaLink": "str", "defaultConfigurationLink": "str"}, + "advancedSettings": {"str": "str"}, + "customActions": [ + { + "name": "str", + "script": "str", + "description": "str", + "parameters": [ + { + "name": "str", + "defaultValue": "str", + "description": "str", + "required": bool, + "type": "str", + } + ], + } + ], "enableHealthCheck": bool, "endOfLifeDate": "2020-02-20 00:00:00", "excludeFromLatest": bool, "manageActions": {"install": "str", "remove": "str", "update": "str"}, "publishedDate": "2020-02-20 00:00:00", "replicaCount": 0, + "replicationMode": "str", + "settings": {"configFileName": "str", "packageFileName": "str"}, "storageAccountType": "str", - "targetRegions": [{"name": "str", "regionalReplicaCount": 0, "storageAccountType": "str"}], + "targetExtendedLocations": [ + { + "encryption": { + "dataDiskImages": [{"lun": 0, "diskEncryptionSetId": "str"}], + "osDiskImage": { + "diskEncryptionSetId": "str", + "securityProfile": { + "confidentialVMEncryptionType": "str", + "secureVMDiskEncryptionSetId": "str", + }, + }, + }, + "extendedLocation": {"name": "str", "type": "str"}, + "extendedLocationReplicaCount": 0, + "name": "str", + "storageAccountType": "str", + } + ], + "targetRegions": [ + { + "name": "str", + "encryption": { + "dataDiskImages": [{"lun": 0, "diskEncryptionSetId": "str"}], + "osDiskImage": { + "diskEncryptionSetId": "str", + "securityProfile": { + "confidentialVMEncryptionType": "str", + "secureVMDiskEncryptionSetId": "str", + }, + }, + }, + "excludeFromLatest": bool, + "regionalReplicaCount": 0, + "storageAccountType": "str", + } + ], }, "replicationStatus": { "aggregatedState": "str", "summary": [{"details": "str", "progress": 0, "region": "str", "state": "str"}], }, + "safetyProfile": {"allowDeletionOfReplicatedLocations": bool}, "tags": {"str": "str"}, "type": "str", }, - api_version="2019-03-01", + api_version="2023-07-03", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -57,13 +112,104 @@ def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_gallery_application_versions_begin_update(self, resource_group): + response = self.client.gallery_application_versions.begin_update( + resource_group_name=resource_group.name, + gallery_name="str", + gallery_application_name="str", + gallery_application_version_name="str", + gallery_application_version={ + "id": "str", + "name": "str", + "provisioningState": "str", + "publishingProfile": { + "source": {"mediaLink": "str", "defaultConfigurationLink": "str"}, + "advancedSettings": {"str": "str"}, + "customActions": [ + { + "name": "str", + "script": "str", + "description": "str", + "parameters": [ + { + "name": "str", + "defaultValue": "str", + "description": "str", + "required": bool, + "type": "str", + } + ], + } + ], + "enableHealthCheck": bool, + "endOfLifeDate": "2020-02-20 00:00:00", + "excludeFromLatest": bool, + "manageActions": {"install": "str", "remove": "str", "update": "str"}, + "publishedDate": "2020-02-20 00:00:00", + "replicaCount": 0, + "replicationMode": "str", + "settings": {"configFileName": "str", "packageFileName": "str"}, + "storageAccountType": "str", + "targetExtendedLocations": [ + { + "encryption": { + "dataDiskImages": [{"lun": 0, "diskEncryptionSetId": "str"}], + "osDiskImage": { + "diskEncryptionSetId": "str", + "securityProfile": { + "confidentialVMEncryptionType": "str", + "secureVMDiskEncryptionSetId": "str", + }, + }, + }, + "extendedLocation": {"name": "str", "type": "str"}, + "extendedLocationReplicaCount": 0, + "name": "str", + "storageAccountType": "str", + } + ], + "targetRegions": [ + { + "name": "str", + "encryption": { + "dataDiskImages": [{"lun": 0, "diskEncryptionSetId": "str"}], + "osDiskImage": { + "diskEncryptionSetId": "str", + "securityProfile": { + "confidentialVMEncryptionType": "str", + "secureVMDiskEncryptionSetId": "str", + }, + }, + }, + "excludeFromLatest": bool, + "regionalReplicaCount": 0, + "storageAccountType": "str", + } + ], + }, + "replicationStatus": { + "aggregatedState": "str", + "summary": [{"details": "str", "progress": 0, "region": "str", "state": "str"}], + }, + "safetyProfile": {"allowDeletionOfReplicatedLocations": bool}, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-03", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_gallery_application_versions_get(self, resource_group): response = self.client.gallery_application_versions.get( resource_group_name=resource_group.name, gallery_name="str", gallery_application_name="str", gallery_application_version_name="str", - api_version="2019-03-01", + api_version="2023-07-03", ) # please add some check logic here by yourself @@ -71,13 +217,13 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_delete(self, resource_group): + def test_gallery_application_versions_begin_delete(self, resource_group): response = self.client.gallery_application_versions.begin_delete( resource_group_name=resource_group.name, gallery_name="str", gallery_application_name="str", gallery_application_version_name="str", - api_version="2019-03-01", + api_version="2023-07-03", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -85,12 +231,12 @@ def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_gallery_application(self, resource_group): + def test_gallery_application_versions_list_by_gallery_application(self, resource_group): response = self.client.gallery_application_versions.list_by_gallery_application( resource_group_name=resource_group.name, gallery_name="str", gallery_application_name="str", - api_version="2019-03-01", + api_version="2023-07-03", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_application_versions_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_application_versions_operations_async.py index 9d95ce96579b..807d0e0c10e7 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_application_versions_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_application_versions_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_gallery_application_versions_begin_create_or_update(self, resource_group): response = await ( await self.client.gallery_application_versions.begin_create_or_update( resource_group_name=resource_group.name, @@ -35,23 +35,78 @@ async def test_begin_create_or_update(self, resource_group): "provisioningState": "str", "publishingProfile": { "source": {"mediaLink": "str", "defaultConfigurationLink": "str"}, + "advancedSettings": {"str": "str"}, + "customActions": [ + { + "name": "str", + "script": "str", + "description": "str", + "parameters": [ + { + "name": "str", + "defaultValue": "str", + "description": "str", + "required": bool, + "type": "str", + } + ], + } + ], "enableHealthCheck": bool, "endOfLifeDate": "2020-02-20 00:00:00", "excludeFromLatest": bool, "manageActions": {"install": "str", "remove": "str", "update": "str"}, "publishedDate": "2020-02-20 00:00:00", "replicaCount": 0, + "replicationMode": "str", + "settings": {"configFileName": "str", "packageFileName": "str"}, "storageAccountType": "str", - "targetRegions": [{"name": "str", "regionalReplicaCount": 0, "storageAccountType": "str"}], + "targetExtendedLocations": [ + { + "encryption": { + "dataDiskImages": [{"lun": 0, "diskEncryptionSetId": "str"}], + "osDiskImage": { + "diskEncryptionSetId": "str", + "securityProfile": { + "confidentialVMEncryptionType": "str", + "secureVMDiskEncryptionSetId": "str", + }, + }, + }, + "extendedLocation": {"name": "str", "type": "str"}, + "extendedLocationReplicaCount": 0, + "name": "str", + "storageAccountType": "str", + } + ], + "targetRegions": [ + { + "name": "str", + "encryption": { + "dataDiskImages": [{"lun": 0, "diskEncryptionSetId": "str"}], + "osDiskImage": { + "diskEncryptionSetId": "str", + "securityProfile": { + "confidentialVMEncryptionType": "str", + "secureVMDiskEncryptionSetId": "str", + }, + }, + }, + "excludeFromLatest": bool, + "regionalReplicaCount": 0, + "storageAccountType": "str", + } + ], }, "replicationStatus": { "aggregatedState": "str", "summary": [{"details": "str", "progress": 0, "region": "str", "state": "str"}], }, + "safetyProfile": {"allowDeletionOfReplicatedLocations": bool}, "tags": {"str": "str"}, "type": "str", }, - api_version="2019-03-01", + api_version="2023-07-03", ) ).result() # call '.result()' to poll until service return final result @@ -60,13 +115,106 @@ async def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_gallery_application_versions_begin_update(self, resource_group): + response = await ( + await self.client.gallery_application_versions.begin_update( + resource_group_name=resource_group.name, + gallery_name="str", + gallery_application_name="str", + gallery_application_version_name="str", + gallery_application_version={ + "id": "str", + "name": "str", + "provisioningState": "str", + "publishingProfile": { + "source": {"mediaLink": "str", "defaultConfigurationLink": "str"}, + "advancedSettings": {"str": "str"}, + "customActions": [ + { + "name": "str", + "script": "str", + "description": "str", + "parameters": [ + { + "name": "str", + "defaultValue": "str", + "description": "str", + "required": bool, + "type": "str", + } + ], + } + ], + "enableHealthCheck": bool, + "endOfLifeDate": "2020-02-20 00:00:00", + "excludeFromLatest": bool, + "manageActions": {"install": "str", "remove": "str", "update": "str"}, + "publishedDate": "2020-02-20 00:00:00", + "replicaCount": 0, + "replicationMode": "str", + "settings": {"configFileName": "str", "packageFileName": "str"}, + "storageAccountType": "str", + "targetExtendedLocations": [ + { + "encryption": { + "dataDiskImages": [{"lun": 0, "diskEncryptionSetId": "str"}], + "osDiskImage": { + "diskEncryptionSetId": "str", + "securityProfile": { + "confidentialVMEncryptionType": "str", + "secureVMDiskEncryptionSetId": "str", + }, + }, + }, + "extendedLocation": {"name": "str", "type": "str"}, + "extendedLocationReplicaCount": 0, + "name": "str", + "storageAccountType": "str", + } + ], + "targetRegions": [ + { + "name": "str", + "encryption": { + "dataDiskImages": [{"lun": 0, "diskEncryptionSetId": "str"}], + "osDiskImage": { + "diskEncryptionSetId": "str", + "securityProfile": { + "confidentialVMEncryptionType": "str", + "secureVMDiskEncryptionSetId": "str", + }, + }, + }, + "excludeFromLatest": bool, + "regionalReplicaCount": 0, + "storageAccountType": "str", + } + ], + }, + "replicationStatus": { + "aggregatedState": "str", + "summary": [{"details": "str", "progress": 0, "region": "str", "state": "str"}], + }, + "safetyProfile": {"allowDeletionOfReplicatedLocations": bool}, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-03", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_gallery_application_versions_get(self, resource_group): response = await self.client.gallery_application_versions.get( resource_group_name=resource_group.name, gallery_name="str", gallery_application_name="str", gallery_application_version_name="str", - api_version="2019-03-01", + api_version="2023-07-03", ) # please add some check logic here by yourself @@ -74,14 +222,14 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_delete(self, resource_group): + async def test_gallery_application_versions_begin_delete(self, resource_group): response = await ( await self.client.gallery_application_versions.begin_delete( resource_group_name=resource_group.name, gallery_name="str", gallery_application_name="str", gallery_application_version_name="str", - api_version="2019-03-01", + api_version="2023-07-03", ) ).result() # call '.result()' to poll until service return final result @@ -90,12 +238,12 @@ async def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_gallery_application(self, resource_group): + async def test_gallery_application_versions_list_by_gallery_application(self, resource_group): response = self.client.gallery_application_versions.list_by_gallery_application( resource_group_name=resource_group.name, gallery_name="str", gallery_application_name="str", - api_version="2019-03-01", + api_version="2023-07-03", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_applications_operations.py index 3c4836c70777..b1955bc74695 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_applications_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_applications_operations.py @@ -20,13 +20,29 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_gallery_applications_begin_create_or_update(self, resource_group): response = self.client.gallery_applications.begin_create_or_update( resource_group_name=resource_group.name, gallery_name="str", gallery_application_name="str", gallery_application={ "location": "str", + "customActions": [ + { + "name": "str", + "script": "str", + "description": "str", + "parameters": [ + { + "name": "str", + "defaultValue": "str", + "description": "str", + "required": bool, + "type": "str", + } + ], + } + ], "description": "str", "endOfLifeDate": "2020-02-20 00:00:00", "eula": "str", @@ -38,7 +54,7 @@ def test_begin_create_or_update(self, resource_group): "tags": {"str": "str"}, "type": "str", }, - api_version="2019-03-01", + api_version="2023-07-03", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -46,12 +62,53 @@ def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_gallery_applications_begin_update(self, resource_group): + response = self.client.gallery_applications.begin_update( + resource_group_name=resource_group.name, + gallery_name="str", + gallery_application_name="str", + gallery_application={ + "customActions": [ + { + "name": "str", + "script": "str", + "description": "str", + "parameters": [ + { + "name": "str", + "defaultValue": "str", + "description": "str", + "required": bool, + "type": "str", + } + ], + } + ], + "description": "str", + "endOfLifeDate": "2020-02-20 00:00:00", + "eula": "str", + "id": "str", + "name": "str", + "privacyStatementUri": "str", + "releaseNoteUri": "str", + "supportedOSType": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-03", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_gallery_applications_get(self, resource_group): response = self.client.gallery_applications.get( resource_group_name=resource_group.name, gallery_name="str", gallery_application_name="str", - api_version="2019-03-01", + api_version="2023-07-03", ) # please add some check logic here by yourself @@ -59,12 +116,12 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_delete(self, resource_group): + def test_gallery_applications_begin_delete(self, resource_group): response = self.client.gallery_applications.begin_delete( resource_group_name=resource_group.name, gallery_name="str", gallery_application_name="str", - api_version="2019-03-01", + api_version="2023-07-03", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -72,11 +129,11 @@ def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_gallery(self, resource_group): + def test_gallery_applications_list_by_gallery(self, resource_group): response = self.client.gallery_applications.list_by_gallery( resource_group_name=resource_group.name, gallery_name="str", - api_version="2019-03-01", + api_version="2023-07-03", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_applications_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_applications_operations_async.py index cb90dfa41ff0..9c6f68fd9242 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_applications_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_applications_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_gallery_applications_begin_create_or_update(self, resource_group): response = await ( await self.client.gallery_applications.begin_create_or_update( resource_group_name=resource_group.name, @@ -29,6 +29,22 @@ async def test_begin_create_or_update(self, resource_group): gallery_application_name="str", gallery_application={ "location": "str", + "customActions": [ + { + "name": "str", + "script": "str", + "description": "str", + "parameters": [ + { + "name": "str", + "defaultValue": "str", + "description": "str", + "required": bool, + "type": "str", + } + ], + } + ], "description": "str", "endOfLifeDate": "2020-02-20 00:00:00", "eula": "str", @@ -40,7 +56,7 @@ async def test_begin_create_or_update(self, resource_group): "tags": {"str": "str"}, "type": "str", }, - api_version="2019-03-01", + api_version="2023-07-03", ) ).result() # call '.result()' to poll until service return final result @@ -49,12 +65,55 @@ async def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_gallery_applications_begin_update(self, resource_group): + response = await ( + await self.client.gallery_applications.begin_update( + resource_group_name=resource_group.name, + gallery_name="str", + gallery_application_name="str", + gallery_application={ + "customActions": [ + { + "name": "str", + "script": "str", + "description": "str", + "parameters": [ + { + "name": "str", + "defaultValue": "str", + "description": "str", + "required": bool, + "type": "str", + } + ], + } + ], + "description": "str", + "endOfLifeDate": "2020-02-20 00:00:00", + "eula": "str", + "id": "str", + "name": "str", + "privacyStatementUri": "str", + "releaseNoteUri": "str", + "supportedOSType": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-03", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_gallery_applications_get(self, resource_group): response = await self.client.gallery_applications.get( resource_group_name=resource_group.name, gallery_name="str", gallery_application_name="str", - api_version="2019-03-01", + api_version="2023-07-03", ) # please add some check logic here by yourself @@ -62,13 +121,13 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_delete(self, resource_group): + async def test_gallery_applications_begin_delete(self, resource_group): response = await ( await self.client.gallery_applications.begin_delete( resource_group_name=resource_group.name, gallery_name="str", gallery_application_name="str", - api_version="2019-03-01", + api_version="2023-07-03", ) ).result() # call '.result()' to poll until service return final result @@ -77,11 +136,11 @@ async def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_gallery(self, resource_group): + async def test_gallery_applications_list_by_gallery(self, resource_group): response = self.client.gallery_applications.list_by_gallery( resource_group_name=resource_group.name, gallery_name="str", - api_version="2019-03-01", + api_version="2023-07-03", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_image_versions_operations.py index 94ee1209344d..991a6f7e970c 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_image_versions_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_gallery_image_versions_begin_create_or_update(self, resource_group): response = self.client.gallery_image_versions.begin_create_or_update( resource_group_name=resource_group.name, gallery_name="str", @@ -32,25 +32,190 @@ def test_begin_create_or_update(self, resource_group): "name": "str", "provisioningState": "str", "publishingProfile": { - "source": {"managedImage": {"id": "str"}}, "endOfLifeDate": "2020-02-20 00:00:00", "excludeFromLatest": bool, "publishedDate": "2020-02-20 00:00:00", "replicaCount": 0, - "targetRegions": [{"name": "str", "regionalReplicaCount": 0}], + "replicationMode": "str", + "storageAccountType": "str", + "targetExtendedLocations": [ + { + "encryption": { + "dataDiskImages": [{"lun": 0, "diskEncryptionSetId": "str"}], + "osDiskImage": { + "diskEncryptionSetId": "str", + "securityProfile": { + "confidentialVMEncryptionType": "str", + "secureVMDiskEncryptionSetId": "str", + }, + }, + }, + "extendedLocation": {"name": "str", "type": "str"}, + "extendedLocationReplicaCount": 0, + "name": "str", + "storageAccountType": "str", + } + ], + "targetRegions": [ + { + "name": "str", + "encryption": { + "dataDiskImages": [{"lun": 0, "diskEncryptionSetId": "str"}], + "osDiskImage": { + "diskEncryptionSetId": "str", + "securityProfile": { + "confidentialVMEncryptionType": "str", + "secureVMDiskEncryptionSetId": "str", + }, + }, + }, + "excludeFromLatest": bool, + "regionalReplicaCount": 0, + "storageAccountType": "str", + } + ], }, "replicationStatus": { "aggregatedState": "str", "summary": [{"details": "str", "progress": 0, "region": "str", "state": "str"}], }, + "safetyProfile": { + "allowDeletionOfReplicatedLocations": bool, + "policyViolations": [{"category": "str", "details": "str"}], + "reportedForPolicyViolation": bool, + }, + "securityProfile": { + "uefiSettings": { + "additionalSignatures": { + "db": [{"type": "str", "value": ["str"]}], + "dbx": [{"type": "str", "value": ["str"]}], + "kek": [{"type": "str", "value": ["str"]}], + "pk": {"type": "str", "value": ["str"]}, + }, + "signatureTemplateNames": ["str"], + } + }, + "storageProfile": { + "dataDiskImages": [ + { + "lun": 0, + "hostCaching": "str", + "sizeInGB": 0, + "source": {"id": "str", "storageAccountId": "str", "uri": "str"}, + } + ], + "osDiskImage": { + "hostCaching": "str", + "sizeInGB": 0, + "source": {"id": "str", "storageAccountId": "str", "uri": "str"}, + }, + "source": {"communityGalleryImageId": "str", "id": "str", "virtualMachineId": "str"}, + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-03", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_gallery_image_versions_begin_update(self, resource_group): + response = self.client.gallery_image_versions.begin_update( + resource_group_name=resource_group.name, + gallery_name="str", + gallery_image_name="str", + gallery_image_version_name="str", + gallery_image_version={ + "id": "str", + "name": "str", + "provisioningState": "str", + "publishingProfile": { + "endOfLifeDate": "2020-02-20 00:00:00", + "excludeFromLatest": bool, + "publishedDate": "2020-02-20 00:00:00", + "replicaCount": 0, + "replicationMode": "str", + "storageAccountType": "str", + "targetExtendedLocations": [ + { + "encryption": { + "dataDiskImages": [{"lun": 0, "diskEncryptionSetId": "str"}], + "osDiskImage": { + "diskEncryptionSetId": "str", + "securityProfile": { + "confidentialVMEncryptionType": "str", + "secureVMDiskEncryptionSetId": "str", + }, + }, + }, + "extendedLocation": {"name": "str", "type": "str"}, + "extendedLocationReplicaCount": 0, + "name": "str", + "storageAccountType": "str", + } + ], + "targetRegions": [ + { + "name": "str", + "encryption": { + "dataDiskImages": [{"lun": 0, "diskEncryptionSetId": "str"}], + "osDiskImage": { + "diskEncryptionSetId": "str", + "securityProfile": { + "confidentialVMEncryptionType": "str", + "secureVMDiskEncryptionSetId": "str", + }, + }, + }, + "excludeFromLatest": bool, + "regionalReplicaCount": 0, + "storageAccountType": "str", + } + ], + }, + "replicationStatus": { + "aggregatedState": "str", + "summary": [{"details": "str", "progress": 0, "region": "str", "state": "str"}], + }, + "safetyProfile": { + "allowDeletionOfReplicatedLocations": bool, + "policyViolations": [{"category": "str", "details": "str"}], + "reportedForPolicyViolation": bool, + }, + "securityProfile": { + "uefiSettings": { + "additionalSignatures": { + "db": [{"type": "str", "value": ["str"]}], + "dbx": [{"type": "str", "value": ["str"]}], + "kek": [{"type": "str", "value": ["str"]}], + "pk": {"type": "str", "value": ["str"]}, + }, + "signatureTemplateNames": ["str"], + } + }, "storageProfile": { - "dataDiskImages": [{"hostCaching": "str", "lun": 0, "sizeInGB": 0}], - "osDiskImage": {"hostCaching": "str", "sizeInGB": 0}, + "dataDiskImages": [ + { + "lun": 0, + "hostCaching": "str", + "sizeInGB": 0, + "source": {"id": "str", "storageAccountId": "str", "uri": "str"}, + } + ], + "osDiskImage": { + "hostCaching": "str", + "sizeInGB": 0, + "source": {"id": "str", "storageAccountId": "str", "uri": "str"}, + }, + "source": {"communityGalleryImageId": "str", "id": "str", "virtualMachineId": "str"}, }, "tags": {"str": "str"}, "type": "str", }, - api_version="2018-06-01", + api_version="2023-07-03", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -58,13 +223,13 @@ def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_gallery_image_versions_get(self, resource_group): response = self.client.gallery_image_versions.get( resource_group_name=resource_group.name, gallery_name="str", gallery_image_name="str", gallery_image_version_name="str", - api_version="2018-06-01", + api_version="2023-07-03", ) # please add some check logic here by yourself @@ -72,13 +237,13 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_delete(self, resource_group): + def test_gallery_image_versions_begin_delete(self, resource_group): response = self.client.gallery_image_versions.begin_delete( resource_group_name=resource_group.name, gallery_name="str", gallery_image_name="str", gallery_image_version_name="str", - api_version="2018-06-01", + api_version="2023-07-03", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -86,12 +251,12 @@ def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_gallery_image(self, resource_group): + def test_gallery_image_versions_list_by_gallery_image(self, resource_group): response = self.client.gallery_image_versions.list_by_gallery_image( resource_group_name=resource_group.name, gallery_name="str", gallery_image_name="str", - api_version="2018-06-01", + api_version="2023-07-03", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_image_versions_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_image_versions_operations_async.py index 34418c47fc57..311337a4be52 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_image_versions_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_image_versions_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_gallery_image_versions_begin_create_or_update(self, resource_group): response = await ( await self.client.gallery_image_versions.begin_create_or_update( resource_group_name=resource_group.name, @@ -34,25 +34,192 @@ async def test_begin_create_or_update(self, resource_group): "name": "str", "provisioningState": "str", "publishingProfile": { - "source": {"managedImage": {"id": "str"}}, "endOfLifeDate": "2020-02-20 00:00:00", "excludeFromLatest": bool, "publishedDate": "2020-02-20 00:00:00", "replicaCount": 0, - "targetRegions": [{"name": "str", "regionalReplicaCount": 0}], + "replicationMode": "str", + "storageAccountType": "str", + "targetExtendedLocations": [ + { + "encryption": { + "dataDiskImages": [{"lun": 0, "diskEncryptionSetId": "str"}], + "osDiskImage": { + "diskEncryptionSetId": "str", + "securityProfile": { + "confidentialVMEncryptionType": "str", + "secureVMDiskEncryptionSetId": "str", + }, + }, + }, + "extendedLocation": {"name": "str", "type": "str"}, + "extendedLocationReplicaCount": 0, + "name": "str", + "storageAccountType": "str", + } + ], + "targetRegions": [ + { + "name": "str", + "encryption": { + "dataDiskImages": [{"lun": 0, "diskEncryptionSetId": "str"}], + "osDiskImage": { + "diskEncryptionSetId": "str", + "securityProfile": { + "confidentialVMEncryptionType": "str", + "secureVMDiskEncryptionSetId": "str", + }, + }, + }, + "excludeFromLatest": bool, + "regionalReplicaCount": 0, + "storageAccountType": "str", + } + ], }, "replicationStatus": { "aggregatedState": "str", "summary": [{"details": "str", "progress": 0, "region": "str", "state": "str"}], }, + "safetyProfile": { + "allowDeletionOfReplicatedLocations": bool, + "policyViolations": [{"category": "str", "details": "str"}], + "reportedForPolicyViolation": bool, + }, + "securityProfile": { + "uefiSettings": { + "additionalSignatures": { + "db": [{"type": "str", "value": ["str"]}], + "dbx": [{"type": "str", "value": ["str"]}], + "kek": [{"type": "str", "value": ["str"]}], + "pk": {"type": "str", "value": ["str"]}, + }, + "signatureTemplateNames": ["str"], + } + }, + "storageProfile": { + "dataDiskImages": [ + { + "lun": 0, + "hostCaching": "str", + "sizeInGB": 0, + "source": {"id": "str", "storageAccountId": "str", "uri": "str"}, + } + ], + "osDiskImage": { + "hostCaching": "str", + "sizeInGB": 0, + "source": {"id": "str", "storageAccountId": "str", "uri": "str"}, + }, + "source": {"communityGalleryImageId": "str", "id": "str", "virtualMachineId": "str"}, + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-03", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_gallery_image_versions_begin_update(self, resource_group): + response = await ( + await self.client.gallery_image_versions.begin_update( + resource_group_name=resource_group.name, + gallery_name="str", + gallery_image_name="str", + gallery_image_version_name="str", + gallery_image_version={ + "id": "str", + "name": "str", + "provisioningState": "str", + "publishingProfile": { + "endOfLifeDate": "2020-02-20 00:00:00", + "excludeFromLatest": bool, + "publishedDate": "2020-02-20 00:00:00", + "replicaCount": 0, + "replicationMode": "str", + "storageAccountType": "str", + "targetExtendedLocations": [ + { + "encryption": { + "dataDiskImages": [{"lun": 0, "diskEncryptionSetId": "str"}], + "osDiskImage": { + "diskEncryptionSetId": "str", + "securityProfile": { + "confidentialVMEncryptionType": "str", + "secureVMDiskEncryptionSetId": "str", + }, + }, + }, + "extendedLocation": {"name": "str", "type": "str"}, + "extendedLocationReplicaCount": 0, + "name": "str", + "storageAccountType": "str", + } + ], + "targetRegions": [ + { + "name": "str", + "encryption": { + "dataDiskImages": [{"lun": 0, "diskEncryptionSetId": "str"}], + "osDiskImage": { + "diskEncryptionSetId": "str", + "securityProfile": { + "confidentialVMEncryptionType": "str", + "secureVMDiskEncryptionSetId": "str", + }, + }, + }, + "excludeFromLatest": bool, + "regionalReplicaCount": 0, + "storageAccountType": "str", + } + ], + }, + "replicationStatus": { + "aggregatedState": "str", + "summary": [{"details": "str", "progress": 0, "region": "str", "state": "str"}], + }, + "safetyProfile": { + "allowDeletionOfReplicatedLocations": bool, + "policyViolations": [{"category": "str", "details": "str"}], + "reportedForPolicyViolation": bool, + }, + "securityProfile": { + "uefiSettings": { + "additionalSignatures": { + "db": [{"type": "str", "value": ["str"]}], + "dbx": [{"type": "str", "value": ["str"]}], + "kek": [{"type": "str", "value": ["str"]}], + "pk": {"type": "str", "value": ["str"]}, + }, + "signatureTemplateNames": ["str"], + } + }, "storageProfile": { - "dataDiskImages": [{"hostCaching": "str", "lun": 0, "sizeInGB": 0}], - "osDiskImage": {"hostCaching": "str", "sizeInGB": 0}, + "dataDiskImages": [ + { + "lun": 0, + "hostCaching": "str", + "sizeInGB": 0, + "source": {"id": "str", "storageAccountId": "str", "uri": "str"}, + } + ], + "osDiskImage": { + "hostCaching": "str", + "sizeInGB": 0, + "source": {"id": "str", "storageAccountId": "str", "uri": "str"}, + }, + "source": {"communityGalleryImageId": "str", "id": "str", "virtualMachineId": "str"}, }, "tags": {"str": "str"}, "type": "str", }, - api_version="2018-06-01", + api_version="2023-07-03", ) ).result() # call '.result()' to poll until service return final result @@ -61,13 +228,13 @@ async def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_gallery_image_versions_get(self, resource_group): response = await self.client.gallery_image_versions.get( resource_group_name=resource_group.name, gallery_name="str", gallery_image_name="str", gallery_image_version_name="str", - api_version="2018-06-01", + api_version="2023-07-03", ) # please add some check logic here by yourself @@ -75,14 +242,14 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_delete(self, resource_group): + async def test_gallery_image_versions_begin_delete(self, resource_group): response = await ( await self.client.gallery_image_versions.begin_delete( resource_group_name=resource_group.name, gallery_name="str", gallery_image_name="str", gallery_image_version_name="str", - api_version="2018-06-01", + api_version="2023-07-03", ) ).result() # call '.result()' to poll until service return final result @@ -91,12 +258,12 @@ async def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_gallery_image(self, resource_group): + async def test_gallery_image_versions_list_by_gallery_image(self, resource_group): response = self.client.gallery_image_versions.list_by_gallery_image( resource_group_name=resource_group.name, gallery_name="str", gallery_image_name="str", - api_version="2018-06-01", + api_version="2023-07-03", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_images_operations.py index 7aadd5214b94..4fd8a5786c43 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_images_operations.py @@ -20,17 +20,20 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_gallery_images_begin_create_or_update(self, resource_group): response = self.client.gallery_images.begin_create_or_update( resource_group_name=resource_group.name, gallery_name="str", gallery_image_name="str", gallery_image={ "location": "str", + "architecture": "str", "description": "str", "disallowed": {"diskTypes": ["str"]}, "endOfLifeDate": "2020-02-20 00:00:00", "eula": "str", + "features": [{"name": "str", "value": "str"}], + "hyperVGeneration": "str", "id": "str", "identifier": {"offer": "str", "publisher": "str", "sku": "str"}, "name": "str", @@ -44,7 +47,7 @@ def test_begin_create_or_update(self, resource_group): "tags": {"str": "str"}, "type": "str", }, - api_version="2018-06-01", + api_version="2023-07-03", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -52,12 +55,46 @@ def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_gallery_images_begin_update(self, resource_group): + response = self.client.gallery_images.begin_update( + resource_group_name=resource_group.name, + gallery_name="str", + gallery_image_name="str", + gallery_image={ + "architecture": "str", + "description": "str", + "disallowed": {"diskTypes": ["str"]}, + "endOfLifeDate": "2020-02-20 00:00:00", + "eula": "str", + "features": [{"name": "str", "value": "str"}], + "hyperVGeneration": "str", + "id": "str", + "identifier": {"offer": "str", "publisher": "str", "sku": "str"}, + "name": "str", + "osState": "str", + "osType": "str", + "privacyStatementUri": "str", + "provisioningState": "str", + "purchasePlan": {"name": "str", "product": "str", "publisher": "str"}, + "recommended": {"memory": {"max": 0, "min": 0}, "vCPUs": {"max": 0, "min": 0}}, + "releaseNoteUri": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-03", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_gallery_images_get(self, resource_group): response = self.client.gallery_images.get( resource_group_name=resource_group.name, gallery_name="str", gallery_image_name="str", - api_version="2018-06-01", + api_version="2023-07-03", ) # please add some check logic here by yourself @@ -65,12 +102,12 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_delete(self, resource_group): + def test_gallery_images_begin_delete(self, resource_group): response = self.client.gallery_images.begin_delete( resource_group_name=resource_group.name, gallery_name="str", gallery_image_name="str", - api_version="2018-06-01", + api_version="2023-07-03", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -78,11 +115,11 @@ def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_gallery(self, resource_group): + def test_gallery_images_list_by_gallery(self, resource_group): response = self.client.gallery_images.list_by_gallery( resource_group_name=resource_group.name, gallery_name="str", - api_version="2018-06-01", + api_version="2023-07-03", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_images_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_images_operations_async.py index 9547a48589fc..f7fa450ab3aa 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_images_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_images_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_gallery_images_begin_create_or_update(self, resource_group): response = await ( await self.client.gallery_images.begin_create_or_update( resource_group_name=resource_group.name, @@ -29,10 +29,13 @@ async def test_begin_create_or_update(self, resource_group): gallery_image_name="str", gallery_image={ "location": "str", + "architecture": "str", "description": "str", "disallowed": {"diskTypes": ["str"]}, "endOfLifeDate": "2020-02-20 00:00:00", "eula": "str", + "features": [{"name": "str", "value": "str"}], + "hyperVGeneration": "str", "id": "str", "identifier": {"offer": "str", "publisher": "str", "sku": "str"}, "name": "str", @@ -46,7 +49,7 @@ async def test_begin_create_or_update(self, resource_group): "tags": {"str": "str"}, "type": "str", }, - api_version="2018-06-01", + api_version="2023-07-03", ) ).result() # call '.result()' to poll until service return final result @@ -55,12 +58,48 @@ async def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_gallery_images_begin_update(self, resource_group): + response = await ( + await self.client.gallery_images.begin_update( + resource_group_name=resource_group.name, + gallery_name="str", + gallery_image_name="str", + gallery_image={ + "architecture": "str", + "description": "str", + "disallowed": {"diskTypes": ["str"]}, + "endOfLifeDate": "2020-02-20 00:00:00", + "eula": "str", + "features": [{"name": "str", "value": "str"}], + "hyperVGeneration": "str", + "id": "str", + "identifier": {"offer": "str", "publisher": "str", "sku": "str"}, + "name": "str", + "osState": "str", + "osType": "str", + "privacyStatementUri": "str", + "provisioningState": "str", + "purchasePlan": {"name": "str", "product": "str", "publisher": "str"}, + "recommended": {"memory": {"max": 0, "min": 0}, "vCPUs": {"max": 0, "min": 0}}, + "releaseNoteUri": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-03", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_gallery_images_get(self, resource_group): response = await self.client.gallery_images.get( resource_group_name=resource_group.name, gallery_name="str", gallery_image_name="str", - api_version="2018-06-01", + api_version="2023-07-03", ) # please add some check logic here by yourself @@ -68,13 +107,13 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_delete(self, resource_group): + async def test_gallery_images_begin_delete(self, resource_group): response = await ( await self.client.gallery_images.begin_delete( resource_group_name=resource_group.name, gallery_name="str", gallery_image_name="str", - api_version="2018-06-01", + api_version="2023-07-03", ) ).result() # call '.result()' to poll until service return final result @@ -83,11 +122,11 @@ async def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_gallery(self, resource_group): + async def test_gallery_images_list_by_gallery(self, resource_group): response = self.client.gallery_images.list_by_gallery( resource_group_name=resource_group.name, gallery_name="str", - api_version="2018-06-01", + api_version="2023-07-03", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_sharing_profile_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_sharing_profile_operations.py index a04499f94ba8..4d839a6b8032 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_sharing_profile_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_sharing_profile_operations.py @@ -20,12 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_update(self, resource_group): + def test_gallery_sharing_profile_begin_update(self, resource_group): response = self.client.gallery_sharing_profile.begin_update( resource_group_name=resource_group.name, gallery_name="str", sharing_update={"operationType": "str", "groups": [{"ids": ["str"], "type": "str"}]}, - api_version="2020-09-30", + api_version="2023-07-03", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_sharing_profile_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_sharing_profile_operations_async.py index 44acdb92d8a9..05966f33197c 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_sharing_profile_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_gallery_sharing_profile_operations_async.py @@ -21,13 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_update(self, resource_group): + async def test_gallery_sharing_profile_begin_update(self, resource_group): response = await ( await self.client.gallery_sharing_profile.begin_update( resource_group_name=resource_group.name, gallery_name="str", sharing_update={"operationType": "str", "groups": [{"ids": ["str"], "type": "str"}]}, - api_version="2020-09-30", + api_version="2023-07-03", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_images_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_images_operations.py index b6f1fcf22c1c..abcfc43a14ab 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_images_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_images_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_images_operations_async.py index 523beda29eda..1c424610f662 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_images_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_images_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_log_analytics_operations.py index d0855d0ac2cd..301993f9a19f 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_log_analytics_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_log_analytics_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_log_analytics_operations_async.py index 67c934d92275..3d7976d99d17 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_log_analytics_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_log_analytics_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_operations.py index 13932fafd4b9..ed05bcf20bf4 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_operations_async.py index 83171f08bd8a..30a354b38846 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_proximity_placement_groups_operations.py index a4e9f0442e16..1e8b01f49c31 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_proximity_placement_groups_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_proximity_placement_groups_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_proximity_placement_groups_operations_async.py index af8efbf9891e..382d00cf7e19 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_proximity_placement_groups_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_proximity_placement_groups_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_resource_skus_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_resource_skus_operations.py index b401b92478f3..9ad4d78493c1 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_resource_skus_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_resource_skus_operations.py @@ -20,9 +20,9 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_resource_skus_list(self, resource_group): response = self.client.resource_skus.list( - api_version="2017-03-30", + api_version="2021-07-01", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_resource_skus_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_resource_skus_operations_async.py index bd7b768e8e1b..670b37802ffb 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_resource_skus_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_resource_skus_operations_async.py @@ -21,9 +21,9 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_resource_skus_list(self, resource_group): response = self.client.resource_skus.list( - api_version="2017-03-30", + api_version="2021-07-01", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_point_collections_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_point_collections_operations.py index 54b93790627a..33d58b69721a 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_point_collections_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_point_collections_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_point_collections_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_point_collections_operations_async.py index 16ed8815485a..03ef773cc144 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_point_collections_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_point_collections_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_points_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_points_operations.py index 2384e7b34c74..4da05bdfd1ce 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_points_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_points_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_points_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_points_operations_async.py index 1be346762de7..1bb94068c6ab 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_points_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_points_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_galleries_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_galleries_operations.py index b3f536246565..dba2ce4e797a 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_galleries_operations.py @@ -20,10 +20,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_shared_galleries_list(self, resource_group): response = self.client.shared_galleries.list( location="str", - api_version="2020-09-30", + api_version="2023-07-03", ) result = [r for r in response] # please add some check logic here by yourself @@ -31,11 +31,11 @@ def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_shared_galleries_get(self, resource_group): response = self.client.shared_galleries.get( location="str", gallery_unique_name="str", - api_version="2020-09-30", + api_version="2023-07-03", ) # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_galleries_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_galleries_operations_async.py index 29276e0688e7..08bb30f87176 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_galleries_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_galleries_operations_async.py @@ -21,10 +21,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_shared_galleries_list(self, resource_group): response = self.client.shared_galleries.list( location="str", - api_version="2020-09-30", + api_version="2023-07-03", ) result = [r async for r in response] # please add some check logic here by yourself @@ -32,11 +32,11 @@ async def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_shared_galleries_get(self, resource_group): response = await self.client.shared_galleries.get( location="str", gallery_unique_name="str", - api_version="2020-09-30", + api_version="2023-07-03", ) # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_gallery_image_versions_operations.py index bae62e3835f7..ccfd206544b9 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_gallery_image_versions_operations.py @@ -20,12 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_shared_gallery_image_versions_list(self, resource_group): response = self.client.shared_gallery_image_versions.list( location="str", gallery_unique_name="str", gallery_image_name="str", - api_version="2020-09-30", + api_version="2023-07-03", ) result = [r for r in response] # please add some check logic here by yourself @@ -33,13 +33,13 @@ def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_shared_gallery_image_versions_get(self, resource_group): response = self.client.shared_gallery_image_versions.get( location="str", gallery_unique_name="str", gallery_image_name="str", gallery_image_version_name="str", - api_version="2020-09-30", + api_version="2023-07-03", ) # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_gallery_image_versions_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_gallery_image_versions_operations_async.py index d5fae70c87f7..94c35f0d6971 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_gallery_image_versions_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_gallery_image_versions_operations_async.py @@ -21,12 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_shared_gallery_image_versions_list(self, resource_group): response = self.client.shared_gallery_image_versions.list( location="str", gallery_unique_name="str", gallery_image_name="str", - api_version="2020-09-30", + api_version="2023-07-03", ) result = [r async for r in response] # please add some check logic here by yourself @@ -34,13 +34,13 @@ async def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_shared_gallery_image_versions_get(self, resource_group): response = await self.client.shared_gallery_image_versions.get( location="str", gallery_unique_name="str", gallery_image_name="str", gallery_image_version_name="str", - api_version="2020-09-30", + api_version="2023-07-03", ) # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_gallery_images_operations.py index 40b1cc359e10..9f171c4a99de 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_gallery_images_operations.py @@ -20,11 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_shared_gallery_images_list(self, resource_group): response = self.client.shared_gallery_images.list( location="str", gallery_unique_name="str", - api_version="2020-09-30", + api_version="2023-07-03", ) result = [r for r in response] # please add some check logic here by yourself @@ -32,12 +32,12 @@ def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_shared_gallery_images_get(self, resource_group): response = self.client.shared_gallery_images.get( location="str", gallery_unique_name="str", gallery_image_name="str", - api_version="2020-09-30", + api_version="2023-07-03", ) # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_gallery_images_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_gallery_images_operations_async.py index 6422dca37bbd..66db296c716b 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_gallery_images_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_shared_gallery_images_operations_async.py @@ -21,11 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_shared_gallery_images_list(self, resource_group): response = self.client.shared_gallery_images.list( location="str", gallery_unique_name="str", - api_version="2020-09-30", + api_version="2023-07-03", ) result = [r async for r in response] # please add some check logic here by yourself @@ -33,12 +33,12 @@ async def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_shared_gallery_images_get(self, resource_group): response = await self.client.shared_gallery_images.get( location="str", gallery_unique_name="str", gallery_image_name="str", - api_version="2020-09-30", + api_version="2023-07-03", ) # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_snapshots_operations.py index 68306678ba67..eeeb8fb2d2e7 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_snapshots_operations.py @@ -20,36 +20,81 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_snapshots_begin_create_or_update(self, resource_group): response = self.client.snapshots.begin_create_or_update( resource_group_name=resource_group.name, snapshot_name="str", snapshot={ "location": "str", - "accountType": "str", + "completionPercent": 0.0, + "copyCompletionError": {"errorCode": "str", "errorMessage": "str"}, "creationData": { "createOption": "str", - "imageReference": {"id": "str", "lun": 0}, + "elasticSanResourceId": "str", + "galleryImageReference": { + "communityGalleryImageId": "str", + "id": "str", + "lun": 0, + "sharedGalleryImageId": "str", + }, + "imageReference": { + "communityGalleryImageId": "str", + "id": "str", + "lun": 0, + "sharedGalleryImageId": "str", + }, + "logicalSectorSize": 0, + "performancePlus": bool, + "provisionedBandwidthCopySpeed": "str", + "securityDataUri": "str", "sourceResourceId": "str", + "sourceUniqueId": "str", "sourceUri": "str", "storageAccountId": "str", + "uploadSizeBytes": 0, }, + "dataAccessAuthMode": "str", + "diskAccessId": "str", + "diskSizeBytes": 0, "diskSizeGB": 0, - "encryptionSettings": { - "diskEncryptionKey": {"secretUrl": "str", "sourceVault": {"id": "str"}}, + "diskState": "str", + "encryption": {"diskEncryptionSetId": "str", "type": "str"}, + "encryptionSettingsCollection": { "enabled": bool, - "keyEncryptionKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + "encryptionSettings": [ + { + "diskEncryptionKey": {"secretUrl": "str", "sourceVault": {"id": "str"}}, + "keyEncryptionKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + } + ], + "encryptionSettingsVersion": "str", }, + "extendedLocation": {"name": "str", "type": "str"}, + "hyperVGeneration": "str", "id": "str", + "incremental": bool, + "incrementalSnapshotFamilyId": "str", + "managedBy": "str", "name": "str", + "networkAccessPolicy": "str", "osType": "str", - "ownerId": "str", "provisioningState": "str", + "publicNetworkAccess": "str", + "purchasePlan": {"name": "str", "product": "str", "publisher": "str", "promotionCode": "str"}, + "securityProfile": {"secureVMDiskEncryptionSetId": "str", "securityType": "str"}, + "sku": {"name": "str", "tier": "str"}, + "supportedCapabilities": { + "acceleratedNetwork": bool, + "architecture": "str", + "diskControllerTypes": "str", + }, + "supportsHibernation": bool, "tags": {"str": "str"}, "timeCreated": "2020-02-20 00:00:00", "type": "str", + "uniqueId": "str", }, - api_version="2016-04-30-preview", + api_version="2023-10-02", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -57,29 +102,38 @@ def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_update(self, resource_group): + def test_snapshots_begin_update(self, resource_group): response = self.client.snapshots.begin_update( resource_group_name=resource_group.name, snapshot_name="str", snapshot={ - "accountType": "str", - "creationData": { - "createOption": "str", - "imageReference": {"id": "str", "lun": 0}, - "sourceResourceId": "str", - "sourceUri": "str", - "storageAccountId": "str", - }, + "dataAccessAuthMode": "str", + "diskAccessId": "str", "diskSizeGB": 0, - "encryptionSettings": { - "diskEncryptionKey": {"secretUrl": "str", "sourceVault": {"id": "str"}}, + "encryption": {"diskEncryptionSetId": "str", "type": "str"}, + "encryptionSettingsCollection": { "enabled": bool, - "keyEncryptionKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + "encryptionSettings": [ + { + "diskEncryptionKey": {"secretUrl": "str", "sourceVault": {"id": "str"}}, + "keyEncryptionKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + } + ], + "encryptionSettingsVersion": "str", }, + "networkAccessPolicy": "str", "osType": "str", + "publicNetworkAccess": "str", + "sku": {"name": "str", "tier": "str"}, + "supportedCapabilities": { + "acceleratedNetwork": bool, + "architecture": "str", + "diskControllerTypes": "str", + }, + "supportsHibernation": bool, "tags": {"str": "str"}, }, - api_version="2016-04-30-preview", + api_version="2023-10-02", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -87,11 +141,11 @@ def test_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_snapshots_get(self, resource_group): response = self.client.snapshots.get( resource_group_name=resource_group.name, snapshot_name="str", - api_version="2016-04-30-preview", + api_version="2023-10-02", ) # please add some check logic here by yourself @@ -99,11 +153,11 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_delete(self, resource_group): + def test_snapshots_begin_delete(self, resource_group): response = self.client.snapshots.begin_delete( resource_group_name=resource_group.name, snapshot_name="str", - api_version="2016-04-30-preview", + api_version="2023-10-02", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -111,10 +165,10 @@ def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list_by_resource_group(self, resource_group): + def test_snapshots_list_by_resource_group(self, resource_group): response = self.client.snapshots.list_by_resource_group( resource_group_name=resource_group.name, - api_version="2016-04-30-preview", + api_version="2023-10-02", ) result = [r for r in response] # please add some check logic here by yourself @@ -122,9 +176,9 @@ def test_list_by_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_snapshots_list(self, resource_group): response = self.client.snapshots.list( - api_version="2016-04-30-preview", + api_version="2023-10-02", ) result = [r for r in response] # please add some check logic here by yourself @@ -132,12 +186,17 @@ def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_grant_access(self, resource_group): + def test_snapshots_begin_grant_access(self, resource_group): response = self.client.snapshots.begin_grant_access( resource_group_name=resource_group.name, snapshot_name="str", - grant_access_data={"access": "str", "durationInSeconds": 0}, - api_version="2016-04-30-preview", + grant_access_data={ + "access": "str", + "durationInSeconds": 0, + "fileFormat": "str", + "getSecureVMGuestStateSAS": bool, + }, + api_version="2023-10-02", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -145,11 +204,11 @@ def test_begin_grant_access(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_revoke_access(self, resource_group): + def test_snapshots_begin_revoke_access(self, resource_group): response = self.client.snapshots.begin_revoke_access( resource_group_name=resource_group.name, snapshot_name="str", - api_version="2016-04-30-preview", + api_version="2023-10-02", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_snapshots_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_snapshots_operations_async.py index 9c830f36515f..d4d7c22c872f 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_snapshots_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_snapshots_operations_async.py @@ -21,37 +21,82 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_snapshots_begin_create_or_update(self, resource_group): response = await ( await self.client.snapshots.begin_create_or_update( resource_group_name=resource_group.name, snapshot_name="str", snapshot={ "location": "str", - "accountType": "str", + "completionPercent": 0.0, + "copyCompletionError": {"errorCode": "str", "errorMessage": "str"}, "creationData": { "createOption": "str", - "imageReference": {"id": "str", "lun": 0}, + "elasticSanResourceId": "str", + "galleryImageReference": { + "communityGalleryImageId": "str", + "id": "str", + "lun": 0, + "sharedGalleryImageId": "str", + }, + "imageReference": { + "communityGalleryImageId": "str", + "id": "str", + "lun": 0, + "sharedGalleryImageId": "str", + }, + "logicalSectorSize": 0, + "performancePlus": bool, + "provisionedBandwidthCopySpeed": "str", + "securityDataUri": "str", "sourceResourceId": "str", + "sourceUniqueId": "str", "sourceUri": "str", "storageAccountId": "str", + "uploadSizeBytes": 0, }, + "dataAccessAuthMode": "str", + "diskAccessId": "str", + "diskSizeBytes": 0, "diskSizeGB": 0, - "encryptionSettings": { - "diskEncryptionKey": {"secretUrl": "str", "sourceVault": {"id": "str"}}, + "diskState": "str", + "encryption": {"diskEncryptionSetId": "str", "type": "str"}, + "encryptionSettingsCollection": { "enabled": bool, - "keyEncryptionKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + "encryptionSettings": [ + { + "diskEncryptionKey": {"secretUrl": "str", "sourceVault": {"id": "str"}}, + "keyEncryptionKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + } + ], + "encryptionSettingsVersion": "str", }, + "extendedLocation": {"name": "str", "type": "str"}, + "hyperVGeneration": "str", "id": "str", + "incremental": bool, + "incrementalSnapshotFamilyId": "str", + "managedBy": "str", "name": "str", + "networkAccessPolicy": "str", "osType": "str", - "ownerId": "str", "provisioningState": "str", + "publicNetworkAccess": "str", + "purchasePlan": {"name": "str", "product": "str", "publisher": "str", "promotionCode": "str"}, + "securityProfile": {"secureVMDiskEncryptionSetId": "str", "securityType": "str"}, + "sku": {"name": "str", "tier": "str"}, + "supportedCapabilities": { + "acceleratedNetwork": bool, + "architecture": "str", + "diskControllerTypes": "str", + }, + "supportsHibernation": bool, "tags": {"str": "str"}, "timeCreated": "2020-02-20 00:00:00", "type": "str", + "uniqueId": "str", }, - api_version="2016-04-30-preview", + api_version="2023-10-02", ) ).result() # call '.result()' to poll until service return final result @@ -60,30 +105,39 @@ async def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_update(self, resource_group): + async def test_snapshots_begin_update(self, resource_group): response = await ( await self.client.snapshots.begin_update( resource_group_name=resource_group.name, snapshot_name="str", snapshot={ - "accountType": "str", - "creationData": { - "createOption": "str", - "imageReference": {"id": "str", "lun": 0}, - "sourceResourceId": "str", - "sourceUri": "str", - "storageAccountId": "str", - }, + "dataAccessAuthMode": "str", + "diskAccessId": "str", "diskSizeGB": 0, - "encryptionSettings": { - "diskEncryptionKey": {"secretUrl": "str", "sourceVault": {"id": "str"}}, + "encryption": {"diskEncryptionSetId": "str", "type": "str"}, + "encryptionSettingsCollection": { "enabled": bool, - "keyEncryptionKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + "encryptionSettings": [ + { + "diskEncryptionKey": {"secretUrl": "str", "sourceVault": {"id": "str"}}, + "keyEncryptionKey": {"keyUrl": "str", "sourceVault": {"id": "str"}}, + } + ], + "encryptionSettingsVersion": "str", }, + "networkAccessPolicy": "str", "osType": "str", + "publicNetworkAccess": "str", + "sku": {"name": "str", "tier": "str"}, + "supportedCapabilities": { + "acceleratedNetwork": bool, + "architecture": "str", + "diskControllerTypes": "str", + }, + "supportsHibernation": bool, "tags": {"str": "str"}, }, - api_version="2016-04-30-preview", + api_version="2023-10-02", ) ).result() # call '.result()' to poll until service return final result @@ -92,11 +146,11 @@ async def test_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_snapshots_get(self, resource_group): response = await self.client.snapshots.get( resource_group_name=resource_group.name, snapshot_name="str", - api_version="2016-04-30-preview", + api_version="2023-10-02", ) # please add some check logic here by yourself @@ -104,12 +158,12 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_delete(self, resource_group): + async def test_snapshots_begin_delete(self, resource_group): response = await ( await self.client.snapshots.begin_delete( resource_group_name=resource_group.name, snapshot_name="str", - api_version="2016-04-30-preview", + api_version="2023-10-02", ) ).result() # call '.result()' to poll until service return final result @@ -118,10 +172,10 @@ async def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list_by_resource_group(self, resource_group): + async def test_snapshots_list_by_resource_group(self, resource_group): response = self.client.snapshots.list_by_resource_group( resource_group_name=resource_group.name, - api_version="2016-04-30-preview", + api_version="2023-10-02", ) result = [r async for r in response] # please add some check logic here by yourself @@ -129,9 +183,9 @@ async def test_list_by_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_snapshots_list(self, resource_group): response = self.client.snapshots.list( - api_version="2016-04-30-preview", + api_version="2023-10-02", ) result = [r async for r in response] # please add some check logic here by yourself @@ -139,13 +193,18 @@ async def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_grant_access(self, resource_group): + async def test_snapshots_begin_grant_access(self, resource_group): response = await ( await self.client.snapshots.begin_grant_access( resource_group_name=resource_group.name, snapshot_name="str", - grant_access_data={"access": "str", "durationInSeconds": 0}, - api_version="2016-04-30-preview", + grant_access_data={ + "access": "str", + "durationInSeconds": 0, + "fileFormat": "str", + "getSecureVMGuestStateSAS": bool, + }, + api_version="2023-10-02", ) ).result() # call '.result()' to poll until service return final result @@ -154,12 +213,12 @@ async def test_begin_grant_access(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_revoke_access(self, resource_group): + async def test_snapshots_begin_revoke_access(self, resource_group): response = await ( await self.client.snapshots.begin_revoke_access( resource_group_name=resource_group.name, snapshot_name="str", - api_version="2016-04-30-preview", + api_version="2023-10-02", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_ssh_public_keys_operations.py index af2d0bd3295f..770b3d2568c3 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_ssh_public_keys_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_ssh_public_keys_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_ssh_public_keys_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_ssh_public_keys_operations_async.py index c8822cf6d878..7aa5bc3f20c5 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_ssh_public_keys_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_ssh_public_keys_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_usage_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_usage_operations.py index b67341e9a785..1fe516cfd211 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_usage_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_usage_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_usage_operations_async.py index 06f7715ff9aa..aea1886af5c3 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_usage_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_usage_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extension_images_operations.py index f2654e5dcffd..159582a87dda 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extension_images_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extension_images_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extension_images_operations_async.py index c976f2e90375..9e5e4f48bf01 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extension_images_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extension_images_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extensions_operations.py index 5cf8a36f4c9c..66df37fdbdbd 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extensions_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extensions_operations_async.py index 57c0db415d24..b8e7c8178582 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extensions_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extensions_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_edge_zone_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_edge_zone_operations.py index a082a91fba82..b24680890026 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_edge_zone_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_edge_zone_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_edge_zone_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_edge_zone_operations_async.py index 87dce50ec700..ccb3d45e3cfe 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_edge_zone_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_edge_zone_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_operations.py index 5c4023bbc0b1..8cde44bbb50a 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_operations_async.py index 4734ac9fa5f4..3a10199b295a 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_run_commands_operations.py index d52d6464f09f..31c6237e0100 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_run_commands_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_run_commands_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_run_commands_operations_async.py index f8699fe05ff5..d59112620044 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_run_commands_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_run_commands_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_extensions_operations.py index 3a99b58c1e21..4d3a58587e18 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_extensions_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_extensions_operations_async.py index bcaf9d0a5bad..da8856bcd638 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_extensions_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_extensions_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_rolling_upgrades_operations.py index 3624654ca3cf..739e00e8c77c 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_rolling_upgrades_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_rolling_upgrades_operations_async.py index e6ebbd70a669..b1f83bcb293a 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_rolling_upgrades_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_rolling_upgrades_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_extensions_operations.py index 652215072c5e..79bc0c5db2e4 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_extensions_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_extensions_operations_async.py index f7f02c624fe9..714184f060bd 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_extensions_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_extensions_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_run_commands_operations.py index 3ddb97403784..e239d1deedea 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_run_commands_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_run_commands_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_run_commands_operations_async.py index 7dd4f1a50a94..1a4a123f955f 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_run_commands_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_run_commands_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vms_operations.py index 881b1ffe7e09..da3cb27f718c 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vms_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vms_operations_async.py index 18032ce234eb..68b2d4a768dd 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vms_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vms_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_sets_operations.py index 1d32f10572bd..2b5331383efa 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_sets_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_sets_operations_async.py index 7a9395aaff75..f990eea21915 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_sets_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_sets_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_sizes_operations.py index 138b35591870..30802dc0c73a 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_sizes_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_sizes_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_sizes_operations_async.py index 2829a3f46d52..e6bceb227f59 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_sizes_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_sizes_operations_async.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machines_operations.py index 35bd8af9a0e3..6d15e596393f 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machines_operations.py @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01 import ComputeManagementClient +from azure.mgmt.compute import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machines_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machines_operations_async.py index 509635e9501e..b5ddd5f9288c 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machines_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machines_operations_async.py @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest -from azure.mgmt.compute.v2024_11_01.aio import ComputeManagementClient +from azure.mgmt.compute.aio import ComputeManagementClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer from devtools_testutils.aio import recorded_by_proxy_async